| Previous | 15994 Revisions | Next |
| r3868 Thursday 18th December, 2008 at 15:37:56 UTC by Miodrag Milanović |
|---|
| WD17XX and NEC765 converted to device |
| [docs] | messnew.txt |
| [src/mess/devices] | coco_fdc.c flopdrv.c flopdrv.h thomflop.c |
| [src/mess/drivers] | a310.c amstrad.c apf.c at.c atarist.c b2m.c bbc.c bebox.c bw2.c cgenie.c coco.c compis.c comx35.c concept.c dgn_beta.c einstein.c enterp.c exidy.c geneve.c kc.c mbee.c msx.c nascom1.c nc.c newbrain.c oric.c orion.c osborne1.c osi.c partner.c pc.c pc8801.c pcw.c pcw16.c pentagon.c samcoupe.c scorpion.c sg1000.c sord.c special.c specpls3.c svi318.c thomson.c ti99_4x.c trs80.c vector06.c x68k.c |
| [src/mess/includes] | bbc.h cgenie.h coco.h compis.h comx35.h concept.h dgn_beta.h kc.h mbee.h msx.h nascom1.h oric.h osborne1.h partner.h pc8801.h samcoupe.h special.h svi318.h trs80.h |
| [src/mess/machine] | 99_dsk.c 99_dsk.h at.c b2m.c bbc.c bebox.c beta.c beta.h cgenie.c coco.c compis.c comx35.c concept.c conkort.c dgn_beta.c kc.c mbee.c msx.c msx_slot.c nascom1.c nec765.c nec765.h oric.c orion.c osborne1.c partner.c pc.c pc8801.c pc_fdc.c pc_fdc.h samcoupe.c special.c svi318.c trs80.c vector06.c wd17xx.c wd17xx.h |
| r3867 | r3868 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | #include "driver.h" |
| 16 | 16 | #include "machine/msm8251.h" |
| 17 | #include "machine/nec765.h" | |
| 17 | 18 | |
| 18 | 19 | /*----------- defined in machine/compis.c -----------*/ |
| 19 | 20 | |
| r3867 | r3868 | |
| 23 | 24 | extern const struct pic8259_interface compis_pic8259_master_config; |
| 24 | 25 | extern const struct pic8259_interface compis_pic8259_slave_config; |
| 25 | 26 | extern const msm8251_interface compis_usart_interface; |
| 27 | extern const nec765_interface compis_fdc_interface; | |
| 26 | 28 | |
| 27 | 29 | DRIVER_INIT(compis); |
| 28 | 30 | MACHINE_RESET(compis); |
| r3867 | r3868 | |
|---|---|---|
| 11 | 11 | #include "machine/z80ctc.h" |
| 12 | 12 | #include "machine/z80pio.h" |
| 13 | 13 | #include "devices/snapquik.h" |
| 14 | #include "machine/nec765.h" | |
| 14 | 15 | |
| 15 | ||
| 16 | 16 | #define KC85_4_CLOCK 1750000 |
| 17 | 17 | #define KC85_3_CLOCK 1750000 |
| 18 | 18 | |
| r3867 | r3868 | |
| 43 | 43 | |
| 44 | 44 | /*----------- defined in machine/kc.c -----------*/ |
| 45 | 45 | |
| 46 | extern const nec765_interface kc_fdc_interface; | |
| 46 | 47 | extern QUICKLOAD_LOAD( kc ); |
| 47 | 48 | |
| 48 | 49 | MACHINE_RESET( kc85_3 ); |
| r3867 | r3868 | |
|---|---|---|
| 7 | 7 | #ifndef DGN_BETA_H_ |
| 8 | 8 | #define DGN_BETA_H_ |
| 9 | 9 | |
| 10 | #include "machine/wd17xx.h" | |
| 10 | 11 | |
| 11 | 12 | #define DGNBETA_CPU_SPEED_HZ 2000000 /* 2MHz */ |
| 12 | 13 | #define DGNBETA_FRAMES_PER_SECOND 50 |
| r3867 | r3868 | |
| 63 | 64 | |
| 64 | 65 | /*----------- defined in machine/dgn_beta.c -----------*/ |
| 65 | 66 | |
| 67 | extern const wd17xx_interface dgnbeta_wd17xx_interface; | |
| 66 | 68 | MACHINE_START( dgnbeta ); |
| 67 | 69 | |
| 68 | 70 | // Page IO at FE00 |
| r3867 | r3868 | |
|---|---|---|
| 7 | 7 | #ifndef MBEE_H_ |
| 8 | 8 | #define MBEE_H_ |
| 9 | 9 | |
| 10 | #include "machine/wd17xx.h" | |
| 10 | 11 | #include "cpu/z80/z80daisy.h" |
| 11 | 12 | |
| 12 | 13 | /*----------- defined in machine/mbee.c -----------*/ |
| 13 | 14 | |
| 15 | extern const wd17xx_interface mbee_wd17xx_interface; | |
| 16 | ||
| 14 | 17 | MACHINE_RESET( mbee ); |
| 15 | MACHINE_START( mbee ); | |
| 16 | 18 | |
| 17 | 19 | extern UINT8 *mbee_workram; |
| 18 | 20 |
| r3867 | r3868 | |
|---|---|---|
| 10 | 10 | #define COCO_H_ |
| 11 | 11 | |
| 12 | 12 | #include "devices/snapquik.h" |
| 13 | #include "machine/wd17xx.h" | |
| 13 | 14 | |
| 14 | ||
| 15 | 15 | #define COCO_CPU_SPEED_HZ 894886 /* 0.894886 MHz */ |
| 16 | 16 | #define COCO_FRAMES_PER_SECOND (COCO_CPU_SPEED_HZ / 57.0 / 263) |
| 17 | 17 | #define COCO_CPU_SPEED (ATTOTIME_IN_HZ(COCO_CPU_SPEED_HZ)) |
| r3867 | r3868 | |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /*----------- defined in machine/coco.c -----------*/ |
| 41 | ||
| 41 | extern const wd17xx_interface dragon_wd17xx_interface; | |
| 42 | extern const wd17xx_interface coco_wd17xx_interface; | |
| 43 | extern const wd17xx_interface dgnalpha_wd17xx_interface; | |
| 42 | 44 | extern UINT8 coco3_gimereg[16]; |
| 43 | 45 | |
| 44 | 46 | MACHINE_START( dragon32 ); |
| r3867 | r3868 | |
|---|---|---|
| 12 | 12 | #define CONCEPT_H_ |
| 13 | 13 | |
| 14 | 14 | #include "machine/6522via.h" |
| 15 | #include "machine/wd17xx.h" | |
| 15 | 16 | |
| 16 | 17 | /*----------- defined in machine/concept.c -----------*/ |
| 17 | 18 | |
| 18 | 19 | extern const via6522_interface concept_via6522_intf; |
| 20 | extern const wd17xx_interface concept_wd17xx_interface; | |
| 19 | 21 | |
| 20 | 22 | MACHINE_START(concept); |
| 21 | 23 | VIDEO_START(concept); |
| r3867 | r3868 | |
|---|---|---|
| 7 | 7 | #ifndef MSX_H_ |
| 8 | 8 | #define MSX_H_ |
| 9 | 9 | |
| 10 | #include "machine/wd17xx.h" | |
| 10 | 11 | |
| 11 | 12 | #define MSX_MAX_CARTS (2) |
| 12 | 13 | |
| r3867 | r3868 | |
| 48 | 49 | |
| 49 | 50 | extern MSX msx1; |
| 50 | 51 | extern const ppi8255_interface msx_ppi8255_interface; |
| 51 | ||
| 52 | extern const wd17xx_interface msx_wd17xx_interface; | |
| 52 | 53 | /* start/stop functions */ |
| 53 | 54 | extern DRIVER_INIT( msx ); |
| 54 | 55 | extern MACHINE_START( msx ); |
| r3867 | r3868 | |
|---|---|---|
| 7 | 7 | #ifndef CGENIE_H_ |
| 8 | 8 | #define CGENIE_H_ |
| 9 | 9 | |
| 10 | #include "machine/wd17xx.h" | |
| 10 | 11 | |
| 11 | 12 | /*----------- defined in audio/cgenie.c -----------*/ |
| 12 | 13 | |
| r3867 | r3868 | |
| 19 | 20 | /*----------- defined in machine/cgenie.c -----------*/ |
| 20 | 21 | |
| 21 | 22 | extern UINT8 *cgenie_fontram; |
| 23 | extern const wd17xx_interface cgenie_wd17xx_interface; | |
| 22 | 24 | |
| 23 | 25 | DEVICE_IMAGE_LOAD( cgenie_floppy ); |
| 24 | 26 |
| r3867 | r3868 | |
|---|---|---|
| 7 | 7 | #ifndef PC8801_H_ |
| 8 | 8 | #define PC8801_H_ |
| 9 | 9 | |
| 10 | #include "machine/nec765.h" | |
| 10 | 11 | |
| 11 | 12 | /*----------- defined in machine/pc8801.c -----------*/ |
| 12 | 13 | |
| 13 | 14 | extern const ppi8255_interface pc8801_8255_config_0; |
| 14 | 15 | extern const ppi8255_interface pc8801_8255_config_1; |
| 16 | extern const nec765_interface pc8801_fdc_interface; | |
| 15 | 17 | |
| 16 | 18 | WRITE8_HANDLER(pc8801_write_interrupt_level); |
| 17 | 19 | WRITE8_HANDLER(pc8801_write_interrupt_mask); |
| r3867 | r3868 | |
|---|---|---|
| 8 | 8 | #define ORIC_H_ |
| 9 | 9 | |
| 10 | 10 | #include "machine/6522via.h" |
| 11 | #include "machine/wd17xx.h" | |
| 11 | 12 | |
| 12 | ||
| 13 | 13 | /*----------- defined in machine/oric.c -----------*/ |
| 14 | 14 | |
| 15 | 15 | extern const via6522_interface oric_6522_interface; |
| 16 | 16 | extern const via6522_interface telestrat_via2_interface; |
| 17 | extern const wd17xx_interface oric_wd17xx_interface; | |
| 17 | 18 | |
| 18 | 19 | MACHINE_START( oric ); |
| 19 | 20 | MACHINE_RESET( oric ); |
| r3867 | r3868 | |
|---|---|---|
| 9 | 9 | |
| 10 | 10 | #include "machine/8255ppi.h" |
| 11 | 11 | #include "machine/8257dma.h" |
| 12 | #include "machine/wd17xx.h" | |
| 12 | 13 | |
| 13 | 14 | /*----------- defined in machine/partner.c -----------*/ |
| 14 | 15 | |
| r3867 | r3868 | |
| 19 | 20 | extern DEVICE_IMAGE_LOAD( partner_floppy ); |
| 20 | 21 | |
| 21 | 22 | extern const dma8257_interface partner_dma; |
| 23 | extern const wd17xx_interface partner_wd17xx_interface; | |
| 22 | 24 | |
| 23 | 25 | extern WRITE8_HANDLER (partner_mem_page_w ); |
| 24 | 26 | extern WRITE8_HANDLER (partner_win_memory_page_w); |
| r3867 | r3868 | |
|---|---|---|
| 8 | 8 | #define NASCOM1_H_ |
| 9 | 9 | |
| 10 | 10 | #include "devices/snapquik.h" |
| 11 | #include "machine/wd17xx.h" | |
| 11 | 12 | |
| 12 | 13 | |
| 13 | 14 | /*----------- defined in machine/nascom1.c -----------*/ |
| 14 | 15 | |
| 16 | extern const wd17xx_interface nascom2_wd17xx_interface; | |
| 17 | ||
| 15 | 18 | DRIVER_INIT( nascom1 ); |
| 16 | 19 | DEVICE_IMAGE_LOAD( nascom1_cassette ); |
| 17 | 20 | DEVICE_IMAGE_UNLOAD( nascom1_cassette ); |
| 18 | MACHINE_START( nascom2 ); | |
| 19 | 21 | SNAPSHOT_LOAD( nascom1 ); |
| 20 | 22 | |
| 21 | 23 | READ8_HANDLER( nascom2_fdc_select_r ); |
| r3867 | r3868 | |
|---|---|---|
| 39 | 39 | |
| 40 | 40 | extern DRIVER_INIT( erik ); |
| 41 | 41 | extern MACHINE_RESET( erik ); |
| 42 | extern MACHINE_START( erik ); | |
| 43 | 42 | |
| 44 | 43 | extern READ8_HANDLER ( erik_rr_reg_r ); |
| 45 | 44 | extern WRITE8_HANDLER( erik_rr_reg_w ); |
| r3867 | r3868 | |
|---|---|---|
| 22 | 22 | DEVICE_IMAGE_LOAD( osborne1_floppy ); |
| 23 | 23 | |
| 24 | 24 | DRIVER_INIT( osborne1 ); |
| 25 | MACHINE_START( osborne1 ); | |
| 26 | 25 | MACHINE_RESET( osborne1 ); |
| 27 | 26 | |
| 28 | 27 | /* Osborne1 specific daisy chain interface */ |
| r3867 | r3868 | |
|---|---|---|
| 34 | 34 | void samcoupe_update_memory(const address_space *space); |
| 35 | 35 | |
| 36 | 36 | WRITE8_HANDLER( samcoupe_ext_mem_w ); |
| 37 | MACHINE_START( samcoupe ); | |
| 38 | 37 | MACHINE_RESET( samcoupe ); |
| 39 | 38 | |
| 40 | 39 |
| r3867 | r3868 | |
|---|---|---|
| 2 | 2 | #define __COMX35__ |
| 3 | 3 | |
| 4 | 4 | #include "devices/snapquik.h" |
| 5 | #include "machine/wd17xx.h" | |
| 5 | 6 | |
| 6 | 7 | #define SCREEN_TAG "main" |
| 7 | 8 | #define MC6845_SCREEN_TAG "mc6845" |
| r3867 | r3868 | |
| 69 | 70 | |
| 70 | 71 | /* ---------- defined in machine/comx35.c ---------- */ |
| 71 | 72 | |
| 73 | extern const wd17xx_interface comx35_wd17xx_interface; | |
| 74 | ||
| 72 | 75 | WRITE8_HANDLER( comx35_bank_select_w ); |
| 73 | 76 | READ8_HANDLER( comx35_io_r ); |
| 74 | 77 | READ8_HANDLER( comx35_io2_r ); |
| r3867 | r3868 | |
|---|---|---|
| 8 | 8 | #define TRS80_H_ |
| 9 | 9 | |
| 10 | 10 | #include "devices/snapquik.h" |
| 11 | #include "machine/wd17xx.h" | |
| 11 | 12 | |
| 12 | ||
| 13 | 13 | #define TRS80_FONT_W 6 |
| 14 | 14 | #define TRS80_FONT_H 12 |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | /*----------- defined in machine/trs80.c -----------*/ |
| 18 | 18 | |
| 19 | extern const wd17xx_interface trs80_wd17xx_interface; | |
| 19 | 20 | extern UINT8 trs80_port_ff; |
| 20 | 21 | |
| 21 | 22 | DEVICE_IMAGE_LOAD( trs80_floppy ); |
| 22 | 23 | QUICKLOAD_LOAD( trs80_cmd ); |
| 23 | 24 | |
| 24 | MACHINE_START( trs80 ); | |
| 25 | 25 | MACHINE_RESET( trs80 ); |
| 26 | 26 | DRIVER_INIT( trs80 ); |
| 27 | 27 | DRIVER_INIT( lnw80 ); |
| r3867 | r3868 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | #include "machine/8255ppi.h" |
| 13 | 13 | #include "machine/ins8250.h" |
| 14 | #include "machine/wd17xx.h" | |
| 14 | 15 | |
| 15 | 16 | /*----------- defined in machine/svi318.c -----------*/ |
| 16 | 17 | |
| 17 | 18 | extern const ppi8255_interface svi318_ppi8255_interface; |
| 18 | 19 | extern const ins8250_interface svi318_ins8250_interface[2]; |
| 20 | extern const wd17xx_interface svi_wd17xx_interface; | |
| 19 | 21 | |
| 20 | 22 | DRIVER_INIT( svi318 ); |
| 21 | 23 | MACHINE_START( svi318_pal ); |
| r3867 | r3868 | |
|---|---|---|
| 14 | 14 | #include "machine/6522via.h" |
| 15 | 15 | #include "machine/6850acia.h" |
| 16 | 16 | #include "machine/i8271.h" |
| 17 | #include "machine/wd17xx.h" | |
| 17 | 18 | #include "machine/upd7002.h" |
| 18 | 19 | |
| 19 | 20 | |
| r3867 | r3868 | |
| 21 | 22 | |
| 22 | 23 | extern const via6522_interface bbcb_system_via; |
| 23 | 24 | extern const via6522_interface bbcb_user_via; |
| 24 | ||
| 25 | extern const wd17xx_interface bbc_wd17xx_interface; | |
| 25 | 26 | DRIVER_INIT( bbc ); |
| 26 | 27 | DRIVER_INIT( bbcm ); |
| 27 | 28 |
| r3867 | r3868 | |
|---|---|---|
| 657 | 657 | static WRITE8_HANDLER(d_pia1_pa_w) |
| 658 | 658 | { |
| 659 | 659 | int HALT_DMA; |
| 660 | ||
| 660 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 661 | ||
| 661 | 662 | /* Only play with halt line if halt bit changed since last write */ |
| 662 | 663 | if((data & 0x80)!=d_pia1_pa_last) |
| 663 | 664 | { |
| r3867 | r3868 | |
| 678 | 679 | } |
| 679 | 680 | |
| 680 | 681 | /* Drive selects are binary encoded on PA0 & PA1 */ |
| 681 | wd17xx_set_drive(~data & DSMask); | |
| 682 | wd17xx_set_drive(fdc,~data & DSMask); | |
| 682 | 683 | |
| 683 | 684 | /* Set density of WD2797 */ |
| 684 | 685 | if (data & DDenCtrl) |
| 685 | 686 | { |
| 686 | wd17xx_set_density(DEN_FM_LO); | |
| 687 | wd17xx_set_density(fdc,DEN_FM_LO); | |
| 687 | 688 | LOG_DISK(("Set density low %d\n",(data & DDenCtrl))); |
| 688 | 689 | } |
| 689 | 690 | else |
| 690 | 691 | { |
| 691 | wd17xx_set_density(DEN_MFM_LO); | |
| 692 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 692 | 693 | LOG_DISK(("Set density high %d\n",(data & DDenCtrl))); |
| 693 | 694 | } |
| 694 | 695 | } |
| r3867 | r3868 | |
| 883 | 884 | /* Dragon Beta onboard FDC */ |
| 884 | 885 | /********************************************************************************************/ |
| 885 | 886 | |
| 886 | static | |
| 887 | static WD17XX_CALLBACK( dgnbeta_fdc_callback | |
| 887 | 888 | { |
| 888 | 889 | /* The INTRQ line goes through pia2 ca1, in exactly the same way as DRQ from DragonDos does */ |
| 889 | 890 | /* DRQ is routed through various logic to the FIRQ inturrupt line on *BOTH* CPUs */ |
| 890 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); | |
| 891 | const address_space *space = cpu_get_address_space( device->machine->cpu[0], ADDRESS_SPACE_PROGRAM ); | |
| 891 | 892 | |
| 892 | switch( | |
| 893 | switch(s | |
| 893 | 894 | { |
| 894 | 895 | case WD17XX_IRQ_CLR: |
| 895 | 896 | pia_2_ca1_w(space, 0, CLEAR_LINE); |
| r3867 | r3868 | |
| 899 | 900 | break; |
| 900 | 901 | case WD17XX_DRQ_CLR: |
| 901 | 902 | /*wd2797_drq=CLEAR_LINE;*/ |
| 902 | cpu1_recalc_firq(machine, CLEAR_LINE); | |
| 903 | cpu1_recalc_firq(device->machine, CLEAR_LINE); | |
| 903 | 904 | break; |
| 904 | 905 | case WD17XX_DRQ_SET: |
| 905 | 906 | /*wd2797_drq=ASSERT_LINE;*/ |
| 906 | cpu1_recalc_firq(machine, ASSERT_LINE); | |
| 907 | cpu1_recalc_firq(device->machine, ASSERT_LINE); | |
| 907 | 908 | break; |
| 908 | 909 | } |
| 909 | 910 | |
| 910 | LOG_DISK(("dgnbeta_fdc_callback(%d)\n", | |
| 911 | LOG_DISK(("dgnbeta_fdc_callback(%d)\n",s | |
| 911 | 912 | } |
| 912 | 913 | |
| 914 | const wd17xx_interface dgnbeta_wd17xx_interface = { dgnbeta_fdc_callback, NULL }; | |
| 915 | ||
| 913 | 916 | READ8_HANDLER(dgnbeta_wd2797_r) |
| 914 | 917 | { |
| 915 | 918 | int result = 0; |
| 919 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 916 | 920 | |
| 917 | 921 | switch(offset & 0x03) |
| 918 | 922 | { |
| 919 | 923 | case 0: |
| 920 | result = wd17xx_status_r( | |
| 924 | result = wd17xx_status_r(fd | |
| 921 | 925 | LOG_DISK(("Disk status=%2.2X\n",result)); |
| 922 | 926 | break; |
| 923 | 927 | case 1: |
| 924 | result = wd17xx_track_r( | |
| 928 | result = wd17xx_track_r(fd | |
| 925 | 929 | break; |
| 926 | 930 | case 2: |
| 927 | result = wd17xx_sector_r( | |
| 931 | result = wd17xx_sector_r(fd | |
| 928 | 932 | break; |
| 929 | 933 | case 3: |
| 930 | result = wd17xx_data_r( | |
| 934 | result = wd17xx_data_r(fd | |
| 931 | 935 | break; |
| 932 | 936 | default: |
| 933 | 937 | break; |
| r3867 | r3868 | |
| 938 | 942 | |
| 939 | 943 | WRITE8_HANDLER(dgnbeta_wd2797_w) |
| 940 | 944 | { |
| 945 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 946 | ||
| 941 | 947 | switch(offset & 0x3) |
| 942 | 948 | { |
| 943 | 949 | case 0: |
| 944 | 950 | /* disk head is encoded in the command byte */ |
| 945 | 951 | /* But only for Type 3/4 commands */ |
| 946 | 952 | if(data & 0x80) |
| 947 | wd17xx_set_side((data & 0x02) ? 1 : 0); | |
| 948 | wd17xx_command_w(space, 0, data); | |
| 953 | wd17xx_set_side(fdc,(data & 0x02) ? 1 : 0); | |
| 954 | wd17xx_command_w(fdc, 0, data); | |
| 949 | 955 | break; |
| 950 | 956 | case 1: |
| 951 | wd17xx_track_w( | |
| 957 | wd17xx_track_w(fd | |
| 952 | 958 | break; |
| 953 | 959 | case 2: |
| 954 | wd17xx_sector_w( | |
| 960 | wd17xx_sector_w(fd | |
| 955 | 961 | break; |
| 956 | 962 | case 3: |
| 957 | wd17xx_data_w( | |
| 963 | wd17xx_data_w(fd | |
| 958 | 964 | break; |
| 959 | 965 | }; |
| 960 | 966 | } |
| r3867 | r3868 | |
| 1027 | 1033 | |
| 1028 | 1034 | static void dgnbeta_reset(running_machine *machine) |
| 1029 | 1035 | { |
| 1036 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 1037 | ||
| 1030 | 1038 | system_rom = memory_region(machine, "main"); |
| 1031 | 1039 | |
| 1032 | 1040 | /* Make sure CPU 1 is started out halted ! */ |
| r3867 | r3868 | |
| 1061 | 1069 | DMA_NMI_LAST=0x80; /* start with DMA NMI inactive, as pulled up */ |
| 1062 | 1070 | // DMA_NMI=CLEAR_LINE; /* start with DMA NMI inactive */ |
| 1063 | 1071 | |
| 1064 | wd17xx_reset(machine); | |
| 1065 | wd17xx_set_density(DEN_MFM_LO); | |
| 1066 | wd17xx_set_drive(0); | |
| 1072 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 1073 | wd17xx_set_drive(fdc,0); | |
| 1067 | 1074 | |
| 1068 | 1075 | videoram=mess_ram; /* Point video ram at the start of physical ram */ |
| 1069 | 1076 | } |
| r3867 | r3868 | |
| 1077 | 1084 | |
| 1078 | 1085 | init_video(machine); |
| 1079 | 1086 | |
| 1080 | wd17xx_init(machine, WD_TYPE_179X,dgnbeta_fdc_callback, NULL); | |
| 1081 | 1087 | cpu_set_dasm_override(machine->cpu[0],dgnbeta_dasm_override); |
| 1082 | 1088 | |
| 1083 | 1089 | add_reset_callback(machine, dgnbeta_reset); |
| r3867 | r3868 | |
|---|---|---|
| 232 | 232 | |
| 233 | 233 | static WRITE8_HANDLER( slow_ctrl_w ) |
| 234 | 234 | { |
| 235 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 235 | 236 | /* |
| 236 | 237 | |
| 237 | 238 | bit description |
| r3867 | r3868 | |
| 248 | 249 | */ |
| 249 | 250 | |
| 250 | 251 | /* drive selection */ |
| 251 | if (!BIT(data, 0)) wd17xx_set_drive(0); | |
| 252 | if (!BIT(data, 1)) wd17xx_set_drive(1); | |
| 253 | // if (!BIT(data, 2)) wd17xx_set_drive(2); | |
| 252 | if (!BIT(data, 0)) wd17xx_set_drive(fdc,0); | |
| 253 | if (!BIT(data, 1)) wd17xx_set_drive(fdc,1); | |
| 254 | // if (!BIT(data, 2)) wd17xx_set_drive(fdc,2); | |
| 254 | 255 | |
| 255 | 256 | /* motor enable */ |
| 256 | 257 | floppy_drive_set_motor_state(get_floppy_image(0), !BIT(data, 3)); |
| r3867 | r3868 | |
| 259 | 260 | floppy_drive_set_ready_state(get_floppy_image(1), 1, 1); |
| 260 | 261 | |
| 261 | 262 | /* disk side selection */ |
| 262 | wd17xx_set_side(!BIT(data, 4)); | |
| 263 | wd17xx_set_side(fdc,!BIT(data, 4)); | |
| 263 | 264 | |
| 264 | 265 | if (!BIT(data, 7)) |
| 265 | 266 | { |
| 266 | 267 | /* FDC master reset */ |
| 267 | wd17xx_reset( | |
| 268 | wd17xx_reset(fd | |
| 268 | 269 | } |
| 269 | 270 | } |
| 270 | 271 | |
| r3867 | r3868 | |
| 397 | 398 | static ADDRESS_MAP_START( slow_io_map, ADDRESS_SPACE_IO, 8 ) |
| 398 | 399 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 399 | 400 | AM_RANGE(0x7c, 0x7f) AM_DEVREADWRITE(Z80PIO, CONKORT_Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w) |
| 400 | AM_RANGE(0xbc, 0xbf) AM_READWRITE(wd17xx_r, wd17xx_w) | |
| 401 | AM_RANGE(0xbc, 0xbf) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_r, wd17xx_w) | |
| 401 | 402 | AM_RANGE(0xdf, 0xdf) AM_WRITE(slow_status_w) |
| 402 | 403 | AM_RANGE(0xef, 0xef) AM_WRITE(slow_ctrl_w) |
| 403 | 404 | ADDRESS_MAP_END |
| r3867 | r3868 | |
| 417 | 418 | // AM_RANGE(0x3f, 0x3f) AM_WRITE() |
| 418 | 419 | // AM_RANGE(0x4f, 0x4f) AM_WRITE() |
| 419 | 420 | AM_RANGE(0x5d, 0x5d) AM_READ(fast_ctrl_r) |
| 420 | AM_RANGE(0x68, 0x6b) AM_READ(wd17xx_r) | |
| 421 | AM_RANGE(0x78, 0x7b) AM_WRITE(wd17xx_w) | |
| 421 | AM_RANGE(0x68, 0x6b) AM_DEVREAD(WD1793, "wd1793", wd17xx_r) | |
| 422 | AM_RANGE(0x78, 0x7b) AM_DEVWRITE(WD1793, "wd1793", wd17xx_w) | |
| 422 | 423 | AM_RANGE(0x87, 0x87) AM_DEVREADWRITE(Z80DMA, CONKORT_Z80DMA_TAG, z80dma_r, z80dma_w) |
| 423 | 424 | ADDRESS_MAP_END |
| 424 | 425 | |
| r3867 | r3868 | |
| 680 | 681 | |
| 681 | 682 | /* FD1791 */ |
| 682 | 683 | |
| 683 | static | |
| 684 | static WD17XX_CALLBACK( slow_wd1791_callback | |
| 684 | 685 | { |
| 685 | slow_t *conkort = get_safe_token_machine_slow(machine); | |
| 686 | slow_t *conkort = get_safe_token_machine_slow(device->machine); | |
| 686 | 687 | |
| 687 | 688 | switch(state) |
| 688 | 689 | { |
| r3867 | r3868 | |
| 699 | 700 | } |
| 700 | 701 | } |
| 701 | 702 | |
| 703 | static const wd17xx_interface slow_wd17xx_interface = { slow_wd1791_callback, NULL }; | |
| 704 | ||
| 702 | 705 | /* FD1793 */ |
| 703 | 706 | |
| 704 | static | |
| 707 | static WD17XX_CALLBACK( fast_wd1793_callback | |
| 705 | 708 | { |
| 706 | fast_t *conkort = get_safe_token_machine_fast(machine); | |
| 709 | fast_t *conkort = get_safe_token_machine_fast(device->machine); | |
| 707 | 710 | |
| 708 | 711 | switch(state) |
| 709 | 712 | { |
| r3867 | r3868 | |
| 720 | 723 | } |
| 721 | 724 | } |
| 722 | 725 | |
| 726 | static const wd17xx_interface fast_wd17xx_interface = { fast_wd1793_callback }; | |
| 727 | ||
| 723 | 728 | /* Machine Driver */ |
| 724 | 729 | |
| 725 | 730 | static MACHINE_DRIVER_START( luxor_55_10828 ) |
| r3867 | r3868 | |
| 729 | 734 | MDRV_CPU_CONFIG(slow_daisy_chain) |
| 730 | 735 | |
| 731 | 736 | MDRV_Z80PIO_ADD(CONKORT_Z80PIO_TAG, pio_intf) |
| 737 | MDRV_WD179X_ADD("wd179x", slow_wd17xx_interface ) | |
| 732 | 738 | MACHINE_DRIVER_END |
| 733 | 739 | |
| 734 | 740 | static MACHINE_DRIVER_START( luxor_55_21046 ) |
| r3867 | r3868 | |
| 739 | 745 | |
| 740 | 746 | MDRV_DEVICE_ADD(CONKORT_Z80DMA_TAG, Z80DMA) |
| 741 | 747 | MDRV_DEVICE_CONFIG(dma_intf) |
| 748 | ||
| 749 | MDRV_WD1793_ADD("wd1793", fast_wd17xx_interface ) | |
| 742 | 750 | MACHINE_DRIVER_END |
| 743 | 751 | |
| 744 | 752 | /* ROMs */ |
| r3867 | r3868 | |
| 808 | 816 | astring_printf(tempstring, "%s:%s", device->tag, CONKORT_Z80PIO_TAG); |
| 809 | 817 | conkort->z80pio = devtag_get_device(device->machine, Z80PIO, astring_c(tempstring)); |
| 810 | 818 | |
| 811 | /* initialize FDC */ | |
| 812 | wd17xx_init(device->machine, WD_TYPE_179X, slow_wd1791_callback, NULL); // FD1791-01 | |
| 813 | ||
| 814 | 819 | /* register for state saving */ |
| 815 | 820 | state_save_register_device_item(device, 0, conkort->status); |
| 816 | 821 | state_save_register_device_item(device, 0, conkort->data); |
| r3867 | r3868 | |
| 824 | 829 | |
| 825 | 830 | static DEVICE_RESET( luxor_55_10828 ) |
| 826 | 831 | { |
| 827 | ||
| 832 | ||
| 828 | 833 | } |
| 829 | 834 | |
| 830 | 835 | static DEVICE_SET_INFO( luxor_55_10828 ) |
| r3867 | r3868 | |
| 882 | 887 | astring_printf(tempstring, "%s:%s", device->tag, CONKORT_Z80DMA_TAG); |
| 883 | 888 | conkort->z80dma = devtag_get_device(device->machine, Z80DMA, astring_c(tempstring)); |
| 884 | 889 | |
| 885 | /* initialize FDC */ | |
| 886 | wd17xx_init(device->machine, WD_TYPE_1793, fast_wd1793_callback, NULL); // FD1793-01 | |
| 887 | ||
| 888 | 890 | /* register for state saving */ |
| 889 | 891 | state_save_register_device_item(device, 0, conkort->status); |
| 890 | 892 | state_save_register_device_item(device, 0, conkort->data); |
| r3867 | r3868 | |
| 897 | 899 | |
| 898 | 900 | static DEVICE_RESET( luxor_55_21046 ) |
| 899 | 901 | { |
| 900 | /* reset the FDC */ | |
| 901 | wd17xx_reset(device->machine); | |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | static DEVICE_SET_INFO( luxor_55_21046 ) |
| r3867 | r3868 | |
|---|---|---|
| 1127 | 1127 | |
| 1128 | 1128 | MSX_SLOT_RESET(diskrom) |
| 1129 | 1129 | { |
| 1130 | wd17xx_reset (machine); | |
| 1130 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 1131 | wd17xx_reset(fdc); | |
| 1131 | 1132 | } |
| 1132 | 1133 | |
| 1133 | 1134 | static READ8_HANDLER (msx_diskrom_page1_r) |
| 1134 | 1135 | { |
| 1136 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1135 | 1137 | switch (offset) { |
| 1136 | case 0: return wd17xx_status_r (space, 0); | |
| 1137 | case 1: return wd17xx_track_r (space, 0); | |
| 1138 | case 2: return wd17xx_sector_r (space, 0); | |
| 1139 | case 3: return wd17xx_data_r (space, 0); | |
| 1138 | case 0: return wd17xx_status_r (fdc, 0); | |
| 1139 | case 1: return wd17xx_track_r (fdc, 0); | |
| 1140 | case 2: return wd17xx_sector_r (fdc, 0); | |
| 1141 | case 3: return wd17xx_data_r (fdc, 0); | |
| 1140 | 1142 | case 7: return msx1.dsk_stat; |
| 1141 | 1143 | default: |
| 1142 | 1144 | return msx1.state[1]->mem[offset + 0x3ff8]; |
| r3867 | r3868 | |
| 1145 | 1147 | |
| 1146 | 1148 | static READ8_HANDLER (msx_diskrom_page2_r) |
| 1147 | 1149 | { |
| 1150 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1148 | 1151 | if (offset >= 0x7f8) { |
| 1149 | 1152 | switch (offset) { |
| 1150 | 1153 | case 0x7f8: |
| 1151 | return wd17xx_status_r ( | |
| 1154 | return wd17xx_status_r (fd | |
| 1152 | 1155 | case 0x7f9: |
| 1153 | return wd17xx_track_r ( | |
| 1156 | return wd17xx_track_r (fd | |
| 1154 | 1157 | case 0x7fa: |
| 1155 | return wd17xx_sector_r ( | |
| 1158 | return wd17xx_sector_r (fd | |
| 1156 | 1159 | case 0x7fb: |
| 1157 | return wd17xx_data_r ( | |
| 1160 | return wd17xx_data_r (fd | |
| 1158 | 1161 | case 0x7ff: |
| 1159 | 1162 | return msx1.dsk_stat; |
| 1160 | 1163 | default: |
| r3867 | r3868 | |
| 1193 | 1196 | |
| 1194 | 1197 | MSX_SLOT_WRITE(diskrom) |
| 1195 | 1198 | { |
| 1196 | | |
| 1199 | | |
| 1197 | 1200 | if (addr >= 0xa000 && addr < 0xc000) { |
| 1198 | 1201 | addr -= 0x4000; |
| 1199 | 1202 | } |
| 1200 | 1203 | switch (addr) { |
| 1201 | 1204 | case 0x7ff8: |
| 1202 | wd17xx_command_w ( | |
| 1205 | wd17xx_command_w (fd | |
| 1203 | 1206 | break; |
| 1204 | 1207 | case 0x7ff9: |
| 1205 | wd17xx_track_w ( | |
| 1208 | wd17xx_track_w (fd | |
| 1206 | 1209 | break; |
| 1207 | 1210 | case 0x7ffa: |
| 1208 | wd17xx_sector_w ( | |
| 1211 | wd17xx_sector_w (fd | |
| 1209 | 1212 | break; |
| 1210 | 1213 | case 0x7ffb: |
| 1211 | wd17xx_data_w ( | |
| 1214 | wd17xx_data_w (fd | |
| 1212 | 1215 | break; |
| 1213 | 1216 | case 0x7ffc: |
| 1214 | wd17xx_set_side (val & 1); | |
| 1217 | wd17xx_set_side (fdc,val & 1); | |
| 1215 | 1218 | state->mem[0x3ffc] = val | 0xfe; |
| 1216 | 1219 | break; |
| 1217 | 1220 | case 0x7ffd: |
| 1218 | wd17xx_set_drive (val & 1); | |
| 1221 | wd17xx_set_drive (fdc,val & 1); | |
| 1219 | 1222 | if ((state->mem[0x3ffd] ^ val) & 0x40) { |
| 1220 | 1223 | set_led_status (0, !(val & 0x40)); |
| 1221 | 1224 | } |
| r3867 | r3868 | |
| 1240 | 1243 | |
| 1241 | 1244 | MSX_SLOT_RESET(diskrom2) |
| 1242 | 1245 | { |
| 1243 | wd17xx_reset (machine); | |
| 1246 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 1247 | wd17xx_reset (fdc); | |
| 1244 | 1248 | } |
| 1245 | 1249 | |
| 1246 | 1250 | static READ8_HANDLER (msx_diskrom2_page1_r) |
| 1247 | 1251 | { |
| 1252 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1248 | 1253 | switch (offset) { |
| 1249 | case 0: return wd17xx_status_r(space, 0); | |
| 1250 | case 1: return wd17xx_track_r(space, 0); | |
| 1251 | case 2: return wd17xx_sector_r(space, 0); | |
| 1252 | case 3: return wd17xx_data_r(space, 0); | |
| 1254 | case 0: return wd17xx_status_r(fdc, 0); | |
| 1255 | case 1: return wd17xx_track_r(fdc, 0); | |
| 1256 | case 2: return wd17xx_sector_r(fdc, 0); | |
| 1257 | case 3: return wd17xx_data_r(fdc, 0); | |
| 1253 | 1258 | case 4: return msx1.dsk_stat; |
| 1254 | 1259 | default: |
| 1255 | 1260 | return msx1.state[1]->mem[offset + 0x3ff8]; |
| r3867 | r3868 | |
| 1258 | 1263 | |
| 1259 | 1264 | static READ8_HANDLER (msx_diskrom2_page2_r) |
| 1260 | 1265 | { |
| 1266 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1261 | 1267 | if (offset >= 0x7b8) { |
| 1262 | 1268 | switch (offset) { |
| 1263 | 1269 | case 0x7b8: |
| 1264 | return wd17xx_status_r ( | |
| 1270 | return wd17xx_status_r (fd | |
| 1265 | 1271 | case 0x7b9: |
| 1266 | return wd17xx_track_r ( | |
| 1272 | return wd17xx_track_r (fd | |
| 1267 | 1273 | case 0x7ba: |
| 1268 | return wd17xx_sector_r ( | |
| 1274 | return wd17xx_sector_r (fd | |
| 1269 | 1275 | case 0x7bb: |
| 1270 | return wd17xx_data_r ( | |
| 1276 | return wd17xx_data_r (fd | |
| 1271 | 1277 | case 0x7bc: |
| 1272 | 1278 | return msx1.dsk_stat; |
| 1273 | 1279 | default: |
| r3867 | r3868 | |
| 1305 | 1311 | |
| 1306 | 1312 | MSX_SLOT_WRITE(diskrom2) |
| 1307 | 1313 | { |
| 1308 | | |
| 1314 | | |
| 1309 | 1315 | if (addr >= 0xa000 && addr < 0xc000) { |
| 1310 | 1316 | addr -= 0x4000; |
| 1311 | 1317 | } |
| 1312 | 1318 | switch (addr) { |
| 1313 | 1319 | case 0x7fb8: |
| 1314 | wd17xx_command_w ( | |
| 1320 | wd17xx_command_w (fd | |
| 1315 | 1321 | break; |
| 1316 | 1322 | case 0x7fb9: |
| 1317 | wd17xx_track_w ( | |
| 1323 | wd17xx_track_w (fd | |
| 1318 | 1324 | break; |
| 1319 | 1325 | case 0x7fba: |
| 1320 | wd17xx_sector_w ( | |
| 1326 | wd17xx_sector_w (fd | |
| 1321 | 1327 | break; |
| 1322 | 1328 | case 0x7fbb: |
| 1323 | wd17xx_data_w ( | |
| 1329 | wd17xx_data_w (fd | |
| 1324 | 1330 | break; |
| 1325 | 1331 | case 0x7fbc: |
| 1326 | wd17xx_set_side (val & 1); | |
| 1332 | wd17xx_set_side (fdc,val & 1); | |
| 1327 | 1333 | state->mem[0x3fbc] = val | 0xfe; |
| 1328 | wd17xx_set_drive (val & 1); | |
| 1334 | wd17xx_set_drive (fdc,val & 1); | |
| 1329 | 1335 | if ((state->mem[0x3fbc] ^ val) & 0x40) { |
| 1330 | 1336 | set_led_status (0, !(val & 0x40)); |
| 1331 | 1337 | } |
| r3867 | r3868 | |
|---|---|---|
| 28 | 28 | static UINT8 fdc_head = 0; |
| 29 | 29 | static UINT8 fdc_den = 0; |
| 30 | 30 | static UINT8 fdc_status = 0; |
| 31 | static void mbee_fdc_callback(running_machine *machine, wd17xx_state_t event, void *param); | |
| 32 | 31 | |
| 33 | 32 | UINT8 *mbee_workram; |
| 34 | 33 | |
| r3867 | r3868 | |
| 51 | 50 | memory_set_bank(machine, 1, 1); |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | ||
| 53 | static WD17XX_C | |
| 55 | 54 | { |
| 56 | wd17xx_init(machine, WD_TYPE_179X,mbee_fdc_callback, NULL); | |
| 57 | } | |
| 58 | ||
| 59 | static void mbee_fdc_callback(running_machine *machine, wd17xx_state_t state, void *param) | |
| 60 | { | |
| 61 | 55 | switch( state ) |
| 62 | 56 | { |
| 63 | 57 | case WD17XX_IRQ_CLR: |
| r3867 | r3868 | |
| 77 | 71 | } |
| 78 | 72 | } |
| 79 | 73 | |
| 74 | const wd17xx_interface mbee_wd17xx_interface = { mbee_fdc_callback, NULL }; | |
| 75 | ||
| 80 | 76 | READ8_HANDLER ( mbee_fdc_status_r ) |
| 81 | 77 | { |
| 82 | 78 | logerror("mbee fdc_motor_r $%02X\n", fdc_status); |
| r3867 | r3868 | |
| 85 | 81 | |
| 86 | 82 | WRITE8_HANDLER ( mbee_fdc_motor_w ) |
| 87 | 83 | { |
| 84 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 88 | 85 | logerror("mbee fdc_motor_w $%02X\n", data); |
| 89 | 86 | /* Controller latch bits |
| 90 | 87 | * 0-1 driver select |
| r3867 | r3868 | |
| 95 | 92 | fdc_drv = data & 3; |
| 96 | 93 | fdc_head = (data >> 2) & 1; |
| 97 | 94 | fdc_den = (data >> 3) & 1; |
| 98 | wd17xx_set_drive(fdc_drv); | |
| 99 | wd17xx_set_side(fdc_head); | |
| 95 | wd17xx_set_drive(fdc,fdc_drv); | |
| 96 | wd17xx_set_side(fdc,fdc_head); | |
| 100 | 97 | if (data & (1<<3)) |
| 101 | 98 | { |
| 102 | wd17xx_set_density(DEN_FM_HI); | |
| 99 | wd17xx_set_density(fdc,DEN_FM_HI); | |
| 103 | 100 | } |
| 104 | 101 | else |
| 105 | 102 | { |
| 106 | wd17xx_set_density(DEN_MFM_LO); | |
| 103 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 107 | 104 | } |
| 108 | 105 | |
| 109 | 106 | } |
| r3867 | r3868 | |
|---|---|---|
| 393 | 393 | coco3_sam_set_maptype |
| 394 | 394 | }; |
| 395 | 395 | |
| 396 | ||
| 396 | ||
| 397 | 397 | static emu_timer *cart_timer; |
| 398 | 398 | static emu_timer *nmi_timer; |
| 399 | 399 | static emu_timer *halt_timer; |
| r3867 | r3868 | |
| 1231 | 1231 | |
| 1232 | 1232 | WRITE8_HANDLER ( dgnalpha_psg_porta_write ) |
| 1233 | 1233 | { |
| 1234 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1234 | 1235 | /* Bits 0..3 are the drive select lines for the internal floppy interface */ |
| 1235 | 1236 | /* Bit 4 is the motor on, in the real hardware these are inverted on their way to the drive */ |
| 1236 | 1237 | /* Bits 5,6,7 are connected to /DDEN, ENP and 5/8 on the WD2797 */ |
| 1237 | 1238 | switch (data & 0xF) |
| 1238 | 1239 | { |
| 1239 | 1240 | case(0x01) : |
| 1240 | wd17xx_set_drive(0); | |
| 1241 | wd17xx_set_drive(fdc,0); | |
| 1241 | 1242 | break; |
| 1242 | 1243 | case(0x02) : |
| 1243 | wd17xx_set_drive(1); | |
| 1244 | wd17xx_set_drive(fdc,1); | |
| 1244 | 1245 | break; |
| 1245 | 1246 | case(0x04) : |
| 1246 | wd17xx_set_drive(2); | |
| 1247 | wd17xx_set_drive(fdc,2); | |
| 1247 | 1248 | break; |
| 1248 | 1249 | case(0x08) : |
| 1249 | wd17xx_set_drive(3); | |
| 1250 | wd17xx_set_drive(fdc,3); | |
| 1250 | 1251 | break; |
| 1251 | 1252 | } |
| 1252 | 1253 | } |
| r3867 | r3868 | |
| 1650 | 1651 | /* Dragon Alpha onboard FDC */ |
| 1651 | 1652 | /********************************************************************************************/ |
| 1652 | 1653 | |
| 1653 | static | |
| 1654 | static WD17XX_CALLBACK( d | |
| 1654 | 1655 | { |
| 1655 | 1656 | /* The NMI line on the alphaAlpha is gated through IC16 (early PLD), and is gated by pia2 CA2 */ |
| 1656 | 1657 | /* The DRQ line goes through pia2 cb1, in exactly the same way as DRQ from DragonDos does */ |
| 1657 | 1658 | /* for pia1 cb1 */ |
| 1658 | 1659 | |
| 1659 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); | |
| 1660 | const address_space *space = cpu_get_address_space( device->machine->cpu[0], ADDRESS_SPACE_PROGRAM ); | |
| 1660 | 1661 | |
| 1661 | switch( | |
| 1662 | switch(s | |
| 1662 | 1663 | { |
| 1663 | 1664 | case WD17XX_IRQ_CLR: |
| 1664 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE); | |
| 1665 | cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE); | |
| 1665 | 1666 | break; |
| 1666 | 1667 | case WD17XX_IRQ_SET: |
| 1667 | 1668 | if(dgnalpha_just_reset) |
| r3867 | r3868 | |
| 1671 | 1672 | else |
| 1672 | 1673 | { |
| 1673 | 1674 | if (pia_get_output_ca2_z(2)) |
| 1674 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, ASSERT_LINE); | |
| 1675 | cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, ASSERT_LINE); | |
| 1675 | 1676 | } |
| 1676 | 1677 | break; |
| 1677 | 1678 | case WD17XX_DRQ_CLR: |
| r3867 | r3868 | |
| 1686 | 1687 | /* The Dragon Alpha hardware reverses the order of the WD2797 registers */ |
| 1687 | 1688 | READ8_HANDLER(wd2797_r) |
| 1688 | 1689 | { |
| 1690 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1689 | 1691 | int result = 0; |
| 1690 | 1692 | |
| 1691 | 1693 | switch(offset & 0x03) |
| 1692 | 1694 | { |
| 1693 | 1695 | case 0: |
| 1694 | result = wd17xx_data_r( | |
| 1696 | result = wd17xx_data_r(fd | |
| 1695 | 1697 | break; |
| 1696 | 1698 | case 1: |
| 1697 | result = wd17xx_sector_r( | |
| 1699 | result = wd17xx_sector_r(fd | |
| 1698 | 1700 | break; |
| 1699 | 1701 | case 2: |
| 1700 | result = wd17xx_track_r( | |
| 1702 | result = wd17xx_track_r(fd | |
| 1701 | 1703 | break; |
| 1702 | 1704 | case 3: |
| 1703 | result = wd17xx_status_r( | |
| 1705 | result = wd17xx_status_r(fd | |
| 1704 | 1706 | break; |
| 1705 | 1707 | default: |
| 1706 | 1708 | break; |
| r3867 | r3868 | |
| 1711 | 1713 | |
| 1712 | 1714 | WRITE8_HANDLER(wd2797_w) |
| 1713 | 1715 | { |
| 1716 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1714 | 1717 | switch(offset & 0x3) |
| 1715 | 1718 | { |
| 1716 | 1719 | case 0: |
| 1717 | wd17xx_data_w( | |
| 1720 | wd17xx_data_w(fd | |
| 1718 | 1721 | break; |
| 1719 | 1722 | case 1: |
| 1720 | wd17xx_sector_w( | |
| 1723 | wd17xx_sector_w(fd | |
| 1721 | 1724 | break; |
| 1722 | 1725 | case 2: |
| 1723 | wd17xx_track_w( | |
| 1726 | wd17xx_track_w(fd | |
| 1724 | 1727 | break; |
| 1725 | 1728 | case 3: |
| 1726 | wd17xx_command_w( | |
| 1729 | wd17xx_command_w(fd | |
| 1727 | 1730 | |
| 1728 | 1731 | /* disk head is encoded in the command byte */ |
| 1729 | wd17xx_set_side((data & 0x02) ? 1 : 0); | |
| 1732 | wd17xx_set_side(fdc,(data & 0x02) ? 1 : 0); | |
| 1730 | 1733 | break; |
| 1731 | 1734 | }; |
| 1732 | 1735 | } |
| r3867 | r3868 | |
| 2999 | 3002 | /* dgnalpha_just_reset, is here to flag that we should ignore the first irq generated */ |
| 3000 | 3003 | /* by the WD2797, it is reset to 0 after the first inurrupt */ |
| 3001 | 3004 | dgnalpha_just_reset=1; |
| 3002 | ||
| 3003 | wd17xx_init(machine, WD_TYPE_179X, dgnalpha_fdc_callback, NULL); | |
| 3004 | 3005 | } |
| 3005 | 3006 | |
| 3007 | const wd17xx_interface dgnalpha_wd17xx_interface = { | |
| 3008 | dgnalpha_fdc_callback, | |
| 3009 | NULL | |
| 3010 | }; | |
| 3006 | 3011 | /******* Machine Setups CoCos **********/ |
| 3007 | 3012 | |
| 3008 | 3013 | MACHINE_START( coco ) |
| r3867 | r3868 | |
|---|---|---|
| 367 | 367 | /* |
| 368 | 368 | callback called whenever DRQ/IRQ state change |
| 369 | 369 | */ |
| 370 | static | |
| 370 | static WD17XX_CALLBACK( fdc_callback | |
| 371 | 371 | { |
| 372 | switch ( | |
| 372 | switch (s | |
| 373 | 373 | { |
| 374 | 374 | case WD17XX_IRQ_CLR: |
| 375 | 375 | DRQ_IRQ_status &= ~fdc_IRQ; |
| r3867 | r3868 | |
| 387 | 387 | break; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | fdc_handle_hold(machine); | |
| 390 | fdc_handle_hold(device->machine); | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | const wd17xx_interface ti99_wd17xx_interface = { fdc_callback, NULL }; | |
| 394 | ||
| 395 | ||
| 393 | 396 | /* |
| 394 | 397 | Initializes all available controllers. This routine is only used in the |
| 395 | 398 | init state of the emulator. During the normal operation, only the |
| r3867 | r3868 | |
| 397 | 400 | */ |
| 398 | 401 | void ti99_floppy_controllers_init_all(running_machine *machine) |
| 399 | 402 | { |
| 400 | /* initialize the controller chip for TI FDC, CC, BwG */ | |
| 401 | wd17xx_init(machine, WD_TYPE_179X, fdc_callback, NULL); | |
| 402 | ||
| 403 | 403 | /* initialize the controller chip for HFDC */ |
| 404 | 404 | smc92x4_init(0, & hfdc_intf); |
| 405 | 405 | |
| r3867 | r3868 | |
| 414 | 414 | */ |
| 415 | 415 | |
| 416 | 416 | /* prototypes */ |
| 417 | static void fdc_callback(running_machine *machine, wd17xx_state_t event, void *param); | |
| 418 | 417 | static TIMER_CALLBACK(motor_on_timer_callback); |
| 419 | 418 | static int fdc_cru_r(running_machine *machine, int offset); |
| 420 | 419 | static void fdc_cru_w(running_machine *machine, int offset, int data); |
| r3867 | r3868 | |
| 437 | 436 | */ |
| 438 | 437 | void ti99_fdc_reset(running_machine *machine) |
| 439 | 438 | { |
| 439 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 440 | 440 | ti99_disk_DSR = memory_region(machine, region_dsr) + offset_fdc_dsr; |
| 441 | 441 | DSEL = 0; |
| 442 | 442 | DSKnum = -1; |
| r3867 | r3868 | |
| 448 | 448 | use_80_track_drives = FALSE; |
| 449 | 449 | |
| 450 | 450 | ti99_peb_set_card_handlers(0x1100, & fdc_handlers); |
| 451 | wd17xx_reset(machine); /* resets the fdc */ | |
| 452 | wd17xx_set_density(DEN_FM_LO); | |
| 451 | wd17xx_reset(fdc); /* resets the fdc */ | |
| 452 | wd17xx_set_density(fdc,DEN_FM_LO); | |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /* |
| r3867 | r3868 | |
| 491 | 491 | */ |
| 492 | 492 | static void fdc_cru_w(running_machine *machine, int offset, int data) |
| 493 | 493 | { |
| 494 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 495 | ||
| 494 | 496 | switch (offset) |
| 495 | 497 | { |
| 496 | 498 | case 0: |
| r3867 | r3868 | |
| 539 | 541 | { |
| 540 | 542 | DSKnum = drive; |
| 541 | 543 | |
| 542 | wd17xx_set_drive(DSKnum); | |
| 544 | wd17xx_set_drive(fdc,DSKnum); | |
| 543 | 545 | /*wd17xx_set_side(DSKside);*/ |
| 544 | 546 | } |
| 545 | 547 | } |
| r3867 | r3868 | |
| 558 | 560 | case 7: |
| 559 | 561 | /* Select side of disk (bit 7) */ |
| 560 | 562 | DSKside = data; |
| 561 | wd17xx_set_side(DSKside); | |
| 563 | wd17xx_set_side(fdc,DSKside); | |
| 562 | 564 | break; |
| 563 | 565 | } |
| 564 | 566 | } |
| r3867 | r3868 | |
| 569 | 571 | */ |
| 570 | 572 | static READ8_HANDLER(fdc_mem_r) |
| 571 | 573 | { |
| 574 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 575 | ||
| 572 | 576 | switch (offset) |
| 573 | 577 | { |
| 574 | 578 | case 0x1FF0: /* Status register */ |
| 575 | return (wd17xx_status_r( | |
| 579 | return (wd17xx_status_r(fd | |
| 576 | 580 | break; |
| 577 | 581 | case 0x1FF2: /* Track register */ |
| 578 | return wd17xx_track_r( | |
| 582 | return wd17xx_track_r(fd | |
| 579 | 583 | break; |
| 580 | 584 | case 0x1FF4: /* Sector register */ |
| 581 | return wd17xx_sector_r( | |
| 585 | return wd17xx_sector_r(fd | |
| 582 | 586 | break; |
| 583 | 587 | case 0x1FF6: /* Data register */ |
| 584 | return wd17xx_data_r( | |
| 588 | return wd17xx_data_r(fd | |
| 585 | 589 | break; |
| 586 | 590 | default: /* DSR ROM */ |
| 587 | 591 | return ti99_disk_DSR[offset]; |
| r3867 | r3868 | |
| 594 | 598 | */ |
| 595 | 599 | static WRITE8_HANDLER(fdc_mem_w) |
| 596 | 600 | { |
| 601 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 602 | ||
| 597 | 603 | data ^= 0xFF; /* inverted data bus */ |
| 598 | 604 | |
| 599 | 605 | switch (offset) |
| 600 | 606 | { |
| 601 | 607 | case 0x1FF8: /* Command register */ |
| 602 | wd17xx_command_w( | |
| 608 | wd17xx_command_w(fd | |
| 603 | 609 | break; |
| 604 | 610 | case 0x1FFA: /* Track register */ |
| 605 | wd17xx_track_w( | |
| 611 | wd17xx_track_w(fd | |
| 606 | 612 | break; |
| 607 | 613 | case 0x1FFC: /* Sector register */ |
| 608 | wd17xx_sector_w( | |
| 614 | wd17xx_sector_w(fd | |
| 609 | 615 | break; |
| 610 | 616 | case 0x1FFE: /* Data register */ |
| 611 | wd17xx_data_w( | |
| 617 | wd17xx_data_w(fd | |
| 612 | 618 | break; |
| 613 | 619 | } |
| 614 | 620 | } |
| r3867 | r3868 | |
| 644 | 650 | #if HAS_99CCFDC |
| 645 | 651 | void ti99_ccfdc_reset(running_machine *machine) |
| 646 | 652 | { |
| 653 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 654 | ||
| 647 | 655 | ti99_disk_DSR = memory_region(machine, region_dsr) + offset_ccfdc_dsr; |
| 648 | 656 | DSEL = 0; |
| 649 | 657 | DSKnum = -1; |
| r3867 | r3868 | |
| 656 | 664 | |
| 657 | 665 | ti99_peb_set_card_handlers(0x1100, & ccfdc_handlers); |
| 658 | 666 | |
| 659 | wd17xx_reset(machine); /* initialize the floppy disk controller */ | |
| 660 | wd17xx_set_density(DEN_MFM_LO); | |
| 667 | wd17xx_reset(fdc); /* initialize the floppy disk controller */ | |
| 668 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 661 | 669 | } |
| 662 | 670 | #endif |
| 663 | 671 | |
| r3867 | r3868 | |
| 696 | 704 | */ |
| 697 | 705 | static void ccfdc_cru_w(running_machine *machine, int offset, int data) |
| 698 | 706 | { |
| 707 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 708 | ||
| 699 | 709 | switch (offset) |
| 700 | 710 | { |
| 701 | 711 | case 0: |
| r3867 | r3868 | |
| 741 | 751 | { |
| 742 | 752 | DSKnum = drive; |
| 743 | 753 | |
| 744 | wd17xx_set_drive(DSKnum); | |
| 745 | /*wd17xx_set_side(DSKside);*/ | |
| 754 | wd17xx_set_drive(fdc,DSKnum); | |
| 755 | /*wd17xx_set_side(fdc,DSKside);*/ | |
| 746 | 756 | } |
| 747 | 757 | } |
| 748 | 758 | else |
| r3867 | r3868 | |
| 760 | 770 | case 7: |
| 761 | 771 | /* Select side of disk (bit 7) */ |
| 762 | 772 | DSKside = data; |
| 763 | wd17xx_set_side(DSKside); | |
| 773 | wd17xx_set_side(fdc,DSKside); | |
| 764 | 774 | break; |
| 765 | 775 | |
| 766 | 776 | case 10: |
| 767 | 777 | /* double density enable (active low) */ |
| 768 | wd17xx_set_density(data ? DEN_FM_LO : DEN_MFM_LO); | |
| 778 | wd17xx_set_density(fdc,data ? DEN_FM_LO : DEN_MFM_LO); | |
| 769 | 779 | break; |
| 770 | 780 | |
| 771 | 781 | case 11: |
| r3867 | r3868 | |
| 855 | 865 | */ |
| 856 | 866 | void ti99_bwg_reset(running_machine *machine) |
| 857 | 867 | { |
| 868 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 869 | ||
| 858 | 870 | ti99_disk_DSR = memory_region(machine, region_dsr) + offset_bwg_dsr; |
| 859 | 871 | bwg_ram = memory_region(machine, region_dsr) + offset_bwg_ram; |
| 860 | 872 | bwg_ram_offset = 0; |
| r3867 | r3868 | |
| 872 | 884 | |
| 873 | 885 | ti99_peb_set_card_handlers(0x1100, & bwg_handlers); |
| 874 | 886 | |
| 875 | wd17xx_reset(machine); /* initialize the floppy disk controller */ | |
| 876 | wd17xx_set_density(DEN_MFM_LO); | |
| 887 | wd17xx_reset(fdc); /* initialize the floppy disk controller */ | |
| 888 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 877 | 889 | } |
| 878 | 890 | |
| 879 | 891 | /* |
| r3867 | r3868 | |
| 910 | 922 | */ |
| 911 | 923 | static void bwg_cru_w(running_machine *machine, int offset, int data) |
| 912 | 924 | { |
| 925 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 926 | ||
| 913 | 927 | switch (offset) |
| 914 | 928 | { |
| 915 | 929 | case 0: |
| r3867 | r3868 | |
| 955 | 969 | { |
| 956 | 970 | DSKnum = drive; |
| 957 | 971 | |
| 958 | wd17xx_set_drive(DSKnum); | |
| 959 | /*wd17xx_set_side(DSKside);*/ | |
| 972 | wd17xx_set_drive(fdc,DSKnum); | |
| 973 | /*wd17xx_set_side(fdc,DSKside);*/ | |
| 960 | 974 | } |
| 961 | 975 | } |
| 962 | 976 | else |
| r3867 | r3868 | |
| 974 | 988 | case 7: |
| 975 | 989 | /* Select side of disk (bit 7) */ |
| 976 | 990 | DSKside = data; |
| 977 | wd17xx_set_side(DSKside); | |
| 991 | wd17xx_set_side(fdc,DSKside); | |
| 978 | 992 | break; |
| 979 | 993 | |
| 980 | 994 | case 10: |
| 981 | 995 | /* double density enable (active low) */ |
| 982 | wd17xx_set_density(data ? DEN_FM_LO : DEN_MFM_LO); | |
| 996 | wd17xx_set_density(fdc,data ? DEN_FM_LO : DEN_MFM_LO); | |
| 983 | 997 | break; |
| 984 | 998 | |
| 985 | 999 | case 11: |
| r3867 | r3868 | |
| 1025 | 1039 | */ |
| 1026 | 1040 | static READ8_HANDLER(bwg_mem_r) |
| 1027 | 1041 | { |
| 1042 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1043 | ||
| 1028 | 1044 | int reply = 0; |
| 1029 | 1045 | |
| 1030 | 1046 | if (offset < 0x1c00) |
| r3867 | r3868 | |
| 1044 | 1060 | switch (offset) |
| 1045 | 1061 | { |
| 1046 | 1062 | case 0x1FF0: /* Status register */ |
| 1047 | reply = wd17xx_status_r( | |
| 1063 | reply = wd17xx_status_r(fd | |
| 1048 | 1064 | break; |
| 1049 | 1065 | case 0x1FF2: /* Track register */ |
| 1050 | reply = wd17xx_track_r( | |
| 1066 | reply = wd17xx_track_r(fd | |
| 1051 | 1067 | break; |
| 1052 | 1068 | case 0x1FF4: /* Sector register */ |
| 1053 | reply = wd17xx_sector_r( | |
| 1069 | reply = wd17xx_sector_r(fd | |
| 1054 | 1070 | break; |
| 1055 | 1071 | case 0x1FF6: /* Data register */ |
| 1056 | reply = wd17xx_data_r( | |
| 1072 | reply = wd17xx_data_r(fd | |
| 1057 | 1073 | break; |
| 1058 | 1074 | default: |
| 1059 | 1075 | reply = 0; |
| r3867 | r3868 | |
| 1068 | 1084 | */ |
| 1069 | 1085 | static WRITE8_HANDLER(bwg_mem_w) |
| 1070 | 1086 | { |
| 1087 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1088 | ||
| 1071 | 1089 | if (offset < 0x1c00) |
| 1072 | 1090 | ; |
| 1073 | 1091 | else if (offset < 0x1fe0) |
| r3867 | r3868 | |
| 1088 | 1106 | switch (offset) |
| 1089 | 1107 | { |
| 1090 | 1108 | case 0x1FF8: /* Command register */ |
| 1091 | wd17xx_command_w( | |
| 1109 | wd17xx_command_w(fd | |
| 1092 | 1110 | break; |
| 1093 | 1111 | case 0x1FFA: /* Track register */ |
| 1094 | wd17xx_track_w( | |
| 1112 | wd17xx_track_w(fd | |
| 1095 | 1113 | break; |
| 1096 | 1114 | case 0x1FFC: /* Sector register */ |
| 1097 | wd17xx_sector_w( | |
| 1115 | wd17xx_sector_w(fd | |
| 1098 | 1116 | break; |
| 1099 | 1117 | case 0x1FFE: /* Data register */ |
| 1100 | wd17xx_data_w( | |
| 1118 | wd17xx_data_w(fd | |
| 1101 | 1119 | break; |
| 1102 | 1120 | } |
| 1103 | 1121 | } |
| r3867 | r3868 | |
|---|---|---|
| 1 | #ifndef TI99_DSK_H_ | |
| 2 | #define TI99_DSK_H_ | |
| 3 | ||
| 4 | #include "machine/wd17xx.h" | |
| 5 | ||
| 1 | 6 | FLOPPY_OPTIONS_EXTERN(ti99); |
| 2 | 7 | |
| 3 | 8 | void ti99_floppy_controllers_init_all(running_machine *machine); |
| r3867 | r3868 | |
| 7 | 12 | #endif |
| 8 | 13 | void ti99_bwg_reset(running_machine *machine); |
| 9 | 14 | void ti99_hfdc_reset(running_machine *machine); |
| 15 | ||
| 16 | extern const wd17xx_interface ti99_wd17xx_interface; | |
| 17 | #endif /* TI99_DSK_H_ */ |
| r3867 | r3868 | |
|---|---|---|
| 233 | 233 | static WRITE8_DEVICE_HANDLER (b2m_ext_8255_portc_w ) |
| 234 | 234 | { |
| 235 | 235 | UINT8 drive = ((data >> 1) & 1) ^ 1; |
| 236 | UINT8 side = (data & 1) ^ 1; | |
| 236 | UINT8 side = (data & 1) ^ 1; | |
| 237 | device_config *fdc = (device_config*)device_list_find_by_tag( device->machine->config->devicelist, WD1793, "wd1793"); | |
| 237 | 238 | |
| 238 | 239 | if (b2m_drive!=drive) { |
| 239 | wd17xx_set_drive(drive); | |
| 240 | wd17xx_set_drive(fdc,drive); | |
| 240 | 241 | b2m_drive = drive; |
| 241 | 242 | } |
| 242 | 243 | if (b2m_side!=side) { |
| 243 | wd17xx_set_side(side); | |
| 244 | wd17xx_set_side(fdc,side); | |
| 244 | 245 | b2m_side = side; |
| 245 | 246 | } |
| 246 | 247 | } |
| r3867 | r3868 | |
| 329 | 330 | |
| 330 | 331 | MACHINE_START(b2m) |
| 331 | 332 | { |
| 332 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 333 | wd17xx_set_pause_time(10); | |
| 333 | wd17xx_set_pause_time((device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"),10); | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | static IRQ_CALLBACK(b2m_irq_callback) |
| r3867 | r3868 | |
| 353 | 353 | MACHINE_RESET(b2m) |
| 354 | 354 | { |
| 355 | 355 | b2m_sound_input = 0; |
| 356 | ||
| 357 | wd17xx_reset(machine); | |
| 358 | ||
| 356 | ||
| 359 | 357 | b2m_side = 0; |
| 360 | 358 | b2m_drive = 0; |
| 361 | wd17xx_set_side(0); | |
| 362 | wd17xx_set_drive(0); | |
| 363 | 359 | |
| 364 | 360 | cpu_set_irq_callback(machine->cpu[0], b2m_irq_callback); |
| 365 | 361 | b2m_set_bank(machine,7); |
| r3867 | r3868 | |
|---|---|---|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | static | |
| 708 | static WD17XX_CALLBACK( oric_jasmin_wd179x_callback | |
| 709 | 709 | { |
| 710 | switch ( | |
| 710 | switch (state) | |
| 711 | 711 | { |
| 712 | 712 | /* DRQ is connected to interrupt */ |
| 713 | 713 | case WD17XX_DRQ_CLR: |
| 714 | 714 | { |
| 715 | 715 | oric_irqs &=~(1<<1); |
| 716 | 716 | |
| 717 | oric_refresh_ints(machine); | |
| 717 | oric_refresh_ints(device->machine); | |
| 718 | 718 | } |
| 719 | 719 | break; |
| 720 | 720 | |
| r3867 | r3868 | |
| 722 | 722 | { |
| 723 | 723 | oric_irqs |= (1<<1); |
| 724 | 724 | |
| 725 | oric_refresh_ints(machine); | |
| 725 | oric_refresh_ints(device->machine); | |
| 726 | 726 | } |
| 727 | 727 | break; |
| 728 | 728 | |
| r3867 | r3868 | |
| 734 | 734 | static READ8_HANDLER (oric_jasmin_r) |
| 735 | 735 | { |
| 736 | 736 | const device_config *via_0 = device_list_find_by_tag(space->machine->config->devicelist, VIA6522, "via6522_0"); |
| 737 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 737 | 738 | unsigned char data = 0x0ff; |
| 738 | 739 | |
| 739 | 740 | switch (offset & 0x0f) |
| 740 | 741 | { |
| 741 | 742 | /* jasmin floppy disc interface */ |
| 742 | 743 | case 0x04: |
| 743 | data = wd17xx_status_r( | |
| 744 | data = wd17xx_status_r(fd | |
| 744 | 745 | break; |
| 745 | 746 | case 0x05: |
| 746 | data =wd17xx_track_r( | |
| 747 | data =wd17xx_track_r(fd | |
| 747 | 748 | break; |
| 748 | 749 | case 0x06: |
| 749 | data = wd17xx_sector_r( | |
| 750 | data = wd17xx_sector_r(fd | |
| 750 | 751 | break; |
| 751 | 752 | case 0x07: |
| 752 | data = wd17xx_data_r( | |
| 753 | data = wd17xx_data_r(fd | |
| 753 | 754 | break; |
| 754 | 755 | default: |
| 755 | 756 | data = via_r(via_0, offset & 0x0f); |
| r3867 | r3868 | |
| 764 | 765 | static WRITE8_HANDLER(oric_jasmin_w) |
| 765 | 766 | { |
| 766 | 767 | const device_config *via_0 = device_list_find_by_tag(space->machine->config->devicelist, VIA6522, "via6522_0"); |
| 768 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 767 | 769 | switch (offset & 0x0f) |
| 768 | 770 | { |
| 769 | 771 | /* microdisc floppy disc interface */ |
| 770 | 772 | case 0x04: |
| 771 | wd17xx_command_w( | |
| 773 | wd17xx_command_w(fd | |
| 772 | 774 | break; |
| 773 | 775 | case 0x05: |
| 774 | wd17xx_track_w( | |
| 776 | wd17xx_track_w(fd | |
| 775 | 777 | break; |
| 776 | 778 | case 0x06: |
| 777 | wd17xx_sector_w( | |
| 779 | wd17xx_sector_w(fd | |
| 778 | 780 | break; |
| 779 | 781 | case 0x07: |
| 780 | wd17xx_data_w( | |
| 782 | wd17xx_data_w(fd | |
| 781 | 783 | break; |
| 782 | 784 | /* bit 0 = side */ |
| 783 | 785 | case 0x08: |
| 784 | wd17xx_set_side(data & 0x01); | |
| 786 | wd17xx_set_side(fdc,data & 0x01); | |
| 785 | 787 | break; |
| 786 | 788 | /* any write will cause wd179x to reset */ |
| 787 | 789 | case 0x09: |
| 788 | wd17xx_reset( | |
| 790 | wd17xx_reset(fd | |
| 789 | 791 | break; |
| 790 | 792 | case 0x0a: |
| 791 | 793 | logerror("jasmin overlay ram w: %02x PC: %04x\n",data,cpu_get_pc(space->machine->cpu[0])); |
| r3867 | r3868 | |
| 802 | 804 | case 0x0d: |
| 803 | 805 | case 0x0e: |
| 804 | 806 | case 0x0f: |
| 805 | wd17xx_set_drive(offset & 0x03); | |
| 807 | wd17xx_set_drive(fdc,offset & 0x03); | |
| 806 | 808 | break; |
| 807 | 809 | |
| 808 | 810 | default: |
| r3867 | r3868 | |
| 857 | 859 | oric_refresh_ints(machine); |
| 858 | 860 | } |
| 859 | 861 | |
| 860 | static | |
| 862 | static WD17XX_CALLBACK( oric_microdisc_wd179x_callback | |
| 861 | 863 | { |
| 862 | switch ( | |
| 864 | switch (state) | |
| 863 | 865 | { |
| 864 | 866 | case WD17XX_IRQ_CLR: |
| 865 | 867 | { |
| r3867 | r3868 | |
| 867 | 869 | |
| 868 | 870 | oric_wd179x_int_state = 0; |
| 869 | 871 | |
| 870 | oric_microdisc_refresh_wd179x_ints(machine); | |
| 872 | oric_microdisc_refresh_wd179x_ints(device->machine); | |
| 871 | 873 | } |
| 872 | 874 | break; |
| 873 | 875 | |
| r3867 | r3868 | |
| 877 | 879 | |
| 878 | 880 | oric_wd179x_int_state = 1; |
| 879 | 881 | |
| 880 | oric_microdisc_refresh_wd179x_ints(machine); | |
| 882 | oric_microdisc_refresh_wd179x_ints(device->machine); | |
| 881 | 883 | } |
| 882 | 884 | break; |
| 883 | 885 | |
| r3867 | r3868 | |
| 969 | 971 | READ8_HANDLER (oric_microdisc_r) |
| 970 | 972 | { |
| 971 | 973 | unsigned char data = 0x0ff; |
| 972 | ||
| 974 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 975 | ||
| 973 | 976 | switch (offset & 0x0ff) |
| 974 | 977 | { |
| 975 | 978 | /* microdisc floppy disc interface */ |
| 976 | 979 | case 0x00: |
| 977 | data = wd17xx_status_r( | |
| 980 | data = wd17xx_status_r(fd | |
| 978 | 981 | break; |
| 979 | 982 | case 0x01: |
| 980 | data =wd17xx_track_r( | |
| 983 | data =wd17xx_track_r(fd | |
| 981 | 984 | break; |
| 982 | 985 | case 0x02: |
| 983 | data = wd17xx_sector_r( | |
| 986 | data = wd17xx_sector_r(fd | |
| 984 | 987 | break; |
| 985 | 988 | case 0x03: |
| 986 | data = wd17xx_data_r( | |
| 989 | data = wd17xx_data_r(fd | |
| 987 | 990 | break; |
| 988 | 991 | case 0x04: |
| 989 | 992 | data = port_314_r | 0x07f; |
| r3867 | r3868 | |
| 1008 | 1011 | |
| 1009 | 1012 | WRITE8_HANDLER(oric_microdisc_w) |
| 1010 | 1013 | { |
| 1014 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 1011 | 1015 | switch (offset & 0x0ff) |
| 1012 | 1016 | { |
| 1013 | 1017 | /* microdisc floppy disc interface */ |
| 1014 | 1018 | case 0x00: |
| 1015 | wd17xx_command_w( | |
| 1019 | wd17xx_command_w(fd | |
| 1016 | 1020 | break; |
| 1017 | 1021 | case 0x01: |
| 1018 | wd17xx_track_w( | |
| 1022 | wd17xx_track_w(fd | |
| 1019 | 1023 | break; |
| 1020 | 1024 | case 0x02: |
| 1021 | wd17xx_sector_w( | |
| 1025 | wd17xx_sector_w(fd | |
| 1022 | 1026 | break; |
| 1023 | 1027 | case 0x03: |
| 1024 | wd17xx_data_w( | |
| 1028 | wd17xx_data_w(fd | |
| 1025 | 1029 | break; |
| 1026 | 1030 | case 0x04: |
| 1027 | 1031 | { |
| r3867 | r3868 | |
| 1035 | 1039 | /* bit 4: side */ |
| 1036 | 1040 | /* bit 3: double density enable */ |
| 1037 | 1041 | /* bit 0: enable FDC IRQ to trigger IRQ on CPU */ |
| 1038 | wd17xx_set_drive((data>>5) & 0x03); | |
| 1039 | wd17xx_set_side((data>>4) & 0x01); | |
| 1042 | wd17xx_set_drive(fdc,(data>>5) & 0x03); | |
| 1043 | wd17xx_set_side(fdc,(data>>4) & 0x01); | |
| 1040 | 1044 | if (data & (1<<3)) |
| 1041 | 1045 | { |
| 1042 | 1046 | density = DEN_MFM_LO; |
| r3867 | r3868 | |
| 1046 | 1050 | density = DEN_FM_HI; |
| 1047 | 1051 | } |
| 1048 | 1052 | |
| 1049 | wd17xx_set_density(density); | |
| 1053 | wd17xx_set_density(fdc,density); | |
| 1050 | 1054 | |
| 1051 | 1055 | oric_microdisc_set_mem_0x0c000(space->machine); |
| 1052 | 1056 | oric_microdisc_refresh_wd179x_ints(space->machine); |
| r3867 | r3868 | |
| 1086 | 1090 | /*********************************************************/ |
| 1087 | 1091 | |
| 1088 | 1092 | |
| 1089 | static | |
| 1093 | static WD17XX_CALLBACK(o | |
| 1090 | 1094 | { |
| 1091 | switch (input_port_read(machine, "FLOPPY") & 0x07) | |
| 1095 | switch (input_port_read(device->machine, "FLOPPY") & 0x07) | |
| 1092 | 1096 | { |
| 1093 | 1097 | default: |
| 1094 | 1098 | case ORIC_FLOPPY_INTERFACE_NONE: |
| 1095 | 1099 | case ORIC_FLOPPY_INTERFACE_APPLE2: |
| 1096 | 1100 | return; |
| 1097 | 1101 | case ORIC_FLOPPY_INTERFACE_MICRODISC: |
| 1098 | oric_microdisc_wd179x_callback( | |
| 1102 | oric_microdisc_wd179x_callback(dev | |
| 1099 | 1103 | return; |
| 1100 | 1104 | case ORIC_FLOPPY_INTERFACE_JASMIN: |
| 1101 | oric_jasmin_wd179x_callback( | |
| 1105 | oric_jasmin_wd179x_callback(dev | |
| 1102 | 1106 | return; |
| 1103 | 1107 | } |
| 1104 | 1108 | } |
| 1105 | 1109 | |
| 1110 | const wd17xx_interface oric_wd17xx_interface = { oric_wd179x_callback, NULL }; | |
| 1111 | ||
| 1106 | 1112 | DEVICE_START( oric_floppy ) |
| 1107 | 1113 | { |
| 1108 | 1114 | /* TODO - THIS DOES NOT MULTITASK BETWEEN ORIC BASICDSKs AND MFM DISKS */ |
| r3867 | r3868 | |
| 1155 | 1161 | oric_is_telestrat = 0; |
| 1156 | 1162 | |
| 1157 | 1163 | oric_ram_0x0c000 = auto_malloc(16384); |
| 1158 | ||
| 1159 | wd17xx_init(machine, WD_TYPE_179X,oric_wd179x_callback, NULL); | |
| 1160 | 1164 | } |
| 1161 | 1165 | |
| 1162 | 1166 | |
| r3867 | r3868 | |
| 1545 | 1549 | /* disable os rom, enable microdisc rom */ |
| 1546 | 1550 | /* 0x0c000-0x0dfff will be ram, 0x0e000-0x0ffff will be microdisc rom */ |
| 1547 | 1551 | port_314_w = 0x0ff^((1<<7) | (1<<1)); |
| 1548 | ||
| 1549 | wd17xx_init(machine, WD_TYPE_179X,oric_wd179x_callback, NULL); | |
| 1550 | 1552 | } |
| r3867 | r3868 | |
|---|---|---|
| 404 | 404 | dma8237_drq_write( at_devices.dma8237_1, FDC_DMA, state); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | static device_config * at_get_device(running_machine *machine ) | |
| 408 | { | |
| 409 | return (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC765A, "nec765"); | |
| 410 | } | |
| 411 | ||
| 407 | 412 | static const struct pc_fdc_interface fdc_interface = |
| 408 | 413 | { |
| 409 | NEC765A, | |
| 410 | NEC765_RDY_PIN_NOT_CONNECTED, | |
| 411 | 414 | at_fdc_interrupt, |
| 412 | 415 | at_fdc_dma_drq, |
| 416 | NULL, | |
| 417 | at_get_device | |
| 413 | 418 | }; |
| 414 | 419 | |
| 415 | 420 |
| r3867 | r3868 | |
|---|---|---|
| 171 | 171 | |
| 172 | 172 | WRITE8_HANDLER(vector_disc_w) |
| 173 | 173 | { |
| 174 | wd17xx_set_side (((data & 4) >> 2) ^ 1); | |
| 175 | wd17xx_set_drive(data & 1); | |
| 174 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 175 | wd17xx_set_side (fdc,((data & 4) >> 2) ^ 1); | |
| 176 | wd17xx_set_drive(fdc,data & 1); | |
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | DEVICE_IMAGE_LOAD( vector_floppy ) |
| r3867 | r3868 | |
| 204 | 205 | |
| 205 | 206 | MACHINE_START( vector06 ) |
| 206 | 207 | { |
| 207 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 208 | wd17xx_set_density (DEN_FM_HI); | |
| 208 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"); | |
| 209 | wd17xx_set_density (fdc, DEN_FM_HI); | |
| 209 | 210 | } |
| 210 | 211 | |
| 211 | 212 | MACHINE_RESET( vector06 ) |
| r3867 | r3868 | |
| 227 | 228 | vector_color_index = 0; |
| 228 | 229 | vector_video_mode = 0; |
| 229 | 230 | timer_pulse(machine, ATTOTIME_IN_HZ(50), NULL, 0, reset_check_callback); |
| 230 | ||
| 231 | wd17xx_reset(machine); | |
| 232 | wd17xx_set_pause_time(0); | |
| 233 | 231 | } |
| r3867 | r3868 | |
|---|---|---|
| 71 | 71 | |
| 72 | 72 | MACHINE_START( orion128 ) |
| 73 | 73 | { |
| 74 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 75 | wd17xx_set_density (DEN_FM_HI); | |
| 74 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"); | |
| 75 | ||
| 76 | wd17xx_set_density (fdc,DEN_FM_HI); | |
| 76 | 77 | orion_video_mode_mask = 7; |
| 77 | 78 | } |
| 78 | 79 | |
| r3867 | r3868 | |
| 158 | 159 | |
| 159 | 160 | MACHINE_RESET ( orion128 ) |
| 160 | 161 | { |
| 161 | wd17xx_reset(machine); | |
| 162 | wd17xx_set_density (DEN_FM_HI); | |
| 163 | 162 | orion128_video_page = 0; |
| 164 | 163 | orion128_video_mode = 0; |
| 165 | 164 | orion128_memory_page = -1; |
| r3867 | r3868 | |
| 205 | 204 | |
| 206 | 205 | static WRITE8_HANDLER ( orion_disk_control_w ) |
| 207 | 206 | { |
| 208 | wd17xx_set_side(((data & 0x10) >> 4) ^ 1); | |
| 209 | wd17xx_set_drive(data & 3); | |
| 207 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 208 | ||
| 209 | wd17xx_set_side(fdc,((data & 0x10) >> 4) ^ 1); | |
| 210 | wd17xx_set_drive(fdc,data & 3); | |
| 210 | 211 | } |
| 211 | 212 | |
| 212 | 213 | READ8_HANDLER ( orion128_floppy_r ) |
| 213 | 214 | { |
| 215 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 216 | ||
| 214 | 217 | switch(offset) { |
| 215 | 218 | case 0x0 : |
| 216 | case 0x10 : return wd17xx_status_r( | |
| 219 | case 0x10 : return wd17xx_status_r(fd | |
| 217 | 220 | case 0x1 : |
| 218 | case 0x11 : return wd17xx_track_r( | |
| 221 | case 0x11 : return wd17xx_track_r(fd | |
| 219 | 222 | case 0x2 : |
| 220 | case 0x12 : return wd17xx_sector_r( | |
| 223 | case 0x12 : return wd17xx_sector_r(fd | |
| 221 | 224 | case 0x3 : |
| 222 | case 0x13 : return wd17xx_data_r( | |
| 225 | case 0x13 : return wd17xx_data_r(fd | |
| 223 | 226 | } |
| 224 | 227 | return 0xff; |
| 225 | 228 | } |
| 226 | 229 | |
| 227 | 230 | WRITE8_HANDLER ( orion128_floppy_w ) |
| 228 | 231 | { |
| 232 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 233 | ||
| 229 | 234 | switch(offset) { |
| 230 | 235 | case 0x0 : |
| 231 | case 0x10 : wd17xx_command_w( | |
| 236 | case 0x10 : wd17xx_command_w(fd | |
| 232 | 237 | case 0x1 : |
| 233 | case 0x11 : wd17xx_track_w( | |
| 238 | case 0x11 : wd17xx_track_w(fd | |
| 234 | 239 | case 0x2 : |
| 235 | case 0x12 : wd17xx_sector_w( | |
| 240 | case 0x12 : wd17xx_sector_w(fd | |
| 236 | 241 | case 0x3 : |
| 237 | case 0x13 : wd17xx_data_w( | |
| 242 | case 0x13 : wd17xx_data_w(fd | |
| 238 | 243 | case 0x4 : |
| 239 | 244 | case 0x14 : |
| 240 | 245 | case 0x20 : orion_disk_control_w(space, offset, data);break; |
| r3867 | r3868 | |
| 267 | 272 | |
| 268 | 273 | MACHINE_START( orionz80 ) |
| 269 | 274 | { |
| 270 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 271 | wd17xx_set_density (DEN_FM_HI); | |
| 275 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"); | |
| 276 | ||
| 277 | wd17xx_set_density (fdc,DEN_FM_HI); | |
| 272 | 278 | mc146818_init(machine, MC146818_IGNORE_CENTURY); |
| 273 | 279 | orion_video_mode_mask = 7; |
| 274 | 280 | } |
| r3867 | r3868 | |
| 375 | 381 | memory_set_bankptr(machine, 3, mess_ram + 0xf000); |
| 376 | 382 | memory_set_bankptr(machine, 5, memory_region(machine, "main") + 0xf800); |
| 377 | 383 | |
| 378 | ||
| 384 | ||
| 379 | 385 | orion128_video_page = 0; |
| 380 | 386 | orion128_video_mode = 0; |
| 381 | 387 | orionz80_memory_page = 0; |
| r3867 | r3868 | |
| 437 | 443 | |
| 438 | 444 | MACHINE_START( orionpro ) |
| 439 | 445 | { |
| 440 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 441 | wd17xx_set_density (DEN_FM_HI); | |
| 446 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"); | |
| 447 | wd17xx_set_density (fdc,DEN_FM_HI); | |
| 442 | 448 | } |
| 443 | 449 | |
| 444 | 450 | static WRITE8_HANDLER ( orionpro_memory_page_w ); |
| r3867 | r3868 | |
| 533 | 539 | MACHINE_RESET ( orionpro ) |
| 534 | 540 | { |
| 535 | 541 | radio86_init_keyboard(); |
| 536 | ||
| 537 | wd17xx_reset(machine); | |
| 538 | 542 | |
| 539 | 543 | orion128_video_page = 0; |
| 540 | 544 | orion128_video_mode = 0; |
| r3867 | r3868 | |
| 558 | 562 | } |
| 559 | 563 | |
| 560 | 564 | READ8_HANDLER ( orionpro_io_r ) { |
| 565 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 566 | ||
| 561 | 567 | switch (offset & 0xff) { |
| 562 | 568 | case 0x00 : return 0x56; |
| 563 | 569 | case 0x04 : return orionpro_ram0_segment; |
| r3867 | r3868 | |
| 566 | 572 | case 0x08 : return orionpro_page; |
| 567 | 573 | case 0x09 : return orionpro_rom2_segment; |
| 568 | 574 | case 0x0a : return orionpro_dispatcher; |
| 569 | case 0x10 : return wd17xx_status_r(space,0); | |
| 570 | case 0x11 : return wd17xx_track_r(space,0); | |
| 571 | case 0x12 : return wd17xx_sector_r(space,0); | |
| 572 | case 0x13 : return wd17xx_data_r(space,0); | |
| 575 | case 0x10 : return wd17xx_status_r(fdc,0); | |
| 576 | case 0x11 : return wd17xx_track_r(fdc,0); | |
| 577 | case 0x12 : return wd17xx_sector_r(fdc,0); | |
| 578 | case 0x13 : return wd17xx_data_r(fdc,0); | |
| 573 | 579 | case 0x18 : |
| 574 | 580 | case 0x19 : |
| 575 | 581 | case 0x1a : |
| r3867 | r3868 | |
| 587 | 593 | } |
| 588 | 594 | |
| 589 | 595 | WRITE8_HANDLER ( orionpro_io_w ) { |
| 596 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 597 | ||
| 590 | 598 | switch (offset & 0xff) { |
| 591 | 599 | case 0x04 : orionpro_ram0_segment = data; orionpro_bank_switch(space->machine); break; |
| 592 | 600 | case 0x05 : orionpro_ram1_segment = data; orionpro_bank_switch(space->machine); break; |
| r3867 | r3868 | |
| 594 | 602 | case 0x08 : orionpro_page = data; orionpro_bank_switch(space->machine); break; |
| 595 | 603 | case 0x09 : orionpro_rom2_segment = data; orionpro_bank_switch(space->machine); break; |
| 596 | 604 | case 0x0a : orionpro_dispatcher = data; orionpro_bank_switch(space->machine); break; |
| 597 | case 0x10 : wd17xx_command_w(space,0,data); break; | |
| 598 | case 0x11 : wd17xx_track_w(space,0,data);break; | |
| 599 | case 0x12 : wd17xx_sector_w(space,0,data);break; | |
| 600 | case 0x13 : wd17xx_data_w(space,0,data);break; | |
| 605 | case 0x10 : wd17xx_command_w(fdc,0,data); break; | |
| 606 | case 0x11 : wd17xx_track_w(fdc,0,data);break; | |
| 607 | case 0x12 : wd17xx_sector_w(fdc,0,data);break; | |
| 608 | case 0x13 : wd17xx_data_w(fdc,0,data);break; | |
| 601 | 609 | case 0x14 : orion_disk_control_w(space, 9, data);break; |
| 602 | 610 | case 0x18 : |
| 603 | 611 | case 0x19 : |
| r3867 | r3868 | |
|---|---|---|
| 55 | 55 | * |
| 56 | 56 | *************************************/ |
| 57 | 57 | |
| 58 | static | |
| 58 | static WD17XX_CALLBACK( nascom2_fdc_callback | |
| 59 | 59 | { |
| 60 | switch ( | |
| 60 | switch (s | |
| 61 | 61 | { |
| 62 | 62 | case WD17XX_IRQ_SET: nascom2_fdc.irq = 1; break; |
| 63 | 63 | case WD17XX_IRQ_CLR: nascom2_fdc.irq = 0; break; |
| r3867 | r3868 | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
| 70 | const wd17xx_interface nascom2_wd17xx_interface = { nascom2_fdc_callback, NULL }; | |
| 71 | ||
| 72 | ||
| 70 | 73 | READ8_HANDLER( nascom2_fdc_select_r ) |
| 71 | 74 | { |
| 72 | 75 | return nascom2_fdc.select | 0xa0; |
| r3867 | r3868 | |
| 75 | 78 | |
| 76 | 79 | WRITE8_HANDLER( nascom2_fdc_select_w ) |
| 77 | 80 | { |
| 81 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 78 | 82 | nascom2_fdc.select = data; |
| 79 | 83 | |
| 80 | 84 | logerror("nascom2_fdc_select_w: %02x\n", data); |
| 81 | 85 | |
| 82 | if (data & 0x01) wd17xx_set_drive(0); | |
| 83 | if (data & 0x02) wd17xx_set_drive(1); | |
| 84 | if (data & 0x04) wd17xx_set_drive(2); | |
| 85 | if (data & 0x08) wd17xx_set_drive(3); | |
| 86 | if (data & 0x10) wd17xx_set_side((data & 0x10) >> 4); | |
| 86 | if (data & 0x01) wd17xx_set_drive(fdc,0); | |
| 87 | if (data & 0x02) wd17xx_set_drive(fdc,1); | |
| 88 | if (data & 0x04) wd17xx_set_drive(fdc,2); | |
| 89 | if (data & 0x08) wd17xx_set_drive(fdc,3); | |
| 90 | if (data & 0x10) wd17xx_set_side(fdc,(data & 0x10) >> 4); | |
| 87 | 91 | } |
| 88 | 92 | |
| 89 | 93 | |
| r3867 | r3868 | |
| 103 | 107 | DEVICE_IMAGE_LOAD( nascom2_floppy ) |
| 104 | 108 | { |
| 105 | 109 | int sides, sectors; |
| 106 | ||
| 110 | device_config *fdc = (device_config*)device_list_find_by_tag( image->machine->config->devicelist, WD1793, "wd1793"); | |
| 107 | 111 | if (!image_has_been_created(image)) |
| 108 | 112 | { |
| 109 | 113 | switch (image_length(image)) |
| r3867 | r3868 | |
| 111 | 115 | case 80 * 2 * 2 * 8 * 256: |
| 112 | 116 | sides = 2; |
| 113 | 117 | sectors = 2 * 8; |
| 114 | wd17xx_set_density(DEN_FM_HI); | |
| 118 | wd17xx_set_density(fdc,DEN_FM_HI); | |
| 115 | 119 | break; |
| 116 | 120 | |
| 117 | 121 | case 80 * 1 * 2 * 8 * 256: |
| 118 | 122 | sides = 1; |
| 119 | 123 | sectors = 2 * 8; |
| 120 | wd17xx_set_density(DEN_FM_HI); | |
| 124 | wd17xx_set_density(fdc,DEN_FM_HI); | |
| 121 | 125 | break; |
| 122 | 126 | |
| 123 | 127 | default: |
| r3867 | r3868 | |
| 290 | 294 | * |
| 291 | 295 | *************************************/ |
| 292 | 296 | |
| 293 | MACHINE_START( nascom2 ) | |
| 294 | { | |
| 295 | wd17xx_init(machine, WD_TYPE_1793, nascom2_fdc_callback, NULL); | |
| 296 | } | |
| 297 | ||
| 298 | ||
| 299 | 297 | MACHINE_RESET( nascom1 ) |
| 300 | 298 | { |
| 301 | 299 | nascom1_hd6402 = device_list_find_by_tag( machine->config->devicelist, AY31015, "hd6402" ); |
| r3867 | r3868 | |
|---|---|---|
| 74 | 74 | READ8_HANDLER( osborne1_2000_r ) |
| 75 | 75 | { |
| 76 | 76 | UINT8 data = 0xFF; |
| 77 | ||
| 77 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, MB8877, "mb8877"); | |
| 78 | 78 | /* Check whether regular RAM is enabled */ |
| 79 | 79 | if ( ! osborne1.bank2_enabled ) |
| 80 | 80 | { |
| r3867 | r3868 | |
| 85 | 85 | switch( offset & 0x0F00 ) |
| 86 | 86 | { |
| 87 | 87 | case 0x100: /* Floppy */ |
| 88 | data = wd17xx_r( | |
| 88 | data = wd17xx_r( fd | |
| 89 | 89 | break; |
| 90 | 90 | case 0x200: /* Keyboard */ |
| 91 | 91 | /* Row 0 */ |
| r3867 | r3868 | |
| 121 | 121 | |
| 122 | 122 | WRITE8_HANDLER( osborne1_2000_w ) |
| 123 | 123 | { |
| 124 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, MB8877, "mb8877"); | |
| 124 | 125 | /* Check whether regular RAM is enabled */ |
| 125 | 126 | if ( ! osborne1.bank2_enabled ) |
| 126 | 127 | { |
| r3867 | r3868 | |
| 136 | 137 | switch( offset & 0x0F00 ) |
| 137 | 138 | { |
| 138 | 139 | case 0x100: /* Floppy */ |
| 139 | wd17xx_w( | |
| 140 | wd17xx_w( fd | |
| 140 | 141 | break; |
| 141 | 142 | case 0x900: /* IEEE488 PIA */ |
| 142 | 143 | pia_0_w( space, offset & 0x03, data ); |
| r3867 | r3868 | |
| 276 | 277 | |
| 277 | 278 | static WRITE8_HANDLER( video_pia_port_a_w ) |
| 278 | 279 | { |
| 280 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, MB8877, "mb8877"); | |
| 279 | 281 | osborne1.new_start_x = data >> 1; |
| 280 | wd17xx_set_density( ( data & 0x01 ) ? DEN_FM_LO : DEN_FM_HI ); | |
| 282 | wd17xx_set_density(fdc, ( data & 0x01 ) ? DEN_FM_LO : DEN_FM_HI ); | |
| 281 | 283 | |
| 282 | 284 | //logerror("Video pia port a write: %02X, density set to %s\n", data, data & 1 ? "DEN_FM_LO" : "DEN_FM_HI" ); |
| 283 | 285 | } |
| r3867 | r3868 | |
| 285 | 287 | |
| 286 | 288 | static WRITE8_HANDLER( video_pia_port_b_w ) |
| 287 | 289 | { |
| 290 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, MB8877, "mb8877"); | |
| 288 | 291 | osborne1.new_start_y = data & 0x1F; |
| 289 | 292 | osborne1.beep = ( data & 0x20 ) ? 1 : 0; |
| 290 | 293 | if ( data & 0x40 ) |
| 291 | 294 | { |
| 292 | wd17xx_set_drive( 0 ); | |
| 295 | wd17xx_set_drive( fdc, 0 ); | |
| 293 | 296 | } |
| 294 | 297 | else if ( data & 0x80 ) |
| 295 | 298 | { |
| 296 | wd17xx_set_drive( 1 ); | |
| 299 | wd17xx_set_drive( fdc, 1 ); | |
| 297 | 300 | } |
| 298 | 301 | //logerror("Video pia port b write: %02X\n", data ); |
| 299 | 302 | } |
| r3867 | r3868 | |
| 412 | 415 | DEVICE_IMAGE_LOAD( osborne1_floppy ) |
| 413 | 416 | { |
| 414 | 417 | int size, sectors, sectorsize; |
| 418 | device_config *fdc = (device_config*)device_list_find_by_tag( image->machine->config->devicelist, MB8877, "mb8877"); | |
| 415 | 419 | |
| 416 | 420 | if ( ! image_has_been_created( image ) ) |
| 417 | 421 | { |
| r3867 | r3868 | |
| 422 | 426 | case 40 * 10 * 256: |
| 423 | 427 | sectors = 10; |
| 424 | 428 | sectorsize = 256; |
| 425 | wd17xx_set_density( DEN_FM_LO ); | |
| 429 | wd17xx_set_density( fdc, DEN_FM_LO ); | |
| 426 | 430 | break; |
| 427 | 431 | case 40 * 5 * 1024: |
| 428 | 432 | sectors = 5; |
| 429 | 433 | sectorsize = 1024; |
| 430 | wd17xx_set_density( DEN_FM_HI ); | |
| 434 | wd17xx_set_density( fdc, DEN_FM_HI ); | |
| 431 | 435 | break; |
| 432 | 436 | case 40 * 8 * 512: |
| 433 | 437 | sectors = 8; |
| 434 | 438 | sectorsize = 512; |
| 435 | wd17xx_set_density( DEN_FM_LO ); | |
| 439 | wd17xx_set_density( fdc, DEN_FM_LO ); | |
| 436 | 440 | return INIT_FAIL; |
| 437 | 441 | case 40 * 18 * 128: |
| 438 | 442 | sectors = 18; |
| 439 | 443 | sectorsize = 128; |
| 440 | wd17xx_set_density( DEN_FM_LO ); | |
| 444 | wd17xx_set_density( fdc, DEN_FM_LO ); | |
| 441 | 445 | return INIT_FAIL; |
| 442 | 446 | case 40 * 9 * 512: |
| 443 | 447 | sectors = 9; |
| 444 | 448 | sectorsize = 512; |
| 445 | wd17xx_set_density( DEN_FM_HI ); | |
| 449 | wd17xx_set_density( fdc, DEN_FM_HI ); | |
| 446 | 450 | return INIT_FAIL; |
| 447 | 451 | default: |
| 448 | 452 | return INIT_FAIL; |
| r3867 | r3868 | |
| 471 | 475 | } |
| 472 | 476 | |
| 473 | 477 | |
| 474 | MACHINE_START( osborne1 ) | |
| 475 | { | |
| 476 | /* Configure the floppy disk interface */ | |
| 477 | wd17xx_init( machine, WD_TYPE_MB8877, NULL, NULL ); | |
| 478 | } | |
| 479 | ||
| 480 | ||
| 481 | 478 | MACHINE_RESET( osborne1 ) |
| 482 | 479 | { |
| 483 | 480 | const address_space* space = cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM); |
| r3867 | r3868 | |
|---|---|---|
| 24 | 24 | the host should read the id data through the data register. This |
| 25 | 25 | was accomplished by making this change in the wd17xx_read_id |
| 26 | 26 | function: |
| 27 | - wd17xx_complete_command( | |
| 27 | - wd17xx_complete_command(device, DELAY_DATADONE); | |
| 28 | 28 | + wd17xx_set_data_request(); |
| 29 | 29 | |
| 30 | 30 | TODO: |
| r3867 | r3868 | |
| 54 | 54 | #define DELAY_DATADONE 3 |
| 55 | 55 | |
| 56 | 56 | |
| 57 | /* enumeration to specify the type of FDC; there are subtle differences */ | |
| 58 | typedef enum | |
| 59 | { | |
| 60 | WD_TYPE_1770, | |
| 61 | WD_TYPE_1772, | |
| 62 | WD_TYPE_1773, | |
| 63 | WD_TYPE_179X, | |
| 64 | WD_TYPE_1793, | |
| 65 | WD_TYPE_2793, | |
| 57 | 66 | |
| 67 | /* duplicate constants */ | |
| 68 | WD_TYPE_177X = WD_TYPE_1770, | |
| 69 | WD_TYPE_MB8877 = WD_TYPE_179X | |
| 70 | } wd17xx_type_t; | |
| 71 | ||
| 72 | ||
| 58 | 73 | /*************************************************************************** |
| 59 | 74 | |
| 60 | 75 | Constants |
| r3867 | r3868 | |
| 138 | 153 | |
| 139 | 154 | ***************************************************************************/ |
| 140 | 155 | |
| 141 | typedef struct _wd17xx_info wd17xx_info; | |
| 142 | struct _wd17xx_info | |
| 156 | typedef struct _wd17xx_t wd17xx_t; | |
| 157 | struct _wd17xx_t | |
| 143 | 158 | { |
| 144 | void (*callback)(running_machine *, wd17xx_state_t event, void *param); /* callback for IRQ status */ | |
| 145 | void *callback_param; | |
| 146 | 159 | DENSITY density; /* FM/MFM, single / double density */ |
| 147 | 160 | wd17xx_type_t type; |
| 148 | 161 | UINT8 track_reg; /* value of track register */ |
| r3867 | r3868 | |
| 178 | 191 | int data_direction; |
| 179 | 192 | |
| 180 | 193 | UINT8 ipl; /* index pulse */ |
| 194 | ||
| 195 | emu_timer *busy_timer; | |
| 196 | ||
| 197 | /* this is the drive currently selected */ | |
| 198 | UINT8 current_drive; | |
| 199 | ||
| 200 | /* this is the head currently selected */ | |
| 201 | UINT8 hd; | |
| 202 | ||
| 203 | /* pause time when writeing/reading sector */ | |
| 204 | int pause_time; | |
| 205 | ||
| 206 | /* Pointer to interface */ | |
| 207 | const wd17xx_interface *intf; | |
| 181 | 208 | }; |
| 182 | 209 | |
| 210 | INLINE wd17xx_t *get_safe_token(const device_config *device) | |
| 211 | { | |
| 212 | assert(device != NULL); | |
| 213 | assert(device->token != NULL); | |
| 183 | 214 | |
| 215 | return (wd17xx_t *)device->token; | |
| 216 | } | |
| 184 | 217 | |
| 218 | ||
| 185 | 219 | /*************************************************************************** |
| 186 | 220 | |
| 187 | 221 | Read track stuff |
| r3867 | r3868 | |
| 240 | 274 | |
| 241 | 275 | ***************************************************************************/ |
| 242 | 276 | |
| 243 | static void wd17xx_complete_command(wd17xx_info *, int delay); | |
| 244 | static void wd17xx_clear_data_request(running_machine *); | |
| 245 | static void wd17xx_set_data_request(running_machine *); | |
| 246 | static void wd17xx_timed_data_request(void); | |
| 247 | static void wd17xx_set_irq(running_machine *, wd17xx_info *); | |
| 248 | static emu_timer *busy_timer = NULL; | |
| 249 | ||
| 250 | /* one wd controlling multiple drives */ | |
| 251 | static wd17xx_info wd; | |
| 252 | ||
| 253 | /* this is the drive currently selected */ | |
| 254 | static UINT8 current_drive; | |
| 255 | ||
| 256 | /* this is the head currently selected */ | |
| 257 | static UINT8 hd = 0; | |
| 258 | ||
| 259 | /* pause time when writeing/reading sector */ | |
| 260 | static int wd17xx_pause_time; | |
| 277 | static void wd17xx_complete_command(const device_config *device, int delay); | |
| 278 | static void wd17xx_clear_data_request(const device_config *device); | |
| 279 | static void wd17xx_set_data_request(const device_config *device); | |
| 280 | static void wd17xx_timed_data_request(const device_config *device); | |
| 281 | static void wd17xx_set_irq(const device_config *device); | |
| 261 | 282 | /**************************************************************************/ |
| 262 | 283 | |
| 263 | static const device_config *wd17xx_current_image(void) | |
| 284 | static const device_config *wd17xx_current_image(const device_config *device) | |
| 264 | 285 | { |
| 265 | return image_from_devtype_and_index(IO_FLOPPY, current_drive); | |
| 286 | wd17xx_t *w = get_safe_token(device); | |
| 287 | return image_from_devtype_and_index(IO_FLOPPY, w->current_drive); | |
| 266 | 288 | } |
| 267 | 289 | |
| 268 | 290 | |
| 269 | 291 | |
| 270 | 292 | /* use this to determine which drive is controlled by WD */ |
| 271 | void wd17xx_set_drive(UINT8 drive) | |
| 293 | void wd17xx_set_drive(const device_config *device,UINT8 drive) | |
| 272 | 294 | { |
| 273 | current_drive = drive; | |
| 295 | wd17xx_t *w = get_safe_token(device); | |
| 296 | w->current_drive = drive; | |
| 274 | 297 | } |
| 275 | 298 | |
| 276 | ||
| 277 | ||
| 278 | void wd17xx_set_side(UINT8 head) | |
| 299 | void wd17xx_set_side(const device_config *device,UINT8 head) | |
| 279 | 300 | { |
| 301 | wd17xx_t *w = get_safe_token(device); | |
| 280 | 302 | if (VERBOSE) |
| 281 | 303 | { |
| 282 | if (head != hd) | |
| 304 | if (head != w->hd) | |
| 283 | 305 | logerror("wd17xx_set_side: $%02x\n", head); |
| 284 | 306 | } |
| 285 | hd = head; | |
| 307 | w->hd = head; | |
| 286 | 308 | } |
| 287 | 309 | |
| 288 | 310 | |
| 289 | 311 | |
| 290 | void wd17xx_set_density(DENSITY density) | |
| 312 | void wd17xx_set_density(const device_config *device,DENSITY density) | |
| 291 | 313 | { |
| 292 | wd17xx_ | |
| 314 | wd17xx_t | |
| 293 | 315 | |
| 294 | 316 | if (VERBOSE) |
| 295 | 317 | { |
| r3867 | r3868 | |
| 304 | 326 | |
| 305 | 327 | static TIMER_CALLBACK(wd17xx_busy_callback) |
| 306 | 328 | { |
| 307 | wd17xx_info *info = (wd17xx_info *) ptr; | |
| 308 | wd17xx_set_irq(machine, info); | |
| 309 | timer_reset(busy_timer, attotime_never); | |
| 329 | const device_config *device = ptr; | |
| 330 | wd17xx_t *w = get_safe_token(device); | |
| 331 | wd17xx_set_irq(device); | |
| 332 | timer_reset(w->busy_timer, attotime_never); | |
| 310 | 333 | } |
| 311 | 334 | |
| 312 | 335 | |
| 313 | 336 | |
| 314 | static void wd17xx_set_busy( | |
| 337 | static void wd17xx_set_busy(const dev | |
| 315 | 338 | { |
| 339 | wd17xx_t *w = get_safe_token(device); | |
| 316 | 340 | w->status |= STA_1_BUSY; |
| 317 | timer_adjust_oneshot(busy_timer, duration, 0); | |
| 341 | timer_adjust_oneshot(w->busy_timer, duration, 0); | |
| 318 | 342 | } |
| 319 | 343 | |
| 320 | 344 | |
| 321 | 345 | |
| 322 | 346 | /* BUSY COUNT DOESN'T WORK PROPERLY! */ |
| 323 | 347 | |
| 324 | static void wd17xx_restore( | |
| 348 | static void wd17xx_restore( | |
| 325 | 349 | { |
| 326 | 350 | UINT8 step_counter; |
| 327 | ||
| 328 | if (current_drive >= device_count(machine, IO_FLOPPY)) | |
| 351 | wd17xx_t *w = get_safe_token(device); | |
| 352 | ||
| 353 | if (w->current_drive >= device_count(device->machine, IO_FLOPPY)) | |
| 329 | 354 | return; |
| 330 | 355 | |
| 331 | 356 | step_counter = 255; |
| r3867 | r3868 | |
| 342 | 367 | /* reset busy count */ |
| 343 | 368 | w->busy_count = 0; |
| 344 | 369 | |
| 345 | if (image_slotexists(wd17xx_current_image())) | |
| 370 | if (image_slotexists(wd17xx_current_image(device))) | |
| 346 | 371 | { |
| 347 | 372 | /* keep stepping until track 0 is received or 255 steps have been done */ |
| 348 | while (!(floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_HEAD_AT_TRACK_0)) && (step_counter!=0)) | |
| 373 | while (!(floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_HEAD_AT_TRACK_0)) && (step_counter!=0)) | |
| 349 | 374 | { |
| 350 | 375 | /* update time to simulate seek time busy signal */ |
| 351 | 376 | w->busy_count++; |
| 352 | floppy_drive_seek(wd17xx_current_image(), w->direction); | |
| 377 | floppy_drive_seek(wd17xx_current_image(device), w->direction); | |
| 353 | 378 | step_counter--; |
| 354 | 379 | } |
| 355 | 380 | } |
| r3867 | r3868 | |
| 361 | 386 | w->busy_count = 0; //w->busy_count * ((w->data & FDC_STEP_RATE) + 1); |
| 362 | 387 | |
| 363 | 388 | /* when command completes set irq */ |
| 364 | wd17xx_set_irq( | |
| 389 | wd17xx_set_irq(device); | |
| 365 | 390 | #endif |
| 366 | wd17xx_set_busy( | |
| 391 | wd17xx_set_busy(device, ATTOTIME_IN_USEC(100)); | |
| 367 | 392 | } |
| 368 | 393 | |
| 369 | 394 | |
| r3867 | r3868 | |
| 371 | 396 | static TIMER_CALLBACK(wd17xx_misc_timer_callback); |
| 372 | 397 | static TIMER_CALLBACK(wd17xx_read_sector_callback); |
| 373 | 398 | static TIMER_CALLBACK(wd17xx_write_sector_callback); |
| 374 | static void wd17xx_index_pulse_callback(const device_config *img, int state); | |
| 399 | static void wd17xx_index_pulse_callback(const device_config *controller,const device_config *img, int state); | |
| 375 | 400 | |
| 376 | void wd17xx_reset(running_machine *machine) | |
| 377 | { | |
| 378 | int i; | |
| 379 | for (i = 0; i < device_count(machine, IO_FLOPPY); i++) | |
| 380 | { | |
| 381 | const device_config *img = image_from_devtype_and_index(IO_FLOPPY, i); | |
| 382 | floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback); | |
| 383 | floppy_drive_set_rpm( img, 300.); | |
| 384 | } | |
| 385 | 401 | |
| 386 | wd17xx_restore(machine, &wd); | |
| 387 | } | |
| 388 | ||
| 389 | ||
| 390 | ||
| 391 | void wd17xx_init(running_machine *machine, wd17xx_type_t type, void (*callback)(running_machine *, wd17xx_state_t, void *), void *param) | |
| 392 | { | |
| 393 | assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, "Can only call wd17xx_init at init time!"); | |
| 394 | ||
| 395 | memset(&wd, 0, sizeof(wd)); | |
| 396 | wd.status = STA_1_TRACK0; | |
| 397 | wd.type = type; | |
| 398 | wd.callback = callback; | |
| 399 | wd.callback_param = param; | |
| 400 | // wd.status_ipl = STA_1_IPL; | |
| 401 | wd.density = DEN_MFM_LO; | |
| 402 | busy_timer = timer_alloc(machine, wd17xx_busy_callback, &wd); | |
| 403 | wd.timer = timer_alloc(machine, wd17xx_misc_timer_callback, NULL); | |
| 404 | wd.timer_rs = timer_alloc(machine, wd17xx_read_sector_callback, NULL); | |
| 405 | wd.timer_ws = timer_alloc(machine, wd17xx_write_sector_callback, NULL); | |
| 406 | wd17xx_pause_time = 40; | |
| 407 | wd17xx_reset(machine); | |
| 408 | } | |
| 409 | ||
| 410 | ||
| 411 | ||
| 412 | 402 | /* track writing, converted to format commands */ |
| 413 | static void write_track( | |
| 403 | static void write_track(const dev | |
| 414 | 404 | { |
| 405 | wd17xx_t *w = get_safe_token(device); | |
| 415 | 406 | int i; |
| 416 | 407 | for (i=0;i+4<w->data_offset;) |
| 417 | 408 | { |
| r3867 | r3868 | |
| 424 | 415 | int len = w->buffer[i+4]; |
| 425 | 416 | int filler = 0xe5; /* IBM and Thomson */ |
| 426 | 417 | int density = w->density; |
| 427 | floppy_drive_format_sector(wd17xx_current_image(),side,sector,track, | |
| 428 | hd,sector,density?1:0,filler); | |
| 418 | floppy_drive_format_sector(wd17xx_current_image(device),side,sector,track, | |
| 419 | w->hd,sector,density?1:0,filler); | |
| 429 | 420 | (void)len; |
| 430 | 421 | i += 128; /* at least... */ |
| 431 | 422 | } |
| r3867 | r3868 | |
| 437 | 428 | |
| 438 | 429 | |
| 439 | 430 | /* read an entire track */ |
| 440 | static void read_track( | |
| 431 | static void read_track( | |
| 441 | 432 | { |
| 433 | wd17xx_t *w = get_safe_token(device); | |
| 442 | 434 | #if 0 |
| 443 | 435 | UINT8 *psrc; /* pointer to track format structure */ |
| 444 | 436 | UINT8 *pdst; /* pointer to track buffer */ |
| r3867 | r3868 | |
| 560 | 552 | |
| 561 | 553 | w->data_count = (w->density) ? TRKSIZE_DD : TRKSIZE_SD; |
| 562 | 554 | |
| 563 | floppy_drive_read_track_data_info_buffer( wd17xx_current_image(), hd, (char *)w->buffer, &(w->data_count) ); | |
| 555 | floppy_drive_read_track_data_info_buffer( wd17xx_current_image(device), w->hd, (char *)w->buffer, &(w->data_count) ); | |
| 564 | 556 | |
| 565 | 557 | w->data_offset = 0; |
| 566 | 558 | |
| 567 | wd17xx_set_data_request( | |
| 559 | wd17xx_set_data_request(dev | |
| 568 | 560 | w->status |= STA_2_BUSY; |
| 569 | 561 | w->busy_count = 0; |
| 570 | 562 | } |
| r3867 | r3868 | |
| 597 | 589 | |
| 598 | 590 | |
| 599 | 591 | /* read the next data address mark */ |
| 600 | static void wd17xx_read_id( | |
| 592 | static void wd17xx_read_id( | |
| 601 | 593 | { |
| 602 | 594 | chrn_id id; |
| 595 | wd17xx_t *w = get_safe_token(device); | |
| 603 | 596 | |
| 604 | 597 | w->status &= ~(STA_2_CRC_ERR | STA_2_REC_N_FND); |
| 605 | 598 | |
| 606 | 599 | /* get next id from disc */ |
| 607 | if (floppy_drive_get_next_id(wd17xx_current_image(), hd, &id)) | |
| 600 | if (floppy_drive_get_next_id(wd17xx_current_image(device), w->hd, &id)) | |
| 608 | 601 | { |
| 609 | 602 | UINT16 crc = 0xffff; |
| 610 | 603 | |
| r3867 | r3868 | |
| 635 | 628 | w->status |= STA_2_BUSY; |
| 636 | 629 | w->busy_count = 0; |
| 637 | 630 | |
| 638 | wd17xx_set_data_request( | |
| 631 | wd17xx_set_data_request(dev | |
| 639 | 632 | |
| 640 | 633 | logerror("read id succeeded.\n"); |
| 641 | 634 | } |
| r3867 | r3868 | |
| 646 | 639 | //w->sector = w->track_reg; |
| 647 | 640 | logerror("read id failed\n"); |
| 648 | 641 | |
| 649 | wd17xx_complete_command( | |
| 642 | wd17xx_complete_command(device, DELAY_ERROR); | |
| 650 | 643 | } |
| 651 | 644 | } |
| 652 | 645 | |
| 653 | 646 | |
| 654 | 647 | |
| 655 | static void wd17xx_index_pulse_callback(const device_config *img, int state) | |
| 648 | static void wd17xx_index_pulse_callback(const device_config *controller, const device_config *img, int state) | |
| 656 | 649 | { |
| 657 | wd17xx_info *w = &wd; | |
| 658 | if ( img != wd17xx_current_image() ) | |
| 650 | wd17xx_t *w = get_safe_token(controller); | |
| 651 | if ( img != wd17xx_current_image(controller) ) | |
| 659 | 652 | return; |
| 660 | 653 | w->ipl = state; |
| 661 | 654 | } |
| 662 | 655 | |
| 663 | 656 | |
| 664 | 657 | |
| 665 | static int wd17xx_has_side_select(void) | |
| 658 | static int wd17xx_has_side_select(const device_config *device) | |
| 666 | 659 | { |
| 667 | return (wd.type == WD_TYPE_1773) || (wd.type == WD_TYPE_1793) || (wd.type == WD_TYPE_2793); | |
| 660 | wd17xx_t *w = get_safe_token(device); | |
| 661 | return (w->type == WD_TYPE_1773) || (w->type == WD_TYPE_1793) || (w->type == WD_TYPE_2793); | |
| 668 | 662 | } |
| 669 | 663 | |
| 670 | 664 | |
| 671 | 665 | |
| 672 | static int wd17xx_locate_sector( | |
| 666 | static int wd17xx_locate_sector(const dev | |
| 673 | 667 | { |
| 674 | 668 | UINT8 revolution_count; |
| 675 | 669 | chrn_id id; |
| 676 | ||
| 670 | wd17xx_t *w = get_safe_token(device); | |
| 671 | ||
| 677 | 672 | revolution_count = 0; |
| 678 | 673 | |
| 679 | 674 | w->status &= ~STA_2_REC_N_FND; |
| 680 | 675 | |
| 681 | 676 | while (revolution_count!=4) |
| 682 | 677 | { |
| 683 | if (floppy_drive_get_next_id(wd17xx_current_image(), hd, &id)) | |
| 678 | if (floppy_drive_get_next_id(wd17xx_current_image(device), w->hd, &id)) | |
| 684 | 679 | { |
| 685 | 680 | /* compare track */ |
| 686 | 681 | if (id.C == w->track_reg) |
| 687 | 682 | { |
| 688 | 683 | /* compare head, if we were asked to */ |
| 689 | if (!wd17xx_has_side_select() || (id.H == w->head) || (w->head == (UINT8) ~0)) | |
| 684 | if (!wd17xx_has_side_select(device) || (id.H == w->head) || (w->head == (UINT8) ~0)) | |
| 690 | 685 | { |
| 691 | 686 | /* compare id */ |
| 692 | 687 | if (id.R == w->sector) |
| r3867 | r3868 | |
| 705 | 700 | } |
| 706 | 701 | |
| 707 | 702 | /* index set? */ |
| 708 | if (floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_INDEX)) | |
| 703 | if (floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_INDEX)) | |
| 709 | 704 | { |
| 710 | 705 | /* update revolution count */ |
| 711 | 706 | revolution_count++; |
| r3867 | r3868 | |
| 715 | 710 | } |
| 716 | 711 | |
| 717 | 712 | |
| 718 | static int wd17xx_find_sector( | |
| 713 | static int wd17xx_find_sector(const dev | |
| 719 | 714 | { |
| 720 | if ( wd17xx_locate_sector(w) ) | |
| 715 | wd17xx_t *w = get_safe_token(device); | |
| 716 | if ( wd17xx_locate_sector(device) ) | |
| 721 | 717 | { |
| 722 | 718 | return 1; |
| 723 | 719 | } |
| r3867 | r3868 | |
| 728 | 724 | if (VERBOSE) |
| 729 | 725 | logerror("track %d sector %d not found!\n", w->track_reg, w->sector); |
| 730 | 726 | |
| 731 | wd17xx_complete_command( | |
| 727 | wd17xx_complete_command(device, DELAY_ERROR); | |
| 732 | 728 | |
| 733 | 729 | return 0; |
| 734 | 730 | } |
| r3867 | r3868 | |
| 736 | 732 | |
| 737 | 733 | |
| 738 | 734 | /* read a sector */ |
| 739 | static void wd17xx_read_sector( | |
| 735 | static void wd17xx_read_sector(const dev | |
| 740 | 736 | { |
| 737 | wd17xx_t *w = get_safe_token(device); | |
| 741 | 738 | w->data_offset = 0; |
| 742 | 739 | |
| 743 | 740 | /* side compare? */ |
| r3867 | r3868 | |
| 746 | 743 | else |
| 747 | 744 | w->head = ~0; |
| 748 | 745 | |
| 749 | if (wd17xx_find_sector( | |
| 746 | if (wd17xx_find_sector(device)) | |
| 750 | 747 | { |
| 751 | 748 | w->data_count = w->sector_length; |
| 752 | 749 | |
| 753 | 750 | /* read data */ |
| 754 | floppy_drive_read_sector_data(wd17xx_current_image(), hd, w->sector_data_id, (char *)w->buffer, w->sector_length); | |
| 751 | floppy_drive_read_sector_data(wd17xx_current_image(device), w->hd, w->sector_data_id, (char *)w->buffer, w->sector_length); | |
| 755 | 752 | |
| 756 | wd17xx_timed_data_request(); | |
| 753 | wd17xx_timed_data_request(device); | |
| 757 | 754 | |
| 758 | 755 | w->status |= STA_2_BUSY; |
| 759 | 756 | w->busy_count = 0; |
| r3867 | r3868 | |
| 762 | 759 | |
| 763 | 760 | |
| 764 | 761 | |
| 765 | static void wd17xx_callback( | |
| 762 | static void wd17xx_callback( | |
| 766 | 763 | { |
| 767 | if (w->callback) | |
| 768 | (*w->callback)(machine, state, w->callback_param); | |
| 764 | wd17xx_t *w = get_safe_token(device); | |
| 765 | void *param = NULL; | |
| 766 | if (w->intf->callback_param) | |
| 767 | param = (*w->intf->callback_param)(device); | |
| 768 | if (w->intf->callback) | |
| 769 | (*w->intf->callback)(device, state, param); | |
| 769 | 770 | } |
| 770 | 771 | |
| 771 | 772 | |
| 772 | 773 | |
| 773 | static void wd17xx_set_irq( | |
| 774 | static void wd17xx_set_irq( | |
| 774 | 775 | { |
| 776 | wd17xx_t *w = get_safe_token(device); | |
| 775 | 777 | w->status &= ~STA_2_BUSY; |
| 776 | 778 | /* generate an IRQ */ |
| 777 | wd17xx_callback( | |
| 779 | wd17xx_callback(dev | |
| 778 | 780 | } |
| 779 | 781 | |
| 780 | 782 | |
| r3867 | r3868 | |
| 790 | 792 | |
| 791 | 793 | static TIMER_CALLBACK(wd17xx_misc_timer_callback) |
| 792 | 794 | { |
| 795 | const device_config *device = ptr; | |
| 793 | 796 | int callback_type = param; |
| 794 | wd17xx_ | |
| 797 | wd17xx_t | |
| 795 | 798 | |
| 796 | 799 | switch(callback_type) { |
| 797 | 800 | case MISCCALLBACK_COMMAND: |
| 798 | 801 | /* command callback */ |
| 799 | wd17xx_set_irq( | |
| 802 | wd17xx_set_irq(dev | |
| 800 | 803 | break; |
| 801 | 804 | |
| 802 | 805 | case MISCCALLBACK_DATA: |
| 803 | 806 | /* data callback */ |
| 804 | 807 | /* ok, trigger data request now */ |
| 805 | wd17xx_set_data_request( | |
| 808 | wd17xx_set_data_request(dev | |
| 806 | 809 | break; |
| 807 | 810 | } |
| 808 | 811 | |
| r3867 | r3868 | |
| 819 | 822 | or bytes missed */ |
| 820 | 823 | /* TJL - I have add a parameter to allow the emulation to specify the delay |
| 821 | 824 | */ |
| 822 | static void wd17xx_complete_command( | |
| 825 | static void wd17xx_complete_command(const dev | |
| 823 | 826 | { |
| 824 | 827 | int usecs; |
| 828 | wd17xx_t *w = get_safe_token(device); | |
| 825 | 829 | |
| 826 | 830 | w->data_count = 0; |
| 827 | 831 | |
| r3867 | r3868 | |
| 837 | 841 | |
| 838 | 842 | |
| 839 | 843 | |
| 840 | static void wd17xx_write_sector( | |
| 844 | static void wd17xx_write_sector(const dev | |
| 841 | 845 | { |
| 846 | wd17xx_t *w = get_safe_token(device); | |
| 842 | 847 | /* at this point, the disc is write enabled, and data |
| 843 | 848 | * has been transfered into our buffer - now write it to |
| 844 | 849 | * the disc image or to the real disc |
| r3867 | r3868 | |
| 851 | 856 | w->head = ~0; |
| 852 | 857 | |
| 853 | 858 | /* find sector */ |
| 854 | if (wd17xx_find_sector( | |
| 859 | if (wd17xx_find_sector(device)) | |
| 855 | 860 | { |
| 856 | 861 | w->data_count = w->sector_length; |
| 857 | 862 | |
| 858 | 863 | /* write data */ |
| 859 | floppy_drive_write_sector_data(wd17xx_current_image(), hd, w->sector_data_id, (char *)w->buffer, w->sector_length,w->write_cmd & 0x01); | |
| 864 | floppy_drive_write_sector_data(wd17xx_current_image(device), w->hd, w->sector_data_id, (char *)w->buffer, w->sector_length,w->write_cmd & 0x01); | |
| 860 | 865 | } |
| 861 | 866 | } |
| 862 | 867 | |
| 863 | 868 | |
| 864 | 869 | |
| 865 | 870 | /* verify the seek operation by looking for a id that has a matching track value */ |
| 866 | static void wd17xx_verify_seek( | |
| 871 | static void wd17xx_verify_seek(const dev | |
| 867 | 872 | { |
| 868 | 873 | UINT8 revolution_count; |
| 869 | 874 | chrn_id id; |
| 875 | wd17xx_t *w = get_safe_token(device); | |
| 870 | 876 | |
| 871 | 877 | revolution_count = 0; |
| 872 | 878 | |
| r3867 | r3868 | |
| 877 | 883 | /* must be found within 5 revolutions otherwise error */ |
| 878 | 884 | while (revolution_count!=5) |
| 879 | 885 | { |
| 880 | if (floppy_drive_get_next_id(wd17xx_current_image(), hd, &id)) | |
| 886 | if (floppy_drive_get_next_id(wd17xx_current_image(device), w->hd, &id)) | |
| 881 | 887 | { |
| 882 | 888 | /* compare track */ |
| 883 | 889 | if (id.C == w->track_reg) |
| r3867 | r3868 | |
| 888 | 894 | } |
| 889 | 895 | |
| 890 | 896 | /* index set? */ |
| 891 | if (floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_INDEX)) | |
| 897 | if (floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_INDEX)) | |
| 892 | 898 | { |
| 893 | 899 | /* update revolution count */ |
| 894 | 900 | revolution_count++; |
| r3867 | r3868 | |
| 903 | 909 | |
| 904 | 910 | |
| 905 | 911 | /* clear a data request */ |
| 906 | static void wd17xx_clear_data_request( | |
| 912 | static void wd17xx_clear_data_request(const device_ | |
| 907 | 913 | { |
| 908 | wd17xx_ | |
| 914 | wd17xx_t | |
| 909 | 915 | |
| 910 | 916 | // w->status_drq = 0; |
| 911 | wd17xx_callback( | |
| 917 | wd17xx_callback(dev | |
| 912 | 918 | w->status &= ~STA_2_DRQ; |
| 913 | 919 | } |
| 914 | 920 | |
| 915 | 921 | |
| 916 | 922 | |
| 917 | 923 | /* set data request */ |
| 918 | static void wd17xx_set_data_request( | |
| 924 | static void wd17xx_set_data_request(const device_ | |
| 919 | 925 | { |
| 920 | wd17xx_ | |
| 926 | wd17xx_t | |
| 921 | 927 | |
| 922 | 928 | if (w->status & STA_2_DRQ) |
| 923 | 929 | { |
| r3867 | r3868 | |
| 927 | 933 | |
| 928 | 934 | /* set drq */ |
| 929 | 935 | // w->status_drq = STA_2_DRQ; |
| 930 | wd17xx_callback( | |
| 936 | wd17xx_callback(dev | |
| 931 | 937 | w->status |= STA_2_DRQ; |
| 932 | 938 | } |
| 933 | 939 | |
| r3867 | r3868 | |
| 936 | 942 | /* callback to initiate read sector */ |
| 937 | 943 | static TIMER_CALLBACK(wd17xx_read_sector_callback) |
| 938 | 944 | { |
| 939 | wd17xx_info *w = &wd; | |
| 945 | const device_config *device = ptr; | |
| 946 | wd17xx_t *w = get_safe_token(device); | |
| 940 | 947 | |
| 941 | 948 | /* ok, start that read! */ |
| 942 | 949 | |
| 943 | 950 | if (VERBOSE) |
| 944 | 951 | logerror("wd179x: Read Sector callback.\n"); |
| 945 | 952 | |
| 946 | if (!floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_READY)) | |
| 947 | wd17xx_complete_command(w, DELAY_NOTREADY); | |
| 953 | if (!floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_READY)) | |
| 954 | wd17xx_complete_command(device, DELAY_NOTREADY); | |
| 948 | 955 | else |
| 949 | wd17xx_read_sector( | |
| 956 | wd17xx_read_sector(device); | |
| 950 | 957 | |
| 951 | 958 | /* stop it, but don't allow it to be free'd */ |
| 952 | 959 | timer_reset(w->timer_rs, attotime_never); |
| r3867 | r3868 | |
| 957 | 964 | /* callback to initiate write sector */ |
| 958 | 965 | static TIMER_CALLBACK(wd17xx_write_sector_callback) |
| 959 | 966 | { |
| 960 | wd17xx_info *w = &wd; | |
| 967 | const device_config *device = ptr; | |
| 968 | wd17xx_t *w = get_safe_token(device); | |
| 961 | 969 | |
| 962 | 970 | /* ok, start that write! */ |
| 963 | 971 | |
| 964 | 972 | if (VERBOSE) |
| 965 | 973 | logerror("wd179x: Write Sector callback.\n"); |
| 966 | 974 | |
| 967 | if (!floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_READY)) | |
| 968 | wd17xx_complete_command(w, DELAY_NOTREADY); | |
| 975 | if (!floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_READY)) | |
| 976 | wd17xx_complete_command(device, DELAY_NOTREADY); | |
| 969 | 977 | else |
| 970 | 978 | { |
| 971 | 979 | |
| 972 | 980 | /* drive write protected? */ |
| 973 | if (floppy_drive_get_flag_state(wd17xx_current_image(),FLOPPY_DRIVE_DISK_WRITE_PROTECTED)) | |
| 981 | if (floppy_drive_get_flag_state(wd17xx_current_image(device),FLOPPY_DRIVE_DISK_WRITE_PROTECTED)) | |
| 974 | 982 | { |
| 975 | 983 | w->status |= STA_2_WRITE_PRO; |
| 976 | 984 | |
| 977 | wd17xx_complete_command( | |
| 985 | wd17xx_complete_command(device, DELAY_ERROR); | |
| 978 | 986 | } |
| 979 | 987 | else |
| 980 | 988 | { |
| r3867 | r3868 | |
| 985 | 993 | w->head = ~0; |
| 986 | 994 | |
| 987 | 995 | /* attempt to find it first before getting data from cpu */ |
| 988 | if (wd17xx_find_sector( | |
| 996 | if (wd17xx_find_sector(device)) | |
| 989 | 997 | { |
| 990 | 998 | /* request data */ |
| 991 | 999 | w->data_offset = 0; |
| 992 | 1000 | w->data_count = w->sector_length; |
| 993 | 1001 | |
| 994 | wd17xx_set_data_request( | |
| 1002 | wd17xx_set_data_request(dev | |
| 995 | 1003 | |
| 996 | 1004 | w->status |= STA_2_BUSY; |
| 997 | 1005 | w->busy_count = 0; |
| r3867 | r3868 | |
| 1006 | 1014 | |
| 1007 | 1015 | |
| 1008 | 1016 | /* setup a timed data request - data request will be triggered in a few usecs time */ |
| 1009 | static void wd17xx_timed_data_request(void) | |
| 1017 | static void wd17xx_timed_data_request(const device_config *device) | |
| 1010 | 1018 | { |
| 1011 | 1019 | int usecs; |
| 1012 | wd17xx_ | |
| 1020 | wd17xx_t | |
| 1013 | 1021 | |
| 1014 | 1022 | usecs = floppy_drive_get_datarate_in_us(w->density); |
| 1015 | 1023 | |
| r3867 | r3868 | |
| 1020 | 1028 | |
| 1021 | 1029 | |
| 1022 | 1030 | /* setup a timed read sector - read sector will be triggered in a few usecs time */ |
| 1023 | static void wd17xx_timed_read_sector_request(void) | |
| 1031 | static void wd17xx_timed_read_sector_request(const device_config *device) | |
| 1024 | 1032 | { |
| 1025 | 1033 | int usecs; |
| 1026 | wd17xx_ | |
| 1034 | wd17xx_t | |
| 1027 | 1035 | |
| 1028 | usecs = w | |
| 1036 | usecs = w-> | |
| 1029 | 1037 | |
| 1030 | 1038 | /* set new timer */ |
| 1031 | 1039 | timer_reset(w->timer_rs, ATTOTIME_IN_USEC(usecs)); |
| r3867 | r3868 | |
| 1034 | 1042 | |
| 1035 | 1043 | |
| 1036 | 1044 | /* setup a timed write sector - write sector will be triggered in a few usecs time */ |
| 1037 | static void wd17xx_timed_write_sector_request(void) | |
| 1045 | static void wd17xx_timed_write_sector_request(const device_config *device) | |
| 1038 | 1046 | { |
| 1039 | 1047 | int usecs; |
| 1040 | wd17xx_ | |
| 1048 | wd17xx_t | |
| 1041 | 1049 | |
| 1042 | usecs = w | |
| 1050 | usecs = w-> | |
| 1043 | 1051 | |
| 1044 | 1052 | /* set new timer */ |
| 1045 | 1053 | timer_reset(w->timer_ws, ATTOTIME_IN_USEC(usecs)); |
| 1046 | 1054 | } |
| 1047 | 1055 | |
| 1048 | void wd17xx_set_pause_time(int usec) | |
| 1056 | void wd17xx_set_pause_time(const device_config *device,int usec) | |
| 1049 | 1057 | { |
| 1050 | wd17xx_pause_time = usec; | |
| 1058 | wd17xx_t *w = get_safe_token(device); | |
| 1059 | w->pause_time = usec; | |
| 1051 | 1060 | } |
| 1052 | 1061 | |
| 1053 | 1062 | /* read the FDC status register. This clears IRQ line too */ |
| 1054 | READ8_HANDLER ( wd17xx_status_r ) | |
| 1063 | READ8_DEVICE_HANDLER ( wd17xx_status_r ) | |
| 1055 | 1064 | { |
| 1056 | wd17xx_ | |
| 1065 | wd17xx_t | |
| 1057 | 1066 | int result = w->status; |
| 1058 | 1067 | |
| 1059 | wd17xx_callback( | |
| 1068 | wd17xx_callback(d | |
| 1060 | 1069 | // if (w->busy_count) |
| 1061 | 1070 | // { |
| 1062 | 1071 | // if (!--w->busy_count) |
| r3867 | r3868 | |
| 1072 | 1081 | |
| 1073 | 1082 | /* set track 0 state */ |
| 1074 | 1083 | result &=~STA_1_TRACK0; |
| 1075 | if (floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_HEAD_AT_TRACK_0)) | |
| 1084 | if (floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_HEAD_AT_TRACK_0)) | |
| 1076 | 1085 | result |= STA_1_TRACK0; |
| 1077 | 1086 | |
| 1078 | // floppy_drive_set_ready_state(wd17xx_current_image(), 1,1); | |
| 1087 | // floppy_drive_set_ready_state(wd17xx_current_image(device), 1,1); | |
| 1079 | 1088 | w->status &= ~STA_1_NOT_READY; |
| 1080 | 1089 | |
| 1081 | 1090 | /* TODO: What is this? We need some more info on this */ |
| 1082 | 1091 | if ((w->type == WD_TYPE_179X) || (w->type == WD_TYPE_1793) || (w->type == WD_TYPE_1773)) |
| 1083 | 1092 | { |
| 1084 | if (!floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_READY)) | |
| 1093 | if (!floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_READY)) | |
| 1085 | 1094 | w->status |= STA_1_NOT_READY; |
| 1086 | 1095 | } |
| 1087 | 1096 | else |
| 1088 | 1097 | { |
| 1089 | if (floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_READY)) | |
| 1098 | if (floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_READY)) | |
| 1090 | 1099 | w->status |= STA_1_NOT_READY; |
| 1091 | 1100 | } |
| 1092 | 1101 | } |
| r3867 | r3868 | |
| 1106 | 1115 | |
| 1107 | 1116 | |
| 1108 | 1117 | /* read the FDC track register */ |
| 1109 | READ8_HANDLER ( wd17xx_track_r ) | |
| 1118 | READ8_DEVICE_HANDLER ( wd17xx_track_r ) | |
| 1110 | 1119 | { |
| 1111 | wd17xx_ | |
| 1120 | wd17xx_t | |
| 1112 | 1121 | |
| 1113 | 1122 | if (VERBOSE) |
| 1114 | 1123 | logerror("wd17xx_track_r: $%02X\n", w->track_reg); |
| r3867 | r3868 | |
| 1119 | 1128 | |
| 1120 | 1129 | |
| 1121 | 1130 | /* read the FDC sector register */ |
| 1122 | READ8_HANDLER ( wd17xx_sector_r ) | |
| 1131 | READ8_DEVICE_HANDLER ( wd17xx_sector_r ) | |
| 1123 | 1132 | { |
| 1124 | wd17xx_ | |
| 1133 | wd17xx_t | |
| 1125 | 1134 | |
| 1126 | 1135 | if (VERBOSE) |
| 1127 | 1136 | logerror("wd17xx_sector_r: $%02X\n", w->sector); |
| r3867 | r3868 | |
| 1132 | 1141 | |
| 1133 | 1142 | |
| 1134 | 1143 | /* read the FDC data register */ |
| 1135 | READ8_HANDLER ( wd17xx_data_r ) | |
| 1144 | READ8_DEVICE_HANDLER ( wd17xx_data_r ) | |
| 1136 | 1145 | { |
| 1137 | wd17xx_ | |
| 1146 | wd17xx_t | |
| 1138 | 1147 | |
| 1139 | 1148 | if (w->data_count >= 1) |
| 1140 | 1149 | { |
| 1141 | 1150 | /* clear data request */ |
| 1142 | wd17xx_clear_data_request( | |
| 1151 | wd17xx_clear_data_request(d | |
| 1143 | 1152 | |
| 1144 | 1153 | /* yes */ |
| 1145 | 1154 | w->data = w->buffer[w->data_offset++]; |
| r3867 | r3868 | |
| 1165 | 1174 | /* Check we should handle the next sector for a multi record read */ |
| 1166 | 1175 | if ( w->command_type == TYPE_II && w->command == FDC_READ_SEC && ( w->read_cmd & 0x10 ) ) { |
| 1167 | 1176 | w->sector++; |
| 1168 | if (wd17xx_locate_sector( | |
| 1177 | if (wd17xx_locate_sector(device)) | |
| 1169 | 1178 | { |
| 1170 | 1179 | w->data_count = w->sector_length; |
| 1171 | 1180 | |
| 1172 | 1181 | /* read data */ |
| 1173 | floppy_drive_read_sector_data(wd17xx_current_image(), hd, w->sector_data_id, (char *)w->buffer, w->sector_length); | |
| 1182 | floppy_drive_read_sector_data(wd17xx_current_image(device), w->hd, w->sector_data_id, (char *)w->buffer, w->sector_length); | |
| 1174 | 1183 | |
| 1175 | wd17xx_timed_data_request(); | |
| 1184 | wd17xx_timed_data_request(device); | |
| 1176 | 1185 | |
| 1177 | 1186 | w->status |= STA_2_BUSY; |
| 1178 | 1187 | w->busy_count = 0; |
| 1179 | 1188 | } else { |
| 1180 | wd17xx_complete_command( | |
| 1189 | wd17xx_complete_command(device, DELAY_DATADONE); | |
| 1181 | 1190 | |
| 1182 | 1191 | if (VERBOSE) |
| 1183 | 1192 | logerror("wd17xx_data_r(): multi data read completed\n"); |
| r3867 | r3868 | |
| 1185 | 1194 | } else { |
| 1186 | 1195 | /* Delay the INTRQ 3 byte times becuase we need to read two CRC bytes and |
| 1187 | 1196 | compare them with a calculated CRC */ |
| 1188 | wd17xx_complete_command( | |
| 1197 | wd17xx_complete_command(device, DELAY_DATADONE); | |
| 1189 | 1198 | |
| 1190 | 1199 | if (VERBOSE) |
| 1191 | 1200 | logerror("wd17xx_data_r(): data read completed\n"); |
| r3867 | r3868 | |
| 1194 | 1203 | else |
| 1195 | 1204 | { |
| 1196 | 1205 | /* issue a timed data request */ |
| 1197 | wd17xx_timed_data_request(); | |
| 1206 | wd17xx_timed_data_request(device); | |
| 1198 | 1207 | } |
| 1199 | 1208 | } |
| 1200 | 1209 | else |
| r3867 | r3868 | |
| 1207 | 1216 | |
| 1208 | 1217 | |
| 1209 | 1218 | /* write the FDC command register */ |
| 1210 | WRITE8_HANDLER ( wd17xx_command_w ) | |
| 1219 | WRITE8_DEVICE_HANDLER ( wd17xx_command_w ) | |
| 1211 | 1220 | { |
| 1212 | wd17xx_ | |
| 1221 | wd17xx_t | |
| 1213 | 1222 | |
| 1214 | floppy_drive_set_motor_state(wd17xx_current_image(), 1); | |
| 1215 | floppy_drive_set_ready_state(wd17xx_current_image(), 1,0); | |
| 1223 | floppy_drive_set_motor_state(wd17xx_current_image(device), 1); | |
| 1224 | floppy_drive_set_ready_state(wd17xx_current_image(device), 1,0); | |
| 1216 | 1225 | /* also cleared by writing command */ |
| 1217 | wd17xx_callback( | |
| 1226 | wd17xx_callback(d | |
| 1218 | 1227 | |
| 1219 | 1228 | /* clear write protected. On read sector, read track and read dam, write protected bit is clear */ |
| 1220 | 1229 | w->status &= ~((1<<6) | (1<<5) | (1<<4)); |
| r3867 | r3868 | |
| 1228 | 1237 | w->data_offset = 0; |
| 1229 | 1238 | w->status &= ~(STA_2_BUSY); |
| 1230 | 1239 | |
| 1231 | wd17xx_clear_data_request( | |
| 1240 | wd17xx_clear_data_request(d | |
| 1232 | 1241 | |
| 1233 | 1242 | if (data & 0x0f) |
| 1234 | 1243 | { |
| r3867 | r3868 | |
| 1260 | 1269 | w->command_type = TYPE_II; |
| 1261 | 1270 | w->status &= ~STA_2_LOST_DAT; |
| 1262 | 1271 | w->status |= STA_2_BUSY; |
| 1263 | wd17xx_clear_data_request( | |
| 1272 | wd17xx_clear_data_request(d | |
| 1264 | 1273 | |
| 1265 | wd17xx_timed_read_sector_request(); | |
| 1274 | wd17xx_timed_read_sector_request(device); | |
| 1266 | 1275 | |
| 1267 | 1276 | return; |
| 1268 | 1277 | } |
| r3867 | r3868 | |
| 1277 | 1286 | w->command_type = TYPE_II; |
| 1278 | 1287 | w->status &= ~STA_2_LOST_DAT; |
| 1279 | 1288 | w->status |= STA_2_BUSY; |
| 1280 | wd17xx_clear_data_request( | |
| 1289 | wd17xx_clear_data_request(d | |
| 1281 | 1290 | |
| 1282 | wd17xx_timed_write_sector_request(); | |
| 1291 | wd17xx_timed_write_sector_request(device); | |
| 1283 | 1292 | |
| 1284 | 1293 | return; |
| 1285 | 1294 | } |
| r3867 | r3868 | |
| 1292 | 1301 | w->command = data & ~FDC_MASK_TYPE_III; |
| 1293 | 1302 | w->command_type = TYPE_III; |
| 1294 | 1303 | w->status &= ~STA_2_LOST_DAT; |
| 1295 | wd17xx_clear_data_request( | |
| 1304 | wd17xx_clear_data_request(d | |
| 1296 | 1305 | #if 1 |
| 1297 | 1306 | // w->status = seek(w, w->track, w->head, w->sector); |
| 1298 | 1307 | if (w->status == 0) |
| 1299 | read_track( | |
| 1308 | read_track(d | |
| 1300 | 1309 | #endif |
| 1301 | 1310 | return; |
| 1302 | 1311 | } |
| r3867 | r3868 | |
| 1308 | 1317 | |
| 1309 | 1318 | w->command_type = TYPE_III; |
| 1310 | 1319 | w->status &= ~STA_2_LOST_DAT; |
| 1311 | wd17xx_clear_data_request( | |
| 1320 | wd17xx_clear_data_request(d | |
| 1312 | 1321 | |
| 1313 | if (!floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_READY)) | |
| 1322 | if (!floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_READY)) | |
| 1314 | 1323 | { |
| 1315 | wd17xx_complete_command( | |
| 1324 | wd17xx_complete_command(device, DELAY_NOTREADY); | |
| 1316 | 1325 | } |
| 1317 | 1326 | else |
| 1318 | 1327 | { |
| 1319 | 1328 | |
| 1320 | 1329 | /* drive write protected? */ |
| 1321 | if (floppy_drive_get_flag_state(wd17xx_current_image(),FLOPPY_DRIVE_DISK_WRITE_PROTECTED)) | |
| 1330 | if (floppy_drive_get_flag_state(wd17xx_current_image(device),FLOPPY_DRIVE_DISK_WRITE_PROTECTED)) | |
| 1322 | 1331 | { |
| 1323 | 1332 | /* yes */ |
| 1324 | 1333 | w->status |= STA_2_WRITE_PRO; |
| 1325 | 1334 | /* quit command */ |
| 1326 | wd17xx_complete_command( | |
| 1335 | wd17xx_complete_command(device, DELAY_ERROR); | |
| 1327 | 1336 | } |
| 1328 | 1337 | else |
| 1329 | 1338 | { |
| 1330 | 1339 | w->command = data & ~FDC_MASK_TYPE_III; |
| 1331 | 1340 | w->data_offset = 0; |
| 1332 | 1341 | w->data_count = (w->density) ? TRKSIZE_DD : TRKSIZE_SD; |
| 1333 | wd17xx_set_data_request( | |
| 1342 | wd17xx_set_data_request(d | |
| 1334 | 1343 | |
| 1335 | 1344 | w->status |= STA_2_BUSY; |
| 1336 | 1345 | w->busy_count = 0; |
| r3867 | r3868 | |
| 1346 | 1355 | |
| 1347 | 1356 | w->command_type = TYPE_III; |
| 1348 | 1357 | w->status &= ~STA_2_LOST_DAT; |
| 1349 | wd17xx_clear_data_request( | |
| 1358 | wd17xx_clear_data_request(d | |
| 1350 | 1359 | |
| 1351 | if (!floppy_drive_get_flag_state(wd17xx_current_image(), FLOPPY_DRIVE_READY)) | |
| 1360 | if (!floppy_drive_get_flag_state(wd17xx_current_image(device), FLOPPY_DRIVE_READY)) | |
| 1352 | 1361 | { |
| 1353 | wd17xx_complete_command( | |
| 1362 | wd17xx_complete_command(device, DELAY_NOTREADY); | |
| 1354 | 1363 | } |
| 1355 | 1364 | else |
| 1356 | 1365 | { |
| 1357 | wd17xx_read_id( | |
| 1366 | wd17xx_read_id(d | |
| 1358 | 1367 | } |
| 1359 | 1368 | return; |
| 1360 | 1369 | } |
| r3867 | r3868 | |
| 1375 | 1384 | if (VERBOSE) |
| 1376 | 1385 | logerror("wd17xx_command_w $%02X RESTORE\n", data); |
| 1377 | 1386 | |
| 1378 | wd17xx_restore( | |
| 1387 | wd17xx_restore(d | |
| 1379 | 1388 | } |
| 1380 | 1389 | |
| 1381 | 1390 | if ((data & ~FDC_MASK_TYPE_I) == FDC_SEEK) |
| r3867 | r3868 | |
| 1418 | 1427 | /* update track reg */ |
| 1419 | 1428 | w->track_reg += w->direction; |
| 1420 | 1429 | |
| 1421 | floppy_drive_seek(wd17xx_current_image(), w->direction); | |
| 1430 | floppy_drive_seek(wd17xx_current_image(device), w->direction); | |
| 1422 | 1431 | } |
| 1423 | 1432 | |
| 1424 | 1433 | /* simulate seek time busy signal */ |
| 1425 | 1434 | w->busy_count = 0; //w->busy_count * ((data & FDC_STEP_RATE) + 1); |
| 1426 | 1435 | #if 0 |
| 1427 | wd17xx_set_irq( | |
| 1436 | wd17xx_set_irq(device); | |
| 1428 | 1437 | #endif |
| 1429 | wd17xx_set_busy( | |
| 1438 | wd17xx_set_busy(device, ATTOTIME_IN_USEC(100)); | |
| 1430 | 1439 | |
| 1431 | 1440 | } |
| 1432 | 1441 | |
| r3867 | r3868 | |
| 1440 | 1449 | /* simulate seek time busy signal */ |
| 1441 | 1450 | w->busy_count = 0; //((data & FDC_STEP_RATE) + 1); |
| 1442 | 1451 | |
| 1443 | floppy_drive_seek(wd17xx_current_image(), w->direction); | |
| 1452 | floppy_drive_seek(wd17xx_current_image(device), w->direction); | |
| 1444 | 1453 | |
| 1445 | 1454 | if (data & FDC_STEP_UPDATE) |
| 1446 | 1455 | w->track_reg += w->direction; |
| 1447 | 1456 | |
| 1448 | 1457 | #if 0 |
| 1449 | wd17xx_set_irq( | |
| 1458 | wd17xx_set_irq(device); | |
| 1450 | 1459 | #endif |
| 1451 | wd17xx_set_busy( | |
| 1460 | wd17xx_set_busy(device, ATTOTIME_IN_USEC(100)); | |
| 1452 | 1461 | |
| 1453 | 1462 | |
| 1454 | 1463 | } |
| r3867 | r3868 | |
| 1463 | 1472 | /* simulate seek time busy signal */ |
| 1464 | 1473 | w->busy_count = 0; //((data & FDC_STEP_RATE) + 1); |
| 1465 | 1474 | |
| 1466 | floppy_drive_seek(wd17xx_current_image(), w->direction); | |
| 1475 | floppy_drive_seek(wd17xx_current_image(device), w->direction); | |
| 1467 | 1476 | |
| 1468 | 1477 | if (data & FDC_STEP_UPDATE) |
| 1469 | 1478 | w->track_reg += w->direction; |
| 1470 | 1479 | #if 0 |
| 1471 | wd17xx_set_irq( | |
| 1480 | wd17xx_set_irq(device); | |
| 1472 | 1481 | #endif |
| 1473 | wd17xx_set_busy( | |
| 1482 | wd17xx_set_busy(device, ATTOTIME_IN_USEC(100)); | |
| 1474 | 1483 | |
| 1475 | 1484 | } |
| 1476 | 1485 | |
| r3867 | r3868 | |
| 1485 | 1494 | w->busy_count = 0; //((data & FDC_STEP_RATE) + 1); |
| 1486 | 1495 | |
| 1487 | 1496 | /* for now only allows a single drive to be selected */ |
| 1488 | floppy_drive_seek(wd17xx_current_image(), w->direction); | |
| 1497 | floppy_drive_seek(wd17xx_current_image(device), w->direction); | |
| 1489 | 1498 | |
| 1490 | 1499 | if (data & FDC_STEP_UPDATE) |
| 1491 | 1500 | w->track_reg += w->direction; |
| 1492 | 1501 | |
| 1493 | 1502 | #if 0 |
| 1494 | wd17xx_set_irq( | |
| 1503 | wd17xx_set_irq(device); | |
| 1495 | 1504 | #endif |
| 1496 | wd17xx_set_busy( | |
| 1505 | wd17xx_set_busy(device, ATTOTIME_IN_USEC(100)); | |
| 1497 | 1506 | } |
| 1498 | 1507 | |
| 1499 | 1508 | // if (w->busy_count==0) |
| r3867 | r3868 | |
| 1509 | 1518 | if (data & FDC_STEP_VERIFY) |
| 1510 | 1519 | { |
| 1511 | 1520 | /* verify seek */ |
| 1512 | wd17xx_verify_seek( | |
| 1521 | wd17xx_verify_seek(device); | |
| 1513 | 1522 | } |
| 1514 | 1523 | } |
| 1515 | 1524 | |
| 1516 | 1525 | |
| 1517 | 1526 | |
| 1518 | 1527 | /* write the FDC track register */ |
| 1519 | WRITE8_HANDLER ( wd17xx_track_w ) | |
| 1528 | WRITE8_DEVICE_HANDLER ( wd17xx_track_w ) | |
| 1520 | 1529 | { |
| 1521 | wd17xx_ | |
| 1530 | wd17xx_t | |
| 1522 | 1531 | w->track_reg = data; |
| 1523 | 1532 | |
| 1524 | 1533 | if (VERBOSE) |
| r3867 | r3868 | |
| 1528 | 1537 | |
| 1529 | 1538 | |
| 1530 | 1539 | /* write the FDC sector register */ |
| 1531 | WRITE8_HANDLER ( wd17xx_sector_w ) | |
| 1540 | WRITE8_DEVICE_HANDLER ( wd17xx_sector_w ) | |
| 1532 | 1541 | { |
| 1533 | wd17xx_ | |
| 1542 | wd17xx_t | |
| 1534 | 1543 | w->sector = data; |
| 1535 | 1544 | if (VERBOSE) |
| 1536 | 1545 | logerror("wd17xx_sector_w $%02X\n", data); |
| r3867 | r3868 | |
| 1539 | 1548 | |
| 1540 | 1549 | |
| 1541 | 1550 | /* write the FDC data register */ |
| 1542 | WRITE8_HANDLER ( wd17xx_data_w ) | |
| 1551 | WRITE8_DEVICE_HANDLER ( wd17xx_data_w ) | |
| 1543 | 1552 | { |
| 1544 | wd17xx_ | |
| 1553 | wd17xx_t | |
| 1545 | 1554 | |
| 1546 | 1555 | if (w->data_count > 0) |
| 1547 | 1556 | { |
| 1548 | 1557 | /* clear data request */ |
| 1549 | wd17xx_clear_data_request( | |
| 1558 | wd17xx_clear_data_request(d | |
| 1550 | 1559 | |
| 1551 | 1560 | /* put byte into buffer */ |
| 1552 | 1561 | if (VERBOSE_DATA) |
| r3867 | r3868 | |
| 1557 | 1566 | if (--w->data_count < 1) |
| 1558 | 1567 | { |
| 1559 | 1568 | if (w->command == FDC_WRITE_TRK) |
| 1560 | write_track( | |
| 1569 | write_track(device); | |
| 1561 | 1570 | else |
| 1562 | wd17xx_write_sector( | |
| 1571 | wd17xx_write_sector(device); | |
| 1563 | 1572 | |
| 1564 | 1573 | w->data_offset = 0; |
| 1565 | 1574 | |
| 1566 | wd17xx_complete_command( | |
| 1575 | wd17xx_complete_command(device, DELAY_DATADONE); | |
| 1567 | 1576 | } |
| 1568 | 1577 | else |
| 1569 | 1578 | { |
| 1570 | 1579 | /* yes... setup a timed data request */ |
| 1571 | wd17xx_timed_data_request(); | |
| 1580 | wd17xx_timed_data_request(device); | |
| 1572 | 1581 | } |
| 1573 | 1582 | |
| 1574 | 1583 | } |
| r3867 | r3868 | |
| 1582 | 1591 | |
| 1583 | 1592 | |
| 1584 | 1593 | |
| 1585 | READ8_HANDLER( wd17xx_r ) | |
| 1594 | READ8_DEVICE_HANDLER( wd17xx_r ) | |
| 1586 | 1595 | { |
| 1587 | 1596 | UINT8 result = 0; |
| 1588 | 1597 | |
| 1589 | 1598 | switch(offset % 4) { |
| 1590 | 1599 | case 0: |
| 1591 | result = wd17xx_status_r( | |
| 1600 | result = wd17xx_status_r(device, 0); | |
| 1592 | 1601 | break; |
| 1593 | 1602 | case 1: |
| 1594 | result = wd17xx_track_r( | |
| 1603 | result = wd17xx_track_r(device, 0); | |
| 1595 | 1604 | break; |
| 1596 | 1605 | case 2: |
| 1597 | result = wd17xx_sector_r( | |
| 1606 | result = wd17xx_sector_r(device, 0); | |
| 1598 | 1607 | break; |
| 1599 | 1608 | case 3: |
| 1600 | result = wd17xx_data_r( | |
| 1609 | result = wd17xx_data_r(device, 0); | |
| 1601 | 1610 | break; |
| 1602 | 1611 | } |
| 1603 | 1612 | return result; |
| r3867 | r3868 | |
| 1605 | 1614 | |
| 1606 | 1615 | |
| 1607 | 1616 | |
| 1608 | WRITE8_HANDLER( wd17xx_w ) | |
| 1617 | WRITE8_DEVICE_HANDLER( wd17xx_w ) | |
| 1609 | 1618 | { |
| 1610 | 1619 | switch(offset % 4) { |
| 1611 | 1620 | case 0: |
| 1612 | wd17xx_command_w( | |
| 1621 | wd17xx_command_w(device, 0, data); | |
| 1613 | 1622 | break; |
| 1614 | 1623 | case 1: |
| 1615 | wd17xx_track_w( | |
| 1624 | wd17xx_track_w(device, 0, data); | |
| 1616 | 1625 | break; |
| 1617 | 1626 | case 2: |
| 1618 | wd17xx_sector_w( | |
| 1627 | wd17xx_sector_w(device, 0, data); | |
| 1619 | 1628 | break; |
| 1620 | 1629 | case 3: |
| 1621 | wd17xx_data_w( | |
| 1630 | wd17xx_data_w(device, 0, data); | |
| 1622 | 1631 | break; |
| 1623 | 1632 | } |
| 1624 | 1633 | } |
| 1625 | 1634 | |
| 1635 | const wd17xx_interface default_wd17xx_interface = { NULL, NULL }; | |
| 1636 | ||
| 1637 | /* device interface */ | |
| 1638 | static device_start_err common_start(const device_config *device, wd17xx_type_t device_type) | |
| 1639 | { | |
| 1640 | wd17xx_t *w = get_safe_token(device); | |
| 1641 | ||
| 1642 | assert(device != NULL); | |
| 1643 | assert(device->tag != NULL); | |
| 1644 | assert(strlen(device->tag) < 20); | |
| 1645 | assert(device->static_config != NULL); | |
| 1646 | ||
| 1647 | w->intf = device->static_config; | |
| 1648 | ||
| 1649 | w->status = STA_1_TRACK0; | |
| 1650 | w->type = device_type; | |
| 1651 | w->density = DEN_MFM_LO; | |
| 1652 | w->busy_timer = timer_alloc(device->machine, wd17xx_busy_callback, (void*)device); | |
| 1653 | w->timer = timer_alloc(device->machine, wd17xx_misc_timer_callback, (void*)device); | |
| 1654 | w->timer_rs = timer_alloc(device->machine, wd17xx_read_sector_callback, (void*)device); | |
| 1655 | w->timer_ws = timer_alloc(device->machine, wd17xx_write_sector_callback, (void*)device); | |
| 1656 | w->pause_time = 40; | |
| 1657 | ||
| 1658 | return DEVICE_START_OK; | |
| 1659 | ||
| 1660 | } | |
| 1661 | ||
| 1662 | static DEVICE_RESET( wd17xx ) | |
| 1663 | { | |
| 1664 | wd17xx_t *w = get_safe_token(device); | |
| 1665 | int i; | |
| 1666 | ||
| 1667 | for (i = 0; i < device_count(device->machine, IO_FLOPPY); i++) | |
| 1668 | { | |
| 1669 | const device_config *img = image_from_devtype_and_index(IO_FLOPPY, i); | |
| 1670 | floppy_drive_set_controller(img,device); | |
| 1671 | floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback); | |
| 1672 | floppy_drive_set_rpm( img, 300.); | |
| 1673 | } | |
| 1674 | ||
| 1675 | w->current_drive = 0; | |
| 1676 | w->hd = 0; | |
| 1677 | ||
| 1678 | wd17xx_restore(device); | |
| 1679 | } | |
| 1680 | ||
| 1681 | void wd17xx_reset(const device_config *device) | |
| 1682 | { | |
| 1683 | device_reset_wd17xx(device); | |
| 1684 | } | |
| 1685 | ||
| 1686 | static DEVICE_START( wd1770 ) | |
| 1687 | { | |
| 1688 | return common_start(device, WD_TYPE_1770); | |
| 1689 | } | |
| 1690 | static DEVICE_START( wd1772 ) | |
| 1691 | { | |
| 1692 | return common_start(device, WD_TYPE_1772); | |
| 1693 | } | |
| 1694 | static DEVICE_START( wd1773 ) | |
| 1695 | { | |
| 1696 | return common_start(device, WD_TYPE_1773); | |
| 1697 | } | |
| 1698 | static DEVICE_START( wd179x ) | |
| 1699 | { | |
| 1700 | return common_start(device, WD_TYPE_179X); | |
| 1701 | } | |
| 1702 | static DEVICE_START( wd1793 ) | |
| 1703 | { | |
| 1704 | return common_start(device, WD_TYPE_1793); | |
| 1705 | } | |
| 1706 | static DEVICE_START( wd2793 ) | |
| 1707 | { | |
| 1708 | return common_start(device, WD_TYPE_2793); | |
| 1709 | } | |
| 1710 | static DEVICE_START( wd177x ) | |
| 1711 | { | |
| 1712 | return common_start(device, WD_TYPE_177X); | |
| 1713 | } | |
| 1714 | static DEVICE_START( mb8877 ) | |
| 1715 | { | |
| 1716 | return common_start(device, WD_TYPE_MB8877); | |
| 1717 | } | |
| 1718 | ||
| 1719 | static DEVICE_SET_INFO( wd17xx ) | |
| 1720 | { | |
| 1721 | switch (state) | |
| 1722 | { | |
| 1723 | /* no parameters to set */ | |
| 1724 | } | |
| 1725 | } | |
| 1726 | ||
| 1727 | DEVICE_GET_INFO( wd1770 ) | |
| 1728 | { | |
| 1729 | switch (state) | |
| 1730 | { | |
| 1731 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 1732 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(wd17xx_t); break; | |
| 1733 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; | |
| 1734 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; | |
| 1735 | ||
| 1736 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1737 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(wd17xx); break; | |
| 1738 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1770); break; | |
| 1739 | case DEVINFO_FCT_STOP: /* Nothing */ break; | |
| 1740 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(wd17xx); break; | |
| 1741 | ||
| 1742 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1743 | case DEVINFO_STR_NAME: info->s = "WD1770"; break; | |
| 1744 | case DEVINFO_STR_FAMILY: info->s = "WD17xx"; break; | |
| 1745 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; | |
| 1746 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; | |
| 1747 | case DEVINFO_STR_CREDITS: info->s = "Copyright MESS Team"; break; | |
| 1748 | } | |
| 1749 | } | |
| 1750 | ||
| 1751 | ||
| 1752 | DEVICE_GET_INFO( wd1772 ) | |
| 1753 | { | |
| 1754 | switch (state) | |
| 1755 | { | |
| 1756 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1757 | case DEVINFO_STR_NAME: info->s = "WD1772"; break; | |
| 1758 | ||
| 1759 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1760 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1772); break; | |
| 1761 | ||
| 1762 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1763 | } | |
| 1764 | } | |
| 1765 | DEVICE_GET_INFO( wd1773 ) | |
| 1766 | { | |
| 1767 | switch (state) | |
| 1768 | { | |
| 1769 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1770 | case DEVINFO_STR_NAME: info->s = "WD1773"; break; | |
| 1771 | ||
| 1772 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1773 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1773); break; | |
| 1774 | ||
| 1775 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1776 | } | |
| 1777 | } | |
| 1778 | DEVICE_GET_INFO( wd179x ) | |
| 1779 | { | |
| 1780 | switch (state) | |
| 1781 | { | |
| 1782 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1783 | case DEVINFO_STR_NAME: info->s = "WD179x"; break; | |
| 1784 | ||
| 1785 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1786 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd179x); break; | |
| 1787 | ||
| 1788 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1789 | } | |
| 1790 | } | |
| 1791 | DEVICE_GET_INFO( wd1793 ) | |
| 1792 | { | |
| 1793 | switch (state) | |
| 1794 | { | |
| 1795 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1796 | case DEVINFO_STR_NAME: info->s = "WD1793"; break; | |
| 1797 | ||
| 1798 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1799 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1793); break; | |
| 1800 | ||
| 1801 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1802 | } | |
| 1803 | } | |
| 1804 | DEVICE_GET_INFO( wd2793 ) | |
| 1805 | { | |
| 1806 | switch (state) | |
| 1807 | { | |
| 1808 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1809 | case DEVINFO_STR_NAME: info->s = "WD2793"; break; | |
| 1810 | ||
| 1811 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1812 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd2793); break; | |
| 1813 | ||
| 1814 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1815 | } | |
| 1816 | } | |
| 1817 | DEVICE_GET_INFO( wd177x ) | |
| 1818 | { | |
| 1819 | switch (state) | |
| 1820 | { | |
| 1821 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1822 | case DEVINFO_STR_NAME: info->s = "WD177x"; break; | |
| 1823 | ||
| 1824 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1825 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd177x); break; | |
| 1826 | ||
| 1827 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1828 | } | |
| 1829 | } | |
| 1830 | DEVICE_GET_INFO( mb8877 ) | |
| 1831 | { | |
| 1832 | switch (state) | |
| 1833 | { | |
| 1834 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 1835 | case DEVINFO_STR_NAME: info->s = "MB8877"; break; | |
| 1836 | ||
| 1837 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 1838 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mb8877); break; | |
| 1839 | ||
| 1840 | default: DEVICE_GET_INFO_CALL(wd1770); break; | |
| 1841 | } | |
| 1842 | } | |
| 1843 |
| r3867 | r3868 | |
|---|---|---|
| 12 | 12 | |
| 13 | 13 | #include "devices/flopdrv.h" |
| 14 | 14 | |
| 15 | /*************************************************************************** | |
| 16 | MACROS | |
| 17 | ***************************************************************************/ | |
| 15 | 18 | |
| 19 | #define WD1770 DEVICE_GET_INFO_NAME(wd1770) | |
| 20 | #define WD1772 DEVICE_GET_INFO_NAME(wd1772) | |
| 21 | #define WD1773 DEVICE_GET_INFO_NAME(wd1773) | |
| 22 | #define WD179X DEVICE_GET_INFO_NAME(wd179x) | |
| 23 | #define WD1793 DEVICE_GET_INFO_NAME(wd1793) | |
| 24 | #define WD2793 DEVICE_GET_INFO_NAME(wd2793) | |
| 25 | #define WD177X DEVICE_GET_INFO_NAME(wd177x) | |
| 26 | #define MB8877 DEVICE_GET_INFO_NAME(mb8877) | |
| 16 | 27 | |
| 17 | 28 | /*************************************************************************** |
| 18 | ||
| 19 | Constants and enumerations | |
| 20 | ||
| 29 | TYPE DEFINITIONS | |
| 21 | 30 | ***************************************************************************/ |
| 22 | 31 | |
| 23 | 32 | typedef enum |
| r3867 | r3868 | |
| 28 | 37 | WD17XX_DRQ_SET |
| 29 | 38 | } wd17xx_state_t; |
| 30 | 39 | |
| 31 | /* enumeration to specify the type of FDC; there are subtle differences */ | |
| 32 | typedef enum | |
| 33 | { | |
| 34 | WD_TYPE_1770, | |
| 35 | WD_TYPE_1772, | |
| 36 | WD_TYPE_1773, | |
| 37 | WD_TYPE_179X, | |
| 38 | WD_TYPE_1793, | |
| 39 | WD_TYPE_2793, | |
| 40 | 40 | |
| 41 | /* duplicate constants */ | |
| 42 | WD_TYPE_177X = WD_TYPE_1770, | |
| 43 | WD_TYPE_MB8877 = WD_TYPE_179X | |
| 44 | } wd17xx_type_t; | |
| 41 | typedef void (*wd17xx_callback_func)(const device_config *device, wd17xx_state_t state, void *param); | |
| 42 | #define WD17XX_CALLBACK(name) void name(const device_config *device, wd17xx_state_t state, void *param ) | |
| 45 | 43 | |
| 44 | typedef void* (*wd17xx_param_callback_func)(const device_config *device); | |
| 45 | #define WD17XX_PARAM_CALLBACK(name) void* name(const device_config *device) | |
| 46 | 46 | |
| 47 | 47 | |
| 48 | /* Interface */ | |
| 49 | typedef struct _wd17xx_interface wd17xx_interface; | |
| 50 | struct _wd17xx_interface | |
| 51 | { | |
| 52 | wd17xx_callback_func callback; | |
| 53 | wd17xx_param_callback_func callback_param; | |
| 54 | }; | |
| 55 | ||
| 48 | 56 | /*************************************************************************** |
| 57 | FUNCTION PROTOTYPES | |
| 58 | ***************************************************************************/ | |
| 49 | 59 | |
| 50 | Prototypes | |
| 60 | /* device interface */ | |
| 61 | extern DEVICE_GET_INFO(wd1770); | |
| 62 | extern DEVICE_GET_INFO(wd1772); | |
| 63 | extern DEVICE_GET_INFO(wd1773); | |
| 64 | extern DEVICE_GET_INFO(wd179x); | |
| 65 | extern DEVICE_GET_INFO(wd1793); | |
| 66 | extern DEVICE_GET_INFO(wd2793); | |
| 67 | extern DEVICE_GET_INFO(wd177x); | |
| 68 | extern DEVICE_GET_INFO(mb8877); | |
| 51 | 69 | |
| 52 | * | |
| 70 | void wd17xx_reset(const device_config *device); | |
| 53 | 71 | |
| 54 | void wd17xx_init(running_machine *machine, wd17xx_type_t type, void (*callback)(running_machine *, wd17xx_state_t, void *), void *param); | |
| 55 | void wd17xx_reset(running_machine *machine); | |
| 56 | ||
| 57 | 72 | /* the following are not strictly part of the wd179x hardware/emulation |
| 58 | 73 | but will be put here for now until the flopdrv code has been finalised more */ |
| 59 | void wd17xx_set_drive(UINT8); /* set drive wd179x is accessing */ | |
| 60 | void wd17xx_set_side(UINT8); /* set side wd179x is accessing */ | |
| 61 | void wd17xx_set_density(DENSITY); /* set density */ | |
| 74 | void wd17xx_set_drive(const device_config *device, UINT8); /* set drive wd179x is accessing */ | |
| 75 | void wd17xx_set_side(const device_config *device, UINT8); /* set side wd179x is accessing */ | |
| 76 | void wd17xx_set_density(const device_config *device, DENSITY); /* set density */ | |
| 62 | 77 | |
| 63 | READ8_HANDLER( wd17xx_status_r ); | |
| 64 | READ8_HANDLER( wd17xx_track_r ); | |
| 65 | READ8_HANDLER( wd17xx_sector_r ); | |
| 66 | READ8_HANDLER( wd17xx_data_r ); | |
| 78 | READ8_DEVICE_HANDLER( wd17xx_status_r ); | |
| 79 | READ8_DEVICE_HANDLER( wd17xx_track_r ); | |
| 80 | READ8_DEVICE_HANDLER( wd17xx_sector_r ); | |
| 81 | READ8_DEVICE_HANDLER( wd17xx_data_r ); | |
| 67 | 82 | |
| 68 | WRITE8_HANDLER( wd17xx_command_w ); | |
| 69 | WRITE8_HANDLER( wd17xx_track_w ); | |
| 70 | WRITE8_HANDLER( wd17xx_sector_w ); | |
| 71 | WRITE8_HANDLER( wd17xx_data_w ); | |
| 83 | WRITE8_DEVICE_HANDLER( wd17xx_command_w ); | |
| 84 | WRITE8_DEVICE_HANDLER( wd17xx_track_w ); | |
| 85 | WRITE8_DEVICE_HANDLER( wd17xx_sector_w ); | |
| 86 | WRITE8_DEVICE_HANDLER( wd17xx_data_w ); | |
| 72 | 87 | |
| 73 | READ8_HANDLER( wd17xx_r ); | |
| 74 | WRITE8_HANDLER( wd17xx_w ); | |
| 88 | READ8_DEVICE_HANDLER( wd17xx_r ); | |
| 89 | WRITE8_DEVICE_HANDLER( wd17xx_w ); | |
| 75 | 90 | |
| 76 | void wd17xx_set_pause_time(int usec); /* default is 40 usec if not set */ | |
| 91 | void wd17xx_set_pause_time(const device_config *device, int usec); /* default is 40 usec if not set */ | |
| 92 | ||
| 93 | extern const wd17xx_interface default_wd17xx_interface; | |
| 94 | /*************************************************************************** | |
| 95 | DEVICE CONFIGURATION MACROS | |
| 96 | ***************************************************************************/ | |
| 97 | ||
| 98 | #define MDRV_WD1770_ADD(_tag, _intrf) \ | |
| 99 | MDRV_DEVICE_ADD(_tag, WD1770) \ | |
| 100 | MDRV_DEVICE_CONFIG(_intrf) | |
| 101 | ||
| 102 | #define MDRV_WD1772_ADD(_tag, _intrf) \ | |
| 103 | MDRV_DEVICE_ADD(_tag, WD1772) \ | |
| 104 | MDRV_DEVICE_CONFIG(_intrf) | |
| 105 | ||
| 106 | #define MDRV_WD1773_ADD(_tag, _intrf) \ | |
| 107 | MDRV_DEVICE_ADD(_tag, WD1773) \ | |
| 108 | MDRV_DEVICE_CONFIG(_intrf) | |
| 109 | ||
| 110 | #define MDRV_WD179X_ADD(_tag, _intrf) \ | |
| 111 | MDRV_DEVICE_ADD(_tag, WD179X) \ | |
| 112 | MDRV_DEVICE_CONFIG(_intrf) | |
| 113 | ||
| 114 | #define MDRV_WD1793_ADD(_tag, _intrf) \ | |
| 115 | MDRV_DEVICE_ADD(_tag, WD1793) \ | |
| 116 | MDRV_DEVICE_CONFIG(_intrf) | |
| 117 | ||
| 118 | #define MDRV_WD2793_ADD(_tag, _intrf) \ | |
| 119 | MDRV_DEVICE_ADD(_tag, WD2793) \ | |
| 120 | MDRV_DEVICE_CONFIG(_intrf) | |
| 121 | ||
| 122 | #define MDRV_WD177X_ADD(_tag, _intrf) \ | |
| 123 | MDRV_DEVICE_ADD(_tag, WD177X) \ | |
| 124 | MDRV_DEVICE_CONFIG(_intrf) | |
| 125 | ||
| 126 | #define MDRV_MB8877_ADD(_tag, _intrf) \ | |
| 127 | MDRV_DEVICE_ADD(_tag, MB8877) \ | |
| 128 | MDRV_DEVICE_CONFIG(_intrf) | |
| 129 | ||
| 130 | ||
| 77 | 131 | #endif /* WD179X_H */ |
| 78 | 132 | |
| 79 | 133 | |
| 134 |
| r3867 | r3868 | |
|---|---|---|
| 10 | 10 | #include "driver.h" |
| 11 | 11 | #include "includes/samcoupe.h" |
| 12 | 12 | #include "devices/basicdsk.h" |
| 13 | #include "machine/wd17xx.h" | |
| 14 | 13 | #include "machine/msm6242.h" |
| 15 | 14 | |
| 16 | 15 | |
| r3867 | r3868 | |
| 189 | 188 | samcoupe_update_memory(space); |
| 190 | 189 | } |
| 191 | 190 | |
| 192 | ||
| 193 | MACHINE_START( samcoupe ) | |
| 194 | { | |
| 195 | wd17xx_init(machine, WD_TYPE_1772, NULL, NULL); | |
| 196 | } |
| r3867 | r3868 | |
|---|---|---|
| 143 | 143 | return INIT_FAIL; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | static | |
| 146 | static WD17XX_CALLBACK( comx35_fdc_callback | |
| 147 | 147 | { |
| 148 | comx35_state *state = machine->driver_data; | |
| 148 | comx35_state *driver_state = device->machine->driver_data; | |
| 149 | 149 | |
| 150 | switch ( | |
| 150 | switch (s | |
| 151 | 151 | { |
| 152 | 152 | case WD17XX_IRQ_SET: |
| 153 | state->fdc_irq = 1; | |
| 153 | driver_state->fdc_irq = 1; | |
| 154 | 154 | break; |
| 155 | 155 | |
| 156 | 156 | case WD17XX_IRQ_CLR: |
| 157 | state->fdc_irq = 0; | |
| 157 | driver_state->fdc_irq = 0; | |
| 158 | 158 | break; |
| 159 | 159 | |
| 160 | 160 | case WD17XX_DRQ_SET: |
| 161 | if (state->fdc_drq_enable) | |
| 161 | if (driver_state->fdc_drq_enable) | |
| 162 | 162 | { |
| 163 | state->cdp1802_ef4 = 1; | |
| 163 | driver_state->cdp1802_ef4 = 1; | |
| 164 | 164 | } |
| 165 | 165 | break; |
| 166 | 166 | |
| 167 | 167 | case WD17XX_DRQ_CLR: |
| 168 | if (state->fdc_drq_enable) | |
| 168 | if (driver_state->fdc_drq_enable) | |
| 169 | 169 | { |
| 170 | state->cdp1802_ef4 = 0; | |
| 170 | driver_state->cdp1802_ef4 = 0; | |
| 171 | 171 | } |
| 172 | 172 | break; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | const wd17xx_interface comx35_wd17xx_interface = { comx35_fdc_callback, NULL }; | |
| 177 | ||
| 176 | 178 | static UINT8 fdc_r(const address_space *space) |
| 177 | 179 | { |
| 178 | 180 | comx35_state *state = space->machine->driver_data; |
| 181 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1770, "wd1770"); | |
| 179 | 182 | |
| 180 | 183 | UINT8 data; |
| 181 | 184 | |
| r3867 | r3868 | |
| 185 | 188 | } |
| 186 | 189 | else |
| 187 | 190 | { |
| 188 | data = wd17xx_r( | |
| 191 | data = wd17xx_r(fd | |
| 189 | 192 | } |
| 190 | 193 | |
| 191 | 194 | return data; |
| r3867 | r3868 | |
| 193 | 196 | |
| 194 | 197 | static void fdc_w(const address_space *space, UINT8 data) |
| 195 | 198 | { |
| 199 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1770, "wd1770"); | |
| 196 | 200 | /* |
| 197 | 201 | |
| 198 | 202 | bit description |
| r3867 | r3868 | |
| 216 | 220 | |
| 217 | 221 | if (BIT(data, 2)) |
| 218 | 222 | { |
| 219 | wd17xx_set_drive(0); | |
| 223 | wd17xx_set_drive(fdc,0); | |
| 220 | 224 | } |
| 221 | 225 | else if (BIT(data, 3)) |
| 222 | 226 | { |
| 223 | wd17xx_set_drive(1); | |
| 227 | wd17xx_set_drive(fdc,1); | |
| 224 | 228 | } |
| 225 | 229 | |
| 226 | 230 | state->fdc_drq_enable = BIT(data, 4); |
| r3867 | r3868 | |
| 230 | 234 | state->cdp1802_ef4 = 1; |
| 231 | 235 | } |
| 232 | 236 | |
| 233 | wd17xx_set_side(BIT(data, 5)); | |
| 237 | wd17xx_set_side(fdc,BIT(data, 5)); | |
| 234 | 238 | } |
| 235 | 239 | else |
| 236 | 240 | { |
| 237 | 241 | // write data to WD1770 |
| 238 | 242 | |
| 239 | wd17xx_w( | |
| 243 | wd17xx_w(fd | |
| 240 | 244 | } |
| 241 | 245 | } |
| 242 | 246 | |
| r3867 | r3868 | |
| 610 | 614 | |
| 611 | 615 | state->pal_ntsc = CDP1869_PAL; |
| 612 | 616 | |
| 613 | /* initialize floppy disc controller */ | |
| 614 | ||
| 615 | wd17xx_init(machine, WD_TYPE_1770, comx35_fdc_callback, NULL); | |
| 616 | ||
| 617 | 617 | /* register for state saving */ |
| 618 | 618 | |
| 619 | 619 | state_save_register_postload(machine, comx35_state_save_postload, NULL); |
| r3867 | r3868 | |
|---|---|---|
| 203 | 203 | return INIT_PASS; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | static void trs80_fdc_callback(running_machine *machine, wd17xx_state_t event, void *param); | |
| 207 | ||
| 208 | ||
| 209 | 206 | MACHINE_RESET( trs80 ) |
| 210 | 207 | { |
| 211 | 208 | cassette_data = 0x00; |
| r3867 | r3868 | |
| 287 | 284 | } |
| 288 | 285 | } |
| 289 | 286 | |
| 290 | ||
| 291 | MACHINE_START( trs80 ) | |
| 292 | { | |
| 293 | wd17xx_init(machine, WD_TYPE_179X,trs80_fdc_callback, NULL); | |
| 294 | } | |
| 295 | ||
| 296 | ||
| 297 | 287 | /************************************* |
| 298 | 288 | * |
| 299 | 289 | * Port handlers. |
| r3867 | r3868 | |
| 355 | 345 | trs80_fdc_interrupt_internal(device->machine); |
| 356 | 346 | } |
| 357 | 347 | |
| 358 | ||
| 348 | static WD17XX_CALLBACK( trs80_fdc_callback | |
| 359 | 349 | { |
| 360 | switch ( | |
| 350 | switch (s | |
| 361 | 351 | { |
| 362 | 352 | case WD17XX_IRQ_CLR: |
| 363 | 353 | irq_status &= ~IRQ_FDC; |
| 364 | 354 | break; |
| 365 | 355 | case WD17XX_IRQ_SET: |
| 366 | trs80_fdc_interrupt_internal(machine); | |
| 356 | trs80_fdc_interrupt_internal(device->machine); | |
| 367 | 357 | break; |
| 368 | 358 | case WD17XX_DRQ_CLR: |
| 369 | 359 | case WD17XX_DRQ_SET: |
| r3867 | r3868 | |
| 372 | 362 | } |
| 373 | 363 | } |
| 374 | 364 | |
| 365 | const wd17xx_interface trs80_wd17xx_interface = { trs80_fdc_callback, NULL }; | |
| 366 | ||
| 367 | ||
| 375 | 368 | INTERRUPT_GEN( trs80_frame_interrupt ) |
| 376 | 369 | { |
| 377 | 370 | } |
| r3867 | r3868 | |
| 408 | 401 | WRITE8_HANDLER( trs80_motor_w ) |
| 409 | 402 | { |
| 410 | 403 | UINT8 drive = 255; |
| 404 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 411 | 405 | |
| 412 | 406 | LOG(("trs80 motor_w $%02X\n", data)); |
| 413 | 407 | |
| r3867 | r3868 | |
| 446 | 440 | if (drive > 3) |
| 447 | 441 | return; |
| 448 | 442 | |
| 449 | wd17xx_set_drive(drive); | |
| 450 | wd17xx_set_side(head); | |
| 443 | wd17xx_set_drive(fdc,drive); | |
| 444 | wd17xx_set_side(fdc,head); | |
| 451 | 445 | |
| 452 | 446 | } |
| 453 | 447 |
| r3867 | r3868 | |
|---|---|---|
| 338 | 338 | |
| 339 | 339 | static SVI318_FDC_STRUCT svi318_fdc; |
| 340 | 340 | |
| 341 | static | |
| 341 | static WD17XX_CALLBACK( svi_fdc_callback | |
| 342 | 342 | { |
| 343 | 343 | switch( state ) |
| 344 | 344 | { |
| r3867 | r3868 | |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | const wd17xx_interface svi_wd17xx_interface = { svi_fdc_callback, NULL }; | |
| 361 | ||
| 360 | 362 | static WRITE8_HANDLER( svi318_fdc_drive_motor_w ) |
| 361 | 363 | { |
| 364 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 362 | 365 | switch (data & 3) |
| 363 | 366 | { |
| 364 | 367 | case 1: |
| 365 | wd17xx_set_drive(0); | |
| 368 | wd17xx_set_drive(fdc,0); | |
| 366 | 369 | svi318_fdc.driveselect = 0; |
| 367 | 370 | break; |
| 368 | 371 | case 2: |
| 369 | wd17xx_set_drive(1); | |
| 372 | wd17xx_set_drive(fdc,1); | |
| 370 | 373 | svi318_fdc.driveselect = 1; |
| 371 | 374 | break; |
| 372 | 375 | } |
| r3867 | r3868 | |
| 375 | 378 | static WRITE8_HANDLER( svi318_fdc_density_side_w ) |
| 376 | 379 | { |
| 377 | 380 | const device_config *image; |
| 381 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 378 | 382 | |
| 379 | wd17xx_set_density(data & 0x01 ? DEN_FM_LO:DEN_MFM_LO); | |
| 383 | wd17xx_set_density(fdc, data & 0x01 ? DEN_FM_LO:DEN_MFM_LO); | |
| 380 | 384 | |
| 381 | wd17xx_set_side(data & 0x02 ? 1:0); | |
| 385 | wd17xx_set_side(fdc, data & 0x02 ? 1:0); | |
| 382 | 386 | |
| 383 | 387 | image = image_from_devtype_and_index(IO_FLOPPY, svi318_fdc.driveselect); |
| 384 | 388 | if (image_exists(image)) |
| r3867 | r3868 | |
| 608 | 612 | MACHINE_START( svi318_ntsc ) |
| 609 | 613 | { |
| 610 | 614 | TMS9928A_configure(&svi318_tms9928a_interface); |
| 611 | wd17xx_init(machine, WD_TYPE_179X, svi_fdc_callback, NULL); | |
| 612 | 615 | } |
| 613 | 616 | |
| 614 | 617 | MACHINE_START( svi318_pal ) |
| 615 | 618 | { |
| 616 | 619 | TMS9928A_configure(&svi318_tms9929a_interface); |
| 617 | wd17xx_init(machine, WD_TYPE_179X, svi_fdc_callback, NULL); | |
| 618 | 620 | } |
| 619 | 621 | |
| 620 | 622 | MACHINE_RESET( svi318 ) |
| r3867 | r3868 | |
| 624 | 626 | |
| 625 | 627 | svi.bank_switch = 0xff; |
| 626 | 628 | svi318_set_banks(machine); |
| 627 | ||
| 628 | wd17xx_reset(machine); | |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | INTERRUPT_GEN( svi318_interrupt ) |
| r3867 | r3868 | |
| 787 | 787 | READ8_HANDLER( svi318_io_ext_r ) |
| 788 | 788 | { |
| 789 | 789 | UINT8 data = 0xff; |
| 790 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 790 | 791 | |
| 791 | 792 | if (svi.bankLow == SVI_CART) { |
| 792 | 793 | return 0xff; |
| r3867 | r3868 | |
| 820 | 821 | break; |
| 821 | 822 | |
| 822 | 823 | case 0x30: |
| 823 | data = wd17xx_status_r( | |
| 824 | data = wd17xx_status_r(fd | |
| 824 | 825 | break; |
| 825 | 826 | case 0x31: |
| 826 | data = wd17xx_track_r( | |
| 827 | data = wd17xx_track_r(fd | |
| 827 | 828 | break; |
| 828 | 829 | case 0x32: |
| 829 | data = wd17xx_sector_r( | |
| 830 | data = wd17xx_sector_r(fd | |
| 830 | 831 | break; |
| 831 | 832 | case 0x33: |
| 832 | data = wd17xx_data_r( | |
| 833 | data = wd17xx_data_r(fd | |
| 833 | 834 | break; |
| 834 | 835 | case 0x34: |
| 835 | 836 | data = svi318_fdc_irqdrq_r(space, 0); |
| r3867 | r3868 | |
| 846 | 847 | |
| 847 | 848 | WRITE8_HANDLER( svi318_io_ext_w ) |
| 848 | 849 | { |
| 850 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 851 | ||
| 849 | 852 | if (svi.bankLow == SVI_CART) { |
| 850 | 853 | return; |
| 851 | 854 | } |
| r3867 | r3868 | |
| 879 | 882 | break; |
| 880 | 883 | |
| 881 | 884 | case 0x30: |
| 882 | wd17xx_command_w( | |
| 885 | wd17xx_command_w(fd | |
| 883 | 886 | break; |
| 884 | 887 | case 0x31: |
| 885 | wd17xx_track_w( | |
| 888 | wd17xx_track_w(fd | |
| 886 | 889 | break; |
| 887 | 890 | case 0x32: |
| 888 | wd17xx_sector_w( | |
| 891 | wd17xx_sector_w(fd | |
| 889 | 892 | break; |
| 890 | 893 | case 0x33: |
| 891 | wd17xx_data_w( | |
| 894 | wd17xx_data_w(fd | |
| 892 | 895 | break; |
| 893 | 896 | case 0x34: |
| 894 | 897 | svi318_fdc_drive_motor_w(space, 0, data); |
| r3867 | r3868 | |
|---|---|---|
| 289 | 289 | /*-------------------------------------------------------------------------*/ |
| 290 | 290 | static void compis_fdc_reset(running_machine *machine) |
| 291 | 291 | { |
| 292 | nec765_reset(machine, 0); | |
| 292 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC765A, "nec765"); | |
| 293 | ||
| 294 | nec765_reset(fdc, 0); | |
| 293 | 295 | |
| 294 | 296 | /* set FDC at reset */ |
| 295 | nec765_set_reset_state( | |
| 297 | nec765_set_reset_state(fdc | |
| 296 | 298 | } |
| 297 | 299 | |
| 298 | 300 | static void compis_fdc_tc(running_machine *machine, int state) |
| 299 | 301 | { |
| 302 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC765A, "nec765"); | |
| 300 | 303 | /* Terminal count if iSBX-218A has DMA enabled */ |
| 301 | 304 | if (input_port_read(machine, "DSW1")) |
| 302 | 305 | { |
| 303 | nec765_set_tc_state( | |
| 306 | nec765_set_tc_state(fdc | |
| 304 | 307 | } |
| 305 | 308 | } |
| 306 | 309 | |
| 307 | static | |
| 310 | static NEC765_INTERRUPT( compis_fdc_int | |
| 308 | 311 | { |
| 309 | 312 | /* No interrupt requests if iSBX-218A has DMA enabled */ |
| 310 | if (!input_port_read(machine, "DSW1") && state) | |
| 313 | if (!input_port_read(device->machine, "DSW1") && state) | |
| 311 | 314 | { |
| 312 | 315 | compis_osp_pic_irq(COMPIS_IRQ_SBX0_INT1); |
| 313 | 316 | } |
| 314 | 317 | } |
| 315 | 318 | |
| 316 | static | |
| 319 | static NEC765_DMA_REQUEST( compis_fdc_dma_drq | |
| 317 | 320 | { |
| 318 | 321 | /* DMA requst if iSBX-218A has DMA enabled */ |
| 319 | if (input_port_read(machine, "DSW1") && state) | |
| 322 | if (input_port_read(device->machine, "DSW1") && state) | |
| 320 | 323 | { |
| 321 | 324 | //compis_dma_drq(state, read); |
| 322 | 325 | } |
| 323 | 326 | } |
| 324 | 327 | |
| 325 | ||
| 328 | ||
| 326 | 329 | { |
| 327 | 330 | compis_fdc_int, |
| 328 | compis_fdc_dma_drq | |
| 331 | compis_fdc_dma_drq, | |
| 332 | NULL, | |
| 333 | NEC765_RDY_PIN_CONNECTED | |
| 329 | 334 | }; |
| 330 | 335 | |
| 331 | 336 | READ16_HANDLER (compis_fdc_dack_r) |
| 332 | 337 | { |
| 338 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 333 | 339 | UINT16 data; |
| 334 | data = 0xffff; | |
| 340 | data = 0xffff; | |
| 335 | 341 | /* DMA acknowledge if iSBX-218A has DMA enabled */ |
| 336 | 342 | if (input_port_read(space->machine, "DSW1")) |
| 337 | 343 | { |
| 338 | data = nec765_dack_r( | |
| 344 | data = nec765_dack_r(fd | |
| 339 | 345 | } |
| 340 | 346 | |
| 341 | 347 | return data; |
| r3867 | r3868 | |
| 343 | 349 | |
| 344 | 350 | WRITE16_HANDLER (compis_fdc_w) |
| 345 | 351 | { |
| 352 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 346 | 353 | switch(offset) |
| 347 | 354 | { |
| 348 | 355 | case 2: |
| 349 | nec765_data_w( | |
| 356 | nec765_data_w(fd | |
| 350 | 357 | break; |
| 351 | 358 | default: |
| 352 | 359 | logerror("FDC Unknown Port Write %04X = %04X\n", offset, data); |
| r3867 | r3868 | |
| 356 | 363 | |
| 357 | 364 | READ16_HANDLER (compis_fdc_r) |
| 358 | 365 | { |
| 366 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 359 | 367 | UINT16 data; |
| 360 | 368 | data = 0xffff; |
| 361 | 369 | switch(offset) |
| 362 | 370 | { |
| 363 | 371 | case 0: |
| 364 | data = nec765_status_r( | |
| 372 | data = nec765_status_r(fd | |
| 365 | 373 | break; |
| 366 | 374 | case 1: |
| 367 | data = nec765_data_r( | |
| 375 | data = nec765_data_r(fd | |
| 368 | 376 | break; |
| 369 | 377 | default: |
| 370 | 378 | logerror("FDC Unknown Port Read %04X\n", offset); |
| r3867 | r3868 | |
| 1545 | 1553 | compis_cpu_init(machine); |
| 1546 | 1554 | |
| 1547 | 1555 | /* FDC */ |
| 1548 | nec765_init(machine, &compis_fdc_interface, NEC765A, NEC765_RDY_PIN_CONNECTED); | |
| 1549 | 1556 | compis_fdc_reset(machine); |
| 1550 | 1557 | |
| 1551 | 1558 | /* Keyboard */ |
| r3867 | r3868 | |
|---|---|---|
| 33 | 33 | NEC765_EXECUTION_PHASE_WRITE |
| 34 | 34 | } NEC765_PHASE; |
| 35 | 35 | |
| 36 | /* supported versions */ | |
| 37 | typedef enum | |
| 38 | { | |
| 39 | TYPE_NEC765A = 0, | |
| 40 | TYPE_NEC765B = 1, | |
| 41 | TYPE_SMC37C78 = 2, | |
| 42 | TYPE_NEC72065 = 3 | |
| 43 | } NEC765_VERSION; | |
| 44 | ||
| 45 | ||
| 36 | 46 | /* uncomment the following line for verbose information */ |
| 37 | 47 | #define LOG_VERBOSE 1 |
| 38 | #define LOG_COMMAND 0 | |
| 39 | #define LOG_EXTRA 0 | |
| 40 | #define LOG_INTERRUPT 0 | |
| 48 | #define LOG_COMMAND 1 | |
| 49 | #define LOG_EXTRA 1 | |
| 50 | #define LOG_INTERRUPT 1 | |
| 41 | 51 | |
| 42 | 52 | /* uncomment this to not allow end of cylinder "error" */ |
| 43 | 53 | #define NO_END_OF_CYLINDER |
| r3867 | r3868 | |
| 63 | 73 | |
| 64 | 74 | #define NEC765_RESET 0x080 |
| 65 | 75 | |
| 66 | typedef struct nec765 | |
| 76 | typedef struct _nec765_t nec765_t; | |
| 77 | struct _nec765_t | |
| 67 | 78 | { |
| 68 | 79 | unsigned long sector_counter; |
| 69 | 80 | /* version of fdc to emulate */ |
| r3867 | r3868 | |
| 117 | 128 | int timer_type; |
| 118 | 129 | |
| 119 | 130 | emu_timer *command_timer; |
| 120 | } NEC765; | |
| 131 | ||
| 132 | char *data_buffer; | |
| 133 | const nec765_interface *intf; | |
| 134 | }; | |
| 121 | 135 | |
| 122 | 136 | //static void nec765_setup_data_request(unsigned char Data); |
| 123 | static void nec765_setup_command( | |
| 137 | static void nec765_setup_command(const device_ | |
| 124 | 138 | static TIMER_CALLBACK(nec765_continue_command); |
| 125 | static int nec765_sector_count_complete(running_machine *machine); | |
| 126 | static void nec765_increment_sector(running_machine *machine); | |
| 127 | static void nec765_update_state(running_machine *machine); | |
| 128 | static void nec765_set_dma_drq(running_machine *machine,int state); | |
| 129 | static void nec765_set_int(running_machine *machine,int state); | |
| 139 | static int nec765_sector_count_complete(const device_config *device); | |
| 140 | static void nec765_increment_sector(const device_config *device); | |
| 141 | static void nec765_update_state(const device_config *device); | |
| 142 | static void nec765_set_dma_drq(const device_config *device,int state); | |
| 143 | static void nec765_set_int(const device_config *device,int state); | |
| 130 | 144 | |
| 131 | static NEC765 fdc; | |
| 132 | static char nec765_data_buffer[32*1024]; | |
| 133 | ||
| 134 | ||
| 135 | static nec765_interface nec765_iface; | |
| 136 | ||
| 137 | ||
| 138 | 145 | static const INT8 nec765_cmd_size[32] = |
| 139 | 146 | { |
| 140 | 147 | 1,1,9,3,2,9,9,2,1,9,2,1,9,6,1,3, |
| 141 | 148 | 1,9,1,1,1,1,9,1,1,9,1,1,1,9,1,1 |
| 142 | 149 | }; |
| 143 | 150 | |
| 151 | INLINE nec765_t *get_safe_token(const device_config *device) | |
| 152 | { | |
| 153 | assert(device != NULL); | |
| 154 | assert(device->token != NULL); | |
| 144 | 155 | |
| 156 | return (nec765_t *)device->token; | |
| 157 | } | |
| 145 | 158 | |
| 146 | static const device_config *current_image( | |
| 159 | static const device_config *current_image(const device_ | |
| 147 | 160 | { |
| 148 | 161 | const device_config *image = NULL; |
| 162 | nec765_t *fdc = get_safe_token(device); | |
| 149 | 163 | |
| 150 | if (! | |
| 164 | if (!fdc-> | |
| 151 | 165 | { |
| 152 | if (fdc.drive < device_count(machine, IO_FLOPPY)) | |
| 153 | image = image_from_devtype_and_index(IO_FLOPPY, fdc.drive); | |
| 166 | if (fdc->drive < device_count(device->machine, IO_FLOPPY)) | |
| 167 | image = image_from_devtype_and_index(IO_FLOPPY, fdc->drive); | |
| 154 | 168 | } |
| 155 | 169 | else |
| 156 | 170 | { |
| 157 | image = | |
| 171 | image = fdc-> | |
| 158 | 172 | } |
| 159 | 173 | return image; |
| 160 | 174 | } |
| 161 | 175 | |
| 162 | static void nec765_setup_drive_and_side(void) | |
| 176 | static void nec765_setup_drive_and_side(const device_config *device) | |
| 163 | 177 | { |
| 178 | nec765_t *fdc = get_safe_token(device); | |
| 164 | 179 | /* drive index nec765 sees */ |
| 165 | fdc | |
| 180 | fdc->drive = fdc->nec765_command_bytes[1] & 0x03; | |
| 166 | 181 | /* side index nec765 sees */ |
| 167 | fdc | |
| 182 | fdc->side = (fdc->nec765_command_bytes[1]>>2) & 0x01; | |
| 168 | 183 | } |
| 169 | 184 | |
| 170 | 185 | |
| 171 | 186 | /* setup status register 0 based on data in status register 1 and 2 */ |
| 172 | static void nec765_setup_st0(void) | |
| 187 | static void nec765_setup_st0(const device_config *device) | |
| 173 | 188 | { |
| 189 | nec765_t *fdc = get_safe_token(device); | |
| 174 | 190 | /* clear completition status bits, drive bits and side bits */ |
| 175 | fdc | |
| 191 | fdc->nec765_status[0] &= ~((1<<7) | (1<<6) | (1<<2) | (1<<1) | (1<<0)); | |
| 176 | 192 | /* fill in drive */ |
| 177 | fdc | |
| 193 | fdc->nec765_status[0] |= fdc->drive | (fdc->side<<2); | |
| 178 | 194 | |
| 179 | 195 | /* fill in completion status bits based on bits in st0, st1, st2 */ |
| 180 | 196 | /* no error bits set */ |
| 181 | if ((fdc | |
| 197 | if ((fdc->nec765_status[1] | fdc->nec765_status[2])==0) | |
| 182 | 198 | { |
| 183 | 199 | return; |
| 184 | 200 | } |
| 185 | 201 | |
| 186 | fdc | |
| 202 | fdc->nec765_status[0] |= 0x040; | |
| 187 | 203 | } |
| 188 | 204 | |
| 189 | 205 | |
| r3867 | r3868 | |
| 194 | 210 | return 1<<(n+7); |
| 195 | 211 | } |
| 196 | 212 | |
| 197 | static void nec765_set_data_request(void) | |
| 213 | static void nec765_set_data_request(const device_config *device) | |
| 198 | 214 | { |
| 199 | fdc.FDC_main |= 0x080; | |
| 215 | nec765_t *fdc = get_safe_token(device); | |
| 216 | fdc->FDC_main |= 0x080; | |
| 200 | 217 | } |
| 201 | 218 | |
| 202 | static void nec765_clear_data_request(void) | |
| 219 | static void nec765_clear_data_request(const device_config *device) | |
| 203 | 220 | { |
| 204 | fdc.FDC_main &= ~0x080; | |
| 221 | nec765_t *fdc = get_safe_token(device); | |
| 222 | fdc->FDC_main &= ~0x080; | |
| 205 | 223 | } |
| 206 | 224 | |
| 207 | static void nec765_seek_complete(running_machine *machine) | |
| 208 | { | |
| 225 | static void nec765_seek_complete(const device_config *device) | |
| 226 | { | |
| 209 | 227 | /* tested on Amstrad CPC */ |
| 210 | 228 | |
| 211 | 229 | /* if a seek is done without drive connected: */ |
| r3867 | r3868 | |
| 259 | 277 | This indicates it is always ready!!!!! |
| 260 | 278 | */ |
| 261 | 279 | |
| 262 | const device_config *img = current_image(machine); | |
| 263 | ||
| 280 | const device_config *img = current_image(device); | |
| 281 | nec765_t *fdc = get_safe_token(device); | |
| 282 | ||
| 264 | 283 | if (!img) |
| 265 | 284 | return; |
| 266 | 285 | |
| 267 | fdc | |
| 286 | fdc->pcn[fdc->drive] = fdc->ncn; | |
| 268 | 287 | |
| 269 | 288 | /* drive ready? */ |
| 270 | 289 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| r3867 | r3868 | |
| 272 | 291 | /* yes */ |
| 273 | 292 | |
| 274 | 293 | /* recalibrate? */ |
| 275 | if (fdc | |
| 294 | if (fdc->nec765_flags & NEC765_SEEK_OPERATION_IS_RECALIBRATE) | |
| 276 | 295 | { |
| 277 | 296 | /* yes */ |
| 278 | 297 | |
| r3867 | r3868 | |
| 280 | 299 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_HEAD_AT_TRACK_0)) |
| 281 | 300 | { |
| 282 | 301 | /* yes. Seek complete */ |
| 283 | fdc | |
| 302 | fdc->nec765_status[0] = 0x020; | |
| 284 | 303 | } |
| 285 | 304 | else |
| 286 | 305 | { |
| 287 | 306 | /* no, track 0 failed after 77 steps */ |
| 288 | fdc | |
| 307 | fdc->nec765_status[0] = 0x040 | 0x020 | 0x010; | |
| 289 | 308 | } |
| 290 | 309 | } |
| 291 | 310 | else |
| r3867 | r3868 | |
| 293 | 312 | /* no, seek */ |
| 294 | 313 | |
| 295 | 314 | /* seek complete */ |
| 296 | fdc | |
| 315 | fdc->nec765_status[0] = 0x020; | |
| 297 | 316 | } |
| 298 | 317 | } |
| 299 | 318 | else |
| 300 | 319 | { |
| 301 | 320 | /* abnormal termination, not ready */ |
| 302 | fdc | |
| 321 | fdc->nec765_status[0] = 0x040 | 0x020 | 0x08; | |
| 303 | 322 | } |
| 304 | 323 | |
| 305 | 324 | /* set drive and side */ |
| 306 | fdc | |
| 325 | fdc->nec765_status[0] |= fdc->drive | (fdc->side<<2); | |
| 307 | 326 | |
| 308 | nec765_set_int(machine,0); | |
| 309 | nec765_set_int(machine,1); | |
| 327 | nec765_set_int(device,0); | |
| 328 | nec765_set_int(device,1); | |
| 310 | 329 | |
| 311 | fdc | |
| 330 | fdc->nec765_flags &= ~NEC765_SEEK_ACTIVE; | |
| 312 | 331 | } |
| 313 | 332 | |
| 314 | 333 | static TIMER_CALLBACK(nec765_seek_timer_callback) |
| 315 | 334 | { |
| 335 | const device_config *device = ptr; | |
| 336 | nec765_t *fdc = get_safe_token(device); | |
| 316 | 337 | /* seek complete */ |
| 317 | nec765_seek_complete( | |
| 338 | nec765_seek_complete(dev | |
| 318 | 339 | |
| 319 | timer_reset(fdc | |
| 340 | timer_reset(fdc->seek_timer, attotime_never); | |
| 320 | 341 | } |
| 321 | 342 | |
| 322 | static void nec765_timer_func( | |
| 343 | static void nec765_timer_func(const device_ | |
| 323 | 344 | { |
| 345 | nec765_t *fdc = get_safe_token(device); | |
| 324 | 346 | /* type 0 = data transfer mode in execution phase */ |
| 325 | if (fdc | |
| 347 | if (fdc->timer_type == 0) | |
| 326 | 348 | { |
| 327 | 349 | /* set data request */ |
| 328 | nec765_set_data_request(); | |
| 350 | nec765_set_data_request(device); | |
| 329 | 351 | |
| 330 | fdc | |
| 352 | fdc->timer_type = 4; | |
| 331 | 353 | |
| 332 | if (!(fdc | |
| 354 | if (!(fdc->nec765_flags & NEC765_DMA_MODE)) | |
| 333 | 355 | { |
| 334 | 356 | /* for pcw */ |
| 335 | timer_reset(fdc | |
| 357 | timer_reset(fdc->timer, ATTOTIME_IN_USEC(27)); | |
| 336 | 358 | } |
| 337 | 359 | else |
| 338 | 360 | { |
| 339 | nec765_timer_func( | |
| 361 | nec765_timer_func(dev | |
| 340 | 362 | } |
| 341 | 363 | } |
| 342 | else if (fdc | |
| 364 | else if (fdc->timer_type==2) | |
| 343 | 365 | { |
| 344 | 366 | /* result phase begin */ |
| 345 | 367 | |
| 346 | 368 | /* generate a int for specific commands */ |
| 347 | switch (fdc | |
| 369 | switch (fdc->command) { | |
| 348 | 370 | case 2: /* read a track */ |
| 349 | 371 | case 5: /* write data */ |
| 350 | 372 | case 6: /* read data */ |
| r3867 | r3868 | |
| 355 | 377 | case 17: /* scan equal */ |
| 356 | 378 | case 19: /* scan low or equal */ |
| 357 | 379 | case 29: /* scan high or equal */ |
| 358 | nec765_set_int( | |
| 380 | nec765_set_int(dev | |
| 359 | 381 | break; |
| 360 | 382 | |
| 361 | 383 | default: |
| 362 | 384 | break; |
| 363 | 385 | } |
| 364 | 386 | |
| 365 | nec765_set_data_request(); | |
| 387 | nec765_set_data_request(device); | |
| 366 | 388 | |
| 367 | timer_reset(fdc | |
| 389 | timer_reset(fdc->timer, attotime_never); | |
| 368 | 390 | } |
| 369 | else if (fdc | |
| 391 | else if (fdc->timer_type == 4) | |
| 370 | 392 | { |
| 371 | 393 | /* if in dma mode, a int is not generated per byte. If not in DMA mode |
| 372 | 394 | a int is generated per byte */ |
| 373 | if (fdc | |
| 395 | if (fdc->nec765_flags & NEC765_DMA_MODE) | |
| 374 | 396 | { |
| 375 | nec765_set_dma_drq( | |
| 397 | nec765_set_dma_drq(dev | |
| 376 | 398 | } |
| 377 | 399 | else |
| 378 | 400 | { |
| 379 | if (fdc | |
| 401 | if (fdc->FDC_main & (1<<7)) | |
| 380 | 402 | { |
| 381 | 403 | /* set int to indicate data is ready */ |
| 382 | nec765_set_int( | |
| 404 | nec765_set_int(dev | |
| 383 | 405 | } |
| 384 | 406 | } |
| 385 | 407 | |
| 386 | timer_reset(fdc | |
| 408 | timer_reset(fdc->timer, attotime_never); | |
| 387 | 409 | } |
| 388 | 410 | } |
| 389 | 411 | |
| 390 | 412 | static TIMER_CALLBACK(nec765_timer_callback) |
| 391 | { | |
| 392 | nec765_timer_func(machine,param); | |
| 413 | { | |
| 414 | const device_config *device = ptr; | |
| 415 | nec765_timer_func(device,param); | |
| 393 | 416 | } |
| 394 | 417 | |
| 395 | 418 | /* after (32-27) the DRQ is set, then 27 us later, the int is set. |
| r3867 | r3868 | |
| 398 | 421 | effectively disabled by reading the data before the NMI int can be set. |
| 399 | 422 | */ |
| 400 | 423 | |
| 401 | static void nec765_setup_timed_generic( | |
| 424 | static void nec765_setup_timed_generic(const device_ | |
| 402 | 425 | { |
| 403 | fdc.timer_type = timer_type; | |
| 426 | nec765_t *fdc = get_safe_token(device); | |
| 427 | ||
| 428 | fdc->timer_type = timer_type; | |
| 404 | 429 | |
| 405 | if (!(fdc | |
| 430 | if (!(fdc->nec765_flags & NEC765_DMA_MODE)) | |
| 406 | 431 | { |
| 407 | timer_adjust_oneshot(fdc | |
| 432 | timer_adjust_oneshot(fdc->timer, duration, 0); | |
| 408 | 433 | } |
| 409 | 434 | else |
| 410 | 435 | { |
| 411 | nec765_timer_func(machine,fdc.timer_type); | |
| 412 | timer_reset(fdc.timer, attotime_never); | |
| 436 | nec765_timer_func(device,fdc->timer_type); | |
| 437 | timer_reset(fdc->timer, attotime_never); | |
| 413 | 438 | } |
| 414 | 439 | } |
| 415 | 440 | |
| 416 | 441 | /* setup data request */ |
| 417 | static void nec765_setup_timed_data_request( | |
| 442 | static void nec765_setup_timed_data_request(const device_ | |
| 418 | 443 | { |
| 419 | 444 | /* setup timer to trigger in NEC765_DATA_RATE us */ |
| 420 | nec765_setup_timed_generic( | |
| 445 | nec765_setup_timed_generic(dev | |
| 421 | 446 | } |
| 422 | 447 | |
| 423 | 448 | /* setup result data request */ |
| 424 | static void nec765_setup_timed_result_data_request( | |
| 449 | static void nec765_setup_timed_result_data_request(const device_ | |
| 425 | 450 | { |
| 426 | nec765_setup_timed_generic( | |
| 451 | nec765_setup_timed_generic(dev | |
| 427 | 452 | } |
| 428 | 453 | |
| 429 | 454 | |
| 430 | 455 | /* sets up a timer to issue a seek complete in signed_tracks time */ |
| 431 | static void nec765_setup_timed_int(int signed_tracks) | |
| 456 | static void nec765_setup_timed_int(const device_config *device,int signed_tracks) | |
| 432 | 457 | { |
| 458 | nec765_t *fdc = get_safe_token(device); | |
| 433 | 459 | /* setup timer to signal after seek time is complete */ |
| 434 | timer_adjust_periodic(fdc | |
| 460 | timer_adjust_periodic(fdc->seek_timer, attotime_zero, 0, double_to_attotime(fdc->srt_in_ms*abs(signed_tracks)*0.001)); | |
| 435 | 461 | } |
| 436 | 462 | |
| 437 | static void nec765_seek_setup( | |
| 463 | static void nec765_seek_setup(const device_ | |
| 438 | 464 | { |
| 439 | 465 | const device_config *img; |
| 440 | 466 | int signed_tracks; |
| 467 | nec765_t *fdc = get_safe_token(device); | |
| 441 | 468 | |
| 442 | fdc | |
| 469 | fdc->nec765_flags |= NEC765_SEEK_ACTIVE; | |
| 443 | 470 | |
| 444 | 471 | if (is_recalibrate) |
| 445 | 472 | { |
| 446 | 473 | /* head cannot be specified with recalibrate */ |
| 447 | fdc | |
| 474 | fdc->nec765_command_bytes[1] &=~0x04; | |
| 448 | 475 | } |
| 449 | 476 | |
| 450 | nec765_setup_drive_and_side(); | |
| 477 | nec765_setup_drive_and_side(device); | |
| 451 | 478 | |
| 452 | img = current_image( | |
| 479 | img = current_image(dev | |
| 453 | 480 | |
| 454 | fdc | |
| 481 | fdc->FDC_main |= (1<<fdc->drive); | |
| 455 | 482 | |
| 456 | 483 | /* recalibrate command? */ |
| 457 | 484 | if (is_recalibrate) |
| 458 | 485 | { |
| 459 | fdc | |
| 486 | fdc->nec765_flags |= NEC765_SEEK_OPERATION_IS_RECALIBRATE; | |
| 460 | 487 | |
| 461 | fdc | |
| 488 | fdc->ncn = 0; | |
| 462 | 489 | |
| 463 | 490 | /* if drive is already at track 0, or drive is not ready */ |
| 464 | 491 | if ( |
| r3867 | r3868 | |
| 467 | 494 | ) |
| 468 | 495 | { |
| 469 | 496 | /* seek completed */ |
| 470 | nec765_seek_complete( | |
| 497 | nec765_seek_complete(dev | |
| 471 | 498 | } |
| 472 | 499 | else |
| 473 | 500 | { |
| r3867 | r3868 | |
| 496 | 523 | /* perform seek - if drive isn't present it will not do anything */ |
| 497 | 524 | floppy_drive_seek(img, signed_tracks); |
| 498 | 525 | |
| 499 | nec765_setup_timed_int(signed_tracks); | |
| 526 | nec765_setup_timed_int(device,signed_tracks); | |
| 500 | 527 | } |
| 501 | 528 | else |
| 502 | 529 | { |
| 503 | nec765_seek_complete( | |
| 530 | nec765_seek_complete(dev | |
| 504 | 531 | } |
| 505 | 532 | } |
| 506 | 533 | } |
| 507 | 534 | else |
| 508 | 535 | { |
| 509 | 536 | |
| 510 | fdc | |
| 537 | fdc->nec765_flags &= ~NEC765_SEEK_OPERATION_IS_RECALIBRATE; | |
| 511 | 538 | |
| 512 | fdc | |
| 539 | fdc->ncn = fdc->nec765_command_bytes[2]; | |
| 513 | 540 | |
| 514 | 541 | /* get signed tracks */ |
| 515 | signed_tracks = fdc | |
| 542 | signed_tracks = fdc->ncn - fdc->pcn[fdc->drive]; | |
| 516 | 543 | |
| 517 | 544 | /* if no tracks to seek, or drive is not ready, seek is complete */ |
| 518 | 545 | if ((signed_tracks==0) || (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))) |
| 519 | 546 | { |
| 520 | nec765_seek_complete( | |
| 547 | nec765_seek_complete(dev | |
| 521 | 548 | } |
| 522 | 549 | else |
| 523 | 550 | { |
| r3867 | r3868 | |
| 525 | 552 | floppy_drive_seek(img, signed_tracks); |
| 526 | 553 | |
| 527 | 554 | /* seek complete - issue an interrupt */ |
| 528 | nec765_setup_timed_int(signed_tracks); | |
| 555 | nec765_setup_timed_int(device,signed_tracks); | |
| 529 | 556 | } |
| 530 | 557 | } |
| 531 | 558 | |
| 532 | nec765_idle(); | |
| 559 | nec765_idle(device); | |
| 533 | 560 | |
| 534 | 561 | } |
| 535 | 562 | |
| 536 | 563 | |
| 537 | 564 | |
| 538 | static void nec765_setup_execution_phase_read( | |
| 565 | static void nec765_setup_execution_phase_read(const device_ | |
| 539 | 566 | { |
| 540 | fdc.FDC_main |= 0x040; /* FDC->CPU */ | |
| 567 | nec765_t *fdc = get_safe_token(device); | |
| 568 | fdc->FDC_main |= 0x040; /* FDC->CPU */ | |
| 541 | 569 | |
| 542 | fdc.nec765_transfer_bytes_count = 0; | |
| 543 | fdc.nec765_transfer_bytes_remaining = size; | |
| 544 | fdc.execution_phase_data = ptr; | |
| 545 | fdc.nec765_phase = NEC765_EXECUTION_PHASE_READ; | |
| 570 | fdc->nec765_transfer_bytes_count = 0; | |
| 571 | fdc->nec765_transfer_bytes_remaining = size; | |
| 572 | fdc->execution_phase_data = ptr; | |
| 573 | fdc->nec765_phase = NEC765_EXECUTION_PHASE_READ; | |
| 546 | 574 | |
| 547 | nec765_setup_timed_data_request( | |
| 575 | nec765_setup_timed_data_request(dev | |
| 548 | 576 | } |
| 549 | 577 | |
| 550 | static void nec765_setup_execution_phase_write( | |
| 578 | static void nec765_setup_execution_phase_write(const device_ | |
| 551 | 579 | { |
| 552 | fdc.FDC_main &= ~0x040; /* FDC->CPU */ | |
| 580 | nec765_t *fdc = get_safe_token(device); | |
| 581 | ||
| 582 | fdc->FDC_main &= ~0x040; /* FDC->CPU */ | |
| 553 | 583 | |
| 554 | fdc.nec765_transfer_bytes_count = 0; | |
| 555 | fdc.nec765_transfer_bytes_remaining = size; | |
| 556 | fdc.execution_phase_data = ptr; | |
| 557 | fdc.nec765_phase = NEC765_EXECUTION_PHASE_WRITE; | |
| 584 | fdc->nec765_transfer_bytes_count = 0; | |
| 585 | fdc->nec765_transfer_bytes_remaining = size; | |
| 586 | fdc->execution_phase_data = ptr; | |
| 587 | fdc->nec765_phase = NEC765_EXECUTION_PHASE_WRITE; | |
| 558 | 588 | |
| 559 | 589 | /* setup a data request with first byte */ |
| 560 | nec765_setup_timed_data_request( | |
| 590 | nec765_setup_timed_data_request(dev | |
| 561 | 591 | } |
| 562 | 592 | |
| 563 | 593 | |
| 564 | static void nec765_setup_result_phase( | |
| 594 | static void nec765_setup_result_phase(const device_ | |
| 565 | 595 | { |
| 566 | fdc.FDC_main |= 0x040; /* FDC->CPU */ | |
| 567 | fdc.FDC_main &= ~0x020; /* not execution phase */ | |
| 596 | nec765_t *fdc = get_safe_token(device); | |
| 597 | ||
| 598 | fdc->FDC_main |= 0x040; /* FDC->CPU */ | |
| 599 | fdc->FDC_main &= ~0x020; /* not execution phase */ | |
| 568 | 600 | |
| 569 | fdc.nec765_transfer_bytes_count = 0; | |
| 570 | fdc.nec765_transfer_bytes_remaining = byte_count; | |
| 571 | fdc.nec765_phase = NEC765_RESULT_PHASE; | |
| 601 | fdc->nec765_transfer_bytes_count = 0; | |
| 602 | fdc->nec765_transfer_bytes_remaining = byte_count; | |
| 603 | fdc->nec765_phase = NEC765_RESULT_PHASE; | |
| 572 | 604 | |
| 573 | nec765_setup_timed_result_data_request( | |
| 605 | nec765_setup_timed_result_data_request(dev | |
| 574 | 606 | } |
| 575 | 607 | |
| 576 | void nec765_idle(void) | |
| 608 | void nec765_idle(const device_config *device) | |
| 577 | 609 | { |
| 578 | fdc.FDC_main &= ~0x040; /* CPU->FDC */ | |
| 579 | fdc.FDC_main &= ~0x020; /* not execution phase */ | |
| 580 | fdc.FDC_main &= ~0x010; /* not busy */ | |
| 581 | fdc.nec765_phase = NEC765_COMMAND_PHASE_FIRST_BYTE; | |
| 610 | nec765_t *fdc = get_safe_token(device); | |
| 611 | ||
| 612 | fdc->FDC_main &= ~0x040; /* CPU->FDC */ | |
| 613 | fdc->FDC_main &= ~0x020; /* not execution phase */ | |
| 614 | fdc->FDC_main &= ~0x010; /* not busy */ | |
| 615 | fdc->nec765_phase = NEC765_COMMAND_PHASE_FIRST_BYTE; | |
| 582 | 616 | |
| 583 | nec765_set_data_request(); | |
| 617 | nec765_set_data_request(device); | |
| 584 | 618 | } |
| 585 | 619 | |
| 586 | 620 | |
| 587 | 621 | |
| 588 | 622 | /* change flags */ |
| 589 | static void nec765_change_flags( | |
| 623 | static void nec765_change_flags(const device_ | |
| 590 | 624 | { |
| 591 | 625 | unsigned int new_flags; |
| 592 | 626 | unsigned int changed_flags; |
| 593 | ||
| 627 | nec765_t *fdc = get_safe_token(device); | |
| 628 | ||
| 594 | 629 | assert((flags & ~mask) == 0); |
| 595 | 630 | |
| 596 | 631 | /* compute the new flags and which ones have changed */ |
| 597 | new_flags = fdc | |
| 632 | new_flags = fdc->nec765_flags & ~mask; | |
| 598 | 633 | new_flags |= flags; |
| 599 | changed_flags = fdc.nec765_flags ^ new_flags; | |
| 600 | fdc.nec765_flags = new_flags; | |
| 634 | changed_flags = fdc->nec765_flags ^ new_flags; | |
| 635 | fdc->nec765_flags = new_flags; | |
| 601 | 636 | |
| 602 | 637 | /* if interrupt changed, call the handler */ |
| 603 | if ((changed_flags & NEC765_INT) && nec765_iface.interrupt) | |
| 604 | nec765_iface.interrupt(machine,(fdc.nec765_flags & NEC765_INT) ? 1 : 0); | |
| 638 | if ((changed_flags & NEC765_INT) && fdc->intf->interrupt) | |
| 639 | fdc->intf->interrupt(device,(fdc->nec765_flags & NEC765_INT) ? 1 : 0); | |
| 605 | 640 | |
| 606 | 641 | /* if DRQ changed, call the handler */ |
| 607 | if ((changed_flags & NEC765_DMA_DRQ) && nec765_iface.dma_drq) | |
| 608 | nec765_iface.dma_drq(machine,(fdc.nec765_flags & NEC765_DMA_DRQ) ? 1 : 0, fdc.FDC_main & (1<<6)); | |
| 642 | if ((changed_flags & NEC765_DMA_DRQ) && fdc->intf->dma_drq) | |
| 643 | fdc->intf->dma_drq(device,(fdc->nec765_flags & NEC765_DMA_DRQ) ? 1 : 0, fdc->FDC_main & (1<<6)); | |
| 609 | 644 | } |
| 610 | 645 | |
| 611 | 646 | |
| 612 | 647 | |
| 613 | 648 | /* set int output */ |
| 614 | static void nec765_set_int( | |
| 649 | static void nec765_set_int(const device_ | |
| 615 | 650 | { |
| 616 | 651 | if (LOG_INTERRUPT) |
| 617 | 652 | logerror("nec765_set_int(): state=%d\n", state); |
| 618 | nec765_change_flags( | |
| 653 | nec765_change_flags(dev | |
| 619 | 654 | } |
| 620 | 655 | |
| 621 | 656 | |
| 622 | 657 | |
| 623 | 658 | /* set dma request output */ |
| 624 | static void nec765_set_dma_drq( | |
| 659 | static void nec765_set_dma_drq(const device_ | |
| 625 | 660 | { |
| 626 | nec765_change_flags( | |
| 661 | nec765_change_flags(dev | |
| 627 | 662 | } |
| 628 | 663 | |
| 629 | 664 | |
| r3867 | r3868 | |
| 656 | 691 | /* done when ready state of drive changes */ |
| 657 | 692 | /* this ignores if command is active, in which case command should terminate immediatly |
| 658 | 693 | with error */ |
| 659 | static void nec765_set_ready_change_callback(const device_config *img, int state) | |
| 694 | static void nec765_set_ready_change_callback(const device_config *controller, const device_config *img, int state) | |
| 660 | 695 | { |
| 696 | nec765_t *fdc = get_safe_token(controller); | |
| 661 | 697 | int drive = image_index_in_device(img); |
| 662 | 698 | |
| 663 | 699 | logerror("nec765: ready state change\n"); |
| 664 | 700 | |
| 665 | 701 | /* drive that changed state */ |
| 666 | fdc | |
| 702 | fdc->nec765_status[0] = 0x0c0 | drive; | |
| 667 | 703 | |
| 668 | 704 | /* not ready */ |
| 669 | if (state==0 && fdc.rdy_pin == NEC765_RDY_PIN_CONNECTED ) | |
| 670 | fdc.nec765_status[0] |= 8; | |
| 705 | if (state==0 && fdc->intf->rdy_pin == NEC765_RDY_PIN_CONNECTED ) | |
| 706 | fdc->nec765_status[0] |= 8; | |
| 671 | 707 | |
| 672 | 708 | /* trigger an int */ |
| 673 | nec765_set_int( | |
| 709 | nec765_set_int( | |
| 674 | 710 | } |
| 675 | 711 | |
| 676 | 712 | |
| 677 | ||
| 678 | ||
| 679 | void nec765_init(running_machine *machine, const nec765_interface *iface, NEC765_VERSION version, NEC765_RDY_PIN rdy_pin) | |
| 680 | { | |
| 681 | int i; | |
| 682 | ||
| 683 | fdc.version = version; | |
| 684 | fdc.rdy_pin = rdy_pin; | |
| 685 | fdc.timer = timer_alloc(machine, nec765_timer_callback, NULL); | |
| 686 | fdc.seek_timer = timer_alloc(machine, nec765_seek_timer_callback, NULL); | |
| 687 | fdc.command_timer = timer_alloc(machine, nec765_continue_command, NULL); | |
| 688 | memset(&nec765_iface, 0, sizeof(nec765_interface)); | |
| 689 | ||
| 690 | if (iface) | |
| 691 | { | |
| 692 | memcpy(&nec765_iface, iface, sizeof(nec765_interface)); | |
| 693 | } | |
| 694 | ||
| 695 | fdc.nec765_flags &= NEC765_FDD_READY; | |
| 696 | ||
| 697 | nec765_reset(machine, 0); | |
| 698 | ||
| 699 | for (i = 0; i < device_count(machine, IO_FLOPPY); i++) | |
| 700 | floppy_drive_set_ready_state_change_callback(image_from_devtype_and_index(IO_FLOPPY, i), nec765_set_ready_change_callback); | |
| 701 | } | |
| 702 | ||
| 703 | ||
| 704 | 713 | /* terminal count input */ |
| 705 | void nec765_set_tc_state( | |
| 714 | void nec765_set_tc_state(const device_ | |
| 706 | 715 | { |
| 707 | 716 | int old_state; |
| 717 | nec765_t *fdc = get_safe_token(device); | |
| 708 | 718 | |
| 709 | old_state = fdc | |
| 719 | old_state = fdc->nec765_flags; | |
| 710 | 720 | |
| 711 | 721 | /* clear drq */ |
| 712 | nec765_set_dma_drq( | |
| 722 | nec765_set_dma_drq(dev | |
| 713 | 723 | |
| 714 | fdc | |
| 724 | fdc->nec765_flags &= ~NEC765_TC; | |
| 715 | 725 | if (state) |
| 716 | 726 | { |
| 717 | fdc | |
| 727 | fdc->nec765_flags |= NEC765_TC; | |
| 718 | 728 | } |
| 719 | 729 | |
| 720 | 730 | /* changed state? */ |
| 721 | if (((fdc | |
| 731 | if (((fdc->nec765_flags^old_state) & NEC765_TC)!=0) | |
| 722 | 732 | { |
| 723 | 733 | /* now set? */ |
| 724 | if ((fdc | |
| 734 | if ((fdc->nec765_flags & NEC765_TC)!=0) | |
| 725 | 735 | { |
| 726 | 736 | /* yes */ |
| 727 | if (fdc | |
| 737 | if (fdc->timer) | |
| 728 | 738 | { |
| 729 | if (fdc | |
| 739 | if (fdc->timer_type==0) | |
| 730 | 740 | { |
| 731 | timer_reset(fdc | |
| 741 | timer_reset(fdc->timer, attotime_never); | |
| 732 | 742 | |
| 733 | 743 | |
| 734 | 744 | } |
| 735 | 745 | } |
| 736 | 746 | |
| 737 | 747 | #ifdef NO_END_OF_CYLINDER |
| 738 | timer_adjust_oneshot(fdc | |
| 748 | timer_adjust_oneshot(fdc->command_timer, attotime_zero, 0); | |
| 739 | 749 | #else |
| 740 | nec765_update_state( | |
| 750 | nec765_update_state(dev | |
| 741 | 751 | #endif |
| 742 | 752 | } |
| 743 | 753 | } |
| 744 | 754 | } |
| 745 | 755 | |
| 746 | READ8_HANDLER(nec765_status_r) | |
| 756 | READ8_DEVICE_HANDLER(nec765_status_r) | |
| 747 | 757 | { |
| 758 | nec765_t *fdc = get_safe_token(device); | |
| 748 | 759 | if (LOG_EXTRA) |
| 749 | logerror("nec765 status r: %02x\n",fdc.FDC_main); | |
| 750 | return fdc.FDC_main; | |
| 760 | logerror("nec765 status r: %02x\n",fdc->FDC_main); | |
| 761 | return fdc->FDC_main; | |
| 751 | 762 | } |
| 752 | 763 | |
| 753 | 764 | |
| r3867 | r3868 | |
| 758 | 769 | if SK==1, and we are executing a read deleted data command, and a data mark is found, |
| 759 | 770 | skip it. */ |
| 760 | 771 | |
| 761 | static int nec765_read_skip_sector(void) | |
| 772 | static int nec765_read_skip_sector(const device_config *device) | |
| 762 | 773 | { |
| 774 | nec765_t *fdc = get_safe_token(device); | |
| 763 | 775 | /* skip set? */ |
| 764 | if ((fdc | |
| 776 | if ((fdc->nec765_command_bytes[0] & (1<<5))!=0) | |
| 765 | 777 | { |
| 766 | 778 | /* read data? */ |
| 767 | if (fdc | |
| 779 | if (fdc->command == 0x06) | |
| 768 | 780 | { |
| 769 | 781 | /* did we just find a sector with deleted data mark? */ |
| 770 | if (fdc | |
| 782 | if (fdc->data_type == NEC765_DAM_DELETED_DATA) | |
| 771 | 783 | { |
| 772 | 784 | /* skip it */ |
| 773 | 785 | return TRUE; |
| r3867 | r3868 | |
| 775 | 787 | } |
| 776 | 788 | /* deleted data? */ |
| 777 | 789 | else |
| 778 | if (fdc | |
| 790 | if (fdc->command == 0x0c) | |
| 779 | 791 | { |
| 780 | 792 | /* did we just find a sector with data mark ? */ |
| 781 | if (fdc | |
| 793 | if (fdc->data_type == NEC765_DAM_DATA) | |
| 782 | 794 | { |
| 783 | 795 | /* skip it */ |
| 784 | 796 | return TRUE; |
| r3867 | r3868 | |
| 801 | 813 | - if the index is seen twice while it is searching for a sector, then the sector cannot be found |
| 802 | 814 | */ |
| 803 | 815 | |
| 804 | static void nec765_get_next_id( | |
| 816 | static void nec765_get_next_id(const device_ | |
| 805 | 817 | { |
| 806 | const device_config *img = current_image(machine); | |
| 818 | nec765_t *fdc = get_safe_token(device); | |
| 819 | const device_config *img = current_image(device); | |
| 807 | 820 | |
| 808 | 821 | /* get next id from disc */ |
| 809 | floppy_drive_get_next_id(img, fdc | |
| 822 | floppy_drive_get_next_id(img, fdc->side,id); | |
| 810 | 823 | |
| 811 | fdc | |
| 824 | fdc->sector_id = id->data_id; | |
| 812 | 825 | |
| 813 | 826 | /* set correct data type */ |
| 814 | fdc | |
| 827 | fdc->data_type = NEC765_DAM_DATA; | |
| 815 | 828 | if (id->flags & ID_FLAG_DELETED_DATA) |
| 816 | 829 | { |
| 817 | fdc | |
| 830 | fdc->data_type = NEC765_DAM_DELETED_DATA; | |
| 818 | 831 | } |
| 819 | 832 | } |
| 820 | 833 | |
| 821 | static int nec765_get_matching_sector( | |
| 834 | static int nec765_get_matching_sector(const device_ | |
| 822 | 835 | { |
| 823 | const device_config *img = current_image(machine); | |
| 836 | nec765_t *fdc = get_safe_token(device); | |
| 837 | const device_config *img = current_image(device); | |
| 824 | 838 | chrn_id id; |
| 825 | 839 | |
| 826 | 840 | /* number of times we have seen index hole */ |
| r3867 | r3868 | |
| 829 | 843 | /* get sector id's */ |
| 830 | 844 | do |
| 831 | 845 | { |
| 832 | nec765_get_next_id( | |
| 846 | nec765_get_next_id(dev | |
| 833 | 847 | |
| 834 | 848 | /* tested on Amstrad CPC - All bytes must match, otherwise |
| 835 | 849 | a NO DATA error is reported */ |
| 836 | if (id.R == fdc | |
| 850 | if (id.R == fdc->nec765_command_bytes[4]) | |
| 837 | 851 | { |
| 838 | if (id.C == fdc | |
| 852 | if (id.C == fdc->nec765_command_bytes[2]) | |
| 839 | 853 | { |
| 840 | if (id.H == fdc | |
| 854 | if (id.H == fdc->nec765_command_bytes[3]) | |
| 841 | 855 | { |
| 842 | if (id.N == fdc | |
| 856 | if (id.N == fdc->nec765_command_bytes[5]) | |
| 843 | 857 | { |
| 844 | 858 | /* end of cylinder is set if: |
| 845 | 859 | 1. sector data is read completely (i.e. no other errors occur like |
| 846 | 860 | no data. |
| 847 | 861 | 2. sector being read is same specified by EOT |
| 848 | 862 | 3. terminal count is not received */ |
| 849 | if (fdc | |
| 863 | if (fdc->nec765_command_bytes[4]==fdc->nec765_command_bytes[6]) | |
| 850 | 864 | { |
| 851 | 865 | /* set end of cylinder */ |
| 852 | fdc | |
| 866 | fdc->nec765_status[1] |= NEC765_ST1_END_OF_CYLINDER; | |
| 853 | 867 | } |
| 854 | 868 | |
| 855 | 869 | return TRUE; |
| r3867 | r3868 | |
| 862 | 876 | in the read/write command did not match the C value read from the disc */ |
| 863 | 877 | |
| 864 | 878 | /* no data - checked on Amstrad CPC */ |
| 865 | fdc | |
| 879 | fdc->nec765_status[1] |= NEC765_ST1_NO_DATA; | |
| 866 | 880 | /* bad C value */ |
| 867 | fdc | |
| 881 | fdc->nec765_status[2] |= NEC765_ST2_WRONG_CYLINDER; | |
| 868 | 882 | |
| 869 | 883 | if (id.C == 0x0ff) |
| 870 | 884 | { |
| 871 | 885 | /* the C value is 0x0ff which indicates a bad track in the IBM soft-sectored |
| 872 | 886 | format */ |
| 873 | fdc | |
| 887 | fdc->nec765_status[2] |= NEC765_ST2_BAD_CYLINDER; | |
| 874 | 888 | } |
| 875 | 889 | |
| 876 | 890 | return FALSE; |
| r3867 | r3868 | |
| 887 | 901 | while (index_count!=2); |
| 888 | 902 | |
| 889 | 903 | /* no data - specified sector ID was not found */ |
| 890 | fdc | |
| 904 | fdc->nec765_status[1] |= NEC765_ST1_NO_DATA; | |
| 891 | 905 | |
| 892 | 906 | return 0; |
| 893 | 907 | } |
| 894 | 908 | |
| 895 | static void nec765_read_complete( | |
| 909 | static void nec765_read_complete(const device_ | |
| 896 | 910 | { |
| 897 | ||
| 911 | nec765_t *fdc = get_safe_token(device); | |
| 898 | 912 | /* causes problems!!! - need to fix */ |
| 899 | 913 | #ifdef NO_END_OF_CYLINDER |
| 900 | 914 | /* set end of cylinder */ |
| 901 | fdc | |
| 915 | fdc->nec765_status[1] &= ~NEC765_ST1_END_OF_CYLINDER; | |
| 902 | 916 | #else |
| 903 | 917 | /* completed read command */ |
| 904 | 918 | |
| r3867 | r3868 | |
| 909 | 923 | */ |
| 910 | 924 | |
| 911 | 925 | /* if end of cylinder is set, and we did receive a terminal count, then clear it */ |
| 912 | if ((fdc | |
| 926 | if ((fdc->nec765_flags & NEC765_TC)!=0) | |
| 913 | 927 | { |
| 914 | 928 | /* set end of cylinder */ |
| 915 | fdc | |
| 929 | fdc->nec765_status[1] &= ~NEC765_ST1_END_OF_CYLINDER; | |
| 916 | 930 | } |
| 917 | 931 | #endif |
| 918 | 932 | |
| 919 | nec765_setup_st0(); | |
| 933 | nec765_setup_st0(device); | |
| 920 | 934 | |
| 921 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 922 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 923 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 924 | fdc.nec765_result_bytes[3] = fdc.nec765_command_bytes[2]; /* C */ | |
| 925 | fdc.nec765_result_bytes[4] = fdc.nec765_command_bytes[3]; /* H */ | |
| 926 | fdc.nec765_result_bytes[5] = fdc.nec765_command_bytes[4]; /* R */ | |
| 927 | fdc.nec765_result_bytes[6] = fdc.nec765_command_bytes[5]; /* N */ | |
| 935 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 936 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 937 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 938 | fdc->nec765_result_bytes[3] = fdc->nec765_command_bytes[2]; /* C */ | |
| 939 | fdc->nec765_result_bytes[4] = fdc->nec765_command_bytes[3]; /* H */ | |
| 940 | fdc->nec765_result_bytes[5] = fdc->nec765_command_bytes[4]; /* R */ | |
| 941 | fdc->nec765_result_bytes[6] = fdc->nec765_command_bytes[5]; /* N */ | |
| 928 | 942 | |
| 929 | nec765_setup_result_phase( | |
| 943 | nec765_setup_result_phase(dev | |
| 930 | 944 | } |
| 931 | 945 | |
| 932 | static void nec765_read_data( | |
| 946 | static void nec765_read_data(const device_ | |
| 933 | 947 | { |
| 934 | const device_config *img = current_image(machine); | |
| 948 | nec765_t *fdc = get_safe_token(device); | |
| 949 | const device_config *img = current_image(device); | |
| 935 | 950 | |
| 936 | 951 | if (!(floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))) |
| 937 | 952 | { |
| 938 | fdc.nec765_status[0] = 0x0c0 | (1<<4) | fdc.drive | (fdc.side<<2); | |
| 939 | fdc.nec765_status[1] = 0x00; | |
| 940 | fdc.nec765_status[2] = 0x00; | |
| 953 | fdc->nec765_status[0] = 0x0c0 | (1<<4) | fdc->drive | (fdc->side<<2); | |
| 954 | fdc->nec765_status[1] = 0x00; | |
| 955 | fdc->nec765_status[2] = 0x00; | |
| 941 | 956 | |
| 942 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 943 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 944 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 945 | fdc.nec765_result_bytes[3] = fdc.nec765_command_bytes[2]; /* C */ | |
| 946 | fdc.nec765_result_bytes[4] = fdc.nec765_command_bytes[3]; /* H */ | |
| 947 | fdc.nec765_result_bytes[5] = fdc.nec765_command_bytes[4]; /* R */ | |
| 948 | fdc.nec765_result_bytes[6] = fdc.nec765_command_bytes[5]; /* N */ | |
| 949 | nec765_setup_result_phase(machine,7); | |
| 957 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 958 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 959 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 960 | fdc->nec765_result_bytes[3] = fdc->nec765_command_bytes[2]; /* C */ | |
| 961 | fdc->nec765_result_bytes[4] = fdc->nec765_command_bytes[3]; /* H */ | |
| 962 | fdc->nec765_result_bytes[5] = fdc->nec765_command_bytes[4]; /* R */ | |
| 963 | fdc->nec765_result_bytes[6] = fdc->nec765_command_bytes[5]; /* N */ | |
| 964 | nec765_setup_result_phase(device,7); | |
| 950 | 965 | return; |
| 951 | 966 | } |
| 952 | 967 | |
| 953 | 968 | if (LOG_VERBOSE) |
| 954 | logerror("sector c: %02x h: %02x r: %02x n: %02x\n",fdc | |
| 969 | logerror("sector c: %02x h: %02x r: %02x n: %02x\n",fdc->nec765_command_bytes[2], fdc->nec765_command_bytes[3],fdc->nec765_command_bytes[4], fdc->nec765_command_bytes[5]); | |
| 955 | 970 | |
| 956 | 971 | /* find a sector to read data from */ |
| 957 | 972 | { |
| r3867 | r3868 | |
| 962 | 977 | do |
| 963 | 978 | { |
| 964 | 979 | /* get matching sector */ |
| 965 | if (nec765_get_matching_sector( | |
| 980 | if (nec765_get_matching_sector(dev | |
| 966 | 981 | { |
| 967 | 982 | |
| 968 | 983 | /* skip it? */ |
| 969 | if (nec765_read_skip_sector()) | |
| 984 | if (nec765_read_skip_sector(device)) | |
| 970 | 985 | { |
| 971 | 986 | /* yes */ |
| 972 | 987 | |
| 973 | 988 | /* check that we haven't finished reading all sectors */ |
| 974 | if (nec765_sector_count_complete( | |
| 989 | if (nec765_sector_count_complete(dev | |
| 975 | 990 | { |
| 976 | 991 | /* read complete */ |
| 977 | nec765_read_complete( | |
| 992 | nec765_read_complete(dev | |
| 978 | 993 | return; |
| 979 | 994 | } |
| 980 | 995 | |
| 981 | 996 | /* read not finished */ |
| 982 | 997 | |
| 983 | 998 | /* increment sector count */ |
| 984 | nec765_increment_sector( | |
| 999 | nec765_increment_sector(dev | |
| 985 | 1000 | } |
| 986 | 1001 | else |
| 987 | 1002 | { |
| r3867 | r3868 | |
| 992 | 1007 | else |
| 993 | 1008 | { |
| 994 | 1009 | /* error in finding sector */ |
| 995 | nec765_read_complete( | |
| 1010 | nec765_read_complete(dev | |
| 996 | 1011 | return; |
| 997 | 1012 | } |
| 998 | 1013 | } |
| r3867 | r3868 | |
| 1002 | 1017 | { |
| 1003 | 1018 | int data_size; |
| 1004 | 1019 | |
| 1005 | data_size = nec765_n_to_bytes(fdc | |
| 1020 | data_size = nec765_n_to_bytes(fdc->nec765_command_bytes[5]); | |
| 1006 | 1021 | |
| 1007 | floppy_drive_read_sector_data(img, fdc | |
| 1022 | floppy_drive_read_sector_data(img, fdc->side, fdc->sector_id,fdc-> | |
| 1008 | 1023 | |
| 1009 | nec765_setup_execution_phase_read( | |
| 1024 | nec765_setup_execution_phase_read(dev | |
| 1010 | 1025 | } |
| 1011 | 1026 | } |
| 1012 | 1027 | |
| 1013 | 1028 | |
| 1014 | static void nec765_format_track( | |
| 1029 | static void nec765_format_track(const device_ | |
| 1015 | 1030 | { |
| 1016 | const device_config *img = current_image(machine); | |
| 1031 | nec765_t *fdc = get_safe_token(device); | |
| 1032 | const device_config *img = current_image(device); | |
| 1017 | 1033 | |
| 1018 | 1034 | /* write protected? */ |
| 1019 | 1035 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_DISK_WRITE_PROTECTED)) |
| 1020 | 1036 | { |
| 1021 | fdc | |
| 1037 | fdc->nec765_status[1] |= NEC765_ST1_NOT_WRITEABLE; | |
| 1022 | 1038 | |
| 1023 | nec765_setup_st0(); | |
| 1039 | nec765_setup_st0(device); | |
| 1024 | 1040 | /* TODO: Check result is correct */ |
| 1025 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1026 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1027 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1028 | fdc.nec765_result_bytes[3] = fdc.format_data[0]; | |
| 1029 | fdc.nec765_result_bytes[4] = fdc.format_data[1]; | |
| 1030 | fdc.nec765_result_bytes[5] = fdc.format_data[2]; | |
| 1031 | fdc.nec765_result_bytes[6] = fdc.format_data[3]; | |
| 1032 | nec765_setup_result_phase(machine,7); | |
| 1041 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1042 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1043 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1044 | fdc->nec765_result_bytes[3] = fdc->format_data[0]; | |
| 1045 | fdc->nec765_result_bytes[4] = fdc->format_data[1]; | |
| 1046 | fdc->nec765_result_bytes[5] = fdc->format_data[2]; | |
| 1047 | fdc->nec765_result_bytes[6] = fdc->format_data[3]; | |
| 1048 | nec765_setup_result_phase(device,7); | |
| 1033 | 1049 | |
| 1034 | 1050 | return; |
| 1035 | 1051 | } |
| 1036 | 1052 | |
| 1037 | nec765_setup_execution_phase_write( | |
| 1053 | nec765_setup_execution_phase_write(dev | |
| 1038 | 1054 | } |
| 1039 | 1055 | |
| 1040 | static void nec765_read_a_track( | |
| 1056 | static void nec765_read_a_track(const device_ | |
| 1041 | 1057 | { |
| 1058 | nec765_t *fdc = get_safe_token(device); | |
| 1042 | 1059 | int data_size; |
| 1043 | 1060 | |
| 1044 | 1061 | /* SKIP not allowed with this command! */ |
| r3867 | r3868 | |
| 1046 | 1063 | /* get next id */ |
| 1047 | 1064 | chrn_id id; |
| 1048 | 1065 | |
| 1049 | nec765_get_next_id( | |
| 1066 | nec765_get_next_id(dev | |
| 1050 | 1067 | |
| 1051 | 1068 | /* TO BE CONFIRMED! */ |
| 1052 | 1069 | /* check id from disc */ |
| 1053 | if (id.C==fdc | |
| 1070 | if (id.C==fdc->nec765_command_bytes[2]) | |
| 1054 | 1071 | { |
| 1055 | if (id.H==fdc | |
| 1072 | if (id.H==fdc->nec765_command_bytes[3]) | |
| 1056 | 1073 | { |
| 1057 | if (id.R==fdc | |
| 1074 | if (id.R==fdc->nec765_command_bytes[4]) | |
| 1058 | 1075 | { |
| 1059 | if (id.N==fdc | |
| 1076 | if (id.N==fdc->nec765_command_bytes[5]) | |
| 1060 | 1077 | { |
| 1061 | 1078 | /* if ID found, then no data is not set */ |
| 1062 | 1079 | /* otherwise no data will remain set */ |
| 1063 | fdc | |
| 1080 | fdc->nec765_status[1] &=~NEC765_ST1_NO_DATA; | |
| 1064 | 1081 | } |
| 1065 | 1082 | } |
| 1066 | 1083 | } |
| r3867 | r3868 | |
| 1069 | 1086 | |
| 1070 | 1087 | data_size = nec765_n_to_bytes(id.N); |
| 1071 | 1088 | |
| 1072 | floppy_drive_read_sector_data(current_image( | |
| 1089 | floppy_drive_read_sector_data(current_image(dev | |
| 1073 | 1090 | |
| 1074 | nec765_setup_execution_phase_read( | |
| 1091 | nec765_setup_execution_phase_read(dev | |
| 1075 | 1092 | } |
| 1076 | 1093 | |
| 1077 | static int nec765_just_read_last_sector_on_track( | |
| 1094 | static int nec765_just_read_last_sector_on_track(const device_ | |
| 1078 | 1095 | { |
| 1079 | if (floppy_drive_get_flag_state(current_image( | |
| 1096 | if (floppy_drive_get_flag_state(current_image(dev | |
| 1080 | 1097 | return 1; |
| 1081 | 1098 | return 0; |
| 1082 | 1099 | } |
| 1083 | 1100 | |
| 1084 | static void nec765_write_complete( | |
| 1101 | static void nec765_write_complete(const device_ | |
| 1085 | 1102 | { |
| 1103 | nec765_t *fdc = get_safe_token(device); | |
| 1086 | 1104 | |
| 1087 | 1105 | /* causes problems!!! - need to fix */ |
| 1088 | 1106 | #ifdef NO_END_OF_CYLINDER |
| 1089 | 1107 | /* set end of cylinder */ |
| 1090 | fdc | |
| 1108 | fdc->nec765_status[1] &= ~NEC765_ST1_END_OF_CYLINDER; | |
| 1091 | 1109 | #else |
| 1092 | 1110 | /* completed read command */ |
| 1093 | 1111 | |
| r3867 | r3868 | |
| 1098 | 1116 | */ |
| 1099 | 1117 | |
| 1100 | 1118 | /* if end of cylinder is set, and we did receive a terminal count, then clear it */ |
| 1101 | if ((fdc | |
| 1119 | if ((fdc->nec765_flags & NEC765_TC)!=0) | |
| 1102 | 1120 | { |
| 1103 | 1121 | /* set end of cylinder */ |
| 1104 | fdc | |
| 1122 | fdc->nec765_status[1] &= ~NEC765_ST1_END_OF_CYLINDER; | |
| 1105 | 1123 | } |
| 1106 | 1124 | #endif |
| 1107 | 1125 | |
| 1108 | nec765_setup_st0(); | |
| 1126 | nec765_setup_st0(device); | |
| 1109 | 1127 | |
| 1110 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1111 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1112 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1113 | fdc.nec765_result_bytes[3] = fdc.nec765_command_bytes[2]; /* C */ | |
| 1114 | fdc.nec765_result_bytes[4] = fdc.nec765_command_bytes[3]; /* H */ | |
| 1115 | fdc.nec765_result_bytes[5] = fdc.nec765_command_bytes[4]; /* R */ | |
| 1116 | fdc.nec765_result_bytes[6] = fdc.nec765_command_bytes[5]; /* N */ | |
| 1128 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1129 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1130 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1131 | fdc->nec765_result_bytes[3] = fdc->nec765_command_bytes[2]; /* C */ | |
| 1132 | fdc->nec765_result_bytes[4] = fdc->nec765_command_bytes[3]; /* H */ | |
| 1133 | fdc->nec765_result_bytes[5] = fdc->nec765_command_bytes[4]; /* R */ | |
| 1134 | fdc->nec765_result_bytes[6] = fdc->nec765_command_bytes[5]; /* N */ | |
| 1117 | 1135 | |
| 1118 | nec765_setup_result_phase( | |
| 1136 | nec765_setup_result_phase(dev | |
| 1119 | 1137 | } |
| 1120 | 1138 | |
| 1121 | 1139 | |
| 1122 | static void nec765_write_data( | |
| 1140 | static void nec765_write_data(const device_ | |
| 1123 | 1141 | { |
| 1124 | if (!(floppy_drive_get_flag_state(current_image(machine), FLOPPY_DRIVE_READY))) | |
| 1142 | nec765_t *fdc = get_safe_token(device); | |
| 1143 | if (!(floppy_drive_get_flag_state(current_image(device), FLOPPY_DRIVE_READY))) | |
| 1125 | 1144 | { |
| 1126 | fdc.nec765_status[0] = 0x0c0 | (1<<4) | fdc.drive | (fdc.side<<2); | |
| 1127 | fdc.nec765_status[1] = 0x00; | |
| 1128 | fdc.nec765_status[2] = 0x00; | |
| 1145 | fdc->nec765_status[0] = 0x0c0 | (1<<4) | fdc->drive | (fdc->side<<2); | |
| 1146 | fdc->nec765_status[1] = 0x00; | |
| 1147 | fdc->nec765_status[2] = 0x00; | |
| 1129 | 1148 | |
| 1130 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1131 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1132 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1133 | fdc.nec765_result_bytes[3] = fdc.nec765_command_bytes[2]; /* C */ | |
| 1134 | fdc.nec765_result_bytes[4] = fdc.nec765_command_bytes[3]; /* H */ | |
| 1135 | fdc.nec765_result_bytes[5] = fdc.nec765_command_bytes[4]; /* R */ | |
| 1136 | fdc.nec765_result_bytes[6] = fdc.nec765_command_bytes[5]; /* N */ | |
| 1137 | nec765_setup_result_phase(machine,7); | |
| 1149 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1150 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1151 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1152 | fdc->nec765_result_bytes[3] = fdc->nec765_command_bytes[2]; /* C */ | |
| 1153 | fdc->nec765_result_bytes[4] = fdc->nec765_command_bytes[3]; /* H */ | |
| 1154 | fdc->nec765_result_bytes[5] = fdc->nec765_command_bytes[4]; /* R */ | |
| 1155 | fdc->nec765_result_bytes[6] = fdc->nec765_command_bytes[5]; /* N */ | |
| 1156 | nec765_setup_result_phase(device,7); | |
| 1138 | 1157 | return; |
| 1139 | 1158 | } |
| 1140 | 1159 | |
| 1141 | 1160 | /* write protected? */ |
| 1142 | if (floppy_drive_get_flag_state(current_image( | |
| 1161 | if (floppy_drive_get_flag_state(current_image(dev | |
| 1143 | 1162 | { |
| 1144 | fdc | |
| 1163 | fdc->nec765_status[1] |= NEC765_ST1_NOT_WRITEABLE; | |
| 1145 | 1164 | |
| 1146 | nec765_write_complete( | |
| 1165 | nec765_write_complete(dev | |
| 1147 | 1166 | return; |
| 1148 | 1167 | } |
| 1149 | 1168 | |
| 1150 | if (nec765_get_matching_sector( | |
| 1169 | if (nec765_get_matching_sector(dev | |
| 1151 | 1170 | { |
| 1152 | 1171 | int data_size; |
| 1153 | 1172 | |
| 1154 | data_size = nec765_n_to_bytes(fdc | |
| 1173 | data_size = nec765_n_to_bytes(fdc->nec765_command_bytes[5]); | |
| 1155 | 1174 | |
| 1156 | nec765_setup_execution_phase_write( | |
| 1175 | nec765_setup_execution_phase_write(dev | |
| 1157 | 1176 | } |
| 1158 | 1177 | else |
| 1159 | 1178 | { |
| 1160 | nec765_setup_result_phase( | |
| 1179 | nec765_setup_result_phase(dev | |
| 1161 | 1180 | } |
| 1162 | 1181 | } |
| 1163 | 1182 | |
| 1164 | 1183 | |
| 1165 | 1184 | /* return true if we have read all sectors, false if not */ |
| 1166 | static int nec765_sector_count_complete( | |
| 1185 | static int nec765_sector_count_complete(const device_ | |
| 1167 | 1186 | { |
| 1187 | nec765_t *fdc = get_safe_token(device); | |
| 1168 | 1188 | /* this is not correct?? */ |
| 1169 | 1189 | #if 1 |
| 1170 | 1190 | /* if terminal count has been set - yes */ |
| 1171 | if (fdc | |
| 1191 | if (fdc->nec765_flags & NEC765_TC) | |
| 1172 | 1192 | { |
| 1173 | 1193 | /* completed */ |
| 1174 | 1194 | return 1; |
| r3867 | r3868 | |
| 1177 | 1197 | |
| 1178 | 1198 | |
| 1179 | 1199 | /* multi-track? */ |
| 1180 | if (fdc | |
| 1200 | if (fdc->nec765_command_bytes[0] & 0x080) | |
| 1181 | 1201 | { |
| 1182 | 1202 | /* it appears that in multi-track mode, |
| 1183 | 1203 | the EOT parameter of the command is ignored!? - |
| r3867 | r3868 | |
| 1192 | 1212 | */ |
| 1193 | 1213 | |
| 1194 | 1214 | /* if just read last sector and on side 1 - finish */ |
| 1195 | if ((nec765_just_read_last_sector_on_track(machine)) && | |
| 1196 | (fdc.side==1)) | |
| 1215 | if ((nec765_just_read_last_sector_on_track(device)) && | |
| 1216 | (fdc->side==1)) | |
| 1197 | 1217 | { |
| 1198 | 1218 | return 1; |
| 1199 | 1219 | } |
| 1200 | 1220 | |
| 1201 | 1221 | /* if not on second side then we haven't finished yet */ |
| 1202 | if (fdc | |
| 1222 | if (fdc->side!=1) | |
| 1203 | 1223 | { |
| 1204 | 1224 | /* haven't finished yet */ |
| 1205 | 1225 | return 0; |
| r3867 | r3868 | |
| 1208 | 1228 | else |
| 1209 | 1229 | { |
| 1210 | 1230 | /* sector id == EOT? */ |
| 1211 | if ((fdc | |
| 1231 | if ((fdc->nec765_command_bytes[4]==fdc->nec765_command_bytes[6])) | |
| 1212 | 1232 | { |
| 1213 | 1233 | |
| 1214 | 1234 | /* completed */ |
| r3867 | r3868 | |
| 1218 | 1238 | #else |
| 1219 | 1239 | |
| 1220 | 1240 | /* if terminal count has been set - yes */ |
| 1221 | if (fdc | |
| 1241 | if (fdc->nec765_flags & NEC765_TC) | |
| 1222 | 1242 | { |
| 1223 | 1243 | /* completed */ |
| 1224 | 1244 | return 1; |
| r3867 | r3868 | |
| 1277 | 1297 | */ |
| 1278 | 1298 | |
| 1279 | 1299 | /* sector id == EOT? */ |
| 1280 | if ((fdc | |
| 1300 | if ((fdc->nec765_command_bytes[4]==fdc->nec765_command_bytes[6])) | |
| 1281 | 1301 | { |
| 1282 | 1302 | /* multi-track? */ |
| 1283 | if (fdc | |
| 1303 | if (fdc->nec765_command_bytes[0] & 0x080) | |
| 1284 | 1304 | { |
| 1285 | /* if we have reached EOT (fdc | |
| 1305 | /* if we have reached EOT (fdc->nec765_command_bytes[6]) | |
| 1286 | 1306 | on side 1, then read is complete */ |
| 1287 | if (fdc | |
| 1307 | if (fdc->side==1) | |
| 1288 | 1308 | return 1; |
| 1289 | 1309 | |
| 1290 | 1310 | return 0; |
| r3867 | r3868 | |
| 1299 | 1319 | return 0; |
| 1300 | 1320 | } |
| 1301 | 1321 | |
| 1302 | static void nec765_increment_sector( | |
| 1322 | static void nec765_increment_sector(const device_ | |
| 1303 | 1323 | { |
| 1324 | nec765_t *fdc = get_safe_token(device); | |
| 1304 | 1325 | /* multi-track? */ |
| 1305 | if (fdc | |
| 1326 | if (fdc->nec765_command_bytes[0] & 0x080) | |
| 1306 | 1327 | { |
| 1307 | 1328 | /* reached EOT? */ |
| 1308 | /* if (fdc.nec765_command_bytes[4]==fdc.nec765_command_bytes[6])*/ | |
| 1309 | if (nec765_just_read_last_sector_on_track(machine)) | |
| 1329 | /* if (fdc->nec765_command_bytes[4]==fdc->nec765_command_bytes[6])*/ | |
| 1330 | if (nec765_just_read_last_sector_on_track(device)) | |
| 1310 | 1331 | { |
| 1311 | 1332 | /* yes */ |
| 1312 | 1333 | |
| 1313 | 1334 | /* reached EOT */ |
| 1314 | 1335 | /* change side to 1 */ |
| 1315 | fdc | |
| 1336 | fdc->side = 1; | |
| 1316 | 1337 | /* reset sector id to 1 */ |
| 1317 | fdc | |
| 1338 | fdc->nec765_command_bytes[4] = 1; | |
| 1318 | 1339 | /* set head to 1 for get next sector test */ |
| 1319 | fdc | |
| 1340 | fdc->nec765_command_bytes[3] = 1; | |
| 1320 | 1341 | } |
| 1321 | 1342 | else |
| 1322 | 1343 | { |
| 1323 | 1344 | /* increment */ |
| 1324 | fdc | |
| 1345 | fdc->nec765_command_bytes[4]++; | |
| 1325 | 1346 | } |
| 1326 | 1347 | |
| 1327 | 1348 | } |
| 1328 | 1349 | else |
| 1329 | 1350 | { |
| 1330 | fdc | |
| 1351 | fdc->nec765_command_bytes[4]++; | |
| 1331 | 1352 | } |
| 1332 | 1353 | } |
| 1333 | 1354 | |
| r3867 | r3868 | |
| 1337 | 1358 | the data is not skipped. The data is read, but the control mark is set and the read is stopped */ |
| 1338 | 1359 | /* if SK==0, and we are executing a read deleted data command, and a data sector is found, |
| 1339 | 1360 | the data is not skipped. The data is read, but the control mark is set and the read is stopped */ |
| 1340 | static int nec765_read_data_stop(void) | |
| 1361 | static int nec765_read_data_stop(const device_config *device) | |
| 1341 | 1362 | { |
| 1363 | nec765_t *fdc = get_safe_token(device); | |
| 1342 | 1364 | /* skip not set? */ |
| 1343 | if ((fdc | |
| 1365 | if ((fdc->nec765_command_bytes[0] & (1<<5))==0) | |
| 1344 | 1366 | { |
| 1345 | 1367 | /* read data? */ |
| 1346 | if (fdc | |
| 1368 | if (fdc->command == 0x06) | |
| 1347 | 1369 | { |
| 1348 | 1370 | /* did we just read a sector with deleted data? */ |
| 1349 | if (fdc | |
| 1371 | if (fdc->data_type == NEC765_DAM_DELETED_DATA) | |
| 1350 | 1372 | { |
| 1351 | 1373 | /* set control mark */ |
| 1352 | fdc | |
| 1374 | fdc->nec765_status[2] |= NEC765_ST2_CONTROL_MARK; | |
| 1353 | 1375 | |
| 1354 | 1376 | /* quit */ |
| 1355 | 1377 | return TRUE; |
| r3867 | r3868 | |
| 1357 | 1379 | } |
| 1358 | 1380 | /* deleted data? */ |
| 1359 | 1381 | else |
| 1360 | if (fdc | |
| 1382 | if (fdc->command == 0x0c) | |
| 1361 | 1383 | { |
| 1362 | 1384 | /* did we just read a sector with data? */ |
| 1363 | if (fdc | |
| 1385 | if (fdc->data_type == NEC765_DAM_DATA) | |
| 1364 | 1386 | { |
| 1365 | 1387 | /* set control mark */ |
| 1366 | fdc | |
| 1388 | fdc->nec765_status[2] |= NEC765_ST2_CONTROL_MARK; | |
| 1367 | 1389 | |
| 1368 | 1390 | /* quit */ |
| 1369 | 1391 | return TRUE; |
| r3867 | r3868 | |
| 1377 | 1399 | |
| 1378 | 1400 | static TIMER_CALLBACK(nec765_continue_command) |
| 1379 | 1401 | { |
| 1380 | if ((fdc.nec765_phase == NEC765_EXECUTION_PHASE_READ) || | |
| 1381 | (fdc.nec765_phase == NEC765_EXECUTION_PHASE_WRITE)) | |
| 1402 | const device_config *device = ptr; | |
| 1403 | nec765_t *fdc = get_safe_token(device); | |
| 1404 | if ((fdc->nec765_phase == NEC765_EXECUTION_PHASE_READ) || | |
| 1405 | (fdc->nec765_phase == NEC765_EXECUTION_PHASE_WRITE)) | |
| 1382 | 1406 | { |
| 1383 | switch (fdc | |
| 1407 | switch (fdc->command) | |
| 1384 | 1408 | { |
| 1385 | 1409 | /* read a track */ |
| 1386 | 1410 | case 0x02: |
| 1387 | 1411 | { |
| 1388 | fdc | |
| 1412 | fdc->sector_counter++; | |
| 1389 | 1413 | |
| 1390 | 1414 | /* sector counter == EOT */ |
| 1391 | if (fdc | |
| 1415 | if (fdc->sector_counter==fdc->nec765_command_bytes[6]) | |
| 1392 | 1416 | { |
| 1393 | 1417 | /* TODO: Add correct info here */ |
| 1394 | 1418 | |
| 1395 | fdc | |
| 1419 | fdc->nec765_status[1] |= NEC765_ST1_END_OF_CYLINDER; | |
| 1396 | 1420 | |
| 1397 | nec765_setup_st0(); | |
| 1421 | nec765_setup_st0(device); | |
| 1398 | 1422 | |
| 1399 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1400 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1401 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1402 | fdc.nec765_result_bytes[3] = fdc.nec765_command_bytes[2]; /* C */ | |
| 1403 | fdc.nec765_result_bytes[4] = fdc.nec765_command_bytes[3]; /* H */ | |
| 1404 | fdc.nec765_result_bytes[5] = fdc.nec765_command_bytes[4]; /* R */ | |
| 1405 | fdc.nec765_result_bytes[6] = fdc.nec765_command_bytes[5]; /* N */ | |
| 1423 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1424 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1425 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1426 | fdc->nec765_result_bytes[3] = fdc->nec765_command_bytes[2]; /* C */ | |
| 1427 | fdc->nec765_result_bytes[4] = fdc->nec765_command_bytes[3]; /* H */ | |
| 1428 | fdc->nec765_result_bytes[5] = fdc->nec765_command_bytes[4]; /* R */ | |
| 1429 | fdc->nec765_result_bytes[6] = fdc->nec765_command_bytes[5]; /* N */ | |
| 1406 | 1430 | |
| 1407 | nec765_setup_result_phase( | |
| 1431 | nec765_setup_result_phase(dev | |
| 1408 | 1432 | } |
| 1409 | 1433 | else |
| 1410 | 1434 | { |
| 1411 | nec765_read_a_track( | |
| 1435 | nec765_read_a_track(dev | |
| 1412 | 1436 | } |
| 1413 | 1437 | } |
| 1414 | 1438 | break; |
| r3867 | r3868 | |
| 1416 | 1440 | /* format track */ |
| 1417 | 1441 | case 0x0d: |
| 1418 | 1442 | { |
| 1419 | floppy_drive_format_sector(current_image(machine), fdc.side, fdc.sector_counter, | |
| 1420 | fdc.format_data[0], fdc.format_data[1], | |
| 1421 | fdc.format_data[2], fdc.format_data[3], | |
| 1422 | fdc.nec765_command_bytes[5]); | |
| 1443 | floppy_drive_format_sector(current_image(device), fdc->side, fdc->sector_counter, | |
| 1444 | fdc->format_data[0], fdc->format_data[1], | |
| 1445 | fdc->format_data[2], fdc->format_data[3], | |
| 1446 | fdc->nec765_command_bytes[5]); | |
| 1423 | 1447 | |
| 1424 | fdc | |
| 1448 | fdc->sector_counter++; | |
| 1425 | 1449 | |
| 1426 | 1450 | /* sector_counter = SC */ |
| 1427 | if (fdc | |
| 1451 | if (fdc->sector_counter == fdc->nec765_command_bytes[3]) | |
| 1428 | 1452 | { |
| 1429 | 1453 | /* TODO: Check result is correct */ |
| 1430 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1431 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1432 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1433 | fdc.nec765_result_bytes[3] = fdc.format_data[0]; | |
| 1434 | fdc.nec765_result_bytes[4] = fdc.format_data[1]; | |
| 1435 | fdc.nec765_result_bytes[5] = fdc.format_data[2]; | |
| 1436 | fdc.nec765_result_bytes[6] = fdc.format_data[3]; | |
| 1437 | nec765_setup_result_phase(machine,7); | |
| 1454 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1455 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1456 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1457 | fdc->nec765_result_bytes[3] = fdc->format_data[0]; | |
| 1458 | fdc->nec765_result_bytes[4] = fdc->format_data[1]; | |
| 1459 | fdc->nec765_result_bytes[5] = fdc->format_data[2]; | |
| 1460 | fdc->nec765_result_bytes[6] = fdc->format_data[3]; | |
| 1461 | nec765_setup_result_phase(device,7); | |
| 1438 | 1462 | } |
| 1439 | 1463 | else |
| 1440 | 1464 | { |
| 1441 | nec765_format_track( | |
| 1465 | nec765_format_track(dev | |
| 1442 | 1466 | } |
| 1443 | 1467 | } |
| 1444 | 1468 | break; |
| r3867 | r3868 | |
| 1451 | 1475 | UINT8 ddam; |
| 1452 | 1476 | |
| 1453 | 1477 | ddam = 0; |
| 1454 | if (fdc | |
| 1478 | if (fdc->command == 0x09) | |
| 1455 | 1479 | { |
| 1456 | 1480 | ddam = 1; |
| 1457 | 1481 | } |
| 1458 | 1482 | |
| 1459 | 1483 | /* write data to disc */ |
| 1460 | floppy_drive_write_sector_data(current_image( | |
| 1484 | floppy_drive_write_sector_data(current_image(dev | |
| 1461 | 1485 | |
| 1462 | if (nec765_sector_count_complete( | |
| 1486 | if (nec765_sector_count_complete(dev | |
| 1463 | 1487 | { |
| 1464 | nec765_increment_sector(machine); | |
| 1465 | nec765_write_complete(machine); | |
| 1488 | nec765_increment_sector(device); | |
| 1489 | nec765_write_complete(device); | |
| 1466 | 1490 | } |
| 1467 | 1491 | else |
| 1468 | 1492 | { |
| 1469 | nec765_increment_sector(machine); | |
| 1470 | nec765_write_data(machine); | |
| 1493 | nec765_increment_sector(device); | |
| 1494 | nec765_write_data(device); | |
| 1471 | 1495 | } |
| 1472 | 1496 | } |
| 1473 | 1497 | break; |
| r3867 | r3868 | |
| 1480 | 1504 | /* read all sectors? */ |
| 1481 | 1505 | |
| 1482 | 1506 | /* sector id == EOT */ |
| 1483 | if (nec765_sector_count_complete( | |
| 1507 | if (nec765_sector_count_complete(dev | |
| 1484 | 1508 | { |
| 1485 | nec765_read_complete( | |
| 1509 | nec765_read_complete(dev | |
| 1486 | 1510 | } |
| 1487 | 1511 | else |
| 1488 | 1512 | { |
| 1489 | nec765_increment_sector(machine); | |
| 1490 | nec765_read_data(machine); | |
| 1513 | nec765_increment_sector(device); | |
| 1514 | nec765_read_data(device); | |
| 1491 | 1515 | } |
| 1492 | 1516 | } |
| 1493 | 1517 | break; |
| r3867 | r3868 | |
| 1499 | 1523 | } |
| 1500 | 1524 | |
| 1501 | 1525 | |
| 1502 | static int nec765_get_command_byte_count(void) | |
| 1526 | static int nec765_get_command_byte_count(const device_config *device) | |
| 1503 | 1527 | { |
| 1504 | fdc.command = fdc.nec765_command_bytes[0] & 0x01f; | |
| 1528 | nec765_t *fdc = get_safe_token(device); | |
| 1529 | fdc->command = fdc->nec765_command_bytes[0] & 0x01f; | |
| 1505 | 1530 | |
| 1506 | if (fdc | |
| 1531 | if (fdc->version==TYPE_NEC765A) | |
| 1507 | 1532 | { |
| 1508 | return nec765_cmd_size[fdc | |
| 1533 | return nec765_cmd_size[fdc->command]; | |
| 1509 | 1534 | } |
| 1510 | 1535 | else |
| 1511 | 1536 | { |
| 1512 | if (fdc | |
| 1537 | if (fdc->version==TYPE_SMC37C78) | |
| 1513 | 1538 | { |
| 1514 | switch (fdc | |
| 1539 | switch (fdc->command) | |
| 1515 | 1540 | { |
| 1516 | 1541 | /* version */ |
| 1517 | 1542 | case 0x010: |
| r3867 | r3868 | |
| 1540 | 1565 | /* seek/relative seek are together! */ |
| 1541 | 1566 | |
| 1542 | 1567 | default: |
| 1543 | return nec765_cmd_size[fdc | |
| 1568 | return nec765_cmd_size[fdc->command]; | |
| 1544 | 1569 | } |
| 1545 | 1570 | } |
| 1546 | 1571 | } |
| 1547 | 1572 | |
| 1548 | return nec765_cmd_size[fdc | |
| 1573 | return nec765_cmd_size[fdc->command]; | |
| 1549 | 1574 | } |
| 1550 | 1575 | |
| 1551 | 1576 | |
| 1552 | 1577 | |
| 1553 | 1578 | |
| 1554 | 1579 | |
| 1555 | void nec765_update_state( | |
| 1580 | void nec765_update_state(const device_ | |
| 1556 | 1581 | { |
| 1557 | switch (fdc.nec765_phase) { | |
| 1582 | nec765_t *fdc = get_safe_token(device); | |
| 1583 | switch (fdc->nec765_phase) { | |
| 1558 | 1584 | case NEC765_RESULT_PHASE: |
| 1559 | 1585 | /* set data reg */ |
| 1560 | fdc | |
| 1586 | fdc->nec765_data_reg = fdc->nec765_result_bytes[fdc->nec765_transfer_bytes_count]; | |
| 1561 | 1587 | |
| 1562 | if (fdc | |
| 1588 | if (fdc->nec765_transfer_bytes_count == 0) | |
| 1563 | 1589 | { |
| 1564 | 1590 | /* clear int for specific commands */ |
| 1565 | switch (fdc | |
| 1591 | switch (fdc->command) { | |
| 1566 | 1592 | case 2: /* read a track */ |
| 1567 | 1593 | case 5: /* write data */ |
| 1568 | 1594 | case 6: /* read data */ |
| r3867 | r3868 | |
| 1573 | 1599 | case 17: /* scan equal */ |
| 1574 | 1600 | case 19: /* scan low or equal */ |
| 1575 | 1601 | case 29: /* scan high or equal */ |
| 1576 | nec765_set_int( | |
| 1602 | nec765_set_int(dev | |
| 1577 | 1603 | break; |
| 1578 | 1604 | |
| 1579 | 1605 | default: |
| r3867 | r3868 | |
| 1582 | 1608 | } |
| 1583 | 1609 | |
| 1584 | 1610 | if (LOG_VERBOSE) |
| 1585 | logerror("NEC765: RESULT: %02x\n", fdc | |
| 1611 | logerror("NEC765: RESULT: %02x\n", fdc->nec765_data_reg); | |
| 1586 | 1612 | |
| 1587 | fdc.nec765_transfer_bytes_count++; | |
| 1588 | fdc.nec765_transfer_bytes_remaining--; | |
| 1613 | fdc->nec765_transfer_bytes_count++; | |
| 1614 | fdc->nec765_transfer_bytes_remaining--; | |
| 1589 | 1615 | |
| 1590 | if (fdc | |
| 1616 | if (fdc->nec765_transfer_bytes_remaining==0) | |
| 1591 | 1617 | { |
| 1592 | nec765_idle(); | |
| 1618 | nec765_idle(device); | |
| 1593 | 1619 | } |
| 1594 | 1620 | else |
| 1595 | 1621 | { |
| 1596 | nec765_set_data_request(); | |
| 1622 | nec765_set_data_request(device); | |
| 1597 | 1623 | } |
| 1598 | 1624 | break; |
| 1599 | 1625 | |
| 1600 | 1626 | case NEC765_EXECUTION_PHASE_READ: |
| 1601 | 1627 | /* setup data register */ |
| 1602 | fdc.nec765_data_reg = fdc.execution_phase_data[fdc.nec765_transfer_bytes_count]; | |
| 1603 | fdc.nec765_transfer_bytes_count++; | |
| 1604 | fdc.nec765_transfer_bytes_remaining--; | |
| 1628 | fdc->nec765_data_reg = fdc->execution_phase_data[fdc->nec765_transfer_bytes_count]; | |
| 1629 | fdc->nec765_transfer_bytes_count++; | |
| 1630 | fdc->nec765_transfer_bytes_remaining--; | |
| 1605 | 1631 | |
| 1606 | 1632 | if (LOG_EXTRA) |
| 1607 | logerror("EXECUTION PHASE READ: %02x\n", fdc | |
| 1633 | logerror("EXECUTION PHASE READ: %02x\n", fdc->nec765_data_reg); | |
| 1608 | 1634 | |
| 1609 | if ((fdc | |
| 1635 | if ((fdc->nec765_transfer_bytes_remaining==0) || (fdc->nec765_flags & NEC765_TC)) | |
| 1610 | 1636 | { |
| 1611 | timer_adjust_oneshot(fdc | |
| 1637 | timer_adjust_oneshot(fdc->command_timer, attotime_zero, 0); | |
| 1612 | 1638 | } |
| 1613 | 1639 | else |
| 1614 | 1640 | { |
| 1615 | 1641 | /* trigger int */ |
| 1616 | nec765_setup_timed_data_request( | |
| 1642 | nec765_setup_timed_data_request(dev | |
| 1617 | 1643 | } |
| 1618 | 1644 | break; |
| 1619 | 1645 | |
| 1620 | 1646 | case NEC765_COMMAND_PHASE_FIRST_BYTE: |
| 1621 | fdc | |
| 1647 | fdc->FDC_main |= 0x10; /* set BUSY */ | |
| 1622 | 1648 | |
| 1623 | 1649 | if (LOG_VERBOSE) |
| 1624 | logerror("nec765(): pc=0x%08x command=0x%02x\n", cpu_get_pc(machine->cpu[0]), fdc | |
| 1650 | logerror("nec765(): pc=0x%08x command=0x%02x\n", cpu_get_pc(device->machine->cpu[0]), fdc->nec765_data_reg); | |
| 1625 | 1651 | |
| 1626 | 1652 | /* seek in progress? */ |
| 1627 | if (fdc | |
| 1653 | if (fdc->nec765_flags & NEC765_SEEK_ACTIVE) | |
| 1628 | 1654 | { |
| 1629 | 1655 | /* any command results in a invalid - I think that seek, recalibrate and |
| 1630 | 1656 | sense interrupt status may work*/ |
| 1631 | fdc | |
| 1657 | fdc->nec765_data_reg = 0; | |
| 1632 | 1658 | } |
| 1633 | 1659 | |
| 1634 | fdc | |
| 1660 | fdc->nec765_command_bytes[0] = fdc->nec765_data_reg; | |
| 1635 | 1661 | |
| 1636 | fdc | |
| 1662 | fdc->nec765_transfer_bytes_remaining = nec765_get_command_byte_count(device); | |
| 1637 | 1663 | |
| 1638 | fdc.nec765_transfer_bytes_count = 1; | |
| 1639 | fdc.nec765_transfer_bytes_remaining--; | |
| 1664 | fdc->nec765_transfer_bytes_count = 1; | |
| 1665 | fdc->nec765_transfer_bytes_remaining--; | |
| 1640 | 1666 | |
| 1641 | if (fdc | |
| 1667 | if (fdc->nec765_transfer_bytes_remaining==0) | |
| 1642 | 1668 | { |
| 1643 | nec765_setup_command( | |
| 1669 | nec765_setup_command(dev | |
| 1644 | 1670 | } |
| 1645 | 1671 | else |
| 1646 | 1672 | { |
| 1647 | 1673 | /* request more data */ |
| 1648 | nec765_set_data_request(); | |
| 1649 | fdc.nec765_phase = NEC765_COMMAND_PHASE_BYTES; | |
| 1674 | nec765_set_data_request(device); | |
| 1675 | fdc->nec765_phase = NEC765_COMMAND_PHASE_BYTES; | |
| 1650 | 1676 | } |
| 1651 | 1677 | break; |
| 1652 | 1678 | |
| 1653 | 1679 | case NEC765_COMMAND_PHASE_BYTES: |
| 1654 | 1680 | if (LOG_VERBOSE) |
| 1655 | logerror("nec765(): pc=0x%08x command=0x%02x\n", cpu_get_pc(machine->cpu[0]), fdc | |
| 1681 | logerror("nec765(): pc=0x%08x command=0x%02x\n", cpu_get_pc(device->machine->cpu[0]), fdc->nec765_data_reg); | |
| 1656 | 1682 | |
| 1657 | fdc.nec765_command_bytes[fdc.nec765_transfer_bytes_count] = fdc.nec765_data_reg; | |
| 1658 | fdc.nec765_transfer_bytes_count++; | |
| 1659 | fdc.nec765_transfer_bytes_remaining--; | |
| 1683 | fdc->nec765_command_bytes[fdc->nec765_transfer_bytes_count] = fdc->nec765_data_reg; | |
| 1684 | fdc->nec765_transfer_bytes_count++; | |
| 1685 | fdc->nec765_transfer_bytes_remaining--; | |
| 1660 | 1686 | |
| 1661 | if (fdc | |
| 1687 | if (fdc->nec765_transfer_bytes_remaining==0) | |
| 1662 | 1688 | { |
| 1663 | nec765_setup_command( | |
| 1689 | nec765_setup_command(dev | |
| 1664 | 1690 | } |
| 1665 | 1691 | else |
| 1666 | 1692 | { |
| 1667 | 1693 | /* request more data */ |
| 1668 | nec765_set_data_request(); | |
| 1694 | nec765_set_data_request(device); | |
| 1669 | 1695 | } |
| 1670 | 1696 | break; |
| 1671 | 1697 | |
| 1672 | 1698 | case NEC765_EXECUTION_PHASE_WRITE: |
| 1673 | fdc.execution_phase_data[fdc.nec765_transfer_bytes_count]=fdc.nec765_data_reg; | |
| 1674 | fdc.nec765_transfer_bytes_count++; | |
| 1675 | fdc.nec765_transfer_bytes_remaining--; | |
| 1699 | fdc->execution_phase_data[fdc->nec765_transfer_bytes_count]=fdc->nec765_data_reg; | |
| 1700 | fdc->nec765_transfer_bytes_count++; | |
| 1701 | fdc->nec765_transfer_bytes_remaining--; | |
| 1676 | 1702 | |
| 1677 | if ((fdc | |
| 1703 | if ((fdc->nec765_transfer_bytes_remaining == 0) || (fdc->nec765_flags & NEC765_TC)) | |
| 1678 | 1704 | { |
| 1679 | timer_adjust_oneshot(fdc | |
| 1705 | timer_adjust_oneshot(fdc->command_timer, attotime_zero, 0); | |
| 1680 | 1706 | } |
| 1681 | 1707 | else |
| 1682 | 1708 | { |
| 1683 | nec765_setup_timed_data_request( | |
| 1709 | nec765_setup_timed_data_request(dev | |
| 1684 | 1710 | } |
| 1685 | 1711 | break; |
| 1686 | 1712 | } |
| 1687 | 1713 | } |
| 1688 | 1714 | |
| 1689 | 1715 | |
| 1690 | READ8_HANDLER(nec765_data_r) | |
| 1716 | READ8_DEVICE_HANDLER(nec765_data_r) | |
| 1691 | 1717 | { |
| 1692 | if ((fdc.FDC_main & 0x0c0) == 0x0c0) | |
| 1718 | nec765_t *fdc = get_safe_token(device); | |
| 1719 | ||
| 1720 | if ((fdc->FDC_main & 0x0c0) == 0x0c0) | |
| 1693 | 1721 | { |
| 1694 | 1722 | if ( |
| 1695 | (fdc.nec765_phase == NEC765_EXECUTION_PHASE_READ) || | |
| 1696 | (fdc.nec765_phase == NEC765_EXECUTION_PHASE_WRITE)) | |
| 1723 | (fdc->nec765_phase == NEC765_EXECUTION_PHASE_READ) || | |
| 1724 | (fdc->nec765_phase == NEC765_EXECUTION_PHASE_WRITE)) | |
| 1697 | 1725 | { |
| 1698 | 1726 | |
| 1699 | 1727 | /* reading the data byte clears the interrupt */ |
| 1700 | nec765_set_int( | |
| 1728 | nec765_set_int(d | |
| 1701 | 1729 | } |
| 1702 | 1730 | |
| 1703 | 1731 | /* reset data request */ |
| 1704 | nec765_clear_data_request(); | |
| 1732 | nec765_clear_data_request(device); | |
| 1705 | 1733 | |
| 1706 | 1734 | /* update state */ |
| 1707 | nec765_update_state( | |
| 1735 | nec765_update_state(d | |
| 1708 | 1736 | } |
| 1709 | 1737 | |
| 1710 | 1738 | if (LOG_EXTRA) |
| 1711 | logerror("DATA R: %02x\n", fdc | |
| 1739 | logerror("DATA R: %02x\n", fdc->nec765_data_reg); | |
| 1712 | 1740 | |
| 1713 | return fdc | |
| 1741 | return fdc->nec765_data_reg; | |
| 1714 | 1742 | } |
| 1715 | 1743 | |
| 1716 | WRITE8_HANDLER(nec765_data_w) | |
| 1744 | WRITE8_DEVICE_HANDLER(nec765_data_w) | |
| 1717 | 1745 | { |
| 1746 | nec765_t *fdc = get_safe_token(device); | |
| 1747 | ||
| 1718 | 1748 | if (LOG_EXTRA) |
| 1719 | 1749 | logerror("DATA W: %02x\n", data); |
| 1720 | 1750 | |
| 1721 | 1751 | /* write data to data reg */ |
| 1722 | fdc | |
| 1752 | fdc->nec765_data_reg = data; | |
| 1723 | 1753 | |
| 1724 | if ((fdc | |
| 1754 | if ((fdc->FDC_main & 0x0c0)==0x080) | |
| 1725 | 1755 | { |
| 1726 | 1756 | if ( |
| 1727 | (fdc.nec765_phase == NEC765_EXECUTION_PHASE_READ) || | |
| 1728 | (fdc.nec765_phase == NEC765_EXECUTION_PHASE_WRITE)) | |
| 1757 | (fdc->nec765_phase == NEC765_EXECUTION_PHASE_READ) || | |
| 1758 | (fdc->nec765_phase == NEC765_EXECUTION_PHASE_WRITE)) | |
| 1729 | 1759 | { |
| 1730 | 1760 | |
| 1731 | 1761 | /* reading the data byte clears the interrupt */ |
| 1732 | nec765_set_int( | |
| 1762 | nec765_set_int(d | |
| 1733 | 1763 | } |
| 1734 | 1764 | |
| 1735 | 1765 | /* reset data request */ |
| 1736 | nec765_clear_data_request(); | |
| 1766 | nec765_clear_data_request(device); | |
| 1737 | 1767 | |
| 1738 | 1768 | /* update state */ |
| 1739 | nec765_update_state( | |
| 1769 | nec765_update_state(d | |
| 1740 | 1770 | } |
| 1741 | 1771 | } |
| 1742 | 1772 | |
| 1743 | static void nec765_setup_invalid( | |
| 1773 | static void nec765_setup_invalid(const device_ | |
| 1744 | 1774 | { |
| 1745 | fdc.command = 0; | |
| 1746 | fdc.nec765_result_bytes[0] = 0x080; | |
| 1747 | nec765_setup_result_phase(machine,1); | |
| 1775 | nec765_t *fdc = get_safe_token(device); | |
| 1776 | ||
| 1777 | fdc->command = 0; | |
| 1778 | fdc->nec765_result_bytes[0] = 0x080; | |
| 1779 | nec765_setup_result_phase(device,1); | |
| 1748 | 1780 | } |
| 1749 | 1781 | |
| 1750 | static void nec765_setup_command( | |
| 1782 | static void nec765_setup_command(const device_ | |
| 1751 | 1783 | { |
| 1784 | nec765_t *fdc = get_safe_token(device); | |
| 1785 | ||
| 1752 | 1786 | static const char *const commands[] = |
| 1753 | 1787 | { |
| 1754 | 1788 | NULL, /* [00] */ |
| r3867 | r3868 | |
| 1774 | 1808 | "Lock" /* [14] */ |
| 1775 | 1809 | }; |
| 1776 | 1810 | |
| 1777 | const device_config *img = current_image( | |
| 1811 | const device_config *img = current_image(dev | |
| 1778 | 1812 | const char *cmd = NULL; |
| 1779 | 1813 | chrn_id id; |
| 1780 | 1814 | |
| 1781 | 1815 | /* if not in dma mode set execution phase bit */ |
| 1782 | if (!(fdc | |
| 1816 | if (!(fdc->nec765_flags & NEC765_DMA_MODE)) | |
| 1783 | 1817 | { |
| 1784 | fdc | |
| 1818 | fdc->FDC_main |= 0x020; /* execution phase */ | |
| 1785 | 1819 | } |
| 1786 | 1820 | |
| 1787 | 1821 | if (LOG_COMMAND) |
| 1788 | 1822 | { |
| 1789 | if ((fdc.nec765_command_bytes[0] & 0x1f) < sizeof(commands) / sizeof(commands[0])) | |
| 1790 | cmd = commands[fdc.nec765_command_bytes[0] & 0x1f]; | |
| 1823 | if ((fdc->nec765_command_bytes[0] & 0x1f) < sizeof(commands) / sizeof(commands[0])) | |
| 1824 | cmd = commands[fdc->nec765_command_bytes[0] & 0x1f]; | |
| 1791 | 1825 | logerror("nec765_setup_command(): Setting up command 0x%02X (%s)\n", |
| 1792 | fdc | |
| 1826 | fdc->nec765_command_bytes[0] & 0x1f, cmd ? cmd : "???"); | |
| 1793 | 1827 | } |
| 1794 | 1828 | |
| 1795 | switch (fdc | |
| 1829 | switch (fdc->nec765_command_bytes[0] & 0x1f) | |
| 1796 | 1830 | { |
| 1797 | 1831 | case 0x03: /* specify */ |
| 1798 | 1832 | /* setup step rate */ |
| 1799 | fdc | |
| 1833 | fdc->srt_in_ms = 16-((fdc->nec765_command_bytes[1]>>4) & 0x0f); | |
| 1800 | 1834 | |
| 1801 | fdc | |
| 1835 | fdc->nec765_flags &= ~NEC765_DMA_MODE; | |
| 1802 | 1836 | |
| 1803 | if ((fdc | |
| 1837 | if ((fdc->nec765_command_bytes[2] & 0x01)==0) | |
| 1804 | 1838 | { |
| 1805 | fdc | |
| 1839 | fdc->nec765_flags |= NEC765_DMA_MODE; | |
| 1806 | 1840 | } |
| 1807 | 1841 | |
| 1808 | nec765_idle(); | |
| 1842 | nec765_idle(device); | |
| 1809 | 1843 | break; |
| 1810 | 1844 | |
| 1811 | 1845 | case 0x04: /* sense drive status */ |
| 1812 | nec765_setup_drive_and_side(); | |
| 1846 | nec765_setup_drive_and_side(device); | |
| 1813 | 1847 | |
| 1814 | fdc | |
| 1848 | fdc->nec765_status[3] = fdc->drive | (fdc->side<<2); | |
| 1815 | 1849 | |
| 1816 | 1850 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_DISK_WRITE_PROTECTED)) |
| 1817 | 1851 | { |
| 1818 | fdc | |
| 1852 | fdc->nec765_status[3] |= 0x40; | |
| 1819 | 1853 | } |
| 1820 | 1854 | |
| 1821 | 1855 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 1822 | 1856 | { |
| 1823 | fdc | |
| 1857 | fdc->nec765_status[3] |= 0x20; | |
| 1824 | 1858 | } |
| 1825 | 1859 | |
| 1826 | 1860 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_HEAD_AT_TRACK_0)) |
| 1827 | 1861 | { |
| 1828 | fdc | |
| 1862 | fdc->nec765_status[3] |= 0x10; | |
| 1829 | 1863 | } |
| 1830 | 1864 | |
| 1831 | fdc | |
| 1865 | fdc->nec765_status[3] |= 0x08; | |
| 1832 | 1866 | |
| 1833 | 1867 | /* two side and fault not set but should be? */ |
| 1834 | fdc.nec765_result_bytes[0] = fdc.nec765_status[3]; | |
| 1835 | nec765_setup_result_phase(machine,1); | |
| 1868 | fdc->nec765_result_bytes[0] = fdc->nec765_status[3]; | |
| 1869 | nec765_setup_result_phase(device,1); | |
| 1836 | 1870 | break; |
| 1837 | 1871 | |
| 1838 | 1872 | case 0x07: /* recalibrate */ |
| 1839 | nec765_seek_setup( | |
| 1873 | nec765_seek_setup(dev | |
| 1840 | 1874 | break; |
| 1841 | 1875 | |
| 1842 | 1876 | case 0x0f: /* seek */ |
| 1843 | nec765_seek_setup( | |
| 1877 | nec765_seek_setup(dev | |
| 1844 | 1878 | break; |
| 1845 | 1879 | |
| 1846 | 1880 | case 0x0a: /* read id */ |
| 1847 | nec765_setup_drive_and_side(); | |
| 1881 | nec765_setup_drive_and_side(device); | |
| 1848 | 1882 | |
| 1849 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 1850 | fdc.nec765_status[1] = 0; | |
| 1851 | fdc.nec765_status[2] = 0; | |
| 1883 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 1884 | fdc->nec765_status[1] = 0; | |
| 1885 | fdc->nec765_status[2] = 0; | |
| 1852 | 1886 | |
| 1853 | 1887 | /* drive ready? */ |
| 1854 | 1888 | if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| r3867 | r3868 | |
| 1871 | 1905 | do |
| 1872 | 1906 | { |
| 1873 | 1907 | /* get next id from disc */ |
| 1874 | if (floppy_drive_get_next_id(img, fdc | |
| 1908 | if (floppy_drive_get_next_id(img, fdc->side, &id)) | |
| 1875 | 1909 | { |
| 1876 | 1910 | /* got an id - quit */ |
| 1877 | 1911 | break; |
| r3867 | r3868 | |
| 1886 | 1920 | while (index_count!=2); |
| 1887 | 1921 | |
| 1888 | 1922 | /* at this point, we have seen a id or two index pulses have occured! */ |
| 1889 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1890 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1891 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1892 | fdc.nec765_result_bytes[3] = id.C; /* C */ | |
| 1893 | fdc.nec765_result_bytes[4] = id.H; /* H */ | |
| 1894 | fdc.nec765_result_bytes[5] = id.R; /* R */ | |
| 1895 | fdc.nec765_result_bytes[6] = id.N; /* N */ | |
| 1923 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1924 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1925 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1926 | fdc->nec765_result_bytes[3] = id.C; /* C */ | |
| 1927 | fdc->nec765_result_bytes[4] = id.H; /* H */ | |
| 1928 | fdc->nec765_result_bytes[5] = id.R; /* R */ | |
| 1929 | fdc->nec765_result_bytes[6] = id.N; /* N */ | |
| 1896 | 1930 | |
| 1897 | nec765_setup_result_phase( | |
| 1931 | nec765_setup_result_phase(dev | |
| 1898 | 1932 | } |
| 1899 | 1933 | else |
| 1900 | 1934 | { |
| r3867 | r3868 | |
| 1909 | 1943 | /* what are id values when drive not ready? */ |
| 1910 | 1944 | |
| 1911 | 1945 | /* not ready, abnormal termination */ |
| 1912 | fdc.nec765_status[0] |= (1<<3) | (1<<6); | |
| 1913 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 1914 | fdc.nec765_result_bytes[1] = fdc.nec765_status[1]; | |
| 1915 | fdc.nec765_result_bytes[2] = fdc.nec765_status[2]; | |
| 1916 | fdc.nec765_result_bytes[3] = 0; /* C */ | |
| 1917 | fdc.nec765_result_bytes[4] = 0; /* H */ | |
| 1918 | fdc.nec765_result_bytes[5] = 0; /* R */ | |
| 1919 | fdc.nec765_result_bytes[6] = 0; /* N */ | |
| 1946 | fdc->nec765_status[0] |= (1<<3) | (1<<6); | |
| 1947 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1948 | fdc->nec765_result_bytes[1] = fdc->nec765_status[1]; | |
| 1949 | fdc->nec765_result_bytes[2] = fdc->nec765_status[2]; | |
| 1950 | fdc->nec765_result_bytes[3] = 0; /* C */ | |
| 1951 | fdc->nec765_result_bytes[4] = 0; /* H */ | |
| 1952 | fdc->nec765_result_bytes[5] = 0; /* R */ | |
| 1953 | fdc->nec765_result_bytes[6] = 0; /* N */ | |
| 1920 | 1954 | } |
| 1921 | 1955 | break; |
| 1922 | 1956 | |
| 1923 | 1957 | |
| 1924 | 1958 | case 0x08: /* sense interrupt status */ |
| 1925 | 1959 | /* interrupt pending? */ |
| 1926 | if (fdc | |
| 1960 | if (fdc->nec765_flags & NEC765_INT) | |
| 1927 | 1961 | { |
| 1928 | 1962 | /* yes. Clear int */ |
| 1929 | nec765_set_int( | |
| 1963 | nec765_set_int(dev | |
| 1930 | 1964 | |
| 1931 | 1965 | /* clear drive seek bits */ |
| 1932 | fdc | |
| 1966 | fdc->FDC_main &= ~(1 | 2 | 4 | 8); | |
| 1933 | 1967 | |
| 1934 | 1968 | /* return status */ |
| 1935 | fdc | |
| 1969 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 1936 | 1970 | /* return pcn */ |
| 1937 | fdc | |
| 1971 | fdc->nec765_result_bytes[1] = fdc->pcn[fdc->drive]; | |
| 1938 | 1972 | |
| 1939 | 1973 | /* return result */ |
| 1940 | nec765_setup_result_phase( | |
| 1974 | nec765_setup_result_phase(dev | |
| 1941 | 1975 | } |
| 1942 | 1976 | else |
| 1943 | 1977 | { |
| 1944 | if(fdc | |
| 1978 | if(fdc->version == TYPE_NEC72065 && (fdc->FDC_main & 0x0f) == 0x00) | |
| 1945 | 1979 | { // based on XM6 |
| 1946 | nec765_setup_invalid( | |
| 1980 | nec765_setup_invalid(dev | |
| 1947 | 1981 | } |
| 1948 | 1982 | else |
| 1949 | 1983 | { |
| 1950 | 1984 | /* no int */ |
| 1951 | fdc | |
| 1985 | fdc->nec765_result_bytes[0] = 0x80; | |
| 1952 | 1986 | /* return pcn */ |
| 1953 | fdc | |
| 1987 | fdc->nec765_result_bytes[1] = fdc->pcn[fdc->drive]; | |
| 1954 | 1988 | |
| 1955 | 1989 | /* return result */ |
| 1956 | nec765_setup_result_phase( | |
| 1990 | nec765_setup_result_phase(dev | |
| 1957 | 1991 | } |
| 1958 | 1992 | } |
| 1959 | 1993 | break; |
| 1960 | 1994 | |
| 1961 | 1995 | case 0x06: /* read data */ |
| 1962 | nec765_setup_drive_and_side(); | |
| 1996 | nec765_setup_drive_and_side(device); | |
| 1963 | 1997 | |
| 1964 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 1965 | fdc.nec765_status[1] = 0; | |
| 1966 | fdc.nec765_status[2] = 0; | |
| 1998 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 1999 | fdc->nec765_status[1] = 0; | |
| 2000 | fdc->nec765_status[2] = 0; | |
| 1967 | 2001 | |
| 1968 | nec765_read_data( | |
| 2002 | nec765_read_data(dev | |
| 1969 | 2003 | break; |
| 1970 | 2004 | |
| 1971 | 2005 | case 0x0c: |
| 1972 | 2006 | /* read deleted data */ |
| 1973 | nec765_setup_drive_and_side(); | |
| 2007 | nec765_setup_drive_and_side(device); | |
| 1974 | 2008 | |
| 1975 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 1976 | fdc.nec765_status[1] = 0; | |
| 1977 | fdc.nec765_status[2] = 0; | |
| 2009 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 2010 | fdc->nec765_status[1] = 0; | |
| 2011 | fdc->nec765_status[2] = 0; | |
| 1978 | 2012 | |
| 1979 | 2013 | /* .. for now */ |
| 1980 | nec765_read_data( | |
| 2014 | nec765_read_data(dev | |
| 1981 | 2015 | break; |
| 1982 | 2016 | |
| 1983 | 2017 | case 0x09: |
| 1984 | 2018 | /* write deleted data */ |
| 1985 | nec765_setup_drive_and_side(); | |
| 2019 | nec765_setup_drive_and_side(device); | |
| 1986 | 2020 | |
| 1987 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 1988 | fdc.nec765_status[1] = 0; | |
| 1989 | fdc.nec765_status[2] = 0; | |
| 2021 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 2022 | fdc->nec765_status[1] = 0; | |
| 2023 | fdc->nec765_status[2] = 0; | |
| 1990 | 2024 | |
| 1991 | 2025 | /* ... for now */ |
| 1992 | nec765_write_data( | |
| 2026 | nec765_write_data(dev | |
| 1993 | 2027 | break; |
| 1994 | 2028 | |
| 1995 | 2029 | case 0x02: |
| 1996 | 2030 | /* read a track */ |
| 1997 | nec765_setup_drive_and_side(); | |
| 2031 | nec765_setup_drive_and_side(device); | |
| 1998 | 2032 | |
| 1999 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 2000 | fdc.nec765_status[1] = 0; | |
| 2001 | fdc.nec765_status[2] = 0; | |
| 2033 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 2034 | fdc->nec765_status[1] = 0; | |
| 2035 | fdc->nec765_status[2] = 0; | |
| 2002 | 2036 | |
| 2003 | fdc | |
| 2037 | fdc->nec765_status[0] |= NEC765_ST1_NO_DATA; | |
| 2004 | 2038 | |
| 2005 | 2039 | /* wait for index */ |
| 2006 | 2040 | do |
| 2007 | 2041 | { |
| 2008 | 2042 | /* get next id from disc */ |
| 2009 | floppy_drive_get_next_id(img, fdc | |
| 2043 | floppy_drive_get_next_id(img, fdc->side,&id); | |
| 2010 | 2044 | } |
| 2011 | 2045 | while ((floppy_drive_get_flag_state(img, FLOPPY_DRIVE_INDEX))==0); |
| 2012 | 2046 | |
| 2013 | fdc | |
| 2047 | fdc->sector_counter = 0; | |
| 2014 | 2048 | |
| 2015 | nec765_read_a_track( | |
| 2049 | nec765_read_a_track(dev | |
| 2016 | 2050 | break; |
| 2017 | 2051 | |
| 2018 | 2052 | case 0x05: /* write data */ |
| 2019 | nec765_setup_drive_and_side(); | |
| 2053 | nec765_setup_drive_and_side(device); | |
| 2020 | 2054 | |
| 2021 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 2022 | fdc.nec765_status[1] = 0; | |
| 2023 | fdc.nec765_status[2] = 0; | |
| 2055 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 2056 | fdc->nec765_status[1] = 0; | |
| 2057 | fdc->nec765_status[2] = 0; | |
| 2024 | 2058 | |
| 2025 | nec765_write_data( | |
| 2059 | nec765_write_data(dev | |
| 2026 | 2060 | break; |
| 2027 | 2061 | |
| 2028 | 2062 | case 0x0d: /* format a track */ |
| 2029 | nec765_setup_drive_and_side(); | |
| 2063 | nec765_setup_drive_and_side(device); | |
| 2030 | 2064 | |
| 2031 | fdc.nec765_status[0] = fdc.drive | (fdc.side<<2); | |
| 2032 | fdc.nec765_status[1] = 0; | |
| 2033 | fdc.nec765_status[2] = 0; | |
| 2065 | fdc->nec765_status[0] = fdc->drive | (fdc->side<<2); | |
| 2066 | fdc->nec765_status[1] = 0; | |
| 2067 | fdc->nec765_status[2] = 0; | |
| 2034 | 2068 | |
| 2035 | fdc | |
| 2069 | fdc->sector_counter = 0; | |
| 2036 | 2070 | |
| 2037 | nec765_format_track( | |
| 2071 | nec765_format_track(dev | |
| 2038 | 2072 | break; |
| 2039 | 2073 | |
| 2040 | 2074 | default: /* invalid */ |
| 2041 | switch (fdc | |
| 2075 | switch (fdc->version) | |
| 2042 | 2076 | { |
| 2043 | case NEC765A: | |
| 2044 | case NEC72065: | |
| 2045 | nec765_setup_invalid(machine); | |
| 2077 | case TYPE_NEC765A: | |
| 2078 | case TYPE_NEC72065: | |
| 2079 | nec765_setup_invalid(device); | |
| 2046 | 2080 | break; |
| 2047 | 2081 | |
| 2048 | case NEC765B: | |
| 2082 | case TYPE_NEC765B: | |
| 2049 | 2083 | /* from nec765b data sheet */ |
| 2050 | if ((fdc | |
| 2084 | if ((fdc->nec765_command_bytes[0] & 0x01f)==0x010) | |
| 2051 | 2085 | { |
| 2052 | 2086 | /* version */ |
| 2053 | fdc.nec765_status[0] = 0x090; | |
| 2054 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 2055 | nec765_setup_result_phase(machine,1); | |
| 2087 | fdc->nec765_status[0] = 0x090; | |
| 2088 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 2089 | nec765_setup_result_phase(device,1); | |
| 2056 | 2090 | } |
| 2057 | 2091 | break; |
| 2058 | 2092 | |
| 2059 | case SMC37C78: | |
| 2093 | case TYPE_SMC37C78: | |
| 2060 | 2094 | /* TO BE COMPLETED!!! !*/ |
| 2061 | switch (fdc | |
| 2095 | switch (fdc->nec765_command_bytes[0] & 0x1f) | |
| 2062 | 2096 | { |
| 2063 | 2097 | case 0x10: /* version */ |
| 2064 | fdc.nec765_status[0] = 0x90; | |
| 2065 | fdc.nec765_result_bytes[0] = fdc.nec765_status[0]; | |
| 2066 | nec765_setup_result_phase(machine,1); | |
| 2098 | fdc->nec765_status[0] = 0x90; | |
| 2099 | fdc->nec765_result_bytes[0] = fdc->nec765_status[0]; | |
| 2100 | nec765_setup_result_phase(device,1); | |
| 2067 | 2101 | break; |
| 2068 | 2102 | |
| 2069 | 2103 | case 0x13: /* configure */ |
| 2070 | nec765_idle(); | |
| 2104 | nec765_idle(device); | |
| 2071 | 2105 | break; |
| 2072 | 2106 | |
| 2073 | 2107 | case 0x0e: /* dump reg */ |
| 2074 | fdc.nec765_result_bytes[0] = fdc.pcn[0]; | |
| 2075 | fdc.nec765_result_bytes[1] = fdc.pcn[1]; | |
| 2076 | fdc.nec765_result_bytes[2] = fdc.pcn[2]; | |
| 2077 | fdc.nec765_result_bytes[3] = fdc.pcn[3]; | |
| 2108 | fdc->nec765_result_bytes[0] = fdc->pcn[0]; | |
| 2109 | fdc->nec765_result_bytes[1] = fdc->pcn[1]; | |
| 2110 | fdc->nec765_result_bytes[2] = fdc->pcn[2]; | |
| 2111 | fdc->nec765_result_bytes[3] = fdc->pcn[3]; | |
| 2078 | 2112 | |
| 2079 | nec765_setup_result_phase( | |
| 2113 | nec765_setup_result_phase(dev | |
| 2080 | 2114 | break; |
| 2081 | 2115 | |
| 2082 | 2116 | case 0x12: /* perpendicular mode */ |
| 2083 | nec765_idle(); | |
| 2117 | nec765_idle(device); | |
| 2084 | 2118 | break; |
| 2085 | 2119 | |
| 2086 | 2120 | case 0x14: /* lock */ |
| 2087 | nec765_setup_result_phase( | |
| 2121 | nec765_setup_result_phase(dev | |
| 2088 | 2122 | break; |
| 2089 | 2123 | } |
| 2090 | 2124 | break; |
| r3867 | r3868 | |
| 2094 | 2128 | |
| 2095 | 2129 | |
| 2096 | 2130 | /* dma acknowledge write */ |
| 2097 | WRITE8_HANDLER(nec765_dack_w) | |
| 2131 | WRITE8_DEVICE_HANDLER(nec765_dack_w) | |
| 2098 | 2132 | { |
| 2099 | 2133 | /* clear request */ |
| 2100 | nec765_set_dma_drq( | |
| 2134 | nec765_set_dma_drq(d | |
| 2101 | 2135 | |
| 2102 | 2136 | /* write data */ |
| 2103 | nec765_data_w( | |
| 2137 | nec765_data_w(device, offset, data); | |
| 2104 | 2138 | } |
| 2105 | 2139 | |
| 2106 | READ8_HANDLER(nec765_dack_r) | |
| 2140 | READ8_DEVICE_HANDLER(nec765_dack_r) | |
| 2107 | 2141 | { |
| 2108 | 2142 | /* clear data request */ |
| 2109 | nec765_set_dma_drq( | |
| 2143 | nec765_set_dma_drq(d | |
| 2110 | 2144 | |
| 2111 | 2145 | /* read data */ |
| 2112 | return nec765_data_r( | |
| 2146 | return nec765_data_r(device, offset); | |
| 2113 | 2147 | } |
| 2114 | 2148 | |
| 2115 | 2149 | |
| 2116 | void nec765_reset( | |
| 2150 | void nec765_reset(const device_ | |
| 2117 | 2151 | { |
| 2152 | nec765_t *fdc = get_safe_token(device); | |
| 2153 | ||
| 2118 | 2154 | /* nec765 in idle state - ready to accept commands */ |
| 2119 | nec765_idle(); | |
| 2155 | nec765_idle(device); | |
| 2120 | 2156 | |
| 2121 | 2157 | /* set int low */ |
| 2122 | nec765_set_int( | |
| 2158 | nec765_set_int(dev | |
| 2123 | 2159 | /* set dma drq output */ |
| 2124 | nec765_set_dma_drq( | |
| 2160 | nec765_set_dma_drq(dev | |
| 2125 | 2161 | |
| 2126 | 2162 | /* tandy 100hx assumes that after NEC is reset, it is in DMA mode */ |
| 2127 | fdc | |
| 2163 | fdc->nec765_flags |= NEC765_DMA_MODE; | |
| 2128 | 2164 | |
| 2129 | 2165 | /* if ready input is set during reset generate an int */ |
| 2130 | if (fdc | |
| 2166 | if (fdc->nec765_flags & NEC765_FDD_READY) | |
| 2131 | 2167 | { |
| 2132 | 2168 | int i; |
| 2133 | 2169 | int a_drive_is_ready; |
| 2134 | 2170 | |
| 2135 | fdc | |
| 2171 | fdc->nec765_status[0] = 0x080 | 0x040; | |
| 2136 | 2172 | |
| 2137 | 2173 | /* for the purpose of pc-xt. If any of the drives have a disk inserted, |
| 2138 | do not set not-ready - need to check with pc_fdc | |
| 2174 | do not set not-ready - need to check with pc_fdc->c whether all drives | |
| 2139 | 2175 | are checked or only the drive selected with the drive select bits?? */ |
| 2140 | 2176 | |
| 2141 | 2177 | a_drive_is_ready = 0; |
| 2142 | for (i = 0; i < device_count(machine, IO_FLOPPY); i++) | |
| 2178 | for (i = 0; i < device_count(device->machine, IO_FLOPPY); i++) | |
| 2143 | 2179 | { |
| 2144 | 2180 | if (image_exists(image_from_devtype_and_index(IO_FLOPPY, i))) |
| 2145 | 2181 | { |
| r3867 | r3868 | |
| 2149 | 2185 | |
| 2150 | 2186 | } |
| 2151 | 2187 | |
| 2152 | if (!a_drive_is_ready && fdc | |
| 2188 | if (!a_drive_is_ready && fdc->intf->rdy_pin == NEC765_RDY_PIN_CONNECTED ) | |
| 2153 | 2189 | { |
| 2154 | fdc | |
| 2190 | fdc->nec765_status[0] |= 0x08; | |
| 2155 | 2191 | } |
| 2156 | 2192 | |
| 2157 | nec765_set_int( | |
| 2193 | nec765_set_int(dev | |
| 2158 | 2194 | } |
| 2159 | 2195 | } |
| 2160 | 2196 | |
| 2161 | void nec765_set_reset_state( | |
| 2197 | void nec765_set_reset_state(const device_ | |
| 2162 | 2198 | { |
| 2199 | nec765_t *fdc = get_safe_token(device); | |
| 2200 | ||
| 2163 | 2201 | int flags; |
| 2164 | 2202 | |
| 2165 | 2203 | /* get previous reset state */ |
| 2166 | flags = fdc | |
| 2204 | flags = fdc->nec765_flags; | |
| 2167 | 2205 | |
| 2168 | 2206 | /* set new reset state */ |
| 2169 | 2207 | /* clear reset */ |
| 2170 | fdc | |
| 2208 | fdc->nec765_flags &= ~NEC765_RESET; | |
| 2171 | 2209 | |
| 2172 | 2210 | /* reset */ |
| 2173 | 2211 | if (state) |
| 2174 | 2212 | { |
| 2175 | fdc | |
| 2213 | fdc->nec765_flags |= NEC765_RESET; | |
| 2176 | 2214 | |
| 2177 | nec765_set_int( | |
| 2215 | nec765_set_int(dev | |
| 2178 | 2216 | } |
| 2179 | 2217 | |
| 2180 | 2218 | /* reset changed state? */ |
| 2181 | if (((flags^fdc | |
| 2219 | if (((flags^fdc->nec765_flags) & NEC765_RESET)!=0) | |
| 2182 | 2220 | { |
| 2183 | 2221 | /* yes */ |
| 2184 | 2222 | |
| 2185 | 2223 | /* no longer reset */ |
| 2186 | if ((fdc | |
| 2224 | if ((fdc->nec765_flags & NEC765_RESET)==0) | |
| 2187 | 2225 | { |
| 2188 | 2226 | /* reset nec */ |
| 2189 | nec765_reset( | |
| 2227 | nec765_reset(dev | |
| 2190 | 2228 | } |
| 2191 | 2229 | } |
| 2192 | 2230 | } |
| 2193 | 2231 | |
| 2194 | 2232 | |
| 2195 | void | |
| 2233 | void nec765_set_ready_state(const device_config *device, int state) | |
| 2196 | 2234 | { |
| 2235 | nec765_t *fdc = get_safe_token(device); | |
| 2236 | ||
| 2197 | 2237 | /* clear ready state */ |
| 2198 | fdc | |
| 2238 | fdc->nec765_flags &= ~NEC765_FDD_READY; | |
| 2199 | 2239 | |
| 2200 | 2240 | if (state) |
| 2201 | 2241 | { |
| 2202 | fdc | |
| 2242 | fdc->nec765_flags |= NEC765_FDD_READY; | |
| 2203 | 2243 | } |
| 2204 | 2244 | } |
| 2245 | ||
| 2246 | ||
| 2247 | /* Device Interface */ | |
| 2248 | ||
| 2249 | static device_start_err common_start(const device_config *device, int device_type) | |
| 2250 | { | |
| 2251 | nec765_t *fdc = get_safe_token(device); | |
| 2252 | // validate arguments | |
| 2253 | ||
| 2254 | assert(device != NULL); | |
| 2255 | assert(device->tag != NULL); | |
| 2256 | assert(strlen(device->tag) < 20); | |
| 2257 | assert(device->static_config != NULL); | |
| 2258 | ||
| 2259 | fdc->intf = device->static_config; | |
| 2260 | ||
| 2261 | fdc->version = device_type; | |
| 2262 | fdc->timer = timer_alloc(device->machine, nec765_timer_callback, (void*)device); | |
| 2263 | fdc->seek_timer = timer_alloc(device->machine, nec765_seek_timer_callback, (void*)device); | |
| 2264 | fdc->command_timer = timer_alloc(device->machine, nec765_continue_command, (void*)device); | |
| 2265 | ||
| 2266 | fdc->nec765_flags &= NEC765_FDD_READY; | |
| 2267 | fdc->data_buffer = auto_malloc(32*1024); | |
| 2268 | ||
| 2269 | ||
| 2270 | // register for state saving | |
| 2271 | //state_save_register_item(device->machine, "nec765", device->tag, 0, nec765->number); | |
| 2272 | return DEVICE_START_OK; | |
| 2273 | } | |
| 2274 | ||
| 2275 | static DEVICE_START( nec765a ) | |
| 2276 | { | |
| 2277 | return common_start(device, TYPE_NEC765A); | |
| 2278 | } | |
| 2279 | ||
| 2280 | static DEVICE_START( nec765b ) | |
| 2281 | { | |
| 2282 | return common_start(device, TYPE_NEC765B); | |
| 2283 | } | |
| 2284 | ||
| 2285 | static DEVICE_START( smc37c78 ) | |
| 2286 | { | |
| 2287 | return common_start(device, TYPE_SMC37C78); | |
| 2288 | } | |
| 2289 | ||
| 2290 | static DEVICE_START( nec72065 ) | |
| 2291 | { | |
| 2292 | return common_start(device, TYPE_NEC72065); | |
| 2293 | } | |
| 2294 | ||
| 2295 | static DEVICE_RESET( nec765 ) | |
| 2296 | { | |
| 2297 | int i; | |
| 2298 | ||
| 2299 | for (i = 0; i < device_count(device->machine, IO_FLOPPY); i++) { | |
| 2300 | const device_config *img = image_from_devtype_and_index(IO_FLOPPY, i); | |
| 2301 | floppy_drive_set_controller(img, device); | |
| 2302 | floppy_drive_set_ready_state_change_callback(img, nec765_set_ready_change_callback); | |
| 2303 | } | |
| 2304 | ||
| 2305 | nec765_reset(device,0); | |
| 2306 | } | |
| 2307 | ||
| 2308 | static DEVICE_SET_INFO( nec765 ) | |
| 2309 | { | |
| 2310 | switch (state) | |
| 2311 | { | |
| 2312 | /* no parameters to set */ | |
| 2313 | } | |
| 2314 | } | |
| 2315 | ||
| 2316 | DEVICE_GET_INFO( nec765a ) | |
| 2317 | { | |
| 2318 | switch (state) | |
| 2319 | { | |
| 2320 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2321 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(nec765_t); break; | |
| 2322 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; | |
| 2323 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; | |
| 2324 | ||
| 2325 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2326 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(nec765); break; | |
| 2327 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(nec765a); break; | |
| 2328 | case DEVINFO_FCT_STOP: /* Nothing */ break; | |
| 2329 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(nec765); break; | |
| 2330 | ||
| 2331 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2332 | case DEVINFO_STR_NAME: info->s = "NEC765A"; break; | |
| 2333 | case DEVINFO_STR_FAMILY: info->s = "NEC765A"; break; | |
| 2334 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; | |
| 2335 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; | |
| 2336 | case DEVINFO_STR_CREDITS: info->s = "Copyright MESS Team"; break; | |
| 2337 | } | |
| 2338 | } | |
| 2339 | ||
| 2340 | ||
| 2341 | DEVICE_GET_INFO( nec765b ) | |
| 2342 | { | |
| 2343 | switch (state) | |
| 2344 | { | |
| 2345 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2346 | case DEVINFO_STR_NAME: info->s = "NEC765B"; break; | |
| 2347 | ||
| 2348 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2349 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(nec765b); break; | |
| 2350 | ||
| 2351 | default: DEVICE_GET_INFO_CALL(nec765a); break; | |
| 2352 | } | |
| 2353 | } | |
| 2354 | ||
| 2355 | DEVICE_GET_INFO( smc37c78 ) | |
| 2356 | { | |
| 2357 | switch (state) | |
| 2358 | { | |
| 2359 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2360 | case DEVINFO_STR_NAME: info->s = "SMC37C78"; break; | |
| 2361 | ||
| 2362 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2363 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(smc37c78); break; | |
| 2364 | ||
| 2365 | default: DEVICE_GET_INFO_CALL(nec765a); break; | |
| 2366 | } | |
| 2367 | } | |
| 2368 | ||
| 2369 | DEVICE_GET_INFO( nec72065 ) | |
| 2370 | { | |
| 2371 | switch (state) | |
| 2372 | { | |
| 2373 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2374 | case DEVINFO_STR_NAME: info->s = "NEC72065"; break; | |
| 2375 | ||
| 2376 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2377 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(nec72065); break; | |
| 2378 | ||
| 2379 | default: DEVICE_GET_INFO_CALL(nec765a); break; | |
| 2380 | } | |
| 2381 | } |
| r3867 | r3868 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | #include "devices/flopdrv.h" |
| 13 | 13 | |
| 14 | /*************************************************************************** | |
| 15 | MACROS | |
| 16 | ***************************************************************************/ | |
| 14 | 17 | |
| 15 | /* supported versions */ | |
| 16 | typedef enum | |
| 17 | { | |
| 18 | NEC765A = 0, | |
| 19 | NEC765B = 1, | |
| 20 | SMC37C78 = 2, | |
| 21 | NEC72065 = 3 | |
| 22 | } NEC765_VERSION; | |
| 18 | #define NEC765A DEVICE_GET_INFO_NAME(nec765a) | |
| 19 | #define NEC765B DEVICE_GET_INFO_NAME(nec765b) | |
| 20 | #define SMC37C78 DEVICE_GET_INFO_NAME(smc37c78) | |
| 21 | #define NEC72065 DEVICE_GET_INFO_NAME(nec72065) | |
| 23 | 22 | |
| 23 | /*************************************************************************** | |
| 24 | TYPE DEFINITIONS | |
| 25 | ***************************************************************************/ | |
| 26 | ||
| 24 | 27 | /* RDY pin connected state */ |
| 25 | 28 | typedef enum |
| 26 | 29 | { |
| r3867 | r3868 | |
| 31 | 34 | #define NEC765_DAM_DELETED_DATA 0x0f8 |
| 32 | 35 | #define NEC765_DAM_DATA 0x0fb |
| 33 | 36 | |
| 37 | typedef void (*nec765_interrupt_func)(const device_config *device, int state); | |
| 38 | #define NEC765_INTERRUPT(name) void name(const device_config *device, int state ) | |
| 39 | ||
| 40 | typedef void (*nec765_dma_drq_func)(const device_config *device, int state,int read_write); | |
| 41 | #define NEC765_DMA_REQUEST(name) void name(const device_config *device, int state,int read_write ) | |
| 42 | ||
| 43 | typedef const device_config *(*nec765_get_image_func)(const device_config *device, int floppy_index); | |
| 44 | #define NEC765_GET_IMAGE(name) const device_config *name(const device_config *device, int floppy_index ) | |
| 45 | ||
| 46 | ||
| 34 | 47 | typedef struct nec765_interface |
| 35 | 48 | { |
| 36 | 49 | /* interrupt issued */ |
| 37 | | |
| 50 | nec765_i | |
| 38 | 51 | |
| 39 | 52 | /* dma data request */ |
| 40 | | |
| 53 | nec765_d | |
| 41 | 54 | |
| 42 | 55 | /* image lookup */ |
| 43 | const device_config *(*get_image)(running_machine *machine,int floppy_index); | |
| 56 | nec765_get_image_func get_image; | |
| 57 | ||
| 58 | NEC765_RDY_PIN rdy_pin; | |
| 44 | 59 | } nec765_interface; |
| 45 | 60 | |
| 46 | /* init nec765 interface */ | |
| 47 | void nec765_init(running_machine *machine, const nec765_interface *iface, NEC765_VERSION version, NEC765_RDY_PIN rdy_pin); | |
| 48 | /* set nec765 terminal count input state */ | |
| 49 | void nec765_set_tc_state(running_machine *machine, int); | |
| 50 | /* set nec765 ready input*/ | |
| 51 | void nec765_set_ready_state(int); | |
| 52 | 61 | |
| 53 | void nec765_idle(void); | |
| 62 | /*************************************************************************** | |
| 63 | FUNCTION PROTOTYPES | |
| 64 | ***************************************************************************/ | |
| 54 | 65 | |
| 66 | /* device interface */ | |
| 67 | DEVICE_GET_INFO( nec765a ); | |
| 68 | DEVICE_GET_INFO( nec765b ); | |
| 69 | DEVICE_GET_INFO( smc37c78 ); | |
| 70 | DEVICE_GET_INFO( nec72065 ); | |
| 71 | ||
| 55 | 72 | /* read of data register */ |
| 56 | READ8_HANDLER(nec765_data_r); | |
| 73 | READ8_DEVICE_HANDLER(nec765_data_r); | |
| 57 | 74 | /* write to data register */ |
| 58 | WRITE8_HANDLER(nec765_data_w); | |
| 75 | WRITE8_DEVICE_HANDLER(nec765_data_w); | |
| 59 | 76 | /* read of main status register */ |
| 60 | READ8_HANDLER(nec765_status_r); | |
| 77 | READ8_DEVICE_HANDLER(nec765_status_r); | |
| 61 | 78 | |
| 62 | 79 | /* dma acknowledge with write */ |
| 63 | WRITE8_HANDLER(nec765_dack_w); | |
| 80 | WRITE8_DEVICE_HANDLER(nec765_dack_w); | |
| 64 | 81 | /* dma acknowledge with read */ |
| 65 | READ8_HANDLER(nec765_dack_r); | |
| 82 | READ8_DEVICE_HANDLER(nec765_dack_r); | |
| 66 | 83 | |
| 67 | 84 | /* reset nec765 */ |
| 68 | void nec765_reset( | |
| 85 | void nec765_reset(const device_ | |
| 69 | 86 | |
| 70 | 87 | /* reset pin of nec765 */ |
| 71 | void nec765_set_reset_state( | |
| 88 | void nec765_set_reset_state(const device_ | |
| 72 | 89 | |
| 90 | /* set nec765 terminal count input state */ | |
| 91 | void nec765_set_tc_state(const device_config *device, int); | |
| 92 | /* set nec765 ready input*/ | |
| 93 | void nec765_set_ready_state(const device_config *device,int); | |
| 94 | ||
| 95 | void nec765_idle(const device_config *device); | |
| 96 | ||
| 73 | 97 | /*********************/ |
| 74 | 98 | /* STATUS REGISTER 1 */ |
| 75 | 99 | |
| r3867 | r3868 | |
| 91 | 115 | command, or FDC encounters a Data Mark when executing a read deleted data command */ |
| 92 | 116 | #define NEC765_ST2_CONTROL_MARK (1<<6) |
| 93 | 117 | |
| 118 | /*************************************************************************** | |
| 119 | DEVICE CONFIGURATION MACROS | |
| 120 | ***************************************************************************/ | |
| 121 | ||
| 122 | #define MDRV_NEC765A_ADD(_tag, _intrf) \ | |
| 123 | MDRV_DEVICE_ADD(_tag, NEC765A) \ | |
| 124 | MDRV_DEVICE_CONFIG(_intrf) | |
| 125 | ||
| 126 | #define MDRV_NEC765A_MODIFY(_tag, _intrf) \ | |
| 127 | MDRV_DEVICE_MODIFY(_tag, NEC765A) \ | |
| 128 | MDRV_DEVICE_CONFIG(_intrf) | |
| 129 | ||
| 130 | #define MDRV_NEC765A_REMOVE(_tag) \ | |
| 131 | MDRV_DEVICE_REMOVE(_tag, NEC765A) | |
| 132 | ||
| 133 | #define MDRV_NEC765B_ADD(_tag, _intrf) \ | |
| 134 | MDRV_DEVICE_ADD(_tag, NEC765B) \ | |
| 135 | MDRV_DEVICE_CONFIG(_intrf) | |
| 136 | ||
| 137 | #define MDRV_NEC765B_MODIFY(_tag, _intrf) \ | |
| 138 | MDRV_DEVICE_MODIFY(_tag, NEC765B) \ | |
| 139 | MDRV_DEVICE_CONFIG(_intrf) | |
| 140 | ||
| 141 | #define MDRV_NEC765B_REMOVE(_tag) \ | |
| 142 | MDRV_DEVICE_REMOVE(_tag, NEC765B) | |
| 143 | ||
| 144 | #define MDRV_SMC37C78_ADD(_tag, _intrf) \ | |
| 145 | MDRV_DEVICE_ADD(_tag, SMC37C78) \ | |
| 146 | MDRV_DEVICE_CONFIG(_intrf) | |
| 147 | ||
| 148 | #define MDRV_SMC37C78_MODIFY(_tag, _intrf) \ | |
| 149 | MDRV_DEVICE_MODIFY(_tag, SMC37C78) \ | |
| 150 | MDRV_DEVICE_CONFIG(_intrf) | |
| 151 | ||
| 152 | #define MDRV_SMC37C78_REMOVE(_tag) \ | |
| 153 | MDRV_DEVICE_REMOVE(_tag, SMC37C78) | |
| 154 | ||
| 155 | #define MDRV_NEC72065_ADD(_tag, _intrf) \ | |
| 156 | MDRV_DEVICE_ADD(_tag, NEC72065) \ | |
| 157 | MDRV_DEVICE_CONFIG(_intrf) | |
| 158 | ||
| 159 | #define MDRV_NEC72065_MODIFY(_tag, _intrf) \ | |
| 160 | MDRV_DEVICE_MODIFY(_tag, NEC72065) \ | |
| 161 | MDRV_DEVICE_CONFIG(_intrf) | |
| 162 | ||
| 163 | #define MDRV_NEC72065_REMOVE(_tag) \ | |
| 164 | MDRV_DEVICE_REMOVE(_tag, NEC72065) | |
| 165 | ||
| 94 | 166 | #endif /* NEC765_H */ |
| 95 | 167 | |
| 168 |
| r3867 | r3868 | |
|---|---|---|
| 566 | 566 | LC_FMMFM_mask = (1 << LC_FMMFM_bit) |
| 567 | 567 | }; |
| 568 | 568 | |
| 569 | static void fdc_callback(running_machine *machine, wd17xx_state_t event, void *param); | |
| 570 | 569 | |
| 571 | 570 | static READ8_HANDLER(concept_fdc_reg_r); |
| 572 | 571 | static WRITE8_HANDLER(concept_fdc_reg_w); |
| r3867 | r3868 | |
| 577 | 576 | fdc_local_status = 0; |
| 578 | 577 | fdc_local_command = 0; |
| 579 | 578 | |
| 580 | wd17xx_init(machine, WD_TYPE_179X, fdc_callback, NULL); | |
| 581 | ||
| 582 | 579 | install_expansion_slot(slot, concept_fdc_reg_r, concept_fdc_reg_w, concept_fdc_rom_r, NULL); |
| 583 | 580 | } |
| 584 | 581 | |
| 585 | static | |
| 582 | static WD17XX_CALLBACK( fdc_callback | |
| 586 | 583 | { |
| 587 | switch ( | |
| 584 | switch (s | |
| 588 | 585 | { |
| 589 | 586 | case WD17XX_IRQ_CLR: |
| 590 | 587 | fdc_local_status &= ~LS_INT_mask; |
| r3867 | r3868 | |
| 601 | 598 | } |
| 602 | 599 | } |
| 603 | 600 | |
| 601 | const wd17xx_interface concept_wd17xx_interface = { fdc_callback, NULL }; | |
| 602 | ||
| 604 | 603 | static READ8_HANDLER(concept_fdc_reg_r) |
| 605 | 604 | { |
| 605 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 606 | 606 | switch (offset) |
| 607 | 607 | { |
| 608 | 608 | case 0: |
| r3867 | r3868 | |
| 612 | 612 | |
| 613 | 613 | case 8: |
| 614 | 614 | /* FDC STATUS REG */ |
| 615 | return wd17xx_status_r( | |
| 615 | return wd17xx_status_r(fd | |
| 616 | 616 | break; |
| 617 | 617 | |
| 618 | 618 | case 9: |
| 619 | 619 | /* FDC TRACK REG */ |
| 620 | return wd17xx_track_r( | |
| 620 | return wd17xx_track_r(fd | |
| 621 | 621 | break; |
| 622 | 622 | |
| 623 | 623 | case 10: |
| 624 | 624 | /* FDC SECTOR REG */ |
| 625 | return wd17xx_sector_r( | |
| 625 | return wd17xx_sector_r(fd | |
| 626 | 626 | break; |
| 627 | 627 | |
| 628 | 628 | case 11: |
| 629 | 629 | /* FDC DATA REG */ |
| 630 | return wd17xx_data_r( | |
| 630 | return wd17xx_data_r(fd | |
| 631 | 631 | break; |
| 632 | 632 | } |
| 633 | 633 | |
| r3867 | r3868 | |
| 637 | 637 | static WRITE8_HANDLER(concept_fdc_reg_w) |
| 638 | 638 | { |
| 639 | 639 | int current_drive; |
| 640 | ||
| 640 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 641 | 641 | switch (offset) |
| 642 | 642 | { |
| 643 | 643 | case 0: |
| 644 | 644 | /* local command reg */ |
| 645 | 645 | fdc_local_command = data; |
| 646 | 646 | |
| 647 | wd17xx_set_side((data & LC_FLPSD1_mask) != 0); | |
| 647 | wd17xx_set_side(fdc,(data & LC_FLPSD1_mask) != 0); | |
| 648 | 648 | current_drive = ((data >> LC_DE0_bit) & 1) | ((data >> (LC_DE1_bit-1)) & 2); |
| 649 | wd17xx_set_drive(current_drive); | |
| 649 | wd17xx_set_drive(fdc, current_drive); | |
| 650 | 650 | /*motor_on = (data & LC_MOTOROF_mask) == 0;*/ |
| 651 | 651 | // floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, current_drive), (data & LC_MOTOROF_mask) == 0 ? 1 : 0); |
| 652 | 652 | /*flp_8in = (data & LC_FLP8IN_mask) != 0;*/ |
| 653 | wd17xx_set_density((data & LC_FMMFM_mask) ? DEN_FM_LO : DEN_MFM_LO); | |
| 653 | wd17xx_set_density(fdc, (data & LC_FMMFM_mask) ? DEN_FM_LO : DEN_MFM_LO); | |
| 654 | 654 | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, current_drive), 1, 0); |
| 655 | 655 | break; |
| 656 | 656 | |
| 657 | 657 | case 8: |
| 658 | 658 | /* FDC COMMAMD REG */ |
| 659 | wd17xx_command_w( | |
| 659 | wd17xx_command_w(fd | |
| 660 | 660 | break; |
| 661 | 661 | |
| 662 | 662 | case 9: |
| 663 | 663 | /* FDC TRACK REG */ |
| 664 | wd17xx_track_w( | |
| 664 | wd17xx_track_w(fd | |
| 665 | 665 | break; |
| 666 | 666 | |
| 667 | 667 | case 10: |
| 668 | 668 | /* FDC SECTOR REG */ |
| 669 | wd17xx_sector_w( | |
| 669 | wd17xx_sector_w(fd | |
| 670 | 670 | break; |
| 671 | 671 | |
| 672 | 672 | case 11: |
| 673 | 673 | /* FDC DATA REG */ |
| 674 | wd17xx_data_w( | |
| 674 | wd17xx_data_w(fd | |
| 675 | 675 | break; |
| 676 | 676 | } |
| 677 | 677 | } |
| r3867 | r3868 | |
|---|---|---|
| 295 | 295 | msx_vdp_interrupt |
| 296 | 296 | }; |
| 297 | 297 | |
| 298 | static void msx_wd179x_int (running_machine *machine, wd17xx_state_t state, void *param); | |
| 299 | 298 | |
| 300 | 299 | MACHINE_START( msx ) |
| 301 | 300 | { |
| r3867 | r3868 | |
| 305 | 304 | |
| 306 | 305 | MACHINE_START( msx2 ) |
| 307 | 306 | { |
| 308 | wd17xx_init (machine, WD_TYPE_179X, msx_wd179x_int, NULL); | |
| 309 | wd17xx_set_density (DEN_FM_HI); | |
| 307 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 308 | wd17xx_set_density (fdc,DEN_FM_HI); | |
| 310 | 309 | msx1.dsk_stat = 0x7f; |
| 311 | 310 | } |
| 312 | 311 | |
| r3867 | r3868 | |
| 634 | 633 | |
| 635 | 634 | */ |
| 636 | 635 | |
| 637 | static | |
| 636 | static WD17XX_CALLBACK( msx_wd179x_int | |
| 638 | 637 | { |
| 639 | 638 | switch (state) |
| 640 | 639 | { |
| r3867 | r3868 | |
| 645 | 644 | } |
| 646 | 645 | } |
| 647 | 646 | |
| 647 | const wd17xx_interface msx_wd17xx_interface = { msx_wd179x_int, NULL }; | |
| 648 | 648 | |
| 649 | 649 | DEVICE_IMAGE_LOAD( msx_floppy ) |
| 650 | 650 | { |
| r3867 | r3868 | |
|---|---|---|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | static void cgenie_fdc_callback(running_machine *machine, wd17xx_state_t event, void *param); | |
| 97 | ||
| 98 | 96 | MACHINE_RESET( cgenie ) |
| 99 | 97 | { |
| 100 | 98 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| r3867 | r3868 | |
| 203 | 201 | memory_install_write8_handler(space, 0x4000, 0x4000 + mess_ram_size - 1, 0, 0, cgenie_videoram_w); |
| 204 | 202 | videoram = mess_ram; |
| 205 | 203 | memory_set_bankptr(machine, 1, mess_ram); |
| 206 | ||
| 207 | /* set up FDC */ | |
| 208 | wd17xx_init(machine, WD_TYPE_179X, cgenie_fdc_callback, NULL); | |
| 209 | 204 | } |
| 210 | 205 | |
| 211 | 206 | |
| r3867 | r3868 | |
| 481 | 476 | |
| 482 | 477 | READ8_HANDLER( cgenie_status_r ) |
| 483 | 478 | { |
| 479 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 484 | 480 | /* If the floppy isn't emulated, return 0 */ |
| 485 | 481 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 486 | 482 | return 0; |
| 487 | return wd17xx_status_r( | |
| 483 | return wd17xx_status_r(fd | |
| 488 | 484 | } |
| 489 | 485 | |
| 490 | 486 | READ8_HANDLER( cgenie_track_r ) |
| 491 | 487 | { |
| 488 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 492 | 489 | /* If the floppy isn't emulated, return 0xff */ |
| 493 | 490 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 494 | 491 | return 0xff; |
| 495 | return wd17xx_track_r( | |
| 492 | return wd17xx_track_r(fd | |
| 496 | 493 | } |
| 497 | 494 | |
| 498 | 495 | READ8_HANDLER( cgenie_sector_r ) |
| 499 | 496 | { |
| 497 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 500 | 498 | /* If the floppy isn't emulated, return 0xff */ |
| 501 | 499 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 502 | 500 | return 0xff; |
| 503 | return wd17xx_sector_r( | |
| 501 | return wd17xx_sector_r(fd | |
| 504 | 502 | } |
| 505 | 503 | |
| 506 | 504 | READ8_HANDLER(cgenie_data_r ) |
| 507 | 505 | { |
| 506 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 508 | 507 | /* If the floppy isn't emulated, return 0xff */ |
| 509 | 508 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 510 | 509 | return 0xff; |
| 511 | return wd17xx_data_r( | |
| 510 | return wd17xx_data_r(fd | |
| 512 | 511 | } |
| 513 | 512 | |
| 514 | 513 | WRITE8_HANDLER( cgenie_command_w ) |
| 515 | 514 | { |
| 515 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 516 | 516 | /* If the floppy isn't emulated, return immediately */ |
| 517 | 517 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 518 | 518 | return; |
| 519 | wd17xx_command_w( | |
| 519 | wd17xx_command_w(fd | |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | WRITE8_HANDLER( cgenie_track_w ) |
| 523 | 523 | { |
| 524 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 524 | 525 | /* If the floppy isn't emulated, ignore the write */ |
| 525 | 526 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 526 | 527 | return; |
| 527 | wd17xx_track_w( | |
| 528 | wd17xx_track_w(fd | |
| 528 | 529 | } |
| 529 | 530 | |
| 530 | 531 | WRITE8_HANDLER( cgenie_sector_w ) |
| 531 | 532 | { |
| 533 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 532 | 534 | /* If the floppy isn't emulated, ignore the write */ |
| 533 | 535 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 534 | 536 | return; |
| 535 | wd17xx_sector_w( | |
| 537 | wd17xx_sector_w(fd | |
| 536 | 538 | } |
| 537 | 539 | |
| 538 | 540 | WRITE8_HANDLER( cgenie_data_w ) |
| 539 | 541 | { |
| 542 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 540 | 543 | /* If the floppy isn't emulated, ignore the write */ |
| 541 | 544 | if( (input_port_read(space->machine, "DSW0") & 0x80) == 0 ) |
| 542 | 545 | return; |
| 543 | wd17xx_data_w( | |
| 546 | wd17xx_data_w(fd | |
| 544 | 547 | } |
| 545 | 548 | |
| 546 | 549 | READ8_HANDLER( cgenie_irq_status_r ) |
| r3867 | r3868 | |
| 560 | 563 | } |
| 561 | 564 | } |
| 562 | 565 | |
| 563 | ||
| 566 | static WD17XX_CALLBACK( cgenie_fdc_callback | |
| 564 | 567 | { |
| 565 | 568 | /* if disc hardware is not enabled, do not cause an int */ |
| 566 | if (!( input_port_read(machine, "DSW0") & 0x80 )) | |
| 569 | if (!( input_port_read(device->machine, "DSW0") & 0x80 )) | |
| 567 | 570 | return; |
| 568 | 571 | |
| 569 | switch( | |
| 572 | switch( s | |
| 570 | 573 | { |
| 571 | 574 | case WD17XX_IRQ_CLR: |
| 572 | 575 | irq_status &= ~IRQ_FDC; |
| r3867 | r3868 | |
| 575 | 578 | if( (irq_status & IRQ_FDC) == 0 ) |
| 576 | 579 | { |
| 577 | 580 | irq_status |= IRQ_FDC; |
| 578 | cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE); | |
| 581 | cpu_set_input_line(device->machine->cpu[0], 0, HOLD_LINE); | |
| 579 | 582 | } |
| 580 | 583 | break; |
| 581 | 584 | case WD17XX_DRQ_CLR: |
| r3867 | r3868 | |
| 585 | 588 | } |
| 586 | 589 | } |
| 587 | 590 | |
| 591 | const wd17xx_interface cgenie_wd17xx_interface = { cgenie_fdc_callback, NULL }; | |
| 592 | ||
| 588 | 593 | WRITE8_HANDLER( cgenie_motor_w ) |
| 589 | 594 | { |
| 595 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 590 | 596 | UINT8 drive = 255; |
| 591 | 597 | |
| 592 | 598 | logerror("cgenie motor_w $%02X\n", data); |
| r3867 | r3868 | |
| 609 | 615 | /* currently selected drive */ |
| 610 | 616 | motor_drive = drive; |
| 611 | 617 | |
| 612 | wd17xx_set_drive(drive); | |
| 613 | wd17xx_set_side(head); | |
| 618 | wd17xx_set_drive(fdc,drive); | |
| 619 | wd17xx_set_side(fdc,head); | |
| 614 | 620 | } |
| 615 | 621 | |
| 616 | 622 | /************************************* |
| r3867 | r3868 | |
|---|---|---|
| 35 | 35 | betadisk_status = 0; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | ||
| 38 | static WD17XX_CALLBACK( betadisk_wd179x_callback | |
| 39 | 39 | { |
| 40 | 40 | switch (state) |
| 41 | 41 | { |
| r3867 | r3868 | |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | const wd17xx_interface beta_wd17xx_interface = { betadisk_wd179x_callback, NULL }; | |
| 69 | ||
| 68 | 70 | READ8_HANDLER(betadisk_status_r) |
| 69 | 71 | { |
| 70 | 72 | if (betadisk_active==1) { |
| 71 | return wd17xx_status_r(space, offset); | |
| 73 | return wd17xx_status_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 72 | 74 | } else { |
| 73 | 75 | return 0xff; |
| 74 | 76 | } |
| r3867 | r3868 | |
| 77 | 79 | READ8_HANDLER(betadisk_track_r) |
| 78 | 80 | { |
| 79 | 81 | if (betadisk_active==1) { |
| 80 | return wd17xx_track_r(space, offset); | |
| 82 | return wd17xx_track_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 81 | 83 | } else { |
| 82 | 84 | return 0xff; |
| 83 | 85 | } |
| r3867 | r3868 | |
| 86 | 88 | READ8_HANDLER(betadisk_sector_r) |
| 87 | 89 | { |
| 88 | 90 | if (betadisk_active==1) { |
| 89 | return wd17xx_sector_r(space, offset); | |
| 91 | return wd17xx_sector_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 90 | 92 | } else { |
| 91 | 93 | return 0xff; |
| 92 | 94 | } |
| r3867 | r3868 | |
| 95 | 97 | READ8_HANDLER(betadisk_data_r) |
| 96 | 98 | { |
| 97 | 99 | if (betadisk_active==1) { |
| 98 | return wd17xx_data_r(space, offset); | |
| 100 | return wd17xx_data_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 99 | 101 | } else { |
| 100 | 102 | return 0xff; |
| 101 | 103 | } |
| r3867 | r3868 | |
| 112 | 114 | |
| 113 | 115 | WRITE8_HANDLER(betadisk_param_w) |
| 114 | 116 | { |
| 117 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 115 | 118 | if (betadisk_active==1) { |
| 116 | wd17xx_set_drive ( data & 3); | |
| 117 | wd17xx_set_side ((data & 0x10) ? 0 : 1 ); | |
| 118 | wd17xx_set_density(data & 0x20 ? DEN_MFM_HI : DEN_FM_LO ); | |
| 119 | wd17xx_set_drive(fdc, data & 3); | |
| 120 | wd17xx_set_side (fdc,(data & 0x10) ? 0 : 1 ); | |
| 121 | wd17xx_set_density(fdc, data & 0x20 ? DEN_MFM_HI : DEN_FM_LO ); | |
| 119 | 122 | if ((data & 0x04) == 0) // reset |
| 120 | 123 | { |
| 121 | wd17xx_reset( | |
| 124 | wd17xx_reset(fd | |
| 122 | 125 | } |
| 123 | 126 | betadisk_status = (data & 0x3f) | betadisk_status; |
| 124 | 127 | } |
| r3867 | r3868 | |
| 127 | 130 | WRITE8_HANDLER(betadisk_command_w) |
| 128 | 131 | { |
| 129 | 132 | if (betadisk_active==1) { |
| 130 | wd17xx_command_w(space, offset, data); | |
| 133 | wd17xx_command_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset, data); | |
| 131 | 134 | } |
| 132 | 135 | } |
| 133 | 136 | |
| 134 | 137 | WRITE8_HANDLER(betadisk_track_w) |
| 135 | 138 | { |
| 136 | 139 | if (betadisk_active==1) { |
| 137 | wd17xx_track_w(space, offset, data); | |
| 140 | wd17xx_track_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset, data); | |
| 138 | 141 | } |
| 139 | 142 | } |
| 140 | 143 | |
| 141 | 144 | WRITE8_HANDLER(betadisk_sector_w) |
| 142 | 145 | { |
| 143 | 146 | if (betadisk_active==1) { |
| 144 | wd17xx_sector_w(space, offset, data); | |
| 147 | wd17xx_sector_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset, data); | |
| 145 | 148 | } |
| 146 | 149 | } |
| 147 | 150 | |
| 148 | 151 | WRITE8_HANDLER(betadisk_data_w) |
| 149 | 152 | { |
| 150 | 153 | if (betadisk_active==1) { |
| 151 | wd17xx_data_w(space, offset, data); | |
| 154 | wd17xx_data_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset, data); | |
| 152 | 155 | } |
| 153 | 156 | } |
| 154 | 157 |
| r3867 | r3868 | |
|---|---|---|
| 16 | 16 | void betadisk_enable(void); |
| 17 | 17 | void betadisk_disable(void); |
| 18 | 18 | void betadisk_clear_status(void); |
| 19 | void betadisk_wd179x_callback(running_machine *machine, wd17xx_state_t state, void *param); | |
| 20 | 19 | |
| 20 | extern const wd17xx_interface beta_wd17xx_interface; | |
| 21 | ||
| 21 | 22 | READ8_HANDLER(betadisk_status_r); |
| 22 | 23 | READ8_HANDLER(betadisk_track_r); |
| 23 | 24 | READ8_HANDLER(betadisk_sector_r); |
| r3867 | r3868 | |
|---|---|---|
| 795 | 795 | |
| 796 | 796 | READ8_HANDLER(pc8801fd_nec765_tc) |
| 797 | 797 | { |
| 798 | nec765_set_tc_state(space->machine, 1); | |
| 799 | nec765_set_tc_state(space->machine, 0); | |
| 798 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 799 | nec765_set_tc_state(fdc, 1); | |
| 800 | nec765_set_tc_state(fdc, 0); | |
| 800 | 801 | return 0; |
| 801 | 802 | } |
| 802 | 803 | |
| 803 | 804 | /* callback for /INT output from FDC */ |
| 804 | static | |
| 805 | static NEC765_INTERRUPT( pc8801_fdc_interrupt | |
| 805 | 806 | { |
| 806 | cpu_set_input_line(machine->cpu[1], 0, state ? HOLD_LINE : CLEAR_LINE); | |
| 807 | cpu_set_input_line(device->machine->cpu[1], 0, state ? HOLD_LINE : CLEAR_LINE); | |
| 807 | 808 | } |
| 808 | 809 | |
| 809 | 810 | /* callback for /DRQ output from FDC */ |
| 810 | static | |
| 811 | static NEC765_DMA_REQUEST( pc8801_fdc_dma_drq | |
| 811 | 812 | { |
| 812 | 813 | } |
| 813 | 814 | |
| 814 | ||
| 815 | ||
| 815 | 816 | { |
| 816 | 817 | pc8801_fdc_interrupt, |
| 817 | pc8801_fdc_dma_drq | |
| 818 | pc8801_fdc_dma_drq, | |
| 819 | NULL, | |
| 820 | NEC765_RDY_PIN_CONNECTED | |
| 818 | 821 | }; |
| 819 | 822 | |
| 820 | 823 | static void pc8801_init_5fd(running_machine *machine) |
| r3867 | r3868 | |
| 824 | 827 | cpu_suspend(machine->cpu[1], SUSPEND_REASON_DISABLE, 1); |
| 825 | 828 | else |
| 826 | 829 | cpu_resume(machine->cpu[1], SUSPEND_REASON_DISABLE); |
| 827 | nec765_init(machine, &pc8801_fdc_interface,NEC765A,NEC765_RDY_PIN_CONNECTED); | |
| 828 | 830 | cpu_set_input_line_vector(machine->cpu[1],0,0); |
| 829 | 831 | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1); |
| 830 | 832 | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 1), 1); |
| r3867 | r3868 | |
|---|---|---|
| 28 | 28 | radio86_tape_value = 0x80; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | static | |
| 31 | static WD17XX_CALLBACK( partner_wd17xx_callback | |
| 32 | 32 | { |
| 33 | const device_config *dma8257 = device_list_find_by_tag(machine->config->devicelist, DMA8257, "dma8257"); | |
| 33 | const device_config *dma8257 = device_list_find_by_tag(device->machine->config->devicelist, DMA8257, "dma8257"); | |
| 34 | 34 | switch(state) |
| 35 | 35 | { |
| 36 | 36 | case WD17XX_IRQ_CLR: |
| r3867 | r3868 | |
| 44 | 44 | break; |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | ||
| 48 | const wd17xx_interface partner_wd17xx_interface = { partner_wd17xx_callback, NULL }; | |
| 49 | ||
| 47 | 50 | MACHINE_START(partner) |
| 48 | 51 | { |
| 49 | wd17xx_init(machine, WD_TYPE_1793, partner_wd17xx_callback , NULL); | |
| 50 | wd17xx_set_density (DEN_MFM_HI); | |
| 51 | wd17xx_set_pause_time(10); | |
| 52 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"); | |
| 53 | wd17xx_set_density (fdc,DEN_MFM_HI); | |
| 54 | wd17xx_set_pause_time(fdc,10); | |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | 57 | DEVICE_IMAGE_LOAD( partner_floppy ) |
| r3867 | r3868 | |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | 110 | static READ8_HANDLER ( partner_floppy_r ) { |
| 111 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 112 | ||
| 108 | 113 | if (offset<0x100) { |
| 109 | 114 | switch(offset & 3) { |
| 110 | case 0x00 : return wd17xx_status_r(space,0); | |
| 111 | case 0x01 : return wd17xx_track_r(space,0); | |
| 112 | case 0x02 : return wd17xx_sector_r(space,0); | |
| 115 | case 0x00 : return wd17xx_status_r(fdc,0); | |
| 116 | case 0x01 : return wd17xx_track_r(fdc,0); | |
| 117 | case 0x02 : return wd17xx_sector_r(fdc,0); | |
| 113 | 118 | default : |
| 114 | return wd17xx_data_r( | |
| 119 | return wd17xx_data_r(fd | |
| 115 | 120 | } |
| 116 | 121 | } else { |
| 117 | 122 | return 0; |
| r3867 | r3868 | |
| 119 | 124 | } |
| 120 | 125 | |
| 121 | 126 | static WRITE8_HANDLER ( partner_floppy_w ) { |
| 127 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 128 | ||
| 122 | 129 | if (offset<0x100) { |
| 123 | 130 | switch(offset & 3) { |
| 124 | case 0x00 : wd17xx_command_w(space,0,data); break; | |
| 125 | case 0x01 : wd17xx_track_w(space,0,data);break; | |
| 126 | case 0x02 : wd17xx_sector_w(space,0,data);break; | |
| 127 | default : wd17xx_data_w(space,0,data);break; | |
| 131 | case 0x00 : wd17xx_command_w(fdc,0,data); break; | |
| 132 | case 0x01 : wd17xx_track_w(fdc,0,data);break; | |
| 133 | case 0x02 : wd17xx_sector_w(fdc,0,data);break; | |
| 134 | default : wd17xx_data_w(fdc,0,data);break; | |
| 128 | 135 | } |
| 129 | 136 | } else { |
| 130 | 137 | if (((data >> 6) & 1)==1) { |
| 131 | wd17xx_set_drive(0); | |
| 138 | wd17xx_set_drive(fdc,0); | |
| 132 | 139 | } |
| 133 | 140 | if (((data >> 3) & 1)==1) { |
| 134 | wd17xx_set_drive(1); | |
| 141 | wd17xx_set_drive(fdc,1); | |
| 135 | 142 | } |
| 136 | wd17xx_set_side(data >> 7); | |
| 143 | wd17xx_set_side(fdc,data >> 7); | |
| 137 | 144 | } |
| 138 | 145 | } |
| 139 | 146 | |
| r3867 | r3868 | |
| 376 | 383 | |
| 377 | 384 | static READ8_DEVICE_HANDLER ( partner_wd17xx_data_r ) |
| 378 | 385 | { |
| 379 | return wd17xx_data_r(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), offset); | |
| 386 | device_config *fdc = (device_config*)device_list_find_by_tag( device->machine->config->devicelist, WD1793, "wd1793"); | |
| 387 | return wd17xx_data_r(fdc, offset); | |
| 380 | 388 | } |
| 381 | 389 | |
| 382 | 390 | static WRITE8_DEVICE_HANDLER ( partner_wd17xx_data_w ) |
| 383 | 391 | { |
| 384 | wd17xx_data_w(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), offset, data); | |
| 392 | device_config *fdc = (device_config*)device_list_find_by_tag( device->machine->config->devicelist, WD1793, "wd1793"); | |
| 393 | wd17xx_data_w(fdc, offset, data); | |
| 385 | 394 | } |
| 386 | 395 | |
| 387 | 396 | const dma8257_interface partner_dma = |
| r3867 | r3868 | |
| 397 | 406 | { 0, 0, 0, 0 } |
| 398 | 407 | }; |
| 399 | 408 | |
| 400 | /* | |
| 401 | const dma8257_interface partner_dma = | |
| 402 | { | |
| 403 | 0, | |
| 404 | XTAL_16MHz / 9, | |
| 405 | 409 | |
| 406 | radio86_dma_read_byte, | |
| 407 | partner_dma_write_byte, | |
| 408 | ||
| 409 | { wd17xx_data_r, 0, 0, 0 }, | |
| 410 | { wd17xx_data_w, 0, radio86_write_video, 0 }, | |
| 411 | { 0, 0, 0, 0 } | |
| 412 | }; | |
| 413 | */ | |
| 414 | ||
| 415 | ||
| 416 | 410 | MACHINE_RESET( partner ) |
| 417 | 411 | { |
| 418 | 412 | partner_mem_page = 0; |
| 419 | 413 | partner_win_mem_page = 0; |
| 420 | 414 | partner_bank_switch(machine); |
| 421 | wd17xx_reset(machine); | |
| 422 | 415 | } |
| r3867 | r3868 | |
|---|---|---|
| 55 | 55 | /* Prototypes */ |
| 56 | 56 | |
| 57 | 57 | static TIMER_CALLBACK( watchdog_timeout ); |
| 58 | static void pc_fdc_hw_interrupt(running_machine *machine,int state); | |
| 59 | static void pc_fdc_hw_dma_drq(running_machine *machine,int,int); | |
| 60 | static const device_config *pc_fdc_get_image(running_machine *machine,int floppy_index); | |
| 61 | 58 | |
| 62 | static const nec765_interface pc_fdc_nec765_interface = | |
| 59 | static NEC765_INTERRUPT( pc_fdc_hw_interrupt ); | |
| 60 | static NEC765_DMA_REQUEST(pc_fdc_hw_dma_drq); | |
| 61 | static NEC765_GET_IMAGE ( pc_fdc_get_image); | |
| 62 | ||
| 63 | const nec765_interface pc_fdc_nec765_connected_interface = | |
| 63 | 64 | { |
| 64 | 65 | pc_fdc_hw_interrupt, |
| 65 | 66 | pc_fdc_hw_dma_drq, |
| 66 | pc_fdc_get_image | |
| 67 | pc_fdc_get_image, | |
| 68 | NEC765_RDY_PIN_CONNECTED | |
| 67 | 69 | }; |
| 68 | 70 | |
| 71 | const nec765_interface pc_fdc_nec765_not_connected_interface = | |
| 72 | { | |
| 73 | pc_fdc_hw_interrupt, | |
| 74 | pc_fdc_hw_dma_drq, | |
| 75 | pc_fdc_get_image, | |
| 76 | NEC765_RDY_PIN_NOT_CONNECTED | |
| 77 | }; | |
| 78 | ||
| 79 | static const device_config* pc_get_device(running_machine *machine) | |
| 80 | { | |
| 81 | return (*fdc->fdc_interface.get_device)(machine); | |
| 82 | } | |
| 83 | ||
| 69 | 84 | static void pc_fdc_reset(running_machine *machine) |
| 70 | 85 | { |
| 71 | 86 | /* setup reset condition */ |
| r3867 | r3868 | |
| 75 | 90 | /* bit 7 is disk change */ |
| 76 | 91 | fdc->digital_input_register = 0x07f; |
| 77 | 92 | |
| 78 | nec765_reset(machine, | |
| 93 | nec765_reset(pc_get_device(machine), | |
| 79 | 94 | |
| 80 | 95 | /* set FDC at reset */ |
| 81 | nec765_set_reset_state(machine, 1); | |
| 96 | nec765_set_reset_state(pc_get_device(machine), 1); | |
| 82 | 97 | } |
| 83 | 98 | |
| 84 | 99 | |
| r3867 | r3868 | |
| 97 | 112 | memcpy(&fdc->fdc_interface, iface, sizeof(fdc->fdc_interface)); |
| 98 | 113 | |
| 99 | 114 | /* setup nec765 interface */ |
| 100 | nec765_init(machine, &pc_fdc_nec765_interface, iface->nec765_type, iface->nec765_rdy_pin); | |
| 115 | //nec765_init(machine, &pc_fdc_nec765_interface, iface->nec765_type, iface->nec765_rdy_pin); | |
| 101 | 116 | |
| 102 | 117 | fdc->watchdog = timer_alloc(machine, watchdog_timeout, NULL ); |
| 103 | 118 | |
| r3867 | r3868 | |
| 112 | 127 | |
| 113 | 128 | |
| 114 | 129 | |
| 115 | static | |
| 130 | static NEC765 | |
| 116 | 131 | { |
| 117 | 132 | const device_config *image = NULL; |
| 118 | 133 | |
| 119 | 134 | if (!fdc->fdc_interface.get_image) |
| 120 | 135 | { |
| 121 | if (floppy_index < device_count(machine, IO_FLOPPY)) | |
| 136 | if (floppy_index < device_count(device->machine, IO_FLOPPY)) | |
| 122 | 137 | image = image_from_devtype_and_index(IO_FLOPPY, floppy_index); |
| 123 | 138 | } |
| 124 | 139 | else |
| r3867 | r3868 | |
| 138 | 153 | /* if dma is not enabled, tc's are not acknowledged */ |
| 139 | 154 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0) |
| 140 | 155 | { |
| 141 | nec765_set_tc_state(machine, state); | |
| 156 | nec765_set_tc_state(pc_get_device(machine), state); | |
| 142 | 157 | } |
| 143 | 158 | } |
| 144 | 159 | |
| 145 | 160 | |
| 146 | 161 | |
| 147 | ||
| 162 | static NEC765_INTERRUPT( pc_fdc_hw_interrupt | |
| 148 | 163 | { |
| 149 | 164 | fdc->int_state = state; |
| 150 | 165 | |
| r3867 | r3868 | |
| 154 | 169 | |
| 155 | 170 | /* send irq */ |
| 156 | 171 | if (fdc->fdc_interface.pc_fdc_interrupt) |
| 157 | fdc->fdc_interface.pc_fdc_interrupt(machine, state); | |
| 172 | fdc->fdc_interface.pc_fdc_interrupt(device->machine, state); | |
| 158 | 173 | } |
| 159 | 174 | |
| 160 | 175 | |
| r3867 | r3868 | |
| 169 | 184 | /* if dma is not enabled, dacks are not acknowledged */ |
| 170 | 185 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0) |
| 171 | 186 | { |
| 172 | data = nec765_dack_r( | |
| 187 | data = nec765_dack_r( | |
| 173 | 188 | } |
| 174 | 189 | |
| 175 | 190 | return data; |
| r3867 | r3868 | |
| 183 | 198 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0) |
| 184 | 199 | { |
| 185 | 200 | /* dma acknowledge - and send byte to fdc */ |
| 186 | nec765_dack_w( | |
| 201 | nec765_dack_w( | |
| 187 | 202 | } |
| 188 | 203 | } |
| 189 | 204 | |
| 190 | 205 | |
| 191 | 206 | |
| 192 | ||
| 207 | static NEC765_DMA_REQUEST( pc_fdc_hw_dma_drq | |
| 193 | 208 | { |
| 194 | 209 | fdc->dma_state = state; |
| 195 | fdc->dma_read = read_; | |
| 210 | fdc->dma_read = read_write; | |
| 196 | 211 | |
| 197 | 212 | /* if dma is not enabled, drqs are masked */ |
| 198 | 213 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)==0) |
| 199 | 214 | return; |
| 200 | 215 | |
| 201 | 216 | if (fdc->fdc_interface.pc_fdc_dma_drq) |
| 202 | fdc->fdc_interface.pc_fdc_dma_drq(machine,state, read_); | |
| 217 | fdc->fdc_interface.pc_fdc_dma_drq(device->machine,state, read_write); | |
| 203 | 218 | } |
| 204 | 219 | |
| 205 | 220 | |
| r3867 | r3868 | |
| 209 | 224 | if ((data & 0x080)!=0) |
| 210 | 225 | { |
| 211 | 226 | /* set ready state */ |
| 212 | nec765_set_ready_state(1); | |
| 227 | nec765_set_ready_state(pc_get_device(machine),1); | |
| 213 | 228 | |
| 214 | 229 | /* toggle reset state */ |
| 215 | nec765_set_reset_state(machine, 1); | |
| 216 | nec765_set_reset_state(machine, 0); | |
| 230 | nec765_set_reset_state(pc_get_device(machine), 1); | |
| 231 | nec765_set_reset_state(pc_get_device(machine), 0); | |
| 217 | 232 | |
| 218 | 233 | /* bit is self-clearing */ |
| 219 | 234 | data &= ~0x080; |
| r3867 | r3868 | |
| 274 | 289 | /* changing the DMA enable bit, will affect the dma drq state |
| 275 | 290 | from reaching us - if dma is enabled this will send it through |
| 276 | 291 | otherwise it will be ignored */ |
| 277 | pc_fdc_hw_dma_drq(machine, fdc->dma_state, fdc->dma_read); | |
| 292 | pc_fdc_hw_dma_drq(pc_get_device(machine), fdc->dma_state, fdc->dma_read); | |
| 278 | 293 | |
| 279 | 294 | /* changing the DMA enable bit, will affect the irq state |
| 280 | 295 | from reaching us - if dma is enabled this will send it through |
| 281 | 296 | otherwise it will be ignored */ |
| 282 | pc_fdc_hw_interrupt(machine, fdc->int_state); | |
| 297 | pc_fdc_hw_interrupt(pc_get_device(machine), fdc->int_state); | |
| 283 | 298 | |
| 284 | 299 | /* reset? */ |
| 285 | 300 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_FDC_ENABLED)==0) |
| r3867 | r3868 | |
| 302 | 317 | what is not yet clear is if this is a result of the drives ready state |
| 303 | 318 | changing... |
| 304 | 319 | */ |
| 305 | nec765_set_ready_state(1); | |
| 320 | nec765_set_ready_state(pc_get_device(machine),1); | |
| 306 | 321 | |
| 307 | 322 | /* set FDC at reset */ |
| 308 | nec765_set_reset_state(machine, 1); | |
| 323 | nec765_set_reset_state(pc_get_device(machine), 1); | |
| 309 | 324 | } |
| 310 | 325 | else |
| 311 | 326 | { |
| 312 | 327 | pc_fdc_set_tc_state(machine, 0); |
| 313 | 328 | |
| 314 | 329 | /* release reset on fdc */ |
| 315 | nec765_set_reset_state(machine, 0); | |
| 330 | nec765_set_reset_state(pc_get_device(machine), 0); | |
| 316 | 331 | } |
| 317 | 332 | } |
| 318 | 333 | |
| r3867 | r3868 | |
| 391 | 406 | what is not yet clear is if this is a result of the drives ready state |
| 392 | 407 | changing... |
| 393 | 408 | */ |
| 394 | nec765_set_ready_state(1); | |
| 409 | nec765_set_ready_state(pc_get_device(machine),1); | |
| 395 | 410 | |
| 396 | 411 | /* set FDC at reset */ |
| 397 | nec765_set_reset_state(machine, 1); | |
| 412 | nec765_set_reset_state(pc_get_device(machine), 1); | |
| 398 | 413 | } |
| 399 | 414 | else |
| 400 | 415 | { |
| 401 | 416 | pc_fdc_set_tc_state(machine, 0); |
| 402 | 417 | |
| 403 | 418 | /* release reset on fdc */ |
| 404 | nec765_set_reset_state(machine, 0); | |
| 419 | nec765_set_reset_state(pc_get_device(machine), 0); | |
| 405 | 420 | } |
| 406 | 421 | |
| 407 | 422 | logerror("pcjr_fdc_dor_w: changing dor from %02x to %02x\n", fdc->digital_output_register, data); |
| r3867 | r3868 | |
| 425 | 440 | case 3: /* tape drive select? */ |
| 426 | 441 | break; |
| 427 | 442 | case 4: |
| 428 | data = nec765_status_r(space, 0); | |
| 443 | data = nec765_status_r(pc_get_device(space->machine), 0); | |
| 429 | 444 | break; |
| 430 | 445 | case 5: |
| 431 | data = nec765_data_r(space, offset); | |
| 446 | data = nec765_data_r(pc_get_device(space->machine), offset); | |
| 432 | 447 | break; |
| 433 | 448 | case 6: /* FDC reserved */ |
| 434 | 449 | break; |
| r3867 | r3868 | |
| 464 | 479 | pc_fdc_data_rate_w(space->machine, data); |
| 465 | 480 | break; |
| 466 | 481 | case 5: |
| 467 | nec765_data_w(space, 0, data); | |
| 482 | nec765_data_w(pc_get_device(space->machine), 0, data); | |
| 468 | 483 | break; |
| 469 | 484 | case 6: |
| 470 | 485 | /* FDC reserved */ |
| r3867 | r3868 | |
|---|---|---|
| 25 | 25 | |
| 26 | 26 | /* main interface */ |
| 27 | 27 | struct pc_fdc_interface |
| 28 | { | |
| 29 | NEC765_VERSION nec765_type; | |
| 30 | NEC765_RDY_PIN nec765_rdy_pin; | |
| 28 | { | |
| 31 | 29 | void (*pc_fdc_interrupt)(running_machine*,int); |
| 32 | void (*pc_fdc_dma_drq)(running_machine*,int,int); | |
| 30 | void (*pc_fdc_dma_drq)(running_machine*,int,int); | |
| 33 | 31 | const device_config *(*get_image)(int floppy_index); |
| 32 | device_config *(*get_device)(running_machine*); | |
| 34 | 33 | }; |
| 35 | 34 | |
| 35 | extern const nec765_interface pc_fdc_nec765_connected_interface; | |
| 36 | extern const nec765_interface pc_fdc_nec765_not_connected_interface; | |
| 36 | 37 | |
| 37 | 38 | void pc_fdc_init(running_machine *machine, const struct pc_fdc_interface *iface); |
| 38 | 39 | void pc_fdc_set_tc_state(running_machine *machine, int state); |
| r3867 | r3868 | |
|---|---|---|
| 426 | 426 | return image_from_devtype_and_index(IO_FLOPPY, 0); |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | static device_config * bebox_get_device(running_machine *machine ) | |
| 430 | { | |
| 431 | return (device_config*)device_list_find_by_tag( machine->config->devicelist, SMC37C78, "smc37c78"); | |
| 432 | } | |
| 429 | 433 | |
| 434 | ||
| 430 | 435 | static const struct pc_fdc_interface bebox_fdc_interface = |
| 431 | 436 | { |
| 432 | SMC37C78, | |
| 433 | NEC765_RDY_PIN_CONNECTED, | |
| 434 | 437 | bebox_fdc_interrupt, |
| 435 | 438 | bebox_fdc_dma_drq, |
| 436 | bebox_fdc_get_image | |
| 439 | bebox_fdc_get_image, | |
| 440 | bebox_get_device | |
| 437 | 441 | }; |
| 438 | 442 | |
| 439 | 443 |
| r3867 | r3868 | |
|---|---|---|
| 246 | 246 | |
| 247 | 247 | MACHINE_START( specimx ) |
| 248 | 248 | { |
| 249 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 250 | wd17xx_set_density (DEN_FM_HI); | |
| 249 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1793, "wd1793"); | |
| 250 | wd17xx_set_density (fdc,DEN_FM_HI); | |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | static TIMER_CALLBACK( setup_pit8253_gates ) { |
| r3867 | r3868 | |
| 262 | 262 | { |
| 263 | 263 | specimx_set_bank(machine, 2,0x00); // Initiali load ROM disk |
| 264 | 264 | specimx_color = 0x70; |
| 265 | wd17xx_reset(machine); | |
| 266 | wd17xx_set_side(0); | |
| 267 | 265 | timer_set(machine, attotime_zero, NULL, 0, setup_pit8253_gates ); |
| 268 | 266 | } |
| 269 | 267 | |
| r3867 | r3868 | |
| 274 | 272 | |
| 275 | 273 | WRITE8_HANDLER( specimx_disk_ctrl_w ) |
| 276 | 274 | { |
| 275 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 277 | 276 | |
| 278 | 277 | switch(offset) { |
| 279 | 278 | case 2 : |
| 280 | wd17xx_set_side(data & 1); | |
| 279 | wd17xx_set_side(fdc,data & 1); | |
| 281 | 280 | break; |
| 282 | 281 | case 3 : |
| 283 | wd17xx_set_drive(data & 1); | |
| 282 | wd17xx_set_drive(fdc,data & 1); | |
| 284 | 283 | break; |
| 285 | 284 | |
| 286 | 285 | } |
| r3867 | r3868 | |
| 403 | 402 | erik_background = 0; |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | MACHINE_START( erik ) | |
| 407 | { | |
| 408 | wd17xx_init(machine, WD_TYPE_1793, NULL , NULL); | |
| 409 | } | |
| 410 | ||
| 411 | 405 | MACHINE_RESET( erik ) |
| 412 | 406 | { |
| 413 | wd17xx_reset(machine); | |
| 414 | ||
| 415 | 407 | RR_register = 0x00; |
| 416 | 408 | RC_register = 0x00; |
| 417 | 409 | erik_set_bank(machine); |
| r3867 | r3868 | |
| 446 | 438 | } |
| 447 | 439 | |
| 448 | 440 | WRITE8_HANDLER( erik_disk_reg_w ) { |
| 449 | wd17xx_set_side (data & 1); | |
| 450 | wd17xx_set_drive((data >> 1) & 1); | |
| 441 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1793, "wd1793"); | |
| 442 | ||
| 443 | wd17xx_set_side (fdc,data & 1); | |
| 444 | wd17xx_set_drive(fdc,(data >> 1) & 1); | |
| 451 | 445 | if((data >>2) & 1) { |
| 452 | wd17xx_set_density (DEN_FM_LO); | |
| 446 | wd17xx_set_density (fdc,DEN_FM_LO); | |
| 453 | 447 | } else { |
| 454 | wd17xx_set_density (DEN_FM_HI); | |
| 448 | wd17xx_set_density (fdc,DEN_FM_HI); | |
| 455 | 449 | } |
| 456 | 450 | } |
| r3867 | r3868 | |
|---|---|---|
| 1072 | 1072 | dma8237_drq_write( pc_devices.dma8237, FDC_DMA, state); |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | static device_config * pc_get_device(running_machine *machine ) | |
| 1076 | { | |
| 1077 | return (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC765A, "nec765"); | |
| 1078 | } | |
| 1075 | 1079 | |
| 1076 | 1080 | static const struct pc_fdc_interface fdc_interface_nc = |
| 1077 | 1081 | { |
| 1078 | NEC765A, | |
| 1079 | NEC765_RDY_PIN_NOT_CONNECTED, | |
| 1080 | 1082 | pc_fdc_interrupt, |
| 1081 | 1083 | pc_fdc_dma_drq, |
| 1084 | NULL, | |
| 1085 | pc_get_device | |
| 1082 | 1086 | }; |
| 1083 | 1087 | |
| 1084 | 1088 | static void pc_set_irq_line(int irq, int state) { |
| r3867 | r3868 | |
|---|---|---|
| 1671 | 1671 | |
| 1672 | 1672 | static int bbc_1770_IntEnabled; |
| 1673 | 1673 | |
| 1674 | static | |
| 1674 | static WD17XX_CALLBACK( bbc_wd177x_callback | |
| 1675 | 1675 | { |
| 1676 | int state; | |
| 1676 | int bbc_state; | |
| 1677 | 1677 | /* wd177x_IRQ_SET and latch bit 4 (nmi_enable) are NAND'ED together |
| 1678 | 1678 | wd177x_DRQ_SET and latch bit 4 (nmi_enable) are NAND'ED together |
| 1679 | 1679 | the output of the above two NAND gates are then OR'ED together and sent to the 6502 NMI line. |
| r3867 | r3868 | |
| 1686 | 1686 | The nmi is edge triggered, and triggers on a +ve edge. |
| 1687 | 1687 | */ |
| 1688 | 1688 | |
| 1689 | logerror("callback $%02X\n", | |
| 1689 | logerror("callback $%02X\n", s | |
| 1690 | 1690 | |
| 1691 | 1691 | |
| 1692 | 1692 | /* update bbc_wd177x_drq_irq_state depending on event */ |
| 1693 | switch ( | |
| 1693 | switch (s | |
| 1694 | 1694 | { |
| 1695 | 1695 | case WD17XX_DRQ_SET: |
| 1696 | 1696 | { |
| r3867 | r3868 | |
| 1721 | 1721 | if (((bbc_wd177x_drq_irq_state & 3)!=0) && (bbc_1770_IntEnabled)) |
| 1722 | 1722 | { |
| 1723 | 1723 | /* int trigger */ |
| 1724 | state = 1; | |
| 1724 | bbc_state = 1; | |
| 1725 | 1725 | } |
| 1726 | 1726 | else |
| 1727 | 1727 | { |
| 1728 | 1728 | /* do not trigger int */ |
| 1729 | state = 0; | |
| 1729 | bbc_state = 0; | |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | 1732 | /* nmi is edge triggered, and triggers when the state goes from clear->set. |
| 1733 | 1733 | Here we are checking this transition before triggering the nmi */ |
| 1734 | if (state!=previous_wd177x_int_state) | |
| 1734 | if (bbc_state!=previous_wd177x_int_state) | |
| 1735 | 1735 | { |
| 1736 | if (state) | |
| 1736 | if (bbc_state) | |
| 1737 | 1737 | { |
| 1738 | 1738 | /* I'll pulse it because if I used hold-line I'm not sure |
| 1739 | 1739 | it would clear - to be checked */ |
| 1740 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI,PULSE_LINE); | |
| 1740 | cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI,PULSE_LINE); | |
| 1741 | 1741 | } |
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | previous_wd177x_int_state = state; | |
| 1744 | previous_wd177x_int_state = bbc_state; | |
| 1745 | 1745 | |
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | const wd17xx_interface bbc_wd17xx_interface = { | |
| 1749 | bbc_wd177x_callback, | |
| 1750 | NULL | |
| 1751 | }; | |
| 1752 | ||
| 1748 | 1753 | static WRITE8_HANDLER(bbc_wd177x_status_w) |
| 1749 | 1754 | { |
| 1755 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1750 | 1756 | drive_control = data; |
| 1751 | 1757 | |
| 1752 | 1758 | /* set drive */ |
| 1753 | if ((data>>0) & 0x01) wd17xx_set_drive(0); | |
| 1754 | if ((data>>1) & 0x01) wd17xx_set_drive(1); | |
| 1759 | if ((data>>0) & 0x01) wd17xx_set_drive(fdc,0); | |
| 1760 | if ((data>>1) & 0x01) wd17xx_set_drive(fdc,1); | |
| 1755 | 1761 | |
| 1756 | 1762 | /* set side */ |
| 1757 | wd17xx_set_side((data>>2) & 0x01); | |
| 1763 | wd17xx_set_side(fdc,(data>>2) & 0x01); | |
| 1758 | 1764 | |
| 1759 | 1765 | /* set density */ |
| 1760 | 1766 | if ((data>>3) & 0x01) |
| 1761 | 1767 | { |
| 1762 | 1768 | /* single density */ |
| 1763 | wd17xx_set_density(DEN_FM_HI); | |
| 1769 | wd17xx_set_density(fdc,DEN_FM_HI); | |
| 1764 | 1770 | } |
| 1765 | 1771 | else |
| 1766 | 1772 | { |
| 1767 | 1773 | /* double density */ |
| 1768 | wd17xx_set_density(DEN_MFM_LO); | |
| 1774 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 1769 | 1775 | } |
| 1770 | 1776 | |
| 1771 | 1777 | bbc_1770_IntEnabled=(((data>>4) & 0x01)==0); |
| r3867 | r3868 | |
| 1775 | 1781 | |
| 1776 | 1782 | |
| 1777 | 1783 | READ8_HANDLER ( bbc_wd1770_read ) |
| 1778 | { | |
| 1784 | { | |
| 1779 | 1785 | int retval=0xff; |
| 1786 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1780 | 1787 | switch (offset) |
| 1781 | 1788 | { |
| 1782 | 1789 | case 4: |
| 1783 | retval=wd17xx_status_r( | |
| 1790 | retval=wd17xx_status_r(fd | |
| 1784 | 1791 | break; |
| 1785 | 1792 | case 5: |
| 1786 | retval=wd17xx_track_r( | |
| 1793 | retval=wd17xx_track_r(fd | |
| 1787 | 1794 | break; |
| 1788 | 1795 | case 6: |
| 1789 | retval=wd17xx_sector_r( | |
| 1796 | retval=wd17xx_sector_r(fd | |
| 1790 | 1797 | break; |
| 1791 | 1798 | case 7: |
| 1792 | retval=wd17xx_data_r( | |
| 1799 | retval=wd17xx_data_r(fd | |
| 1793 | 1800 | break; |
| 1794 | 1801 | default: |
| 1795 | 1802 | break; |
| r3867 | r3868 | |
| 1801 | 1808 | |
| 1802 | 1809 | WRITE8_HANDLER ( bbc_wd1770_write ) |
| 1803 | 1810 | { |
| 1811 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1804 | 1812 | logerror("wd177x write: $%02X $%02X\n", offset,data); |
| 1805 | 1813 | switch (offset) |
| 1806 | 1814 | { |
| r3867 | r3868 | |
| 1808 | 1816 | bbc_wd177x_status_w(space, 0, data); |
| 1809 | 1817 | break; |
| 1810 | 1818 | case 4: |
| 1811 | wd17xx_command_w( | |
| 1819 | wd17xx_command_w(fd | |
| 1812 | 1820 | break; |
| 1813 | 1821 | case 5: |
| 1814 | wd17xx_track_w( | |
| 1822 | wd17xx_track_w(fd | |
| 1815 | 1823 | break; |
| 1816 | 1824 | case 6: |
| 1817 | wd17xx_sector_w( | |
| 1825 | wd17xx_sector_w(fd | |
| 1818 | 1826 | break; |
| 1819 | 1827 | case 7: |
| 1820 | wd17xx_data_w( | |
| 1828 | wd17xx_data_w(fd | |
| 1821 | 1829 | break; |
| 1822 | 1830 | default: |
| 1823 | 1831 | break; |
| r3867 | r3868 | |
| 1864 | 1872 | |
| 1865 | 1873 | static WRITE8_HANDLER( bbc_opus_status_w ) |
| 1866 | 1874 | { |
| 1875 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1867 | 1876 | drive_control = data; |
| 1868 | 1877 | |
| 1869 | 1878 | /* set drive */ |
| 1870 | if ((data>>1) & 0x01) wd17xx_set_drive(0); | |
| 1871 | if ((data>>2) & 0x01) wd17xx_set_drive(1); | |
| 1879 | if ((data>>1) & 0x01) wd17xx_set_drive(fdc,0); | |
| 1880 | if ((data>>2) & 0x01) wd17xx_set_drive(fdc,1); | |
| 1872 | 1881 | |
| 1873 | 1882 | /* set side */ |
| 1874 | wd17xx_set_side((data>>0) & 0x01); | |
| 1883 | wd17xx_set_side(fdc,(data>>0) & 0x01); | |
| 1875 | 1884 | |
| 1876 | 1885 | /* set density */ |
| 1877 | 1886 | if ((data>>5) & 0x01) |
| 1878 | 1887 | { |
| 1879 | 1888 | /* single density */ |
| 1880 | wd17xx_set_density(DEN_FM_HI); | |
| 1889 | wd17xx_set_density(fdc,DEN_FM_HI); | |
| 1881 | 1890 | } |
| 1882 | 1891 | else |
| 1883 | 1892 | { |
| 1884 | 1893 | /* double density */ |
| 1885 | wd17xx_set_density(DEN_MFM_LO); | |
| 1894 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 1886 | 1895 | } |
| 1887 | 1896 | |
| 1888 | 1897 | bbc_1770_IntEnabled=(data>>4) & 0x01; |
| r3867 | r3868 | |
| 1891 | 1900 | |
| 1892 | 1901 | READ8_HANDLER( bbc_opus_read ) |
| 1893 | 1902 | { |
| 1903 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1894 | 1904 | logerror("wd177x read: $%02X\n", offset); |
| 1895 | 1905 | |
| 1896 | 1906 | if (bbc_DFSType==6) |
| r3867 | r3868 | |
| 1900 | 1910 | switch (offset) |
| 1901 | 1911 | { |
| 1902 | 1912 | case 0xf8: |
| 1903 | return wd17xx_status_r( | |
| 1913 | return wd17xx_status_r(fd | |
| 1904 | 1914 | break; |
| 1905 | 1915 | case 0xf9: |
| 1906 | return wd17xx_track_r( | |
| 1916 | return wd17xx_track_r(fd | |
| 1907 | 1917 | break; |
| 1908 | 1918 | case 0xfa: |
| 1909 | return wd17xx_sector_r( | |
| 1919 | return wd17xx_sector_r(fd | |
| 1910 | 1920 | break; |
| 1911 | 1921 | case 0xfb: |
| 1912 | return wd17xx_data_r( | |
| 1922 | return wd17xx_data_r(fd | |
| 1913 | 1923 | break; |
| 1914 | 1924 | } |
| 1915 | 1925 | |
| r3867 | r3868 | |
| 1922 | 1932 | |
| 1923 | 1933 | WRITE8_HANDLER (bbc_opus_write) |
| 1924 | 1934 | { |
| 1935 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1925 | 1936 | logerror("wd177x write: $%02X $%02X\n", offset,data); |
| 1926 | 1937 | |
| 1927 | 1938 | if (bbc_DFSType==6) |
| r3867 | r3868 | |
| 1931 | 1942 | switch (offset) |
| 1932 | 1943 | { |
| 1933 | 1944 | case 0xf8: |
| 1934 | wd17xx_command_w( | |
| 1945 | wd17xx_command_w(fd | |
| 1935 | 1946 | break; |
| 1936 | 1947 | case 0xf9: |
| 1937 | wd17xx_track_w( | |
| 1948 | wd17xx_track_w(fd | |
| 1938 | 1949 | break; |
| 1939 | 1950 | case 0xfa: |
| 1940 | wd17xx_sector_w( | |
| 1951 | wd17xx_sector_w(fd | |
| 1941 | 1952 | break; |
| 1942 | 1953 | case 0xfb: |
| 1943 | wd17xx_data_w( | |
| 1954 | wd17xx_data_w(fd | |
| 1944 | 1955 | break; |
| 1945 | 1956 | case 0xfc: |
| 1946 | 1957 | bbc_opus_status_w(space, 0,data); |
| r3867 | r3868 | |
| 1967 | 1978 | READ8_HANDLER ( bbcm_wd1770_read ) |
| 1968 | 1979 | { |
| 1969 | 1980 | int retval=0xff; |
| 1981 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1970 | 1982 | switch (offset) |
| 1971 | 1983 | { |
| 1972 | 1984 | case 0: |
| 1973 | retval=wd17xx_status_r( | |
| 1985 | retval=wd17xx_status_r(fd | |
| 1974 | 1986 | break; |
| 1975 | 1987 | case 1: |
| 1976 | retval=wd17xx_track_r( | |
| 1988 | retval=wd17xx_track_r(fd | |
| 1977 | 1989 | break; |
| 1978 | 1990 | case 2: |
| 1979 | retval=wd17xx_sector_r( | |
| 1991 | retval=wd17xx_sector_r(fd | |
| 1980 | 1992 | break; |
| 1981 | 1993 | case 3: |
| 1982 | retval=wd17xx_data_r( | |
| 1994 | retval=wd17xx_data_r(fd | |
| 1983 | 1995 | break; |
| 1984 | 1996 | default: |
| 1985 | 1997 | break; |
| r3867 | r3868 | |
| 1990 | 2002 | |
| 1991 | 2003 | WRITE8_HANDLER ( bbcm_wd1770_write ) |
| 1992 | 2004 | { |
| 2005 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 1993 | 2006 | //logerror("wd177x write: $%02X $%02X\n", offset,data); |
| 1994 | 2007 | switch (offset) |
| 1995 | 2008 | { |
| 1996 | 2009 | case 0: |
| 1997 | wd17xx_command_w( | |
| 2010 | wd17xx_command_w(fd | |
| 1998 | 2011 | break; |
| 1999 | 2012 | case 1: |
| 2000 | wd17xx_track_w( | |
| 2013 | wd17xx_track_w(fd | |
| 2001 | 2014 | break; |
| 2002 | 2015 | case 2: |
| 2003 | wd17xx_sector_w( | |
| 2016 | wd17xx_sector_w(fd | |
| 2004 | 2017 | break; |
| 2005 | 2018 | case 3: |
| 2006 | wd17xx_data_w( | |
| 2019 | wd17xx_data_w(fd | |
| 2007 | 2020 | break; |
| 2008 | 2021 | default: |
| 2009 | 2022 | break; |
| r3867 | r3868 | |
| 2018 | 2031 | |
| 2019 | 2032 | WRITE8_HANDLER ( bbcm_wd1770l_write ) |
| 2020 | 2033 | { |
| 2034 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 2021 | 2035 | drive_control = data; |
| 2022 | 2036 | |
| 2023 | 2037 | /* set drive */ |
| 2024 | if ((data>>0) & 0x01) wd17xx_set_drive(0); | |
| 2025 | if ((data>>1) & 0x01) wd17xx_set_drive(1); | |
| 2038 | if ((data>>0) & 0x01) wd17xx_set_drive(fdc,0); | |
| 2039 | if ((data>>1) & 0x01) wd17xx_set_drive(fdc,1); | |
| 2026 | 2040 | |
| 2027 | 2041 | /* set side */ |
| 2028 | wd17xx_set_side((data>>4) & 0x01); | |
| 2042 | wd17xx_set_side(fdc,(data>>4) & 0x01); | |
| 2029 | 2043 | |
| 2030 | 2044 | /* set density */ |
| 2031 | 2045 | if ((data>>5) & 0x01) |
| 2032 | 2046 | { |
| 2033 | 2047 | /* single density */ |
| 2034 | wd17xx_set_density(DEN_FM_HI); | |
| 2048 | wd17xx_set_density(fdc,DEN_FM_HI); | |
| 2035 | 2049 | } |
| 2036 | 2050 | else |
| 2037 | 2051 | { |
| 2038 | 2052 | /* double density */ |
| 2039 | wd17xx_set_density(DEN_MFM_LO); | |
| 2053 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 2040 | 2054 | } |
| 2041 | 2055 | |
| 2042 | 2056 | // bbc_1770_IntEnabled=(((data>>4) & 0x01)==0); |
| r3867 | r3868 | |
| 2190 | 2204 | // break; |
| 2191 | 2205 | //case 4: case 5: case 6: |
| 2192 | 2206 | previous_wd177x_int_state=1; |
| 2193 | wd17xx_init(machine, WD_TYPE_177X,bbc_wd177x_callback, NULL); | |
| 2194 | 2207 | // break; |
| 2195 | 2208 | //} |
| 2196 | 2209 | } |
| r3867 | r3868 | |
| 2226 | 2239 | //case 0: case 1: case 2: case 3: |
| 2227 | 2240 | // break; |
| 2228 | 2241 | //case 4: case 5: case 6: |
| 2229 | wd17xx_reset(machine); | |
| 2230 | 2242 | // break; |
| 2231 | 2243 | //} |
| 2232 | 2244 | } |
| r3867 | r3868 | |
| 2240 | 2252 | |
| 2241 | 2253 | /* bank 6 is the paged ROMs from b000 to bfff */ |
| 2242 | 2254 | memory_configure_bank(machine, 6, 0, 16, memory_region(machine, "user1") + 0x3000, 1<<14); |
| 2243 | ||
| 2244 | wd17xx_init(machine, WD_TYPE_177X,bbc_wd177x_callback, NULL); | |
| 2245 | 2255 | } |
| 2246 | 2256 | |
| 2247 | 2257 | MACHINE_RESET( bbcbp ) |
| r3867 | r3868 | |
| 2256 | 2266 | |
| 2257 | 2267 | |
| 2258 | 2268 | previous_wd177x_int_state=1; |
| 2259 | wd17xx_reset(machine); | |
| 2260 | 2269 | } |
| 2261 | 2270 | |
| 2262 | 2271 | |
| r3867 | r3868 | |
| 2273 | 2282 | /* Set ROM/IO bank to point to rom */ |
| 2274 | 2283 | memory_set_bankptr( machine, 8, memory_region(machine, "user1")+0x43c00); |
| 2275 | 2284 | memory_install_read_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),0xFC00,0xFEFF,0,0,8); |
| 2276 | ||
| 2277 | wd17xx_init(machine, WD_TYPE_177X,bbc_wd177x_callback, NULL); | |
| 2278 | 2285 | } |
| 2279 | 2286 | |
| 2280 | 2287 | MACHINE_RESET( bbcm ) |
| r3867 | r3868 | |
| 2288 | 2295 | bbcb_IC32_initialise(); |
| 2289 | 2296 | |
| 2290 | 2297 | |
| 2291 | previous_wd177x_int_state=1; | |
| 2292 | wd17xx_reset(machine); | |
| 2298 | previous_wd177x_int_state=1; | |
| 2293 | 2299 | } |
| r3867 | r3868 | |
|---|---|---|
| 203 | 203 | |
| 204 | 204 | WRITE8_HANDLER(kc85_disc_hw_terminal_count_w) |
| 205 | 205 | { |
| 206 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 206 | 207 | logerror("kc85 disc hw tc w: %02x\n",data); |
| 207 | nec765_set_tc_state( | |
| 208 | nec765_set_tc_state(fd | |
| 208 | 209 | } |
| 209 | 210 | |
| 210 | 211 | |
| 211 | 212 | /* callback for /INT output from FDC */ |
| 212 | static | |
| 213 | static NEC765_INTERRUPT( kc85_fdc_interrupt | |
| 213 | 214 | { |
| 214 | 215 | kc85_disc_hw_input_gate &=~(1<<6); |
| 215 | 216 | if (state) |
| r3867 | r3868 | |
| 217 | 218 | } |
| 218 | 219 | |
| 219 | 220 | /* callback for /DRQ output from FDC */ |
| 220 | static | |
| 221 | static NEC765_DMA_REQUEST( kc85_fdc_dma_drq | |
| 221 | 222 | { |
| 222 | 223 | kc85_disc_hw_input_gate &=~(1<<7); |
| 223 | 224 | if (state) |
| 224 | 225 | kc85_disc_hw_input_gate |=(1<<7); |
| 225 | 226 | } |
| 226 | 227 | |
| 227 | ||
| 228 | ||
| 228 | 229 | { |
| 229 | 230 | kc85_fdc_interrupt, |
| 230 | kc85_fdc_dma_drq | |
| 231 | kc85_fdc_dma_drq, | |
| 232 | NULL, | |
| 233 | NEC765_RDY_PIN_CONNECTED | |
| 231 | 234 | }; |
| 232 | 235 | |
| 233 | 236 | static TIMER_CALLBACK(kc85_disk_reset_timer_callback) |
| r3867 | r3868 | |
| 240 | 243 | { |
| 241 | 244 | timer_set(machine, attotime_zero, NULL, 0, kc85_disk_reset_timer_callback); |
| 242 | 245 | |
| 243 | nec765_init(machine, &kc_fdc_interface,NEC765A,NEC765_RDY_PIN_CONNECTED); | |
| 244 | ||
| 245 | 246 | /* hold cpu at reset */ |
| 246 | 247 | cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, ASSERT_LINE); |
| 247 | 248 | } |
| r3867 | r3868 | |
|---|---|---|
| 57 | 57 | /* default RPM */ |
| 58 | 58 | pDrive->rpm = 300; |
| 59 | 59 | |
| 60 | pDrive->controller = NULL; | |
| 61 | ||
| 60 | 62 | floppy_drive_set_disk_image_interface(img, iface); |
| 61 | 63 | } |
| 62 | 64 | |
| r3867 | r3868 | |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | 85 | if (pDrive->index_pulse_callback) |
| 84 | pDrive->index_pulse_callback(img, pDrive->index); | |
| 86 | pDrive->index_pulse_callback(pDrive->controller, img, pDrive->index); | |
| 85 | 87 | } |
| 86 | 88 | |
| 87 | 89 | |
| r3867 | r3868 | |
| 95 | 97 | |
| 96 | 98 | |
| 97 | 99 | /* set the callback for the index pulse */ |
| 98 | void floppy_drive_set_index_pulse_callback(const device_config *img, void (*callback)(const device_config *image, int state)) | |
| 100 | void floppy_drive_set_index_pulse_callback(const device_config *img, void (*callback)(const device_config *controller,const device_config *image, int state)) | |
| 99 | 101 | { |
| 100 | 102 | struct floppy_drive *pDrive = get_drive(img); |
| 101 | 103 | pDrive->index_pulse_callback = callback; |
| 102 | 104 | } |
| 103 | 105 | |
| 104 | 106 | |
| 105 | void floppy_drive_set_ready_state_change_callback(const device_config *img, void (*callback)(const device_config *img, int state)) | |
| 107 | void floppy_drive_set_ready_state_change_callback(const device_config *img, void (*callback)(const device_config *controller,const device_config *img, int state)) | |
| 106 | 108 | { |
| 107 | 109 | struct floppy_drive *pDrive = get_drive(img); |
| 108 | 110 | pDrive->ready_state_change_callback = callback; |
| r3867 | r3868 | |
| 169 | 171 | { |
| 170 | 172 | /* trigger state change callback */ |
| 171 | 173 | if (drv->ready_state_change_callback) |
| 172 | drv->ready_state_change_callback(img, new_state); | |
| 174 | drv->ready_state_change_callback(drv->controller, img, new_state); | |
| 173 | 175 | } |
| 174 | 176 | } |
| 175 | 177 | } |
| r3867 | r3868 | |
| 510 | 512 | struct floppy_drive *drv = get_drive(img); |
| 511 | 513 | drv->rpm = rpm; |
| 512 | 514 | } |
| 515 | ||
| 516 | void floppy_drive_set_controller(const device_config *img, const device_config *controller) | |
| 517 | { | |
| 518 | struct floppy_drive *drv = get_drive(img); | |
| 519 | drv->controller = controller; | |
| 520 | } | |
| 521 |
| r3867 | r3868 | |
|---|---|---|
| 95 | 95 | /* index pulse timer */ |
| 96 | 96 | void *index_timer; |
| 97 | 97 | /* index pulse callback */ |
| 98 | void (*index_pulse_callback)(const device_config *image, int state); | |
| 98 | void (*index_pulse_callback)(const device_config *controller,const device_config *image, int state); | |
| 99 | 99 | /* rotation per minute => gives index pulse frequency */ |
| 100 | 100 | float rpm; |
| 101 | 101 | /* current index pulse value */ |
| 102 | 102 | int index; |
| 103 | 103 | |
| 104 | void (*ready_state_change_callback)(const device_config *img, int state); | |
| 104 | void (*ready_state_change_callback)(const device_config *controller,const device_config *img, int state); | |
| 105 | 105 | |
| 106 | 106 | unsigned char id_buffer[4]; |
| 107 | 107 | |
| 108 | 108 | int id_index; |
| 109 | 109 | chrn_id ids[32]; |
| 110 | 110 | |
| 111 | const device_config *controller; | |
| 112 | ||
| 111 | 113 | floppy_interface interface_; |
| 112 | 114 | }; |
| 113 | 115 | |
| 114 | 116 | /* a callback which will be executed if the ready state of the drive changes e.g. not ready->ready, ready->not ready */ |
| 115 | void floppy_drive_set_ready_state_change_callback(const device_config *img, void (*callback)(const device_config *img, int state)); | |
| 117 | void floppy_drive_set_ready_state_change_callback(const device_config *img, void (*callback)(const device_config *controller,const device_config *img, int state)); | |
| 116 | 118 | |
| 117 | 119 | /* floppy drive types */ |
| 118 | 120 | typedef enum |
| r3867 | r3868 | |
| 121 | 123 | FLOPPY_DRIVE_DS_80 |
| 122 | 124 | } floppy_type; |
| 123 | 125 | |
| 124 | void floppy_drive_set_index_pulse_callback(const device_config *img, void (*callback)(const device_config *image, int state)); | |
| 126 | void floppy_drive_set_index_pulse_callback(const device_config *img, void (*callback)(const device_config *controller,const device_config *image, int state)); | |
| 125 | 127 | |
| 126 | 128 | /* set flag state */ |
| 127 | 129 | int floppy_drive_get_flag_state(const device_config *img, int flag); |
| r3867 | r3868 | |
| 164 | 166 | */ |
| 165 | 167 | void floppy_drive_set_rpm(const device_config *image, float rpm); |
| 166 | 168 | |
| 167 | ||
| 169 | void floppy_drive_set_controller(const device_config *img, const device_config *controller); | |
| 168 | 170 | #endif /* FLOPDRV_H */ |
| r3867 | r3868 | |
|---|---|---|
| 109 | 109 | fdc_callback - callback from the FDC |
| 110 | 110 | -------------------------------------------------*/ |
| 111 | 111 | |
| 112 | static | |
| 112 | static WD17XX_CALLBACK( fdc_callback | |
| 113 | 113 | { |
| 114 | 114 | coco_cartridge *cartridge = (coco_cartridge *) param; |
| 115 | 115 | fdc_info *info = fdc_get_info(cartridge); |
| r3867 | r3868 | |
| 136 | 136 | (*info->update_lines)(cartridge); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | extern coco_cartridge *coco_cart; | |
| 139 | 140 | |
| 141 | static WD17XX_PARAM_CALLBACK( get_coco_cart ) | |
| 142 | { | |
| 143 | return coco_cart; | |
| 144 | } | |
| 140 | 145 | |
| 146 | const wd17xx_interface dragon_wd17xx_interface = { | |
| 147 | fdc_callback, | |
| 148 | get_coco_cart | |
| 149 | }; | |
| 150 | const wd17xx_interface coco_wd17xx_interface = { | |
| 151 | fdc_callback, | |
| 152 | get_coco_cart | |
| 153 | }; | |
| 154 | ||
| 155 | ||
| 141 | 156 | /*------------------------------------------------- |
| 142 | 157 | fdc_init - general function to initialize FDC |
| 143 | 158 | -------------------------------------------------*/ |
| 144 | 159 | |
| 145 | 160 | static void fdc_init(running_machine *machine, |
| 146 | 161 | coco_cartridge *cartridge, |
| 147 | wd17xx_type_t type, | |
| 148 | 162 | void (*update_lines)(coco_cartridge *cartridge), |
| 149 | 163 | int initial_drq) |
| 150 | 164 | { |
| r3867 | r3868 | |
| 156 | 170 | info->drq = initial_drq ? 1 : 0; |
| 157 | 171 | |
| 158 | 172 | /* initialize FDC */ |
| 159 | wd17xx_init(machine, type, fdc_callback, (void *) cartridge); | |
| 173 | // wd17xx_init(machine, type, fdc_callback, (void *) cartridge); | |
| 160 | 174 | } |
| 161 | 175 | |
| 162 | 176 | |
| r3867 | r3868 | |
| 216 | 230 | |
| 217 | 231 | static void fdc_coco_init(coco_cartridge *cartridge) |
| 218 | 232 | { |
| 219 | fdc_init(Machine, cartridge, | |
| 233 | fdc_init(Machine, cartridge, | |
| 220 | 234 | } |
| 221 | 235 | |
| 222 | 236 | |
| r3867 | r3868 | |
| 228 | 242 | |
| 229 | 243 | static void fdc_coco_dskreg_w(coco_cartridge *cartridge, UINT8 data) |
| 230 | 244 | { |
| 245 | running_machine *machine = Machine; | |
| 246 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1773, "wd1773"); | |
| 231 | 247 | fdc_info *info = fdc_get_info(cartridge); |
| 232 | 248 | UINT8 drive = 0; |
| 233 | 249 | UINT8 head = 0; |
| r3867 | r3868 | |
| 272 | 288 | |
| 273 | 289 | (*info->update_lines)(cartridge); |
| 274 | 290 | |
| 275 | wd17xx_set_drive(drive); | |
| 276 | wd17xx_set_side(head); | |
| 277 | wd17xx_set_density((info->dskreg & 0x20) ? DEN_MFM_LO : DEN_FM_LO); | |
| 291 | wd17xx_set_drive(fdc,drive); | |
| 292 | wd17xx_set_side(fdc,head); | |
| 293 | wd17xx_set_density(fdc,(info->dskreg & 0x20) ? DEN_MFM_LO : DEN_FM_LO); | |
| 278 | 294 | } |
| 279 | 295 | |
| 280 | 296 | |
| r3867 | r3868 | |
| 286 | 302 | static UINT8 fdc_coco_r(coco_cartridge *cartridge, UINT16 addr) |
| 287 | 303 | { |
| 288 | 304 | running_machine *machine = Machine; |
| 289 | | |
| 305 | | |
| 290 | 306 | UINT8 result = 0; |
| 291 | 307 | switch(addr & 0xEF) |
| 292 | 308 | { |
| 293 | 309 | case 8: |
| 294 | result = wd17xx_status_r( | |
| 310 | result = wd17xx_status_r(fd | |
| 295 | 311 | break; |
| 296 | 312 | case 9: |
| 297 | result = wd17xx_track_r( | |
| 313 | result = wd17xx_track_r(fd | |
| 298 | 314 | break; |
| 299 | 315 | case 10: |
| 300 | result = wd17xx_sector_r( | |
| 316 | result = wd17xx_sector_r(fd | |
| 301 | 317 | break; |
| 302 | 318 | case 11: |
| 303 | result = wd17xx_data_r( | |
| 319 | result = wd17xx_data_r(fd | |
| 304 | 320 | break; |
| 305 | 321 | } |
| 306 | 322 | return result; |
| r3867 | r3868 | |
| 315 | 331 | static void fdc_coco_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 316 | 332 | { |
| 317 | 333 | running_machine *machine = Machine; |
| 318 | | |
| 334 | | |
| 319 | 335 | switch(addr & 0xEF) |
| 320 | 336 | { |
| 321 | 337 | case 0: case 1: case 2: case 3: |
| r3867 | r3868 | |
| 323 | 339 | fdc_coco_dskreg_w(cartridge, data); |
| 324 | 340 | break; |
| 325 | 341 | case 8: |
| 326 | wd17xx_command_w( | |
| 342 | wd17xx_command_w(fd | |
| 327 | 343 | break; |
| 328 | 344 | case 9: |
| 329 | wd17xx_track_w( | |
| 345 | wd17xx_track_w(fd | |
| 330 | 346 | break; |
| 331 | 347 | case 10: |
| 332 | wd17xx_sector_w( | |
| 348 | wd17xx_sector_w(fd | |
| 333 | 349 | break; |
| 334 | 350 | case 11: |
| 335 | wd17xx_data_w( | |
| 351 | wd17xx_data_w(fd | |
| 336 | 352 | break; |
| 337 | 353 | }; |
| 338 | 354 | } |
| r3867 | r3868 | |
| 540 | 556 | |
| 541 | 557 | static void fdc_dragon_init(coco_cartridge *cartridge) |
| 542 | 558 | { |
| 543 | fdc_init(Machine, cartridge, | |
| 559 | fdc_init(Machine, cartridge, | |
| 544 | 560 | } |
| 545 | 561 | |
| 546 | 562 | |
| r3867 | r3868 | |
| 552 | 568 | |
| 553 | 569 | static void fdc_dragon_dskreg_w(coco_cartridge *cartridge, UINT8 data) |
| 554 | 570 | { |
| 571 | running_machine *machine = Machine; | |
| 572 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 555 | 573 | fdc_info *info = fdc_get_info(cartridge); |
| 556 | 574 | |
| 557 | 575 | if (LOG_FDC) |
| r3867 | r3868 | |
| 569 | 587 | } |
| 570 | 588 | |
| 571 | 589 | if (data & 0x04) |
| 572 | wd17xx_set_drive(data & 0x03); | |
| 590 | wd17xx_set_drive(fdc,data & 0x03); | |
| 573 | 591 | |
| 574 | wd17xx_set_density((data & 0x08) ? DEN_FM_LO: DEN_MFM_LO); | |
| 592 | wd17xx_set_density(fdc,(data & 0x08) ? DEN_FM_LO: DEN_MFM_LO); | |
| 575 | 593 | info->dskreg = data; |
| 576 | 594 | } |
| 577 | 595 | |
| r3867 | r3868 | |
| 584 | 602 | static UINT8 fdc_dragon_r(coco_cartridge *cartridge, UINT16 addr) |
| 585 | 603 | { |
| 586 | 604 | running_machine *machine = Machine; |
| 587 | | |
| 605 | | |
| 588 | 606 | UINT8 result = 0; |
| 589 | 607 | switch(addr & 0xEF) |
| 590 | 608 | { |
| 591 | 609 | case 0: |
| 592 | result = wd17xx_status_r( | |
| 610 | result = wd17xx_status_r(fd | |
| 593 | 611 | break; |
| 594 | 612 | case 1: |
| 595 | result = wd17xx_track_r( | |
| 613 | result = wd17xx_track_r(fd | |
| 596 | 614 | break; |
| 597 | 615 | case 2: |
| 598 | result = wd17xx_sector_r( | |
| 616 | result = wd17xx_sector_r(fd | |
| 599 | 617 | break; |
| 600 | 618 | case 3: |
| 601 | result = wd17xx_data_r( | |
| 619 | result = wd17xx_data_r(fd | |
| 602 | 620 | break; |
| 603 | 621 | } |
| 604 | 622 | return result; |
| r3867 | r3868 | |
| 613 | 631 | static void fdc_dragon_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 614 | 632 | { |
| 615 | 633 | running_machine *machine = Machine; |
| 616 | | |
| 634 | | |
| 617 | 635 | switch(addr & 0xEF) |
| 618 | 636 | { |
| 619 | 637 | case 0: |
| 620 | wd17xx_command_w( | |
| 638 | wd17xx_command_w(fd | |
| 621 | 639 | |
| 622 | 640 | /* disk head is encoded in the command byte */ |
| 623 | 641 | /* Only for type 3 & 4 commands */ |
| 624 | 642 | if (data & 0x80) |
| 625 | wd17xx_set_side((data & 0x02) ? 1 : 0); | |
| 643 | wd17xx_set_side(fdc,(data & 0x02) ? 1 : 0); | |
| 626 | 644 | break; |
| 627 | 645 | case 1: |
| 628 | wd17xx_track_w( | |
| 646 | wd17xx_track_w(fd | |
| 629 | 647 | break; |
| 630 | 648 | case 2: |
| 631 | wd17xx_sector_w( | |
| 649 | wd17xx_sector_w(fd | |
| 632 | 650 | break; |
| 633 | 651 | case 3: |
| 634 | wd17xx_data_w( | |
| 652 | wd17xx_data_w(fd | |
| 635 | 653 | break; |
| 636 | 654 | case 8: case 9: case 10: case 11: |
| 637 | 655 | case 12: case 13: case 14: case 15: |
| r3867 | r3868 | |
|---|---|---|
| 270 | 270 | |
| 271 | 271 | static READ8_HANDLER ( to7_5p14_r ) |
| 272 | 272 | { |
| 273 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD2793, "wd2793"); | |
| 274 | ||
| 273 | 275 | if ( offset < 4 ) |
| 274 | return wd17xx_r( | |
| 276 | return wd17xx_r( fd | |
| 275 | 277 | else if ( offset == 8 ) |
| 276 | 278 | return to7_5p14_select; |
| 277 | 279 | else |
| r3867 | r3868 | |
| 283 | 285 | |
| 284 | 286 | static WRITE8_HANDLER( to7_5p14_w ) |
| 285 | 287 | { |
| 288 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD2793, "wd2793"); | |
| 286 | 289 | if ( offset < 4 ) |
| 287 | wd17xx_w( | |
| 290 | wd17xx_w( fd | |
| 288 | 291 | else if ( offset == 8 ) |
| 289 | 292 | { |
| 290 | 293 | /* drive select */ |
| r3867 | r3868 | |
| 304 | 307 | |
| 305 | 308 | dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO; |
| 306 | 309 | thom_floppy_set_density( dens ); |
| 307 | wd17xx_set_density( dens ); | |
| 310 | wd17xx_set_density( fdc, dens ); | |
| 308 | 311 | |
| 309 | 312 | to7_5p14_select = data; |
| 310 | 313 | |
| 311 | 314 | if ( drive != -1 ) |
| 312 | 315 | { |
| 313 | 316 | thom_floppy_active( space->machine, 0 ); |
| 314 | wd17xx_set_drive( drive ); | |
| 315 | wd17xx_set_side( side ); | |
| 317 | wd17xx_set_drive( fdc, drive ); | |
| 318 | wd17xx_set_side( fdc, side ); | |
| 316 | 319 | LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n", |
| 317 | 320 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), |
| 318 | 321 | data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" )); |
| r3867 | r3868 | |
| 328 | 331 | static void to7_5p14_reset( running_machine *machine ) |
| 329 | 332 | { |
| 330 | 333 | int i; |
| 334 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD2793, "wd2793"); | |
| 331 | 335 | LOG(( "to7_5p14_reset: CD 90-640 controller\n" )); |
| 332 | 336 | thom_floppy_set_density( DEN_MFM_LO ); |
| 333 | wd17xx_reset( | |
| 337 | wd17xx_reset(fdc | |
| 334 | 338 | for ( i = 0; i < device_count( machine, IO_FLOPPY ); i++ ) |
| 335 | 339 | { |
| 336 | 340 | const device_config * img = image_from_devtype_and_index( IO_FLOPPY, i ); |
| r3867 | r3868 | |
| 345 | 349 | static void to7_5p14_init( running_machine *machine ) |
| 346 | 350 | { |
| 347 | 351 | LOG(( "to7_5p14_init: CD 90-640 controller\n" )); |
| 348 | wd17xx_init( machine, WD_TYPE_2793, NULL, NULL ); | |
| 349 | 352 | state_save_register_global( machine, to7_5p14_select ); |
| 350 | 353 | } |
| 351 | 354 | |
| r3867 | r3868 | |
| 424 | 427 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 425 | 428 | } |
| 426 | 429 | |
| 427 | static void to7_5p14_index_pulse_callback( const device_config *device, int | |
| 430 | static void to7_5p14_index_pulse_callback( const device_config *controller,const device_config *image, int | |
| 428 | 431 | { |
| 429 | mc6843_set_index_pulse( devtag_get_device( | |
| 432 | mc6843_set_index_pulse( devtag_get_device( | |
| 430 | 433 | } |
| 431 | 434 | |
| 432 | 435 | static void to7_5p14sd_reset( running_machine *machine ) |
| r3867 | r3868 | |
| 525 | 528 | |
| 526 | 529 | |
| 527 | 530 | |
| 528 | static void to7_qdd_index_pulse_cb ( const device_config* img, int state ) | |
| 531 | static void to7_qdd_index_pulse_cb ( const device_config *controller,const device_config *image, int state ) | |
| 529 | 532 | { |
| 530 | 533 | to7qdd->index_pulse = state; |
| 531 | 534 | |
| r3867 | r3868 | |
| 537 | 540 | to7qdd->data_size = 0; |
| 538 | 541 | } |
| 539 | 542 | |
| 540 | VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(img->machine)), state )); | |
| 543 | VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(image->machine)), state )); | |
| 541 | 544 | } |
| 542 | 545 | |
| 543 | 546 | |
| r3867 | r3868 | |
| 954 | 957 | |
| 955 | 958 | |
| 956 | 959 | |
| 957 | static void thmfc_floppy_index_pulse_cb ( const device_config *img, int state ) | |
| 960 | static void thmfc_floppy_index_pulse_cb ( const device_config *controller,const device_config *image, int state ) | |
| 958 | 961 | { |
| 959 | if ( img != thmfc_floppy_image() ) | |
| 962 | if ( image != thmfc_floppy_image() ) | |
| 960 | 963 | return; |
| 961 | 964 | |
| 962 | 965 | if ( thmfc_floppy_is_qdd() ) |
| 963 | 966 | { |
| 964 | 967 | /* pulse each time the whole-disk spiraling track ends */ |
| 965 | floppy_drive_set_rpm( img, 16.92f /* 423/25 */ ); | |
| 968 | floppy_drive_set_rpm( image, 16.92f /* 423/25 */ ); | |
| 966 | 969 | thmfc1->ipl = state; |
| 967 | 970 | if ( state ) |
| 968 | 971 | { |
| r3867 | r3868 | |
| 973 | 976 | } |
| 974 | 977 | else |
| 975 | 978 | { |
| 976 | floppy_drive_set_rpm( img, 300. ); | |
| 979 | floppy_drive_set_rpm( image, 300. ); | |
| 977 | 980 | thmfc1->ipl = state; |
| 978 | 981 | if ( state ) |
| 979 | 982 | thmfc1->data_raw_idx = 0; |
| 980 | 983 | } |
| 981 | 984 | |
| 982 | VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(img->machine)), state )); | |
| 985 | VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(image->machine)), state )); | |
| 983 | 986 | } |
| 984 | 987 | |
| 985 | 988 |
| r3867 | r3868 | |
|---|---|---|
| 338 | 338 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 339 | 339 | |
| 340 | 340 | MDRV_VIDEO_UPDATE( dgnbeta ) |
| 341 | ||
| 342 | MDRV_WD179X_ADD("wd179x", dgnbeta_wd17xx_interface ) | |
| 341 | 343 | MACHINE_DRIVER_END |
| 342 | 344 | |
| 343 | 345 | ROM_START(dgnbeta) |
| r3867 | r3868 | |
|---|---|---|
| 1322 | 1322 | }; |
| 1323 | 1323 | |
| 1324 | 1324 | |
| 1325 | static | |
| 1325 | static NEC765_INTERRUPT( nc200_fdc_interrupt | |
| 1326 | 1326 | { |
| 1327 | 1327 | #if 0 |
| 1328 | 1328 | nc_irq_latch &=~(1<<5); |
| r3867 | r3868 | |
| 1339 | 1339 | nc_irq_status |=(1<<5); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | nc_update_interrupts(machine); | |
| 1342 | nc_update_interrupts(device->machine); | |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | static const | |
| 1345 | static const | |
| 1346 | 1346 | { |
| 1347 | 1347 | nc200_fdc_interrupt, |
| 1348 | 1348 | NULL, |
| 1349 | NULL, | |
| 1350 | NEC765_RDY_PIN_CONNECTED | |
| 1349 | 1351 | }; |
| 1350 | 1352 | |
| 1351 | 1353 | #ifdef UNUSED_FUNCTION |
| r3867 | r3868 | |
| 1369 | 1371 | |
| 1370 | 1372 | nc_common_init_machine(machine); |
| 1371 | 1373 | |
| 1372 | nec765_init(machine, &nc200_nec765_interface, NEC765A,NEC765_RDY_PIN_CONNECTED); | |
| 1373 | 1374 | /* double sided, 80 track drive */ |
| 1374 | 1375 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |
| 1375 | 1376 | //floppy_drive_set_index_pulse_callback(image_from_devtype_and_index(IO_FLOPPY, 0), nc200_floppy_drive_index_callback); |
| r3867 | r3868 | |
| 1519 | 1520 | |
| 1520 | 1521 | static WRITE8_HANDLER(nc200_memory_card_wait_state_w) |
| 1521 | 1522 | { |
| 1523 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 1522 | 1524 | LOG_DEBUG(("nc200 memory card wait state: PC: %04x %02x\n",cpu_get_pc(space->machine->cpu[0]),data)); |
| 1523 | 1525 | #if 0 |
| 1524 | 1526 | floppy_drive_set_motor_state(0,1); |
| 1525 | 1527 | floppy_drive_set_ready_state(0,1,1); |
| 1526 | 1528 | #endif |
| 1527 | nec765_set_tc_state( | |
| 1529 | nec765_set_tc_state(fd | |
| 1528 | 1530 | } |
| 1529 | 1531 | |
| 1530 | 1532 | /* bit 2: backlight: 1=off, 0=on */ |
| r3867 | r3868 | |
| 1554 | 1556 | AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE(MSM8251, "uart", msm8251_data_r, msm8251_data_w) |
| 1555 | 1557 | AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE(MSM8251, "uart", msm8251_status_r, msm8251_control_w) |
| 1556 | 1558 | AM_RANGE(0xd0, 0xd1) AM_READWRITE(mc146818_port_r, mc146818_port_w) |
| 1557 | AM_RANGE(0xe0, 0xe0) AM_READ(nec765_status_r) | |
| 1558 | AM_RANGE(0xe1, 0xe1) AM_READWRITE(nec765_data_r, nec765_data_w) | |
| 1559 | AM_RANGE(0xe0, 0xe0) AM_DEVREAD(NEC765A, "nec765", nec765_status_r) | |
| 1560 | AM_RANGE(0xe1, 0xe1) AM_DEVREADWRITE(NEC765A, "nec765",nec765_data_r, nec765_data_w) | |
| 1559 | 1561 | ADDRESS_MAP_END |
| 1560 | 1562 | |
| 1561 | 1563 | static INPUT_PORTS_START(nc200) |
| r3867 | r3868 | |
| 1738 | 1740 | |
| 1739 | 1741 | /* no rtc */ |
| 1740 | 1742 | MDRV_DEVICE_REMOVE("rtc", TC8521) |
| 1743 | ||
| 1744 | MDRV_NEC765A_ADD("nec765", nc200_nec765_interface) | |
| 1741 | 1745 | MACHINE_DRIVER_END |
| 1742 | 1746 | |
| 1743 | 1747 |
| r3867 | r3868 | |
|---|---|---|
| 131 | 131 | |
| 132 | 132 | static WRITE8_HANDLER(fd5_tc_w) |
| 133 | 133 | { |
| 134 | nec765_set_tc_state(space->machine, 1); | |
| 135 | nec765_set_tc_state(space->machine, 0); | |
| 134 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 135 | nec765_set_tc_state(fdc, 1); | |
| 136 | nec765_set_tc_state(fdc, 0); | |
| 136 | 137 | } |
| 137 | 138 | |
| 138 | 139 | /* 0x020 fd5 writes to this port to communicate with m5 */ |
| r3867 | r3868 | |
| 141 | 142 | /* 0x040 */ |
| 142 | 143 | /* 0x050 */ |
| 143 | 144 | static ADDRESS_MAP_START(sord_fd5_io, ADDRESS_SPACE_IO, 8) |
| 144 | AM_RANGE(0x000, 0x000) AM_READ(nec765_status_r) | |
| 145 | AM_RANGE(0x001, 0x001) AM_READWRITE(nec765_data_r, nec765_data_w) | |
| 145 | AM_RANGE(0x000, 0x000) AM_DEVREAD( NEC765A, "nec765", nec765_status_r) | |
| 146 | AM_RANGE(0x001, 0x001) AM_DEVREADWRITE( NEC765A, "nec765", nec765_data_r, nec765_data_w) | |
| 146 | 147 | AM_RANGE(0x010, 0x010) AM_READWRITE(fd5_data_r, fd5_data_w) |
| 147 | 148 | AM_RANGE(0x020, 0x020) AM_WRITE(fd5_communication_w) |
| 148 | 149 | AM_RANGE(0x030, 0x030) AM_READ(fd5_communication_r) |
| r3867 | r3868 | |
| 151 | 152 | ADDRESS_MAP_END |
| 152 | 153 | |
| 153 | 154 | /* nec765 data request is connected to interrupt of z80 inside fd5 interface */ |
| 154 | static | |
| 155 | static NEC765_INTERRUPT( sord_fd5_fdc_interrupt | |
| 155 | 156 | { |
| 156 | 157 | if (state) |
| 157 | 158 | { |
| 158 | cpu_set_input_line(machine->cpu[1], 0, HOLD_LINE); | |
| 159 | cpu_set_input_line(device->machine->cpu[1], 0, HOLD_LINE); | |
| 159 | 160 | } |
| 160 | 161 | else |
| 161 | 162 | { |
| 162 | cpu_set_input_line(machine->cpu[1], 0,CLEAR_LINE); | |
| 163 | cpu_set_input_line(device->machine->cpu[1], 0,CLEAR_LINE); | |
| 163 | 164 | } |
| 164 | 165 | } |
| 165 | 166 | |
| 166 | 167 | static const struct nec765_interface sord_fd5_nec765_interface= |
| 167 | 168 | { |
| 168 | 169 | sord_fd5_fdc_interrupt, |
| 169 | NULL | |
| 170 | NULL, | |
| 171 | NULL, | |
| 172 | NEC765_RDY_PIN_CONNECTED | |
| 170 | 173 | }; |
| 171 | 174 | |
| 172 | static void sord_fd5_init(running_machine *machine) | |
| 173 | { | |
| 174 | nec765_init(machine, &sord_fd5_nec765_interface,NEC765A,NEC765_RDY_PIN_CONNECTED); | |
| 175 | } | |
| 176 | ||
| 177 | 175 | static MACHINE_RESET( sord_m5_fd5 ) |
| 178 | 176 | { |
| 179 | 177 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 180 | 178 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 181 | sord_fd5_init(machine); | |
| 182 | 179 | MACHINE_RESET_CALL(sord_m5); |
| 183 | 180 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 184 | 181 | } |
| r3867 | r3868 | |
| 652 | 649 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 653 | 650 | |
| 654 | 651 | MDRV_CASSETTE_ADD( "cassette", sordm5_cassette_config ) |
| 652 | ||
| 655 | 653 | MACHINE_DRIVER_END |
| 656 | 654 | |
| 657 | 655 | |
| r3867 | r3868 | |
| 667 | 665 | |
| 668 | 666 | MDRV_INTERLEAVE(20) |
| 669 | 667 | MDRV_MACHINE_RESET( sord_m5_fd5 ) |
| 668 | ||
| 669 | MDRV_NEC765A_ADD("nec765", sord_fd5_nec765_interface) | |
| 670 | 670 | MACHINE_DRIVER_END |
| 671 | 671 | |
| 672 | 672 |
| r3867 | r3868 | |
|---|---|---|
| 115 | 115 | AM_RANGE(0x0b, 0x0b) AM_MIRROR(0x10) AM_READWRITE(mbee_video_bank_r, mbee_video_bank_w) |
| 116 | 116 | AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x10) AM_READWRITE(m6545_status_r, m6545_index_w) |
| 117 | 117 | AM_RANGE(0x0d, 0x0d) AM_MIRROR(0x10) AM_READWRITE(m6545_data_r, m6545_data_w) |
| 118 | AM_RANGE(0x44, 0x44) AM_READWRITE(wd17xx_status_r, wd17xx_command_w) | |
| 119 | AM_RANGE(0x45, 0x45) AM_READWRITE(wd17xx_track_r, wd17xx_track_w) | |
| 120 | AM_RANGE(0x46, 0x46) AM_READWRITE(wd17xx_sector_r, wd17xx_sector_w) | |
| 121 | AM_RANGE(0x47, 0x47) AM_READWRITE(wd17xx_data_r, wd17xx_data_w) | |
| 118 | AM_RANGE(0x44, 0x44) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_status_r, wd17xx_command_w) | |
| 119 | AM_RANGE(0x45, 0x45) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_track_r, wd17xx_track_w) | |
| 120 | AM_RANGE(0x46, 0x46) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_sector_r, wd17xx_sector_w) | |
| 121 | AM_RANGE(0x47, 0x47) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_data_r, wd17xx_data_w) | |
| 122 | 122 | AM_RANGE(0x48, 0x48) AM_READWRITE(mbee_fdc_status_r, mbee_fdc_motor_w) |
| 123 | 123 | ADDRESS_MAP_END |
| 124 | 124 | |
| r3867 | r3868 | |
| 409 | 409 | MDRV_CPU_VBLANK_INT("main", mbee_interrupt) |
| 410 | 410 | |
| 411 | 411 | MDRV_MACHINE_RESET( mbee ) |
| 412 | MDRV_MACHINE_START( mbee ) | |
| 413 | 412 | |
| 414 | 413 | MDRV_Z80PIO_ADD( "z80pio", mbee_z80pio_intf ) |
| 415 | 414 | |
| r3867 | r3868 | |
| 438 | 437 | MDRV_Z80BIN_QUICKLOAD_ADD(mbee, 2) |
| 439 | 438 | |
| 440 | 439 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 440 | ||
| 441 | MDRV_WD179X_ADD("wd179x", mbee_wd17xx_interface ) | |
| 441 | 442 | MACHINE_DRIVER_END |
| 442 | 443 | |
| 443 | 444 |
| r3867 | r3868 | |
|---|---|---|
| 11 | 11 | #include "machine/wd17xx.h" |
| 12 | 12 | #include "machine/beta.h" |
| 13 | 13 | |
| 14 | static MACHINE_START( pentagon ) | |
| 15 | { | |
| 16 | wd17xx_init(machine, WD_TYPE_179X, betadisk_wd179x_callback, NULL); | |
| 17 | } | |
| 18 | 14 | |
| 19 | 15 | static int ROMSelection; |
| 20 | 16 | |
| r3867 | r3868 | |
| 111 | 107 | spectrum_128_port_7ffd_data = 0; |
| 112 | 108 | |
| 113 | 109 | pentagon_update_memory(machine); |
| 114 | ||
| 115 | wd17xx_reset(machine); | |
| 116 | 110 | } |
| 117 | 111 | |
| 118 | 112 | static MACHINE_DRIVER_START( pentagon ) |
| 119 | 113 | MDRV_IMPORT_FROM( spectrum_128 ) |
| 120 | 114 | MDRV_CPU_MODIFY("main") |
| 121 | 115 | MDRV_CPU_IO_MAP(pentagon_io, 0) |
| 122 | MDRV_MACHINE_START( pentagon ) | |
| 123 | 116 | MDRV_MACHINE_RESET( pentagon ) |
| 117 | ||
| 118 | MDRV_WD179X_ADD("wd179x", beta_wd17xx_interface ) | |
| 124 | 119 | MACHINE_DRIVER_END |
| 125 | 120 | |
| 126 | 121 |
| r3867 | r3868 | |
|---|---|---|
| 17 | 17 | #include "machine/6883sam.h" |
| 18 | 18 | #include "includes/coco.h" |
| 19 | 19 | #include "devices/basicdsk.h" |
| 20 | #include "machine/wd17xx.h" | |
| 20 | 21 | #include "machine/6551.h" |
| 21 | 22 | #include "formats/coco_dsk.h" |
| 22 | 23 | #include "formats/coco_cas.h" |
| r3867 | r3868 | |
| 667 | 668 | MDRV_SNAPSHOT_ADD(coco_pak, "pak", 0) |
| 668 | 669 | |
| 669 | 670 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 671 | ||
| 672 | MDRV_WD179X_ADD("wd179x", dragon_wd17xx_interface ) | |
| 670 | 673 | MACHINE_DRIVER_END |
| 671 | 674 | |
| 672 | 675 | static MACHINE_DRIVER_START( dragon64 ) |
| r3867 | r3868 | |
| 699 | 702 | |
| 700 | 703 | /* acia */ |
| 701 | 704 | MDRV_DEVICE_ADD("acia", ACIA6551) |
| 705 | ||
| 706 | MDRV_WD179X_ADD("wd179x", dragon_wd17xx_interface ) | |
| 702 | 707 | MACHINE_DRIVER_END |
| 703 | 708 | |
| 704 | 709 | static MACHINE_DRIVER_START( d64plus ) |
| r3867 | r3868 | |
| 731 | 736 | |
| 732 | 737 | /* acia */ |
| 733 | 738 | MDRV_DEVICE_ADD("acia", ACIA6551) |
| 739 | ||
| 740 | MDRV_WD179X_ADD("wd179x", dragon_wd17xx_interface ) | |
| 734 | 741 | MACHINE_DRIVER_END |
| 735 | 742 | |
| 736 | 743 | static MACHINE_DRIVER_START( dgnalpha ) |
| r3867 | r3868 | |
| 766 | 773 | |
| 767 | 774 | /* acia */ |
| 768 | 775 | MDRV_DEVICE_ADD("acia", ACIA6551) |
| 776 | ||
| 777 | MDRV_WD179X_ADD("wd179x", dgnalpha_wd17xx_interface ) | |
| 769 | 778 | MACHINE_DRIVER_END |
| 770 | 779 | |
| 771 | 780 | static MACHINE_DRIVER_START( tanodr64 ) |
| r3867 | r3868 | |
| 798 | 807 | |
| 799 | 808 | /* acia */ |
| 800 | 809 | MDRV_DEVICE_ADD("acia", ACIA6551) |
| 810 | ||
| 811 | MDRV_WD1773_ADD("wd1773", coco_wd17xx_interface ) | |
| 801 | 812 | MACHINE_DRIVER_END |
| 802 | 813 | |
| 803 | 814 | static MACHINE_DRIVER_START( coco ) |
| r3867 | r3868 | |
| 831 | 842 | |
| 832 | 843 | /* cassette */ |
| 833 | 844 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 845 | ||
| 846 | MDRV_WD1773_ADD("wd1773", coco_wd17xx_interface ) | |
| 834 | 847 | MACHINE_DRIVER_END |
| 835 | 848 | |
| 836 | 849 | static MACHINE_DRIVER_START( coco2 ) |
| r3867 | r3868 | |
| 864 | 877 | |
| 865 | 878 | /* cassette */ |
| 866 | 879 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 880 | ||
| 881 | MDRV_WD1773_ADD("wd1773", coco_wd17xx_interface ) | |
| 867 | 882 | MACHINE_DRIVER_END |
| 868 | 883 | |
| 869 | 884 | static MACHINE_DRIVER_START( coco2b ) |
| r3867 | r3868 | |
| 897 | 912 | |
| 898 | 913 | /* cassette */ |
| 899 | 914 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 915 | ||
| 916 | MDRV_WD1773_ADD("wd1773", coco_wd17xx_interface ) | |
| 900 | 917 | MACHINE_DRIVER_END |
| 901 | 918 | |
| 902 | 919 | static MACHINE_DRIVER_START( coco3 ) |
| r3867 | r3868 | |
|---|---|---|
| 34 | 34 | #include "formats/basicdsk.h" |
| 35 | 35 | #include "devices/harddriv.h" |
| 36 | 36 | #include "machine/mm58274c.h" |
| 37 | #include "machine/wd17xx.h" | |
| 37 | 38 | |
| 38 | 39 | static ADDRESS_MAP_START(concept_memmap, ADDRESS_SPACE_PROGRAM, 16) |
| 39 | 40 | AM_RANGE(0x000000, 0x000007) AM_ROM AM_REGION("main", 0x010000) /* boot ROM mirror */ |
| r3867 | r3868 | |
| 92 | 93 | |
| 93 | 94 | /* via */ |
| 94 | 95 | MDRV_VIA6522_ADD("via6522_0", 1022750, concept_via6522_intf) |
| 96 | ||
| 97 | MDRV_WD179X_ADD("wd179x", concept_wd17xx_interface ) | |
| 95 | 98 | MACHINE_DRIVER_END |
| 96 | 99 | |
| 97 | 100 |
| r3867 | r3868 | |
|---|---|---|
| 1202 | 1202 | pcw16_trigger_fdc_int(machine); |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | static device_config * pcw16_get_device(running_machine *machine ) | |
| 1206 | { | |
| 1207 | return (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC765A, "nec765"); | |
| 1208 | } | |
| 1209 | ||
| 1205 | 1210 | static const struct pc_fdc_interface pcw16_fdc_interface= |
| 1206 | 1211 | { |
| 1207 | NEC765A, | |
| 1208 | NEC765_RDY_PIN_CONNECTED, | |
| 1209 | 1212 | pcw16_fdc_interrupt, |
| 1210 | NULL | |
| 1213 | NULL, | |
| 1214 | NULL, | |
| 1215 | pcw16_get_device | |
| 1211 | 1216 | }; |
| 1212 | 1217 | |
| 1213 | 1218 | |
| r3867 | r3868 | |
| 1423 | 1428 | |
| 1424 | 1429 | /* printer */ |
| 1425 | 1430 | /* MDRV_DEVICE_ADD("printer", PRINTER) */ |
| 1431 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_connected_interface) | |
| 1426 | 1432 | MACHINE_DRIVER_END |
| 1427 | 1433 | |
| 1428 | 1434 |
| r3867 | r3868 | |
|---|---|---|
| 278 | 278 | #include "deprecat.h" |
| 279 | 279 | #include "machine/8255ppi.h" |
| 280 | 280 | #include "machine/tc8521.h" |
| 281 | #include "machine/wd17xx.h" | |
| 281 | 282 | #include "video/tms9928a.h" |
| 282 | 283 | #include "video/v9938.h" |
| 283 | 284 | #include "includes/msx_slot.h" |
| r3867 | r3868 | |
| 1065 | 1066 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1066 | 1067 | |
| 1067 | 1068 | MDRV_CASSETTE_ADD( "cassette", msx_cassette_config ) |
| 1069 | ||
| 1070 | MDRV_WD179X_ADD("wd179x", msx_wd17xx_interface ) | |
| 1068 | 1071 | MACHINE_DRIVER_END |
| 1069 | 1072 | |
| 1070 | 1073 | |
| r3867 | r3868 | |
| 1132 | 1135 | |
| 1133 | 1136 | /* real time clock */ |
| 1134 | 1137 | MDRV_DEVICE_ADD("rtc", TC8521) |
| 1138 | ||
| 1139 | MDRV_WD179X_ADD("wd179x", msx_wd17xx_interface ) | |
| 1135 | 1140 | MACHINE_DRIVER_END |
| 1136 | 1141 | |
| 1137 | 1142 |
| r3867 | r3868 | |
|---|---|---|
| 38 | 38 | AM_RANGE(0x14, 0x15) AM_DEVREADWRITE(PIC8259, "pic8259", pic8259_r, pic8259_w ) |
| 39 | 39 | AM_RANGE(0x18, 0x18) AM_DEVREADWRITE(MSM8251, "uart", msm8251_data_r,msm8251_data_w) |
| 40 | 40 | AM_RANGE(0x19, 0x19) AM_DEVREADWRITE(MSM8251, "uart", msm8251_status_r,msm8251_control_w) |
| 41 | AM_RANGE(0x1c, 0x1c) AM_READWRITE(wd17xx_status_r,wd17xx_command_w) | |
| 42 | AM_RANGE(0x1d, 0x1d) AM_READWRITE(wd17xx_track_r,wd17xx_track_w) | |
| 43 | AM_RANGE(0x1e, 0x1e) AM_READWRITE(wd17xx_sector_r,wd17xx_sector_w) | |
| 44 | AM_RANGE(0x1f, 0x1f) AM_READWRITE(wd17xx_data_r,wd17xx_data_w) | |
| 41 | AM_RANGE(0x1c, 0x1c) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_status_r,wd17xx_command_w) | |
| 42 | AM_RANGE(0x1d, 0x1d) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_track_r,wd17xx_track_w) | |
| 43 | AM_RANGE(0x1e, 0x1e) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_sector_r,wd17xx_sector_w) | |
| 44 | AM_RANGE(0x1f, 0x1f) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_data_r,wd17xx_data_w) | |
| 45 | 45 | ADDRESS_MAP_END |
| 46 | 46 | |
| 47 | 47 | static ADDRESS_MAP_START( b2m_rom_io, ADDRESS_SPACE_IO, 8 ) |
| r3867 | r3868 | |
| 205 | 205 | |
| 206 | 206 | /* uart */ |
| 207 | 207 | MDRV_DEVICE_ADD("uart", MSM8251) |
| 208 | ||
| 209 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 208 | 210 | MACHINE_DRIVER_END |
| 209 | 211 | |
| 210 | 212 | static MACHINE_DRIVER_START( b2mrom ) |
| r3867 | r3868 | |
| 254 | 256 | COMP( 1989, b2m, 0, 0, b2m, b2m, b2m, b2m, "BNPO", "Bashkiria-2M", GAME_NOT_WORKING) |
| 255 | 257 | COMP( 1989, b2mrom, b2m, 0, b2mrom, b2m, b2m, b2m, "BNPO", "Bashkiria-2M ROM-disk", GAME_NOT_WORKING) |
| 256 | 258 | |
| 259 |
| r3867 | r3868 | |
|---|---|---|
| 760 | 760 | /* modem */ |
| 761 | 761 | MDRV_DEVICE_ADD( "acia6850", ACIA6850 ) |
| 762 | 762 | MDRV_DEVICE_CONFIG( to7_modem ) |
| 763 | ||
| 763 | ||
| 764 | MDRV_WD2793_ADD("wd2793", default_wd17xx_interface ) | |
| 764 | 765 | MACHINE_DRIVER_END |
| 765 | 766 | |
| 766 | 767 | static MACHINE_DRIVER_START ( t9000 ) |
| r3867 | r3868 | |
|---|---|---|
| 432 | 432 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 433 | 433 | |
| 434 | 434 | MDRV_CASSETTE_ADD( "cassette", cgenie_cassette_config ) |
| 435 | ||
| 436 | MDRV_WD179X_ADD("wd179x", cgenie_wd17xx_interface ) | |
| 435 | 437 | MACHINE_DRIVER_END |
| 436 | 438 | |
| 437 | 439 | /*************************************************************************** |
| r3867 | r3868 | |
|---|---|---|
| 157 | 157 | #include "machine/wd17xx.h" |
| 158 | 158 | #include "machine/beta.h" |
| 159 | 159 | |
| 160 | static MACHINE_START( scorpion ) | |
| 161 | { | |
| 162 | wd17xx_init(machine, WD_TYPE_179X, betadisk_wd179x_callback, NULL); | |
| 163 | } | |
| 164 | ||
| 165 | 160 | /****************************************************************************************************/ |
| 166 | 161 | /* Zs Scorpion 256 */ |
| 167 | 162 | |
| r3867 | r3868 | |
| 319 | 314 | scorpion_256_port_1ffd_data = 0; |
| 320 | 315 | |
| 321 | 316 | scorpion_update_memory(machine); |
| 322 | ||
| 323 | wd17xx_reset(machine); | |
| 324 | ||
| 317 | ||
| 325 | 318 | timer_pulse(machine, ATTOTIME_IN_HZ(50), NULL, 0, nmi_check_callback); |
| 326 | 319 | } |
| 327 | 320 | |
| r3867 | r3868 | |
| 329 | 322 | MDRV_IMPORT_FROM( spectrum_128 ) |
| 330 | 323 | MDRV_CPU_MODIFY("main") |
| 331 | 324 | MDRV_CPU_IO_MAP(scorpion_io, 0) |
| 332 | MDRV_MACHINE_START( scorpion ) | |
| 333 | 325 | MDRV_MACHINE_RESET( scorpion ) |
| 326 | ||
| 327 | MDRV_WD179X_ADD("wd179x", beta_wd17xx_interface ) | |
| 334 | 328 | MACHINE_DRIVER_END |
| 335 | 329 | |
| 336 | 330 |
| r3867 | r3868 | |
|---|---|---|
| 170 | 170 | static const nec765_interface spectrum_plus3_nec765_interface = |
| 171 | 171 | { |
| 172 | 172 | NULL, |
| 173 | NULL | |
| 173 | NULL, | |
| 174 | NULL, | |
| 175 | NEC765_RDY_PIN_CONNECTED | |
| 174 | 176 | }; |
| 175 | 177 | |
| 176 | 178 | |
| r3867 | r3868 | |
| 185 | 187 | static WRITE8_HANDLER(spectrum_plus3_port_3ffd_w) |
| 186 | 188 | { |
| 187 | 189 | if (~input_port_read(space->machine, "CONFIG") & 0x20) |
| 188 | nec765_data_w(space, 0,data); | |
| 190 | nec765_data_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"), 0,data); | |
| 189 | 191 | } |
| 190 | 192 | |
| 191 | 193 | static READ8_HANDLER(spectrum_plus3_port_3ffd_r) |
| r3867 | r3868 | |
| 193 | 195 | if (input_port_read(space->machine, "CONFIG") & 0x20) |
| 194 | 196 | return 0xff; |
| 195 | 197 | else |
| 196 | return nec765_data_r(space, 0); | |
| 198 | return nec765_data_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"), 0); | |
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | |
| r3867 | r3868 | |
| 202 | 204 | if (input_port_read(space->machine, "CONFIG") & 0x20) |
| 203 | 205 | return 0xff; |
| 204 | 206 | else |
| 205 | return nec765_status_r(space, 0); | |
| 207 | return nec765_status_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"), 0); | |
| 206 | 208 | } |
| 207 | 209 | |
| 208 | 210 | |
| r3867 | r3868 | |
| 349 | 351 | { |
| 350 | 352 | memset(mess_ram,0,128*1024); |
| 351 | 353 | |
| 352 | nec765_init(machine, &spectrum_plus3_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED); | |
| 353 | ||
| 354 | 354 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 355 | 355 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 356 | 356 | |
| r3867 | r3868 | |
| 370 | 370 | MDRV_SCREEN_REFRESH_RATE(50.01) |
| 371 | 371 | |
| 372 | 372 | MDRV_MACHINE_RESET( spectrum_plus3 ) |
| 373 | ||
| 374 | MDRV_NEC765A_ADD("nec765", spectrum_plus3_nec765_interface) | |
| 373 | 375 | MACHINE_DRIVER_END |
| 374 | 376 | |
| 375 | 377 | /*************************************************************************** |
| r3867 | r3868 | |
|---|---|---|
| 727 | 727 | // NEC uPD72065 at 0xe94000 |
| 728 | 728 | static WRITE16_HANDLER( x68k_fdc_w ) |
| 729 | 729 | { |
| 730 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC72065, "nec72065"); | |
| 730 | 731 | unsigned int drive, x; |
| 731 | 732 | switch(offset) |
| 732 | 733 | { |
| 733 | 734 | case 0x00: |
| 734 | 735 | case 0x01: |
| 735 | nec765_data_w( | |
| 736 | nec765_data_w(fd | |
| 736 | 737 | break; |
| 737 | 738 | case 0x02: // drive option signal control |
| 738 | 739 | x = data & 0x0f; |
| r3867 | r3868 | |
| 801 | 802 | { |
| 802 | 803 | unsigned int ret; |
| 803 | 804 | int x; |
| 805 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC72065, "nec72065"); | |
| 806 | ||
| 804 | 807 | switch(offset) |
| 805 | 808 | { |
| 806 | 809 | case 0x00: |
| 807 | return nec765_status_r( | |
| 810 | return nec765_status_r(fd | |
| 808 | 811 | case 0x01: |
| 809 | return nec765_data_r( | |
| 812 | return nec765_data_r(fd | |
| 810 | 813 | case 0x02: |
| 811 | 814 | ret = 0x00; |
| 812 | 815 | for(x=0;x<4;x++) |
| r3867 | r3868 | |
| 833 | 836 | } |
| 834 | 837 | } |
| 835 | 838 | |
| 836 | static | |
| 839 | static NEC765_INTERRUPT( fdc_irq | |
| 837 | 840 | { |
| 838 | 841 | if((sys.ioc.irqstatus & 0x04) && state == ASSERT_LINE) |
| 839 | 842 | { |
| r3867 | r3868 | |
| 841 | 844 | sys.ioc.irqstatus |= 0x80; |
| 842 | 845 | current_irq_line = 1; |
| 843 | 846 | logerror("FDC: IRQ triggered\n"); |
| 844 | cpu_set_input_line_and_vector(machine->cpu[0],1,ASSERT_LINE,current_vector[1]); | |
| 847 | cpu_set_input_line_and_vector(device->machine->cpu[0],1,ASSERT_LINE,current_vector[1]); | |
| 845 | 848 | } |
| 846 | 849 | } |
| 847 | 850 | |
| 848 | 851 | static int x68k_fdc_read_byte(running_machine *machine,int addr) |
| 849 | 852 | { |
| 850 | 853 | int data = -1; |
| 854 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC72065, "nec72065"); | |
| 851 | 855 | |
| 852 | 856 | if(sys.fdc.drq_state != 0) |
| 853 | data = nec765_dack_r( | |
| 857 | data = nec765_dack_r(f | |
| 854 | 858 | // logerror("FDC: DACK reading\n"); |
| 855 | 859 | return data; |
| 856 | 860 | } |
| 857 | 861 | |
| 858 | 862 | static void x68k_fdc_write_byte(running_machine *machine,int addr, int data) |
| 859 | 863 | { |
| 860 | nec765_dack_w(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0, data); | |
| 864 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, NEC72065, "nec72065"); | |
| 865 | nec765_dack_w(fdc, 0, data); | |
| 861 | 866 | } |
| 862 | 867 | |
| 863 | static | |
| 868 | static NEC765_DMA_REQUEST ( fdc_drq | |
| 864 | 869 | { |
| 865 | 870 | sys.fdc.drq_state = state; |
| 866 | 871 | } |
| r3867 | r3868 | |
| 890 | 895 | |
| 891 | 896 | static WRITE8_HANDLER( x68k_ct_w ) |
| 892 | 897 | { |
| 898 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC72065, "nec72065"); | |
| 893 | 899 | // CT1 and CT2 bits from YM2151 port 0x1b |
| 894 | 900 | // CT1 - ADPCM clock - 0 = 8MHz, 1 = 4MHz |
| 895 | 901 | // CT2 - 1 = Set ready state of FDC |
| 896 | nec765_set_ready_state(data & 0x01); | |
| 902 | nec765_set_ready_state(fdc,data & 0x01); | |
| 897 | 903 | sys.adpcm.clock = data & 0x02; |
| 898 | 904 | x68k_set_adpcm(space->machine); |
| 899 | 905 | okim6258_set_clock(0, data & 0x02 ? 4000000 : 8000000); |
| r3867 | r3868 | |
| 1654 | 1660 | static const nec765_interface fdc_interface = |
| 1655 | 1661 | { |
| 1656 | 1662 | fdc_irq, |
| 1657 | fdc_drq | |
| 1663 | fdc_drq, | |
| 1664 | NULL, | |
| 1665 | NEC765_RDY_PIN_CONNECTED | |
| 1658 | 1666 | }; |
| 1659 | 1667 | |
| 1660 | 1668 | static const ym2151_interface x68k_ym2151_interface = |
| r3867 | r3868 | |
| 2008 | 2016 | sys.crtc.reg[7] = 552; // Vertical end |
| 2009 | 2017 | sys.crtc.reg[8] = 27; // Horizontal adjust |
| 2010 | 2018 | |
| 2011 | nec765_reset(machine, 0); | |
| 2012 | 2019 | mfp_init(); |
| 2013 | 2020 | |
| 2014 | 2021 | x68k_scanline = video_screen_get_vpos(machine->primary_screen);// = sys.crtc.reg[6]; // Vertical start |
| r3867 | r3868 | |
| 2069 | 2076 | |
| 2070 | 2077 | // start LED timer |
| 2071 | 2078 | timer_adjust_periodic(led_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(400)); |
| 2072 | ||
| 2073 | nec765_init(machine, &fdc_interface,NEC72065,NEC765_RDY_PIN_CONNECTED); | |
| 2074 | nec765_reset(machine, 0); | |
| 2075 | 2079 | } |
| 2076 | 2080 | |
| 2077 | 2081 | static DRIVER_INIT( x68000 ) |
| r3867 | r3868 | |
| 2172 | 2176 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.00) |
| 2173 | 2177 | |
| 2174 | 2178 | MDRV_NVRAM_HANDLER( generic_0fill ) |
| 2179 | ||
| 2180 | MDRV_NEC72065_ADD("nec72065", fdc_interface) | |
| 2175 | 2181 | MACHINE_DRIVER_END |
| 2176 | 2182 | |
| 2177 | ||
| 2178 | 2183 | static SYSTEM_CONFIG_START(x68000) |
| 2179 | 2184 | CONFIG_DEVICE(x68k_floppy_getinfo) |
| 2180 | 2185 | CONFIG_RAM(0x100000) |
| r3867 | r3868 | |
|---|---|---|
| 44 | 44 | |
| 45 | 45 | static void atarist_fdc_dma_transfer(running_machine *machine) |
| 46 | 46 | { |
| 47 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1772, "wd1772"); | |
| 47 | 48 | const address_space *program = cputag_get_address_space(machine, "main", ADDRESS_SPACE_PROGRAM); |
| 48 | 49 | atarist_state *state = machine->driver_data; |
| 49 | 50 | |
| r3867 | r3868 | |
| 55 | 56 | { |
| 56 | 57 | UINT8 data = memory_read_byte_8be(program, state->fdc_dmabase); |
| 57 | 58 | |
| 58 | wd17xx_data_w( | |
| 59 | wd17xx_data_w(fdc | |
| 59 | 60 | } |
| 60 | 61 | else |
| 61 | 62 | { |
| 62 | UINT8 data = wd17xx_data_r( | |
| 63 | UINT8 data = wd17xx_data_r(fdc | |
| 63 | 64 | |
| 64 | 65 | memory_write_byte_8be(program, state->fdc_dmabase, data); |
| 65 | 66 | } |
| r3867 | r3868 | |
| 84 | 85 | } |
| 85 | 86 | } |
| 86 | 87 | |
| 87 | static | |
| 88 | static WD17XX_CALLBACK( atarist_fdc_callback | |
| 88 | 89 | { |
| 89 | atarist_state *state = machine->driver_data; | |
| 90 | atarist_state *driver_state = device->machine->driver_data; | |
| 90 | 91 | |
| 91 | switch ( | |
| 92 | switch (s | |
| 92 | 93 | { |
| 93 | 94 | case WD17XX_IRQ_SET: |
| 94 | state->fdc_irq = 1; | |
| 95 | driver_state->fdc_irq = 1; | |
| 95 | 96 | break; |
| 96 | 97 | |
| 97 | 98 | case WD17XX_IRQ_CLR: |
| 98 | state->fdc_irq = 0; | |
| 99 | driver_state->fdc_irq = 0; | |
| 99 | 100 | break; |
| 100 | 101 | |
| 101 | 102 | case WD17XX_DRQ_SET: |
| 102 | state->fdc_status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; | |
| 103 | atarist_fdc_dma_transfer(machine); | |
| 103 | driver_state->fdc_status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; | |
| 104 | atarist_fdc_dma_transfer(device->machine); | |
| 104 | 105 | break; |
| 105 | 106 | |
| 106 | 107 | case WD17XX_DRQ_CLR: |
| 107 | state->fdc_status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; | |
| 108 | driver_state->fdc_status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; | |
| 108 | 109 | break; |
| 109 | 110 | } |
| 110 | 111 | } |
| 111 | 112 | |
| 113 | const wd17xx_interface atarist_wd17xx_interface = { atarist_fdc_callback, NULL }; | |
| 114 | ||
| 112 | 115 | static READ16_HANDLER( atarist_fdc_data_r ) |
| 113 | 116 | { |
| 114 | 117 | atarist_state *state = space->machine->driver_data; |
| 118 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 115 | 119 | |
| 116 | 120 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 117 | 121 | { |
| r3867 | r3868 | |
| 128 | 132 | } |
| 129 | 133 | else |
| 130 | 134 | { |
| 131 | return wd17xx_r( | |
| 135 | return wd17xx_r(fd | |
| 132 | 136 | } |
| 133 | 137 | } |
| 134 | 138 | } |
| r3867 | r3868 | |
| 136 | 140 | static WRITE16_HANDLER( atarist_fdc_data_w ) |
| 137 | 141 | { |
| 138 | 142 | atarist_state *state = space->machine->driver_data; |
| 139 | ||
| 143 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 144 | ||
| 140 | 145 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 141 | 146 | { |
| 142 | 147 | if (data == 0) |
| r3867 | r3868 | |
| 159 | 164 | } |
| 160 | 165 | else |
| 161 | 166 | { |
| 162 | wd17xx_w( | |
| 167 | wd17xx_w(fd | |
| 163 | 168 | } |
| 164 | 169 | } |
| 165 | 170 | } |
| r3867 | r3868 | |
| 1278 | 1283 | |
| 1279 | 1284 | static WRITE8_HANDLER( ym2149_port_a_w ) |
| 1280 | 1285 | { |
| 1281 | wd17xx_set_side(BIT(data, 0) ? 0 : 1); | |
| 1286 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 1287 | wd17xx_set_side(fdc, BIT(data, 0) ? 0 : 1); | |
| 1282 | 1288 | |
| 1283 | 1289 | if (!BIT(data, 1)) |
| 1284 | 1290 | { |
| 1285 | wd17xx_set_drive(0); | |
| 1291 | wd17xx_set_drive(fdc,0); | |
| 1286 | 1292 | } |
| 1287 | 1293 | |
| 1288 | 1294 | if (!BIT(data, 2)) |
| 1289 | 1295 | { |
| 1290 | wd17xx_set_drive(1); | |
| 1296 | wd17xx_set_drive(fdc,1); | |
| 1291 | 1297 | } |
| 1292 | 1298 | |
| 1293 | 1299 | // 0x08 = RTS |
| r3867 | r3868 | |
| 1494 | 1500 | |
| 1495 | 1501 | /* configure devices */ |
| 1496 | 1502 | centronics_config(0, atarist_centronics_config); |
| 1497 | wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL); | |
| 1498 | 1503 | |
| 1499 | 1504 | /* set CPU interrupt callback */ |
| 1500 | 1505 | cpu_set_irq_callback(machine->cpu[0], atarist_int_ack); |
| r3867 | r3868 | |
| 1590 | 1595 | |
| 1591 | 1596 | /* configure devices */ |
| 1592 | 1597 | centronics_config(0, atarist_centronics_config); |
| 1593 | wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL); | |
| 1594 | ||
| 1598 | ||
| 1595 | 1599 | /* set CPU interrupt callback */ |
| 1596 | 1600 | cpu_set_irq_callback(machine->cpu[0], atarist_int_ack); |
| 1597 | 1601 | |
| r3867 | r3868 | |
| 1649 | 1653 | |
| 1650 | 1654 | static WRITE8_HANDLER( stbook_ym2149_port_a_w ) |
| 1651 | 1655 | { |
| 1652 | wd17xx_set_side((data & 0x01) ? 0 : 1); | |
| 1656 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 1657 | wd17xx_set_side(fdc,(data & 0x01) ? 0 : 1); | |
| 1653 | 1658 | |
| 1654 | 1659 | if (!(data & 0x02)) |
| 1655 | 1660 | { |
| 1656 | wd17xx_set_drive(0); | |
| 1661 | wd17xx_set_drive(fdc,0); | |
| 1657 | 1662 | } |
| 1658 | 1663 | |
| 1659 | 1664 | if (!(data & 0x04)) |
| 1660 | 1665 | { |
| 1661 | wd17xx_set_drive(1); | |
| 1666 | wd17xx_set_drive(fdc,1); | |
| 1662 | 1667 | } |
| 1663 | 1668 | |
| 1664 | 1669 | // 0x08 = RTS |
| r3867 | r3868 | |
| 1744 | 1749 | |
| 1745 | 1750 | /* configure devices */ |
| 1746 | 1751 | centronics_config(0, atarist_centronics_config); |
| 1747 | wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL); | |
| 1748 | 1752 | rp5c15_init(machine, &rtc_intf); |
| 1749 | 1753 | |
| 1750 | 1754 | /* set CPU interrupt callback */ |
| r3867 | r3868 | |
| 1805 | 1809 | MDRV_DEVICE_CONFIG(acia_ikbd_intf) |
| 1806 | 1810 | MDRV_DEVICE_ADD("acia_1", ACIA6850) |
| 1807 | 1811 | MDRV_DEVICE_CONFIG(acia_midi_intf) |
| 1812 | ||
| 1813 | MDRV_WD1772_ADD("wd1772", atarist_wd17xx_interface ) | |
| 1808 | 1814 | MACHINE_DRIVER_END |
| 1809 | 1815 | |
| 1810 | 1816 | static MACHINE_DRIVER_START( megast ) |
| r3867 | r3868 | |
| 1866 | 1872 | MDRV_DEVICE_CONFIG(acia_ikbd_intf) |
| 1867 | 1873 | MDRV_DEVICE_ADD("acia_1", ACIA6850) |
| 1868 | 1874 | MDRV_DEVICE_CONFIG(acia_midi_intf) |
| 1875 | ||
| 1876 | MDRV_WD1772_ADD("wd1772", atarist_wd17xx_interface ) | |
| 1869 | 1877 | MACHINE_DRIVER_END |
| 1870 | 1878 | |
| 1871 | 1879 | static MACHINE_DRIVER_START( megaste ) |
| r3867 | r3868 | |
| 1919 | 1927 | MDRV_DEVICE_CONFIG(stbook_acia_ikbd_intf) |
| 1920 | 1928 | MDRV_DEVICE_ADD("acia_1", ACIA6850) |
| 1921 | 1929 | MDRV_DEVICE_CONFIG(acia_midi_intf) |
| 1930 | ||
| 1931 | MDRV_WD1772_ADD("wd1772", atarist_wd17xx_interface ) | |
| 1922 | 1932 | MACHINE_DRIVER_END |
| 1923 | 1933 | |
| 1924 | 1934 | /* ROMs */ |
| r3867 | r3868 | |
|---|---|---|
| 514 | 514 | /* tms9902 */ |
| 515 | 515 | MDRV_TMS9902_ADD("tms9902_0", tms9902_params_0) |
| 516 | 516 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) |
| 517 | ||
| 518 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) | |
| 517 | 519 | MACHINE_DRIVER_END |
| 518 | 520 | |
| 519 | 521 |
| r3867 | r3868 | |
|---|---|---|
| 194 | 194 | AM_RANGE(0xbe, 0xbe) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 195 | 195 | AM_RANGE(0xbf, 0xbf) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 196 | 196 | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w) |
| 197 | AM_RANGE(0xe0, 0xe0) AM_READ(nec765_status_r) | |
| 198 | AM_RANGE(0xe1, 0xe1) AM_READWRITE(nec765_data_r, nec765_data_w) | |
| 197 | AM_RANGE(0xe0, 0xe0) AM_DEVREAD(NEC765A, "nec765", nec765_status_r) | |
| 198 | AM_RANGE(0xe1, 0xe1) AM_DEVREADWRITE(NEC765A, "nec765", nec765_data_r, nec765_data_w) | |
| 199 | 199 | AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w) |
| 200 | 200 | AM_RANGE(0xe8, 0xe8) AM_DEVREADWRITE(MSM8251, "uart", msm8251_data_r, msm8251_data_w) |
| 201 | 201 | AM_RANGE(0xe9, 0xe9) AM_DEVREADWRITE(MSM8251, "uart", msm8251_status_r, msm8251_control_w) |
| r3867 | r3868 | |
| 641 | 641 | |
| 642 | 642 | static WRITE8_DEVICE_HANDLER( sf7000_ppi8255_c_w ) |
| 643 | 643 | { |
| 644 | device_config *fdc = (device_config*)device_list_find_by_tag( device->machine->config->devicelist, NEC765A, "nec765"); | |
| 644 | 645 | /* |
| 645 | 646 | Signal Description |
| 646 | 647 | |
| r3867 | r3868 | |
| 659 | 660 | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1, 0); |
| 660 | 661 | |
| 661 | 662 | /* FDC terminal count */ |
| 662 | nec765_set_tc_state(d | |
| 663 | nec765_set_tc_state(fd | |
| 663 | 664 | |
| 664 | 665 | /* FDC reset */ |
| 665 | 666 | if (data & 0x08) |
| 666 | 667 | { |
| 667 | nec765_reset(d | |
| 668 | nec765_reset(fd | |
| 668 | 669 | } |
| 669 | 670 | |
| 670 | 671 | /* ROM selection */ |
| r3867 | r3868 | |
| 695 | 696 | }; |
| 696 | 697 | |
| 697 | 698 | /* callback for /INT output from FDC */ |
| 698 | static | |
| 699 | static NEC765_INTERRUPT( sf7000_fdc_interrupt | |
| 699 | 700 | { |
| 700 | sg1000_state *driver_state = machine->driver_data; // TODO | |
| 701 | sg1000_state *driver_state = device->machine->driver_data; // TODO | |
| 701 | 702 | |
| 702 | 703 | driver_state->fdc_irq = state; |
| 703 | 704 | } |
| 704 | 705 | |
| 705 | static void sf7000_fdc_index_callback(const device_config *img, int state) | |
| 706 | static void sf7000_fdc_index_callback(const device_config *controller, const device_config *img, int state) | |
| 706 | 707 | { |
| 707 | 708 | sg1000_state *driver_state = img->machine->driver_data; |
| 708 | 709 | |
| r3867 | r3868 | |
| 712 | 713 | static const struct nec765_interface sf7000_nec765_interface = |
| 713 | 714 | { |
| 714 | 715 | sf7000_fdc_interrupt, |
| 715 | NULL | |
| 716 | NULL, | |
| 717 | NULL, | |
| 718 | NEC765_RDY_PIN_CONNECTED | |
| 716 | 719 | }; |
| 717 | 720 | |
| 718 | 721 | static const CENTRONICS_CONFIG sf7000_centronics_config[1] = { |
| r3867 | r3868 | |
| 730 | 733 | TMS9928A_configure(&tms9928a_interface); |
| 731 | 734 | |
| 732 | 735 | /* configure FDC */ |
| 733 | nec765_init(machine, &sf7000_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED); | |
| 734 | 736 | floppy_drive_set_index_pulse_callback(image_from_devtype_and_index(IO_FLOPPY, 0), sf7000_fdc_index_callback); |
| 735 | 737 | |
| 736 | 738 | /* configure PPI */ |
| r3867 | r3868 | |
| 856 | 858 | |
| 857 | 859 | /* uart */ |
| 858 | 860 | MDRV_DEVICE_ADD("uart", MSM8251) |
| 861 | ||
| 862 | MDRV_NEC765A_ADD("nec765", sf7000_nec765_interface) | |
| 859 | 863 | MACHINE_DRIVER_END |
| 860 | 864 | |
| 861 | 865 | /* ROMs */ |
| r3867 | r3868 | |
|---|---|---|
| 342 | 342 | static MACHINE_START( exidy ) |
| 343 | 343 | { |
| 344 | 344 | MACHINE_START_CALL( exidyd ); |
| 345 | wd17xx_init(machine, WD_TYPE_179X, NULL, NULL); | |
| 346 | 345 | } |
| 347 | 346 | |
| 348 | 347 | static MACHINE_RESET( exidyd ) |
| r3867 | r3868 | |
| 375 | 374 | |
| 376 | 375 | static READ8_HANDLER ( exidy_wd179x_r ) |
| 377 | 376 | { |
| 377 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 378 | 378 | switch (offset & 0x03) |
| 379 | 379 | { |
| 380 | 380 | case 0: |
| 381 | return wd17xx_status_r( | |
| 381 | return wd17xx_status_r(fd | |
| 382 | 382 | case 1: |
| 383 | return wd17xx_track_r( | |
| 383 | return wd17xx_track_r(fd | |
| 384 | 384 | case 2: |
| 385 | return wd17xx_sector_r( | |
| 385 | return wd17xx_sector_r(fd | |
| 386 | 386 | case 3: |
| 387 | return wd17xx_data_r( | |
| 387 | return wd17xx_data_r(fd | |
| 388 | 388 | default: |
| 389 | 389 | return 0xff; |
| 390 | 390 | } |
| r3867 | r3868 | |
| 392 | 392 | |
| 393 | 393 | static WRITE8_HANDLER ( exidy_wd179x_w ) |
| 394 | 394 | { |
| 395 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 395 | 396 | switch (offset & 0x03) |
| 396 | 397 | { |
| 397 | 398 | case 0: |
| 398 | wd17xx_command_w( | |
| 399 | wd17xx_command_w(fd | |
| 399 | 400 | return; |
| 400 | 401 | case 1: |
| 401 | wd17xx_track_w( | |
| 402 | wd17xx_track_w(fd | |
| 402 | 403 | return; |
| 403 | 404 | case 2: |
| 404 | wd17xx_sector_w( | |
| 405 | wd17xx_sector_w(fd | |
| 405 | 406 | return; |
| 406 | 407 | case 3: |
| 407 | wd17xx_data_w( | |
| 408 | wd17xx_data_w(fd | |
| 408 | 409 | return; |
| 409 | 410 | default: |
| 410 | 411 | break; |
| r3867 | r3868 | |
| 825 | 826 | |
| 826 | 827 | MDRV_CASSETTE_ADD( "cassette1", exidy_cassette_config ) |
| 827 | 828 | MDRV_CASSETTE_ADD( "cassette2", exidy_cassette_config ) |
| 829 | ||
| 830 | MDRV_WD179X_ADD("wd179x", default_wd17xx_interface ) | |
| 828 | 831 | MACHINE_DRIVER_END |
| 829 | 832 | |
| 830 | 833 | static MACHINE_DRIVER_START( exidyd ) |
| r3867 | r3868 | |
|---|---|---|
| 463 | 463 | static ADDRESS_MAP_START( pc8801fd_io , ADDRESS_SPACE_IO, 8) |
| 464 | 464 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 465 | 465 | AM_RANGE(0xf8, 0xf8) AM_READ( pc8801fd_nec765_tc ) |
| 466 | AM_RANGE(0xfa, 0xfa) AM_READ( nec765_status_r ) | |
| 467 | AM_RANGE(0xfb, 0xfb) AM_READWRITE( nec765_data_r, nec765_data_w ) | |
| 466 | AM_RANGE(0xfa, 0xfa) AM_DEVREAD(NEC765A, "nec765", nec765_status_r ) | |
| 467 | AM_RANGE(0xfb, 0xfb) AM_DEVREADWRITE(NEC765A, "nec765", nec765_data_r, nec765_data_w ) | |
| 468 | 468 | AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE( PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w ) |
| 469 | 469 | ADDRESS_MAP_END |
| 470 | 470 | |
| r3867 | r3868 | |
| 559 | 559 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 560 | 560 | MDRV_SOUND_ADD("beep", BEEP, 0) |
| 561 | 561 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10) |
| 562 | ||
| 563 | MDRV_NEC765A_ADD("nec765", pc8801_fdc_interface) | |
| 562 | 564 | MACHINE_DRIVER_END |
| 563 | 565 | |
| 564 | 566 |
| r3867 | r3868 | |
|---|---|---|
| 104 | 104 | #define VERBOSE 0 |
| 105 | 105 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 106 | 106 | |
| 107 | static | |
| 107 | static NEC765_INTERRUPT( pcw_fdc_interrupt | |
| 108 | 108 | |
| 109 | 109 | // pointer to pcw ram |
| 110 | 110 | unsigned int roller_ram_addr; |
| r3867 | r3868 | |
| 136 | 136 | static const nec765_interface pcw_nec765_interface = |
| 137 | 137 | { |
| 138 | 138 | pcw_fdc_interrupt, |
| 139 | NULL | |
| 139 | NULL, | |
| 140 | NULL, | |
| 141 | NEC765_RDY_PIN_CONNECTED | |
| 140 | 142 | }; |
| 141 | 143 | |
| 142 | 144 | /* determines if int line is held or cleared */ |
| r3867 | r3868 | |
| 213 | 215 | } |
| 214 | 216 | |
| 215 | 217 | /* fdc interrupt callback. set/clear fdc int */ |
| 216 | static | |
| 218 | static NEC765_INTERRUPT( pcw_fdc_interrupt | |
| 217 | 219 | { |
| 218 | 220 | pcw_system_status &= ~(1<<5); |
| 219 | 221 | |
| r3867 | r3868 | |
| 223 | 225 | pcw_system_status |= (1<<5); |
| 224 | 226 | } |
| 225 | 227 | |
| 226 | pcw_trigger_fdc_int(machine); | |
| 228 | pcw_trigger_fdc_int(device->machine); | |
| 227 | 229 | } |
| 228 | 230 | |
| 229 | 231 | |
| r3867 | r3868 | |
| 431 | 433 | |
| 432 | 434 | static WRITE8_HANDLER(pcw_system_control_w) |
| 433 | 435 | { |
| 436 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 434 | 437 | LOG(("SYSTEM CONTROL: %d\n",data)); |
| 435 | 438 | |
| 436 | 439 | switch (data) |
| r3867 | r3868 | |
| 516 | 519 | /* set fdc terminal count */ |
| 517 | 520 | case 5: |
| 518 | 521 | { |
| 519 | nec765_set_tc_state( | |
| 522 | nec765_set_tc_state(fd | |
| 520 | 523 | } |
| 521 | 524 | break; |
| 522 | 525 | |
| 523 | 526 | /* clear fdc terminal count */ |
| 524 | 527 | case 6: |
| 525 | 528 | { |
| 526 | nec765_set_tc_state( | |
| 529 | nec765_set_tc_state(fd | |
| 527 | 530 | } |
| 528 | 531 | break; |
| 529 | 532 | |
| r3867 | r3868 | |
| 650 | 653 | |
| 651 | 654 | static READ8_HANDLER(pcw_fdc_r) |
| 652 | 655 | { |
| 656 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 653 | 657 | /* from Jacob Nevins docs. FDC I/O is not fully decoded */ |
| 654 | 658 | if (offset & 1) |
| 655 | 659 | { |
| 656 | return nec765_data_r( | |
| 660 | return nec765_data_r(fd | |
| 657 | 661 | } |
| 658 | 662 | |
| 659 | return nec765_status_r( | |
| 663 | return nec765_status_r(fd | |
| 660 | 664 | } |
| 661 | 665 | |
| 662 | 666 | static WRITE8_HANDLER(pcw_fdc_w) |
| 663 | 667 | { |
| 668 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 664 | 669 | /* from Jacob Nevins docs. FDC I/O is not fully decoded */ |
| 665 | 670 | if (offset & 1) |
| 666 | 671 | { |
| 667 | nec765_data_w( | |
| 672 | nec765_data_w(fd | |
| 668 | 673 | } |
| 669 | 674 | } |
| 670 | 675 | |
| r3867 | r3868 | |
| 744 | 749 | |
| 745 | 750 | static MACHINE_START( pcw ) |
| 746 | 751 | { |
| 747 | nec765_init(machine, &pcw_nec765_interface,NEC765A,NEC765_RDY_PIN_CONNECTED); | |
| 748 | 752 | fdc_interrupt_code = 0; |
| 749 | 753 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |
| 750 | 754 | } |
| r3867 | r3868 | |
| 1003 | 1007 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 1004 | 1008 | MDRV_SOUND_ADD("beep", BEEP, 0) |
| 1005 | 1009 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 1010 | ||
| 1011 | MDRV_NEC765A_ADD("nec765", pcw_nec765_interface) | |
| 1006 | 1012 | MACHINE_DRIVER_END |
| 1007 | 1013 | |
| 1008 | 1014 |
| r3867 | r3868 | |
|---|---|---|
| 355 | 355 | C011 ACIAIO DISK CONTROLLER ACIA I/O PORT |
| 356 | 356 | */ |
| 357 | 357 | |
| 358 | static void osi470_index_callback(const device_config *img, int state) | |
| 358 | static void osi470_index_callback(const device_config *controller, const device_config *img, int state) | |
| 359 | 359 | { |
| 360 | 360 | osi_state *driver_state = img->machine->driver_data; |
| 361 | 361 |
| r3867 | r3868 | |
|---|---|---|
| 284 | 284 | return INIT_FAIL; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | static | |
| 287 | static WD17XX_CALLBACK( bw2_wd17xx_callback | |
| 288 | 288 | { |
| 289 | 289 | switch(state) |
| 290 | 290 | { |
| 291 | 291 | case WD17XX_IRQ_CLR: |
| 292 | cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_IRQ0, CLEAR_LINE); | |
| 292 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, CLEAR_LINE); | |
| 293 | 293 | break; |
| 294 | 294 | |
| 295 | 295 | case WD17XX_IRQ_SET: |
| 296 | cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_IRQ0, HOLD_LINE); | |
| 296 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, HOLD_LINE); | |
| 297 | 297 | break; |
| 298 | 298 | |
| 299 | 299 | case WD17XX_DRQ_CLR: |
| 300 | cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE); | |
| 300 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, CLEAR_LINE); | |
| 301 | 301 | break; |
| 302 | 302 | |
| 303 | 303 | case WD17XX_DRQ_SET: |
| 304 | if (cpu_get_reg(machine->cpu[0], Z80_HALT)) | |
| 304 | if (cpu_get_reg(device->machine->cpu[0], Z80_HALT)) | |
| 305 | 305 | { |
| 306 | cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_NMI, HOLD_LINE); | |
| 306 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, HOLD_LINE); | |
| 307 | 307 | } |
| 308 | 308 | break; |
| 309 | 309 | } |
| r3867 | r3868 | |
| 312 | 312 | static READ8_HANDLER( bw2_wd2797_r ) |
| 313 | 313 | { |
| 314 | 314 | UINT8 result = 0xff; |
| 315 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 315 | 316 | |
| 316 | 317 | switch (offset & 0x03) |
| 317 | 318 | { |
| 318 | 319 | case 0: |
| 319 | result = wd17xx_status_r( | |
| 320 | result = wd17xx_status_r(fd | |
| 320 | 321 | break; |
| 321 | 322 | case 1: |
| 322 | result = wd17xx_track_r( | |
| 323 | result = wd17xx_track_r(fd | |
| 323 | 324 | break; |
| 324 | 325 | case 2: |
| 325 | result = wd17xx_sector_r( | |
| 326 | result = wd17xx_sector_r(fd | |
| 326 | 327 | break; |
| 327 | 328 | case 3: |
| 328 | result = wd17xx_data_r( | |
| 329 | result = wd17xx_data_r(fd | |
| 329 | 330 | break; |
| 330 | 331 | } |
| 331 | 332 | |
| r3867 | r3868 | |
| 334 | 335 | |
| 335 | 336 | static WRITE8_HANDLER( bw2_wd2797_w ) |
| 336 | 337 | { |
| 338 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 337 | 339 | switch (offset & 0x3) |
| 338 | 340 | { |
| 339 | 341 | case 0: |
| r3867 | r3868 | |
| 345 | 347 | { |
| 346 | 348 | int side = BIT(data, 1); |
| 347 | 349 | |
| 348 | wd17xx_set_side(side); | |
| 350 | wd17xx_set_side(fdc,side); | |
| 349 | 351 | |
| 350 | 352 | data &= ~0x02; |
| 351 | 353 | } |
| 352 | 354 | } |
| 353 | 355 | |
| 354 | wd17xx_command_w( | |
| 356 | wd17xx_command_w(fd | |
| 355 | 357 | |
| 356 | 358 | break; |
| 357 | 359 | case 1: |
| 358 | wd17xx_track_w( | |
| 360 | wd17xx_track_w(fd | |
| 359 | 361 | break; |
| 360 | 362 | case 2: |
| 361 | wd17xx_sector_w( | |
| 363 | wd17xx_sector_w(fd | |
| 362 | 364 | break; |
| 363 | 365 | case 3: |
| 364 | wd17xx_data_w( | |
| 366 | wd17xx_data_w(fd | |
| 365 | 367 | break; |
| 366 | 368 | }; |
| 367 | 369 | } |
| r3867 | r3868 | |
| 371 | 373 | |
| 372 | 374 | static WRITE8_DEVICE_HANDLER( bw2_ppi8255_a_w ) |
| 373 | 375 | { |
| 376 | device_config *fdc = (device_config*)device_list_find_by_tag( device->machine->config->devicelist, WD179X, "wd179x"); | |
| 374 | 377 | /* |
| 375 | 378 | |
| 376 | 379 | PA0 KB0 Keyboard line select 0 |
| r3867 | r3868 | |
| 391 | 394 | if (BIT(data, 4)) |
| 392 | 395 | { |
| 393 | 396 | state->selected_drive = 0; |
| 394 | wd17xx_set_drive(state->selected_drive); | |
| 397 | wd17xx_set_drive(fdc,state->selected_drive); | |
| 395 | 398 | } |
| 396 | 399 | |
| 397 | 400 | if (BIT(data, 5)) |
| 398 | 401 | { |
| 399 | 402 | state->selected_drive = 1; |
| 400 | wd17xx_set_drive(state->selected_drive); | |
| 403 | wd17xx_set_drive(fdc,state->selected_drive); | |
| 401 | 404 | } |
| 402 | 405 | |
| 403 | 406 | /* assumption: select is tied low */ |
| r3867 | r3868 | |
| 592 | 595 | static MACHINE_START( bw2 ) |
| 593 | 596 | { |
| 594 | 597 | bw2_state *state = machine->driver_data; |
| 598 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); | |
| 595 | 599 | |
| 600 | ||
| 596 | 601 | centronics_config(0, bw2_centronics_config); |
| 597 | 602 | |
| 598 | wd17xx_init(machine, WD_TYPE_179X, bw2_wd17xx_callback, NULL); // really WD2797 | |
| 599 | wd17xx_set_density(DEN_MFM_LO); | |
| 603 | wd17xx_set_density(fdc,DEN_MFM_LO); | |
| 600 | 604 | |
| 601 | 605 | /* find devices */ |
| 602 | 606 | state->msm8251 = devtag_get_device(machine, MSM8251, MSM8251_TAG); |
| r3867 | r3868 | |
| 824 | 828 | bw2_charram_r, |
| 825 | 829 | }; |
| 826 | 830 | |
| 831 | const wd17xx_interface bw2_wd17xx_interface = { bw2_wd17xx_callback, NULL }; | |
| 832 | ||
| 827 | 833 | static MACHINE_DRIVER_START( bw2 ) |
| 828 | 834 | MDRV_DRIVER_DATA(bw2_state) |
| 829 | 835 | |
| r3867 | r3868 | |
| 861 | 867 | |
| 862 | 868 | /* uart */ |
| 863 | 869 | MDRV_DEVICE_ADD(MSM8251_TAG, MSM8251) |
| 870 | ||
| 871 | MDRV_WD179X_ADD("wd179x", default_wd17xx_interface ) | |
| 864 | 872 | MACHINE_DRIVER_END |
| 865 | 873 | |
| 866 | 874 | /*************************************************************************** |
| r3867 | r3868 | |
|---|---|---|
| 27 | 27 | #include "sound/ay8910.h" |
| 28 | 28 | #include "machine/6522via.h" |
| 29 | 29 | #include "machine/6551.h" |
| 30 | ||
| 30 | #include "machine/wd17xx.h" | |
| 31 | 31 | #include "includes/apple2.h" |
| 32 | 32 | |
| 33 | 33 | /* |
| r3867 | r3868 | |
| 388 | 388 | |
| 389 | 389 | /* via */ |
| 390 | 390 | MDRV_VIA6522_ADD( "via6522_0", 1000000, oric_6522_interface ) |
| 391 | ||
| 392 | MDRV_WD179X_ADD("wd179x", oric_wd17xx_interface ) | |
| 391 | 393 | MACHINE_DRIVER_END |
| 392 | 394 | |
| 393 | 395 |
| r3867 | r3868 | |
|---|---|---|
| 172 | 172 | }; |
| 173 | 173 | |
| 174 | 174 | |
| 175 | static void enterp_wd177x_callback(running_machine *machine, wd17xx_state_t event, void *param); | |
| 176 | 175 | |
| 177 | 176 | static void enterprise_reset(running_machine *machine) |
| 178 | 177 | { |
| r3867 | r3868 | |
| 235 | 234 | |
| 236 | 235 | static MACHINE_START(enterprise) |
| 237 | 236 | { |
| 238 | wd17xx_init(machine, WD_TYPE_177X, enterp_wd177x_callback, NULL); | |
| 239 | 237 | add_reset_callback(machine, enterprise_reset); |
| 240 | 238 | } |
| 241 | 239 | |
| 242 | 240 | static READ8_HANDLER ( enterprise_wd177x_read ) |
| 243 | 241 | { |
| 242 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 244 | 243 | switch (offset & 0x03) |
| 245 | 244 | { |
| 246 | 245 | case 0: |
| 247 | return wd17xx_status_r( | |
| 246 | return wd17xx_status_r(fd | |
| 248 | 247 | case 1: |
| 249 | return wd17xx_track_r( | |
| 248 | return wd17xx_track_r(fd | |
| 250 | 249 | case 2: |
| 251 | return wd17xx_sector_r( | |
| 250 | return wd17xx_sector_r(fd | |
| 252 | 251 | case 3: |
| 253 | return wd17xx_data_r( | |
| 252 | return wd17xx_data_r(fd | |
| 254 | 253 | default: |
| 255 | 254 | break; |
| 256 | 255 | } |
| r3867 | r3868 | |
| 260 | 259 | |
| 261 | 260 | static WRITE8_HANDLER ( enterprise_wd177x_write ) |
| 262 | 261 | { |
| 262 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 263 | 263 | switch (offset & 0x03) |
| 264 | 264 | { |
| 265 | 265 | case 0: |
| 266 | wd17xx_command_w( | |
| 266 | wd17xx_command_w(fd | |
| 267 | 267 | return; |
| 268 | 268 | case 1: |
| 269 | wd17xx_track_w( | |
| 269 | wd17xx_track_w(fd | |
| 270 | 270 | return; |
| 271 | 271 | case 2: |
| 272 | wd17xx_sector_w( | |
| 272 | wd17xx_sector_w(fd | |
| 273 | 273 | return; |
| 274 | 274 | case 3: |
| 275 | wd17xx_data_w( | |
| 275 | wd17xx_data_w(fd | |
| 276 | 276 | return; |
| 277 | 277 | default: |
| 278 | 278 | break; |
| r3867 | r3868 | |
| 317 | 317 | |
| 318 | 318 | static char EXDOS_CARD_R = 0; |
| 319 | 319 | |
| 320 | static | |
| 320 | static WD17XX_CALLBACK( enterp_wd177x_callback | |
| 321 | 321 | { |
| 322 | if ( | |
| 322 | if (state==WD17XX_IRQ_CLR) | |
| 323 | 323 | { |
| 324 | 324 | EXDOS_CARD_R &= ~0x02; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | if ( | |
| 327 | if (state==WD17XX_IRQ_SET) | |
| 328 | 328 | { |
| 329 | 329 | EXDOS_CARD_R |= 0x02; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | if ( | |
| 332 | if (state==WD17XX_DRQ_CLR) | |
| 333 | 333 | { |
| 334 | 334 | EXDOS_CARD_R &= ~0x080; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | if ( | |
| 337 | if (state==WD17XX_DRQ_SET) | |
| 338 | 338 | { |
| 339 | 339 | EXDOS_CARD_R |= 0x080; |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | const wd17xx_interface enterp_wd17xx_interface = { enterp_wd177x_callback, NULL }; | |
| 343 | 344 | |
| 344 | 345 | |
| 345 | 346 | static WRITE8_HANDLER ( exdos_card_w ) |
| 346 | 347 | { |
| 348 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 347 | 349 | /* drive side */ |
| 348 | 350 | int head = (data>>4) & 0x01; |
| 349 | 351 | |
| 350 | 352 | int drive = EXDOS_GetDriveSelection(data); |
| 351 | 353 | |
| 352 | wd17xx_set_drive(drive); | |
| 353 | wd17xx_set_side(head); | |
| 354 | wd17xx_set_drive(fdc,drive); | |
| 355 | wd17xx_set_side(fdc,head); | |
| 354 | 356 | } |
| 355 | 357 | |
| 356 | 358 | /* bit 0 - ?? |
| r3867 | r3868 | |
| 561 | 563 | MDRV_SOUND_ADD("custom", CUSTOM, 0) |
| 562 | 564 | MDRV_SOUND_CONFIG(dave_custom_sound) |
| 563 | 565 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 566 | ||
| 567 | MDRV_WD177X_ADD("wd177x", enterp_wd17xx_interface ) | |
| 564 | 568 | MACHINE_DRIVER_END |
| 565 | 569 | |
| 566 | 570 | ROM_START( ep128 ) |
| r3867 | r3868 | |
|---|---|---|
| 470 | 470 | |
| 471 | 471 | /* harddisk */ |
| 472 | 472 | MDRV_IMPORT_FROM( pc_hdc ) |
| 473 | ||
| 474 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 473 | 475 | MACHINE_DRIVER_END |
| 474 | 476 | |
| 475 | 477 | |
| r3867 | r3868 | |
| 523 | 525 | |
| 524 | 526 | /* harddisk */ |
| 525 | 527 | MDRV_IMPORT_FROM( pc_hdc ) |
| 528 | ||
| 529 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 526 | 530 | MACHINE_DRIVER_END |
| 527 | 531 | |
| 528 | 532 | |
| r3867 | r3868 | |
| 583 | 587 | |
| 584 | 588 | /* harddisk */ |
| 585 | 589 | MDRV_IMPORT_FROM( pc_hdc ) |
| 590 | ||
| 591 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 586 | 592 | MACHINE_DRIVER_END |
| 587 | 593 | |
| 588 | 594 | |
| r3867 | r3868 | |
| 645 | 651 | |
| 646 | 652 | /* harddisk */ |
| 647 | 653 | MDRV_IMPORT_FROM( pc_hdc ) |
| 654 | ||
| 655 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 648 | 656 | MACHINE_DRIVER_END |
| 649 | 657 | |
| 650 | 658 | |
| r3867 | r3868 | |
| 704 | 712 | |
| 705 | 713 | /* harddisk */ |
| 706 | 714 | MDRV_IMPORT_FROM( pc_hdc ) |
| 715 | ||
| 716 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 707 | 717 | MACHINE_DRIVER_END |
| 708 | 718 | |
| 709 | 719 |
| r3867 | r3868 | |
|---|---|---|
| 329 | 329 | { |
| 330 | 330 | pia_config(machine, 1,&apf_imagination_pia_interface); |
| 331 | 331 | apf_common_init(machine); |
| 332 | wd17xx_init(machine, WD_TYPE_179X, NULL, NULL); | |
| 333 | 332 | } |
| 334 | 333 | |
| 335 | 334 | static MACHINE_START( apf_m1000 ) |
| r3867 | r3868 | |
| 340 | 339 | static WRITE8_HANDLER(apf_dischw_w) |
| 341 | 340 | { |
| 342 | 341 | int drive; |
| 342 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"); | |
| 343 | 343 | |
| 344 | 344 | /* bit 3 is index of drive to select */ |
| 345 | 345 | drive = (data>>3) & 0x01; |
| 346 | 346 | |
| 347 | wd17xx_set_drive(drive); | |
| 347 | wd17xx_set_drive(fdc, drive); | |
| 348 | 348 | |
| 349 | 349 | logerror("disc w %04x %04x\n",offset,data); |
| 350 | 350 | } |
| r3867 | r3868 | |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | static WRITE8_HANDLER(apf_wd179x_command_w) |
| 364 | { | |
| 365 | wd17xx_command_w(space, offset,~data); | |
| 364 | { | |
| 365 | wd17xx_command_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset,~data); | |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | static WRITE8_HANDLER(apf_wd179x_track_w) |
| 369 | 369 | { |
| 370 | wd17xx_track_w(space, offset,~data); | |
| 370 | wd17xx_track_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset,~data); | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | static WRITE8_HANDLER(apf_wd179x_sector_w) |
| 374 | 374 | { |
| 375 | wd17xx_sector_w(space, offset,~data); | |
| 375 | wd17xx_sector_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset,~data); | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | static WRITE8_HANDLER(apf_wd179x_data_w) |
| 379 | 379 | { |
| 380 | wd17xx_data_w(space, offset,~data); | |
| 380 | wd17xx_data_w((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset,~data); | |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | static READ8_HANDLER(apf_wd179x_status_r) |
| 384 | 384 | { |
| 385 | return ~wd17xx_status_r(space, offset); | |
| 385 | return ~wd17xx_status_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | static READ8_HANDLER(apf_wd179x_track_r) |
| 389 | 389 | { |
| 390 | return ~wd17xx_track_r(space, offset); | |
| 390 | return ~wd17xx_track_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | static READ8_HANDLER(apf_wd179x_sector_r) |
| 394 | 394 | { |
| 395 | return ~wd17xx_sector_r(space, offset); | |
| 395 | return ~wd17xx_sector_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | static READ8_HANDLER(apf_wd179x_data_r) |
| 399 | 399 | { |
| 400 | return wd17xx_data_r(space, offset); | |
| 400 | return wd17xx_data_r((device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD179X, "wd179x"), offset); | |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | static ADDRESS_MAP_START(apf_imagination_map, ADDRESS_SPACE_PROGRAM, 8) |
| r3867 | r3868 | |
| 658 | 658 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 659 | 659 | |
| 660 | 660 | MDRV_CASSETTE_ADD( "cassette", apf_cassette_config ) |
| 661 | ||
| 662 | MDRV_WD179X_ADD("wd179x", default_wd17xx_interface ) | |
| 661 | 663 | MACHINE_DRIVER_END |
| 662 | 664 | |
| 663 | ||
| 664 | 665 | static MACHINE_DRIVER_START( apf_m1000 ) |
| 665 | 666 | MDRV_IMPORT_FROM( apf_imagination ) |
| 666 | 667 | MDRV_CPU_MODIFY( "main" ) |
| r3867 | r3868 | |
|---|---|---|
| 28 | 28 | AM_RANGE( 0x00, 0x03) AM_READWRITE(vector_8255_1_r, vector_8255_1_w ) |
| 29 | 29 | AM_RANGE( 0x04, 0x07) AM_READWRITE(vector_8255_2_r, vector_8255_2_w ) |
| 30 | 30 | AM_RANGE( 0x0C, 0x0C) AM_WRITE ( vector06_color_set ) |
| 31 | AM_RANGE( 0x18, 0x18) AM_READWRITE(wd17xx_data_r,wd17xx_data_w) | |
| 32 | AM_RANGE( 0x19, 0x19) AM_READWRITE(wd17xx_sector_r,wd17xx_sector_w) | |
| 33 | AM_RANGE( 0x1A, 0x1A) AM_READWRITE(wd17xx_track_r,wd17xx_track_w) | |
| 34 | AM_RANGE( 0x1B, 0x1B) AM_READWRITE(wd17xx_status_r,wd17xx_command_w) | |
| 31 | AM_RANGE( 0x18, 0x18) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_data_r,wd17xx_data_w) | |
| 32 | AM_RANGE( 0x19, 0x19) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_sector_r,wd17xx_sector_w) | |
| 33 | AM_RANGE( 0x1A, 0x1A) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_track_r,wd17xx_track_w) | |
| 34 | AM_RANGE( 0x1B, 0x1B) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_status_r,wd17xx_command_w) | |
| 35 | 35 | AM_RANGE( 0x1C, 0x1C) AM_WRITE(vector_disc_w) |
| 36 | 36 | ADDRESS_MAP_END |
| 37 | 37 | |
| r3867 | r3868 | |
| 185 | 185 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 186 | 186 | |
| 187 | 187 | MDRV_CASSETTE_ADD( "cassette", vector_cassette_config ) |
| 188 | ||
| 188 | ||
| 189 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 189 | 190 | MACHINE_DRIVER_END |
| 190 | 191 | |
| 191 | 192 | /* ROM definition */ |
| r3867 | r3868 | |
|---|---|---|
| 11 | 11 | #include "cpu/i8085/i8085.h" |
| 12 | 12 | #include "machine/8255ppi.h" |
| 13 | 13 | #include "machine/8257dma.h" |
| 14 | #include "machine/wd17xx.h" | |
| 14 | 15 | #include "video/i8275.h" |
| 15 | 16 | #include "devices/cassette.h" |
| 16 | 17 | #include "devices/basicdsk.h" |
| r3867 | r3868 | |
| 166 | 167 | MDRV_DEVICE_CONFIG(partner_dma) |
| 167 | 168 | |
| 168 | 169 | MDRV_CASSETTE_ADD( "cassette", partner_cassette_config ) |
| 170 | ||
| 171 | MDRV_WD1793_ADD("wd1793", partner_wd17xx_interface ) | |
| 169 | 172 | MACHINE_DRIVER_END |
| 170 | 173 | |
| 171 | 174 |
| r3867 | r3868 | |
|---|---|---|
| 12 | 12 | #include "cpu/i8085/i8085.h" |
| 13 | 13 | #include "machine/8255ppi.h" |
| 14 | 14 | #include "machine/mc146818.h" |
| 15 | #include "machine/wd17xx.h" | |
| 15 | 16 | #include "devices/basicdsk.h" |
| 16 | 17 | #include "devices/cassette.h" |
| 17 | 18 | #include "devices/cartslot.h" |
| r3867 | r3868 | |
| 116 | 117 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 117 | 118 | |
| 118 | 119 | MDRV_CASSETTE_ADD( "cassette", orion_cassette_config ) |
| 120 | ||
| 121 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 119 | 122 | MACHINE_DRIVER_END |
| 120 | 123 | |
| 121 | 124 | static MACHINE_DRIVER_START( orion128ms ) |
| r3867 | r3868 | |
| 170 | 173 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 171 | 174 | |
| 172 | 175 | MDRV_CASSETTE_ADD( "cassette", orion_cassette_config ) |
| 176 | ||
| 177 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 173 | 178 | MACHINE_DRIVER_END |
| 174 | 179 | |
| 175 | 180 | static MACHINE_DRIVER_START( orionz80ms ) |
| r3867 | r3868 | |
| 214 | 219 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 215 | 220 | |
| 216 | 221 | MDRV_CASSETTE_ADD( "cassette", orion_cassette_config ) |
| 222 | ||
| 223 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 217 | 224 | MACHINE_DRIVER_END |
| 218 | 225 | |
| 219 | 226 |
| r3867 | r3868 | |
|---|---|---|
| 138 | 138 | MDRV_PCI_BUS_DEVICE(1, NULL, NULL, mpc105_pci_read, mpc105_pci_write) |
| 139 | 139 | MDRV_PCI_BUS_DEVICE(1, NULL, NULL, cirrus5430_pci_read, cirrus5430_pci_write) |
| 140 | 140 | /*MDRV_PCI_BUS_DEVICE(12, NULL, NULL, scsi53c810_pci_read, scsi53c810_pci_write)*/ |
| 141 | ||
| 142 | MDRV_SMC37C78_ADD("smc37c78", pc_fdc_nec765_connected_interface) | |
| 141 | 143 | MACHINE_DRIVER_END |
| 142 | 144 | |
| 143 | 145 | static MACHINE_DRIVER_START( bebox2 ) |
| r3867 | r3868 | |
|---|---|---|
| 98 | 98 | AM_RANGE(0x01, 0x01) AM_READWRITE(nascom1_port_01_r, nascom1_port_01_w) |
| 99 | 99 | AM_RANGE(0x02, 0x02) AM_READ(nascom1_port_02_r) |
| 100 | 100 | AM_RANGE(0x04, 0x07) AM_DEVREADWRITE( Z80PIO, "z80pio", z80pio_r, z80pio_w ) |
| 101 | AM_RANGE(0xe0, 0xe3) AM_READWRITE(wd17xx_r, wd17xx_w) | |
| 101 | AM_RANGE(0xe0, 0xe3) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_r, wd17xx_w) | |
| 102 | 102 | AM_RANGE(0xe4, 0xe4) AM_READWRITE(nascom2_fdc_select_r, nascom2_fdc_select_w) |
| 103 | 103 | AM_RANGE(0xe5, 0xe5) AM_READ(nascom2_fdc_status_r) |
| 104 | 104 | ADDRESS_MAP_END |
| r3867 | r3868 | |
| 313 | 313 | MDRV_CPU_REPLACE("main", Z80, XTAL_16MHz/8) |
| 314 | 314 | MDRV_CPU_IO_MAP(nascom2_io, 0) |
| 315 | 315 | |
| 316 | MDRV_MACHINE_START(nascom2) | |
| 317 | ||
| 318 | 316 | /* video hardware */ |
| 319 | 317 | MDRV_SCREEN_MODIFY("main") |
| 320 | 318 | MDRV_SCREEN_SIZE(48 * 8, 16 * 14) |
| 321 | 319 | MDRV_SCREEN_VISIBLE_AREA(0, 48 * 8 - 1, 0, 16 * 14 - 1) |
| 322 | 320 | MDRV_GFXDECODE(nascom2) |
| 323 | 321 | MDRV_VIDEO_UPDATE(nascom2) |
| 322 | ||
| 323 | MDRV_WD1793_ADD("wd1793", nascom2_wd17xx_interface ) | |
| 324 | 324 | MACHINE_DRIVER_END |
| 325 | 325 | |
| 326 | 326 |
| r3867 | r3868 | |
|---|---|---|
| 542 | 542 | |
| 543 | 543 | static WRITE8_HANDLER( fdc_auxiliary_w ) |
| 544 | 544 | { |
| 545 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 545 | 546 | /* |
| 546 | 547 | |
| 547 | 548 | bit description |
| r3867 | r3868 | |
| 560 | 561 | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), BIT(data, 0)); |
| 561 | 562 | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1, 0); |
| 562 | 563 | |
| 563 | nec765_set_reset_state( | |
| 564 | nec765_set_reset_state(fd | |
| 564 | 565 | |
| 565 | nec765_set_tc_state( | |
| 566 | nec765_set_tc_state(fd | |
| 566 | 567 | } |
| 567 | 568 | |
| 568 | 569 | static READ8_HANDLER( fdc_control_r ) |
| r3867 | r3868 | |
| 971 | 972 | static ADDRESS_MAP_START( newbrain_fdc_io_map, ADDRESS_SPACE_IO, 8 ) |
| 972 | 973 | ADDRESS_MAP_UNMAP_HIGH |
| 973 | 974 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 974 | AM_RANGE(0x00, 0x00) AM_READ(nec765_status_r) | |
| 975 | AM_RANGE(0x01, 0x01) AM_READWRITE(nec765_data_r, nec765_data_w) | |
| 975 | AM_RANGE(0x00, 0x00) AM_DEVREAD( NEC765A, "nec765", nec765_status_r) | |
| 976 | AM_RANGE(0x01, 0x01) AM_DEVREADWRITE( NEC765A, "nec765", nec765_data_r, nec765_data_w) | |
| 976 | 977 | AM_RANGE(0x20, 0x20) AM_WRITE(fdc_auxiliary_w) |
| 977 | 978 | AM_RANGE(0x40, 0x40) AM_READ(fdc_control_r) |
| 978 | 979 | ADDRESS_MAP_END |
| r3867 | r3868 | |
| 1098 | 1099 | acia_interrupt |
| 1099 | 1100 | }; |
| 1100 | 1101 | |
| 1101 | static | |
| 1102 | static NEC765_INTERRUPT( newbrain_fdc_interrupt | |
| 1102 | 1103 | { |
| 1103 | newbrain_state *driver_state = machine->driver_data; | |
| 1104 | newbrain_state *driver_state = device->machine->driver_data; | |
| 1104 | 1105 | |
| 1105 | 1106 | driver_state->fdc_int = state; |
| 1106 | 1107 | } |
| 1107 | 1108 | |
| 1108 | static const | |
| 1109 | static const | |
| 1109 | 1110 | { |
| 1110 | 1111 | newbrain_fdc_interrupt, |
| 1111 | NULL | |
| 1112 | NULL, | |
| 1113 | NULL, | |
| 1114 | NEC765_RDY_PIN_NOT_CONNECTED | |
| 1112 | 1115 | }; |
| 1113 | 1116 | |
| 1114 | 1117 | static const z80ctc_interface newbrain_ctc_intf = |
| r3867 | r3868 | |
| 1165 | 1168 | memory_set_bank(machine, bank, 0); |
| 1166 | 1169 | } |
| 1167 | 1170 | |
| 1168 | /* initialize devices */ | |
| 1169 | ||
| 1170 | nec765_init(machine, &newbrain_nec765_interface, NEC765A, NEC765_RDY_PIN_NOT_CONNECTED); | |
| 1171 | ||
| 1172 | 1171 | /* allocate reset timer */ |
| 1173 | 1172 | |
| 1174 | 1173 | state->reset_timer = timer_alloc(machine, reset_tick, NULL); |
| r3867 | r3868 | |
| 1270 | 1269 | /* acia */ |
| 1271 | 1270 | MDRV_DEVICE_ADD("acia_0", ACIA6850) |
| 1272 | 1271 | MDRV_DEVICE_CONFIG(newbrain_acia_intf) |
| 1272 | ||
| 1273 | MDRV_NEC765A_ADD("nec765", newbrain_nec765_interface) | |
| 1273 | 1274 | MACHINE_DRIVER_END |
| 1274 | 1275 | |
| 1275 | 1276 | static MACHINE_DRIVER_START( newbraim ) |
| r3867 | r3868 | |
|---|---|---|
| 598 | 598 | static WRITE8_HANDLER(einstein_fdc_w) |
| 599 | 599 | { |
| 600 | 600 | int reg = offset & 0x03; |
| 601 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 601 | 602 | |
| 602 | 603 | logerror("fdc w: PC: %04x %04x %02x\n",cpu_get_pc(space->machine->cpu[0]),offset,data); |
| 603 | 604 | |
| r3867 | r3868 | |
| 605 | 606 | { |
| 606 | 607 | case 0: |
| 607 | 608 | { |
| 608 | wd17xx_command_w( | |
| 609 | wd17xx_command_w(fd | |
| 609 | 610 | } |
| 610 | 611 | break; |
| 611 | 612 | |
| 612 | 613 | case 1: |
| 613 | 614 | { |
| 614 | wd17xx_track_w( | |
| 615 | wd17xx_track_w(fd | |
| 615 | 616 | } |
| 616 | 617 | break; |
| 617 | 618 | |
| 618 | 619 | case 2: |
| 619 | 620 | { |
| 620 | wd17xx_sector_w( | |
| 621 | wd17xx_sector_w(fd | |
| 621 | 622 | } |
| 622 | 623 | break; |
| 623 | 624 | |
| 624 | 625 | case 3: |
| 625 | 626 | { |
| 626 | wd17xx_data_w( | |
| 627 | wd17xx_data_w(fd | |
| 627 | 628 | } |
| 628 | 629 | break; |
| 629 | 630 | } |
| r3867 | r3868 | |
| 633 | 634 | static READ8_HANDLER(einstein_fdc_r) |
| 634 | 635 | { |
| 635 | 636 | int reg = offset & 0x03; |
| 637 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 636 | 638 | |
| 637 | 639 | logerror("fdc r: PC: %04x %04x\n",cpu_get_pc(space->machine->cpu[0]),offset); |
| 638 | 640 | |
| r3867 | r3868 | |
| 640 | 642 | { |
| 641 | 643 | case 0: |
| 642 | 644 | { |
| 643 | return wd17xx_status_r( | |
| 645 | return wd17xx_status_r(fd | |
| 644 | 646 | } |
| 645 | 647 | break; |
| 646 | 648 | |
| 647 | 649 | case 1: |
| 648 | 650 | { |
| 649 | return wd17xx_track_r( | |
| 651 | return wd17xx_track_r(fd | |
| 650 | 652 | } |
| 651 | 653 | break; |
| 652 | 654 | |
| 653 | 655 | case 2: |
| 654 | 656 | { |
| 655 | return wd17xx_sector_r( | |
| 657 | return wd17xx_sector_r(fd | |
| 656 | 658 | } |
| 657 | 659 | break; |
| 658 | 660 | |
| 659 | 661 | case 3: |
| 660 | 662 | { |
| 661 | return wd17xx_data_r( | |
| 663 | return wd17xx_data_r(fd | |
| 662 | 664 | } |
| 663 | 665 | break; |
| 664 | 666 | } |
| r3867 | r3868 | |
| 823 | 825 | |
| 824 | 826 | static WRITE8_HANDLER(einstein_drive_w) |
| 825 | 827 | { |
| 828 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD177X, "wd177x"); | |
| 829 | ||
| 826 | 830 | /* bit 4: side select */ |
| 827 | 831 | /* bit 3: select drive 3 */ |
| 828 | 832 | /* bit 2: select drive 2 */ |
| r3867 | r3868 | |
| 831 | 835 | |
| 832 | 836 | logerror("drive w: PC: %04x %04x %02x\n",cpu_get_pc(space->machine->cpu[0]),offset,data); |
| 833 | 837 | |
| 834 | wd17xx_set_side((data>>4) & 0x01); | |
| 838 | wd17xx_set_side(fdc,(data>>4) & 0x01); | |
| 835 | 839 | |
| 836 | 840 | if (data & 0x01) |
| 837 | 841 | { |
| 838 | wd17xx_set_drive(0); | |
| 842 | wd17xx_set_drive(fdc,0); | |
| 839 | 843 | } |
| 840 | 844 | else |
| 841 | 845 | if (data & 0x02) |
| 842 | 846 | { |
| 843 | wd17xx_set_drive(1); | |
| 847 | wd17xx_set_drive(fdc,1); | |
| 844 | 848 | } |
| 845 | 849 | else |
| 846 | 850 | if (data & 0x04) |
| 847 | 851 | { |
| 848 | wd17xx_set_drive(2); | |
| 852 | wd17xx_set_drive(fdc,2); | |
| 849 | 853 | } |
| 850 | 854 | else |
| 851 | 855 | if (data & 0x08) |
| 852 | 856 | { |
| 853 | wd17xx_set_drive(3); | |
| 857 | wd17xx_set_drive(fdc,3); | |
| 854 | 858 | } |
| 855 | 859 | } |
| 856 | 860 | |
| r3867 | r3868 | |
| 1426 | 1430 | static MACHINE_START( einstein ) |
| 1427 | 1431 | { |
| 1428 | 1432 | TMS9928A_configure(&tms9928a_interface); |
| 1429 | wd17xx_init(machine, WD_TYPE_177X, NULL, NULL); | |
| 1430 | 1433 | |
| 1431 | 1434 | einstein_z80pio = device_list_find_by_tag( machine->config->devicelist, Z80PIO, "z80pio" ); |
| 1432 | 1435 | } |
| r3867 | r3868 | |
| 1746 | 1749 | |
| 1747 | 1750 | /* uart */ |
| 1748 | 1751 | MDRV_DEVICE_ADD("uart", MSM8251) |
| 1752 | ||
| 1753 | MDRV_WD177X_ADD("wd177x", default_wd17xx_interface ) | |
| 1749 | 1754 | MACHINE_DRIVER_END |
| 1750 | 1755 | |
| 1751 | 1756 |
| r3867 | r3868 | |
|---|---|---|
| 52 | 52 | AM_RANGE(0xf1, 0xf1) AM_READWRITE(erik_rr_reg_r, erik_rr_reg_w) |
| 53 | 53 | AM_RANGE(0xf2, 0xf2) AM_READWRITE(erik_rc_reg_r, erik_rc_reg_w) |
| 54 | 54 | AM_RANGE(0xf3, 0xf3) AM_READWRITE(erik_disk_reg_r, erik_disk_reg_w) |
| 55 | AM_RANGE(0xf4, 0xf4) AM_READWRITE(wd17xx_status_r, wd17xx_command_w) | |
| 56 | AM_RANGE(0xf5, 0xf5) AM_READWRITE(wd17xx_track_r, wd17xx_track_w) | |
| 57 | AM_RANGE(0xf6, 0xf6) AM_READWRITE(wd17xx_sector_r, wd17xx_sector_w) | |
| 58 | AM_RANGE(0xf7, 0xf7) AM_READWRITE(wd17xx_data_r, wd17xx_data_w) | |
| 55 | AM_RANGE(0xf4, 0xf4) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_status_r, wd17xx_command_w) | |
| 56 | AM_RANGE(0xf5, 0xf5) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_track_r, wd17xx_track_w) | |
| 57 | AM_RANGE(0xf6, 0xf6) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_sector_r, wd17xx_sector_w) | |
| 58 | AM_RANGE(0xf7, 0xf7) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_data_r, wd17xx_data_w) | |
| 59 | 59 | ADDRESS_MAP_END |
| 60 | 60 | |
| 61 | 61 | static ADDRESS_MAP_START(specimx_mem, ADDRESS_SPACE_PROGRAM, 8) |
| r3867 | r3868 | |
| 66 | 66 | AM_RANGE( 0xffc0, 0xffdf ) AM_RAMBANK(4) |
| 67 | 67 | AM_RANGE( 0xffe0, 0xffe3 ) AM_READWRITE(specialist_keyboard_r,specialist_keyboard_w) // 8255 for keyboard |
| 68 | 68 | AM_RANGE( 0xffe4, 0xffe7 ) AM_RAM //external 8255 |
| 69 | AM_RANGE( 0xffe8, 0xffe8 ) AM_READWRITE(wd17xx_status_r,wd17xx_command_w) | |
| 70 | AM_RANGE( 0xffe9, 0xffe9 ) AM_READWRITE(wd17xx_track_r,wd17xx_track_w) | |
| 71 | AM_RANGE( 0xffea, 0xffea ) AM_READWRITE(wd17xx_sector_r,wd17xx_sector_w) | |
| 72 | AM_RANGE( 0xffea, 0xffeb ) AM_READWRITE(wd17xx_data_r,wd17xx_data_w) | |
| 69 | AM_RANGE( 0xffe8, 0xffe8 ) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_status_r,wd17xx_command_w) | |
| 70 | AM_RANGE( 0xffe9, 0xffe9 ) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_track_r,wd17xx_track_w) | |
| 71 | AM_RANGE( 0xffea, 0xffea ) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_sector_r,wd17xx_sector_w) | |
| 72 | AM_RANGE( 0xffea, 0xffeb ) AM_DEVREADWRITE(WD1793, "wd1793", wd17xx_data_r,wd17xx_data_w) | |
| 73 | 73 | AM_RANGE( 0xffec, 0xffef ) AM_DEVREADWRITE(PIT8253, "pit8253", pit8253_r, pit8253_w) |
| 74 | 74 | AM_RANGE( 0xfff0, 0xfff3 ) AM_READWRITE(specimx_disk_ctrl_r, specimx_disk_ctrl_w) |
| 75 | 75 | AM_RANGE( 0xfff8, 0xfff8 ) AM_READWRITE(specimx_video_color_r,specimx_video_color_w) |
| r3867 | r3868 | |
| 380 | 380 | MDRV_SOUND_ADD("custom", CUSTOM, 0) |
| 381 | 381 | MDRV_SOUND_CONFIG(specimx_sound_interface) |
| 382 | 382 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 383 | ||
| 384 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 383 | 385 | MACHINE_DRIVER_END |
| 384 | 386 | |
| 385 | 387 | static MACHINE_DRIVER_START( erik ) |
| r3867 | r3868 | |
| 389 | 391 | MDRV_CPU_IO_MAP(erik_io_map, 0) |
| 390 | 392 | |
| 391 | 393 | MDRV_MACHINE_RESET( erik ) |
| 392 | MDRV_MACHINE_START( erik ) | |
| 393 | 394 | |
| 394 | 395 | MDRV_PPI8255_ADD( "ppi8255", specialist_ppi8255_interface ) |
| 395 | 396 | |
| r3867 | r3868 | |
| 413 | 414 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 414 | 415 | |
| 415 | 416 | MDRV_CASSETTE_ADD( "cassette", special_cassette_config ) |
| 417 | ||
| 418 | MDRV_WD1793_ADD("wd1793", default_wd17xx_interface ) | |
| 416 | 419 | MACHINE_DRIVER_END |
| 417 | 420 | |
| 418 | 421 | /* ROM definition */ |
| r3867 | r3868 | |
|---|---|---|
| 37 | 37 | #include "driver.h" |
| 38 | 38 | #include "cpu/z80/z80.h" |
| 39 | 39 | #include "devices/basicdsk.h" |
| 40 | #include "machine/wd17xx.h" | |
| 40 | 41 | #include "cpu/z80/z80daisy.h" |
| 41 | 42 | #include "includes/osborne1.h" |
| 42 | 43 | |
| r3867 | r3868 | |
| 168 | 169 | MDRV_CPU_IO_MAP( osborne1_io, 0 ) |
| 169 | 170 | MDRV_CPU_CONFIG( osborne1_daisy_chain ) |
| 170 | 171 | |
| 171 | MDRV_MACHINE_START( osborne1 ) | |
| 172 | 172 | MDRV_MACHINE_RESET( osborne1 ) |
| 173 | 173 | |
| 174 | 174 | MDRV_DEVICE_ADD( "osborne1_daisy", OSBORNE1_DAISY ) |
| r3867 | r3868 | |
| 184 | 184 | MDRV_SPEAKER_STANDARD_MONO( "mono" ) |
| 185 | 185 | MDRV_SOUND_ADD( "beep", BEEP, 0 ) |
| 186 | 186 | MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) |
| 187 | ||
| 188 | MDRV_MB8877_ADD("mb8877", default_wd17xx_interface ) | |
| 189 | ||
| 187 | 190 | MACHINE_DRIVER_END |
| 188 | 191 | |
| 189 | 192 |
| r3867 | r3868 | |
|---|---|---|
| 428 | 428 | amstrad_ppi_portc_w /* port C write */ |
| 429 | 429 | }; |
| 430 | 430 | |
| 431 | static | |
| 431 | static NEC765_INTERRUPT( aleste_interrupt | |
| 432 | 432 | { |
| 433 | 433 | if(state == CLEAR_LINE) |
| 434 | 434 | aleste_fdc_int = 0; |
| r3867 | r3868 | |
| 440 | 440 | static const nec765_interface amstrad_nec765_interface = |
| 441 | 441 | { |
| 442 | 442 | NULL, |
| 443 | NULL | |
| 443 | NULL, | |
| 444 | NULL, | |
| 445 | NEC765_RDY_PIN_CONNECTED | |
| 444 | 446 | }; |
| 445 | 447 | |
| 446 | 448 | /* Aleste uses an 8272A, with the interrupt flag visible on PPI port B */ |
| 447 | 449 | static const nec765_interface aleste_8272_interface = |
| 448 | 450 | { |
| 449 | 451 | aleste_interrupt, |
| 450 | NULL | |
| 452 | NULL, | |
| 453 | NULL, | |
| 454 | NEC765_RDY_PIN_CONNECTED | |
| 451 | 455 | }; |
| 452 | 456 | |
| 453 | 457 | /* pointers to current ram configuration selected for banks */ |
| r3867 | r3868 | |
| 1242 | 1246 | |
| 1243 | 1247 | static READ8_HANDLER ( AmstradCPC_ReadPortHandler ) |
| 1244 | 1248 | { |
| 1249 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 1245 | 1250 | unsigned char data = 0xFF; |
| 1246 | 1251 | unsigned int r1r0 = (unsigned int)((offset & 0x0300) >> 8); |
| 1247 | 1252 | m6845_personality_t crtc_type; |
| r3867 | r3868 | |
| 1324 | 1329 | int b8b0 = ((offset & (1<<8)) >> (8 - 1)) | (offset & (0x01)); |
| 1325 | 1330 | switch (b8b0) { |
| 1326 | 1331 | case 0x02: { |
| 1327 | data = nec765_status_r( | |
| 1332 | data = nec765_status_r(fd | |
| 1328 | 1333 | } break; |
| 1329 | 1334 | case 0x03: { |
| 1330 | data = nec765_data_r( | |
| 1335 | data = nec765_data_r(fd | |
| 1331 | 1336 | } break; |
| 1332 | 1337 | default: { |
| 1333 | 1338 | } break; |
| r3867 | r3868 | |
| 1341 | 1346 | /* Offset handler for write */ |
| 1342 | 1347 | static WRITE8_HANDLER ( AmstradCPC_WritePortHandler ) |
| 1343 | 1348 | { |
| 1349 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, NEC765A, "nec765"); | |
| 1344 | 1350 | if ((offset & (1<<15)) == 0) |
| 1345 | 1351 | { |
| 1346 | 1352 | if(aleste_mode & 0x04) // Aleste mode |
| r3867 | r3868 | |
| 1456 | 1462 | break; |
| 1457 | 1463 | |
| 1458 | 1464 | case 0x03: /* Write Data register of FDC */ |
| 1459 | nec765_data_w( | |
| 1465 | nec765_data_w(fd | |
| 1460 | 1466 | break; |
| 1461 | 1467 | default: |
| 1462 | 1468 | break; |
| r3867 | r3868 | |
| 2044 | 2050 | |
| 2045 | 2051 | if(amstrad_system_type != SYSTEM_GX4000) |
| 2046 | 2052 | { |
| 2047 | nec765_init(machine, &amstrad_nec765_interface,NEC765A/*?*/,NEC765_RDY_PIN_CONNECTED); | |
| 2048 | 2053 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 2049 | 2054 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 2050 | 2055 | } |
| r3867 | r3868 | |
| 2242 | 2247 | amstrad_common_init(machine); |
| 2243 | 2248 | amstrad_reset_machine(machine); |
| 2244 | 2249 | |
| 2245 | nec765_init(machine, &aleste_8272_interface,NEC765A,NEC765_RDY_PIN_CONNECTED); | |
| 2246 | 2250 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |
| 2247 | 2251 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_DS_80); |
| 2248 | 2252 | } |
| r3867 | r3868 | |
| 2984 | 2988 | MDRV_SNAPSHOT_ADD(amstrad, "sna", 0) |
| 2985 | 2989 | |
| 2986 | 2990 | MDRV_CASSETTE_ADD( "cassette", amstrad_cassette_config ) |
| 2991 | ||
| 2992 | MDRV_NEC765A_ADD("nec765", amstrad_nec765_interface) | |
| 2987 | 2993 | MACHINE_DRIVER_END |
| 2988 | 2994 | |
| 2989 | 2995 | |
| r3867 | r3868 | |
| 3032 | 3038 | MDRV_DEVICE_REMOVE("printer", PRINTER) |
| 3033 | 3039 | |
| 3034 | 3040 | MDRV_CASSETTE_REMOVE( "cassette" ) |
| 3041 | MDRV_NEC765A_REMOVE( "nec765" ) | |
| 3035 | 3042 | MACHINE_DRIVER_END |
| 3036 | 3043 | |
| 3037 | 3044 | |
| r3867 | r3868 | |
| 3045 | 3052 | MDRV_PALETTE_LENGTH(32+64) |
| 3046 | 3053 | MDRV_PALETTE_INIT(aleste) |
| 3047 | 3054 | MDRV_NVRAM_HANDLER(mc146818) |
| 3055 | MDRV_NEC765A_MODIFY("nec765", aleste_8272_interface) | |
| 3048 | 3056 | MACHINE_DRIVER_END |
| 3049 | 3057 | |
| 3050 | 3058 |
| r3867 | r3868 | |
|---|---|---|
| 177 | 177 | a310_memc_reset(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | static | |
| 180 | static WD17XX_CALLBACK ( a310_wd177x_callback | |
| 181 | 181 | { |
| 182 | switch ( | |
| 182 | switch (s | |
| 183 | 183 | { |
| 184 | 184 | case WD17XX_IRQ_CLR: |
| 185 | 185 | a310_iocregs[12] &= ~A310_FIQ_FLOPPY; |
| 186 | 186 | break; |
| 187 | 187 | |
| 188 | 188 | case WD17XX_IRQ_SET: |
| 189 | a310_request_fiq(machine, A310_FIQ_FLOPPY); | |
| 189 | a310_request_fiq(device->machine, A310_FIQ_FLOPPY); | |
| 190 | 190 | break; |
| 191 | 191 | |
| 192 | 192 | case WD17XX_DRQ_CLR: |
| r3867 | r3868 | |
| 194 | 194 | break; |
| 195 | 195 | |
| 196 | 196 | case WD17XX_DRQ_SET: |
| 197 | a310_request_fiq(machine, A310_FIQ_FLOPPY_DRQ); | |
| 197 | a310_request_fiq(device->machine, A310_FIQ_FLOPPY_DRQ); | |
| 198 | 198 | break; |
| 199 | 199 | } |
| 200 | 200 | } |
| r3867 | r3868 | |
| 203 | 203 | static MACHINE_START( a310 ) |
| 204 | 204 | { |
| 205 | 205 | a310_pagesize = 0; |
| 206 | wd17xx_init(machine, WD_TYPE_1772, a310_wd177x_callback, NULL); | |
| 207 | 206 | |
| 208 | 207 | vbl_timer = timer_alloc(machine, a310_vblank, NULL); |
| 209 | 208 | timer_adjust_oneshot(vbl_timer, attotime_never, 0); |
| r3867 | r3868 | |
| 367 | 366 | |
| 368 | 367 | static READ32_HANDLER(ioc_r) |
| 369 | 368 | { |
| 369 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 370 | 370 | if (offset >= 0x80000 && offset < 0xc0000) |
| 371 | 371 | { |
| 372 | 372 | switch (offset & 0x1f) |
| r3867 | r3868 | |
| 407 | 407 | else if (offset >= 0xc4000 && offset <= 0xc4010) |
| 408 | 408 | { |
| 409 | 409 | logerror("17XX: R @ addr %x mask %08x\n", offset*4, mem_mask); |
| 410 | return wd17xx_data_r( | |
| 410 | return wd17xx_data_r(fd | |
| 411 | 411 | } |
| 412 | 412 | else |
| 413 | 413 | { |
| r3867 | r3868 | |
| 420 | 420 | |
| 421 | 421 | static WRITE32_HANDLER(ioc_w) |
| 422 | 422 | { |
| 423 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 423 | 424 | if (offset >= 0x80000 && offset < 0xc0000) |
| 424 | 425 | { |
| 425 | 426 | // logerror("IOC: W %02x @ reg %s (PC=%x)\n", data&0xff, ioc_regnames[offset&0x1f], cpu_get_pc( space->cpu )); |
| r3867 | r3868 | |
| 504 | 505 | else if (offset >= 0xc4000 && offset <= 0xc4010) |
| 505 | 506 | { |
| 506 | 507 | logerror("17XX: %x to addr %x mask %08x\n", data, offset*4, mem_mask); |
| 507 | wd17xx_data_w( | |
| 508 | wd17xx_data_w(fd | |
| 508 | 509 | } |
| 509 | 510 | else if (offset == 0xd40006) |
| 510 | 511 | { |
| 511 | 512 | // latch A |
| 512 | 513 | if (data & 1) |
| 513 | 514 | { |
| 514 | wd17xx_set_drive(0); | |
| 515 | wd17xx_set_drive(fdc,0); | |
| 515 | 516 | } |
| 516 | 517 | if (data & 2) |
| 517 | 518 | { |
| 518 | wd17xx_set_drive(1); | |
| 519 | wd17xx_set_drive(fdc,1); | |
| 519 | 520 | } |
| 520 | 521 | if (data & 4) |
| 521 | 522 | { |
| 522 | wd17xx_set_drive(2); | |
| 523 | wd17xx_set_drive(fdc,2); | |
| 523 | 524 | } |
| 524 | 525 | if (data & 8) |
| 525 | 526 | { |
| 526 | wd17xx_set_drive(3); | |
| 527 | wd17xx_set_drive(fdc,3); | |
| 527 | 528 | } |
| 528 | 529 | |
| 529 | wd17xx_set_side((data & 0x10)>>4); | |
| 530 | wd17xx_set_side(fdc,(data & 0x10)>>4); | |
| 530 | 531 | |
| 531 | 532 | } |
| 532 | 533 | else if (offset == 0xd40010) |
| 533 | 534 | { |
| 534 | 535 | // latch B |
| 535 | wd17xx_set_density((data & 2) ? DEN_MFM_LO : DEN_MFM_HI); | |
| 536 | wd17xx_set_density(fdc,(data & 2) ? DEN_MFM_LO : DEN_MFM_HI); | |
| 536 | 537 | } |
| 537 | 538 | else |
| 538 | 539 | { |
| r3867 | r3868 | |
| 856 | 857 | PORT_BIT (0xf8, 0x80, IPT_UNUSED) |
| 857 | 858 | INPUT_PORTS_END |
| 858 | 859 | |
| 860 | const wd17xx_interface a310_wd17xx_interface = { | |
| 861 | a310_wd177x_callback, | |
| 862 | NULL | |
| 863 | }; | |
| 859 | 864 | |
| 860 | 865 | static MACHINE_DRIVER_START( a310 ) |
| 861 | 866 | /* basic machine hardware */ |
| r3867 | r3868 | |
| 880 | 885 | MDRV_SPEAKER_STANDARD_MONO("a310") |
| 881 | 886 | MDRV_SOUND_ADD("dac", DAC, 0) |
| 882 | 887 | MDRV_SOUND_ROUTE(0, "a310", 1.00) |
| 888 | ||
| 889 | MDRV_WD1772_ADD("wd1772", a310_wd17xx_interface ) | |
| 883 | 890 | MACHINE_DRIVER_END |
| 884 | 891 | |
| 885 | ||
| 886 | 892 | ROM_START(a310) |
| 887 | 893 | ROM_REGION(0x800000, "main", 0) |
| 888 | 894 | ROM_SYSTEM_BIOS(0, "311", "RiscOS 3.11 (29 Sep 1992)") |
| r3867 | r3868 | |
| 900 | 906 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 901 | 907 | COMP( 1988, a310, 0, 0, a310, a310, a310, NULL, "Acorn", "Archimedes 310 (Risc OS 3.11)", GAME_NOT_WORKING) |
| 902 | 908 | |
| 909 |
| r3867 | r3868 | |
|---|---|---|
| 80 | 80 | |
| 81 | 81 | static READ8_HANDLER( samcoupe_disk_r ) |
| 82 | 82 | { |
| 83 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 84 | ||
| 83 | 85 | /* drive and side is encoded into bit 5 and 3 */ |
| 84 | wd17xx_set_drive((offset >> 4) & 1); | |
| 85 | wd17xx_set_side((offset >> 2) & 1); | |
| 86 | wd17xx_set_drive(fdc,(offset >> 4) & 1); | |
| 87 | wd17xx_set_side(fdc,(offset >> 2) & 1); | |
| 86 | 88 | |
| 87 | 89 | /* bit 1 and 2 select the controller register */ |
| 88 | 90 | switch (offset & 0x03) |
| 89 | 91 | { |
| 90 | case 0: return wd17xx_status_r(space, 0); | |
| 91 | case 1: return wd17xx_track_r(space, 0); | |
| 92 | case 2: return wd17xx_sector_r(space, 0); | |
| 93 | case 3: return wd17xx_data_r(space, 0); | |
| 92 | case 0: return wd17xx_status_r(fdc, 0); | |
| 93 | case 1: return wd17xx_track_r(fdc, 0); | |
| 94 | case 2: return wd17xx_sector_r(fdc, 0); | |
| 95 | case 3: return wd17xx_data_r(fdc, 0); | |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | return 0xff; |
| r3867 | r3868 | |
| 99 | 101 | |
| 100 | 102 | static WRITE8_HANDLER( samcoupe_disk_w ) |
| 101 | 103 | { |
| 104 | device_config *fdc = (device_config*)device_list_find_by_tag( space->machine->config->devicelist, WD1772, "wd1772"); | |
| 105 | ||
| 102 | 106 | /* drive and side is encoded into bit 5 and 3 */ |
| 103 | wd17xx_set_drive((offset >> 4) & 1); | |
| 104 | wd17xx_set_side((offset >> 2) & 1); | |
| 107 | wd17xx_set_drive(fdc,(offset >> 4) & 1); | |
| 108 | wd17xx_set_side(fdc,(offset >> 2) & 1); | |
| 105 | 109 | |
| 106 | 110 | /* bit 1 and 2 select the controller register */ |
| 107 | 111 | switch (offset & 0x03) |
| 108 | 112 | { |
| 109 | case 0: wd17xx_command_w(space, 0, data); break; | |
| 110 | case 1: wd17xx_track_w(space, 0, data); break; | |
| 111 | case 2: wd17xx_sector_w(space, 0, data); break; | |
| 112 | case 3: wd17xx_data_w(space, 0, data); break; | |
| 113 | case 0: wd17xx_command_w(fdc, 0, data); break; | |
| 114 | case 1: wd17xx_track_w(fdc, 0, data); break; | |
| 115 | case 2: wd17xx_sector_w(fdc, 0, data); break; | |
| 116 | case 3: wd17xx_data_w(fdc, 0, data); break; | |
| 113 | 117 | } |
| 114 | 118 | } |
| 115 | 119 | |
| r3867 | r3868 | |
| 517 | 521 | MDRV_CPU_IO_MAP(samcoupe_io, 0) |
| 518 | 522 | MDRV_CPU_VBLANK_INT("main", samcoupe_frame_interrupt) |
| 519 | 523 | |
| 520 | MDRV_MACHINE_START(samcoupe) | |
| 521 | 524 | MDRV_MACHINE_RESET(samcoupe) |
| 522 | 525 | |
| 523 | 526 | /* video hardware */ |
| r3867 | r3868 | |
| 540 | 543 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 541 | 544 | MDRV_SOUND_ADD("saa1099", SAA1099, SAMCOUPE_XTAL_X1/3) /* 8 MHz */ |
| 542 | 545 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 546 | ||
| 547 | MDRV_WD1772_ADD("wd1772", default_wd17xx_interface ) | |
| 543 | 548 | MACHINE_DRIVER_END |
| 544 | 549 | |
| 545 | 550 | |
| 546 | ||
| 547 | 551 | /************************************* |
| 548 | 552 | * |
| 549 | 553 | * ROM definitions |
| r3867 | r3868 | |
|---|---|---|
| 390 | 390 | MDRV_QUICKLOAD_ADD(comx35, "comx", 0) |
| 391 | 391 | |
| 392 | 392 | MDRV_CASSETTE_ADD( "cassette", comx35_cassette_config ) |
| 393 | ||
| 394 | MDRV_WD1770_ADD("wd1770", comx35_wd17xx_interface ) | |
| 393 | 395 | MACHINE_DRIVER_END |
| 394 | 396 | |
| 395 | 397 | static MACHINE_DRIVER_START( comx35n ) |
| r3867 | r3868 | |
|---|---|---|
| 94 | 94 | #define FW TRS80_FONT_W |
| 95 | 95 | #define FH TRS80_FONT_H |
| 96 | 96 | |
| 97 | static READ8_HANDLER (trs80_wd179x_r) | |
| 97 | static READ8_DEVICE_HANDLER (trs80_wd179x_r) | |
| 98 | 98 | { |
| 99 | if (input_port_read( | |
| 99 | if (input_port_read(device->machine, "CONFIG") & 0x80) | |
| 100 | 100 | { |
| 101 | return wd17xx_status_r( | |
| 101 | return wd17xx_status_r(device, offset); | |
| 102 | 102 | } |
| 103 | 103 | else |
| 104 | 104 | { |
| r3867 | r3868 | |
| 125 | 125 | AM_RANGE(0x37e0, 0x37e3) AM_READWRITE(trs80_irq_status_r, trs80_motor_w) |
| 126 | 126 | AM_RANGE(0x37e4, 0x37e7) AM_NOP |
| 127 | 127 | AM_RANGE(0x37e8, 0x37eb) AM_READWRITE(trs80_printer_r, trs80_printer_w) |
| 128 | AM_RANGE(0x37ec, 0x37ec) AM_READWRITE(trs80_wd179x_r, wd17xx_command_w) | |
| 129 | AM_RANGE(0x37ed, 0x37ed) AM_READWRITE(wd17xx_track_r, wd17xx_track_w) | |
| 130 | AM_RANGE(0x37ee, 0x37ee) AM_READWRITE(wd17xx_sector_r, wd17xx_sector_w) | |
| 131 | AM_RANGE(0x37ef, 0x37ef) AM_READWRITE(wd17xx_data_r, wd17xx_data_w) | |
| 128 | AM_RANGE(0x37ec, 0x37ec) AM_DEVREADWRITE(WD179X, "wd179x", trs80_wd179x_r, wd17xx_command_w) | |
| 129 | AM_RANGE(0x37ed, 0x37ed) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_track_r, wd17xx_track_w) | |
| 130 | AM_RANGE(0x37ee, 0x37ee) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_sector_r, wd17xx_sector_w) | |
| 131 | AM_RANGE(0x37ef, 0x37ef) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_data_r, wd17xx_data_w) | |
| 132 | 132 | AM_RANGE(0x37f0, 0x37ff) AM_NOP |
| 133 | 133 | AM_RANGE(0x3800, 0x38ff) AM_READ(trs80_keyboard_r) |
| 134 | 134 | AM_RANGE(0x3900, 0x3bff) AM_NOP |
| r3867 | r3868 | |
| 159 | 159 | AM_RANGE(0xea, 0xea) AM_NOP |
| 160 | 160 | AM_RANGE(0xeb, 0xeb) AM_NOP |
| 161 | 161 | AM_RANGE(0xec, 0xec) AM_WRITENOP |
| 162 | AM_RANGE(0xf0, 0xf0) AM_READWRITE(trs80_wd179x_r, wd17xx_command_w) | |
| 163 | AM_RANGE(0xf1, 0xf1) AM_READWRITE(wd17xx_track_r, wd17xx_track_w) | |
| 164 | AM_RANGE(0xf2, 0xf2) AM_READWRITE(wd17xx_sector_r, wd17xx_sector_w) | |
| 165 | AM_RANGE(0xf3, 0xf3) AM_READWRITE(wd17xx_data_r, wd17xx_data_w) | |
| 162 | AM_RANGE(0xf0, 0xf0) AM_DEVREADWRITE(WD179X, "wd179x", trs80_wd179x_r, wd17xx_command_w) | |
| 163 | AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_track_r, wd17xx_track_w) | |
| 164 | AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_sector_r, wd17xx_sector_w) | |
| 165 | AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE(WD179X, "wd179x", wd17xx_data_r, wd17xx_data_w) | |
| 166 | 166 | AM_RANGE(0xf4, 0xf4) AM_WRITENOP |
| 167 | 167 | AM_RANGE(0xf8, 0xf8) AM_WRITENOP |
| 168 | 168 | AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_port_ff_r, trs80_port_ff_w) |
| r3867 | r3868 | |
| 386 | 386 | MDRV_CPU_PERIODIC_INT(trs80_timer_interrupt, 40) |
| 387 | 387 | MDRV_INTERLEAVE(1) |
| 388 | 388 | |
| 389 | MDRV_MACHINE_START( trs80 ) | |
| 390 | 389 | MDRV_MACHINE_RESET( trs80 ) |
| 391 | 390 | |
| 392 | 391 | /* video hardware */ |
| r3867 | r3868 | |
| 412 | 411 | MDRV_QUICKLOAD_ADD(trs80_cmd, "cmd", 0.5) |
| 413 | 412 | |
| 414 | 413 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 414 | ||
| 415 | MDRV_WD179X_ADD("wd179x", trs80_wd17xx_interface ) | |
| 415 | 416 | MACHINE_DRIVER_END |
| 416 | 417 | |
| 417 | ||
| 418 | 418 | static MACHINE_DRIVER_START( model1 ) |
| 419 | 419 | MDRV_IMPORT_FROM( level1 ) |
| 420 | 420 | MDRV_CPU_MODIFY( "main" ) |
| r3867 | r3868 | |
|---|---|---|
| 14 | 14 | #include "includes/svi318.h" |
| 15 | 15 | #include "video/tms9928a.h" |
| 16 | 16 | #include "machine/8255ppi.h" |
| 17 | #include "machine/wd17xx.h" | |
| 17 | 18 | #include "devices/basicdsk.h" |
| 18 | 19 | #include "devices/printer.h" |
| 19 | 20 | #include "devices/cartslot.h" |
| r3867 | r3868 | |
| 303 | 304 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 304 | 305 | |
| 305 | 306 | MDRV_CASSETTE_ADD( "cassette", svi318_cassette_config ) |
| 307 | ||
| 308 | MDRV_WD179X_ADD("wd179x", svi_wd17xx_interface ) | |
| 306 | 309 | MACHINE_DRIVER_END |
| 307 | 310 | |
| 308 | 311 | static MACHINE_DRIVER_START( svi318n ) |
| r3867 | r3868 | |
|---|---|---|
| 1367 | 1367 | |
| 1368 | 1368 | /* harddisk */ |
| 1369 | 1369 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1370 | ||
| 1371 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1370 | 1372 | MACHINE_DRIVER_END |
| 1371 | 1373 | |
| 1372 | 1374 | |
| r3867 | r3868 | |
| 1421 | 1423 | |
| 1422 | 1424 | /* harddisk */ |
| 1423 | 1425 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1426 | ||
| 1427 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1424 | 1428 | MACHINE_DRIVER_END |
| 1425 | 1429 | |
| 1426 | 1430 | static const cassette_config ibm5150_cassette_config = |
| r3867 | r3868 | |
| 1487 | 1491 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1488 | 1492 | |
| 1489 | 1493 | MDRV_CASSETTE_ADD( "cassette", ibm5150_cassette_config ) |
| 1494 | ||
| 1495 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1490 | 1496 | MACHINE_DRIVER_END |
| 1491 | 1497 | |
| 1492 | 1498 | static MACHINE_DRIVER_START( pccga ) |
| r3867 | r3868 | |
| 1541 | 1547 | |
| 1542 | 1548 | /* harddisk */ |
| 1543 | 1549 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1550 | ||
| 1551 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1544 | 1552 | MACHINE_DRIVER_END |
| 1545 | 1553 | |
| 1546 | 1554 | |
| r3867 | r3868 | |
| 1588 | 1596 | |
| 1589 | 1597 | /* harddisk */ |
| 1590 | 1598 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1599 | ||
| 1600 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1591 | 1601 | MACHINE_DRIVER_END |
| 1592 | 1602 | |
| 1593 | 1603 | |
| r3867 | r3868 | |
| 1641 | 1651 | |
| 1642 | 1652 | /* harddisk */ |
| 1643 | 1653 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1654 | ||
| 1655 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1644 | 1656 | MACHINE_DRIVER_END |
| 1645 | 1657 | |
| 1646 | 1658 | |
| r3867 | r3868 | |
| 1681 | 1693 | |
| 1682 | 1694 | /* harddisk */ |
| 1683 | 1695 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1696 | ||
| 1697 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1684 | 1698 | MACHINE_DRIVER_END |
| 1685 | 1699 | |
| 1686 | 1700 | |
| r3867 | r3868 | |
| 1723 | 1737 | |
| 1724 | 1738 | /* harddisk */ |
| 1725 | 1739 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1740 | ||
| 1741 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1726 | 1742 | MACHINE_DRIVER_END |
| 1727 | 1743 | |
| 1728 | 1744 | |
| r3867 | r3868 | |
| 1768 | 1784 | |
| 1769 | 1785 | /* harddisk */ |
| 1770 | 1786 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1787 | ||
| 1788 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1771 | 1789 | MACHINE_DRIVER_END |
| 1772 | 1790 | |
| 1773 | 1791 | |
| r3867 | r3868 | |
| 1817 | 1835 | |
| 1818 | 1836 | /* harddisk */ |
| 1819 | 1837 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1838 | ||
| 1839 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1820 | 1840 | MACHINE_DRIVER_END |
| 1821 | 1841 | |
| 1822 | 1842 | |
| r3867 | r3868 | |
| 1859 | 1879 | |
| 1860 | 1880 | /* harddisk */ |
| 1861 | 1881 | MDRV_IMPORT_FROM( pc_hdc ) |
| 1882 | ||
| 1883 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1862 | 1884 | MACHINE_DRIVER_END |
| 1863 | 1885 | |
| 1864 | 1886 | |
| r3867 | r3868 | |
| 1900 | 1922 | MDRV_DEVICE_ADD("printer3", PRINTER) |
| 1901 | 1923 | |
| 1902 | 1924 | MDRV_CASSETTE_ADD( "cassette", ibm5150_cassette_config ) |
| 1925 | ||
| 1926 | MDRV_NEC765A_ADD("nec765", pc_fdc_nec765_not_connected_interface) | |
| 1903 | 1927 | MACHINE_DRIVER_END |
| 1904 | 1928 | |
| 1905 | 1929 | #if 0 |
| r3867 | r3868 | |
|---|---|---|
| 552 | 552 | /* tms9902 */ |
| 553 | 553 | MDRV_TMS9902_ADD("tms9902_0", tms9902_params_0) |
| 554 | 554 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) |
| 555 | ||
| 556 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) | |
| 555 | 557 | MACHINE_DRIVER_END |
| 556 | 558 | |
| 557 | 559 | static MACHINE_DRIVER_START(ti99_4_50hz) |
| r3867 | r3868 | |
| 598 | 600 | /* tms9902 */ |
| 599 | 601 | MDRV_TMS9902_ADD("tms9902_0", tms9902_params_0) |
| 600 | 602 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) |
| 603 | ||
| 604 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) | |
| 601 | 605 | MACHINE_DRIVER_END |
| 602 | 606 | |
| 603 | 607 | static MACHINE_DRIVER_START(ti99_4a_60hz) |
| r3867 | r3868 | |
| 645 | 649 | /* tms9902 */ |
| 646 | 650 | MDRV_TMS9902_ADD("tms9902_0", tms9902_params_0) |
| 647 | 651 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) |
| 652 | ||
| 653 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) | |
| 648 | 654 | MACHINE_DRIVER_END |
| 649 | 655 | |
| 650 | 656 | |
| r3867 | r3868 | |
| 692 | 698 | /* tms9902 */ |
| 693 | 699 | MDRV_TMS9902_ADD("tms9902_0", tms9902_params_0) |
| 694 | 700 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) |
| 701 | ||
| 702 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) | |
| 695 | 703 | MACHINE_DRIVER_END |
| 696 | 704 | |
| 697 | 705 | |
| r3867 | r3868 | |
| 746 | 754 | MDRV_TMS9901_ADD("tms9901", tms9901reset_param_ti99_4x) |
| 747 | 755 | /* tms9902 */ |
| 748 | 756 | MDRV_TMS9902_ADD("tms9902_0", tms9902_params_0) |
| 749 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) | |
| 757 | MDRV_TMS9902_ADD("tms9902_1", tms9902_params_1) | |
| 758 | ||
| 759 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) | |
| 750 | 760 | MACHINE_DRIVER_END |
| 751 | 761 | |
| 752 | 762 |
| r3867 | r3868 | |
|---|---|---|
| 770 | 770 | MDRV_MACHINE_RESET( bbcb ) |
| 771 | 771 | MDRV_VIDEO_START( bbcb ) |
| 772 | 772 | MDRV_VIA6522_ADD("via6522_1", 1000000, bbcb_user_via) |
| 773 | ||
| 774 | MDRV_WD177X_ADD("wd177x", bbc_wd17xx_interface ) | |
| 773 | 775 | MACHINE_DRIVER_END |
| 774 | 776 | |
| 775 | 777 | |
| r3867 | r3868 | |
| 781 | 783 | MDRV_MACHINE_RESET( bbcbp ) |
| 782 | 784 | MDRV_VIDEO_START( bbcbp ) |
| 783 | 785 | MDRV_VIA6522_ADD("via6522_1", 1000000, bbcb_user_via) |
| 786 | MDRV_WD177X_ADD("wd177x", bbc_wd17xx_interface ) | |
| 784 | 787 | MACHINE_DRIVER_END |
| 785 | 788 | |
| 786 | 789 | |
| r3867 | r3868 | |
| 792 | 795 | MDRV_MACHINE_RESET( bbcbp ) |
| 793 | 796 | MDRV_VIDEO_START( bbcbp ) |
| 794 | 797 | MDRV_VIA6522_ADD("via6522_1", 1000000, bbcb_user_via) |
| 798 | MDRV_WD177X_ADD("wd177x", bbc_wd17xx_interface ) | |
| 795 | 799 | MACHINE_DRIVER_END |
| 796 | 800 | |
| 797 | 801 | |
| r3867 | r3868 | |
| 841 | 845 | MDRV_UPD7002_ADD("upd7002",BBC_uPD7002) |
| 842 | 846 | MDRV_VIA6522_ADD("via6522_0", 1000000, bbcb_system_via) |
| 843 | 847 | MDRV_VIA6522_ADD("via6522_1", 1000000, bbcb_user_via) |
| 848 | MDRV_WD177X_ADD("wd177x", bbc_wd17xx_interface ) | |
| 844 | 849 | MACHINE_DRIVER_END |
| 845 | 850 | |
| 846 | 851 | static void bbc_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| r3867 | r3868 | |
|---|---|---|
| 40 | 40 | #include "machine/pit8253.h" |
| 41 | 41 | #include "machine/pic8259.h" |
| 42 | 42 | #include "machine/mm58274c.h" |
| 43 | #include "machine/nec765.h" | |
| 43 | 44 | #include "formats/cpis_dsk.h" |
| 44 | 45 | |
| 45 | 46 | |
| r3867 | r3868 | |
| 275 | 276 | |
| 276 | 277 | /* rtc */ |
| 277 | 278 | MDRV_MM58274C_ADD("mm58274c", compis_mm58274c_interface) |
| 279 | ||
| 280 | MDRV_NEC765A_ADD("nec765", compis_fdc_interface) | |
| 278 | 281 | MACHINE_DRIVER_END |
| 279 | 282 | |
| 280 | 283 | /*************************************************************************** |
| r3867 | r3868 | |
|---|---|---|
| 333 | 333 | ADDRESS_MAP_END |
| 334 | 334 | |
| 335 | 335 | static ADDRESS_MAP_START(kc85_disc_hw_io, ADDRESS_SPACE_IO, 8) |
| 336 | AM_RANGE(0x0f0, 0x0f0) AM_READ(nec765_status_r) | |
| 337 | AM_RANGE(0x0f1, 0x0f1) AM_READWRITE(nec765_data_r, nec765_data_w) | |
| 338 | AM_RANGE(0x0f2, 0x0f3) AM_READWRITE(nec765_dack_r, nec765_dack_w) | |
| 336 | AM_RANGE(0x0f0, 0x0f0) AM_DEVREAD( NEC765A, "nec765", nec765_status_r) | |
| 337 | AM_RANGE(0x0f1, 0x0f1) AM_DEVREADWRITE( NEC765A, "nec765", nec765_data_r, nec765_data_w) | |
| 338 | AM_RANGE(0x0f2, 0x0f3) AM_DEVREADWRITE( NEC765A, "nec765", nec765_dack_r, nec765_dack_w) | |
| 339 | 339 | AM_RANGE(0x0f4, 0x0f5) AM_READ(kc85_disc_hw_input_gate_r) |
| 340 | 340 | /*{0x0f6, 0x0f7, SMH_NOP},*/ /* for controller */ |
| 341 | 341 | AM_RANGE(0x0f8, 0x0f9) AM_WRITE( kc85_disc_hw_terminal_count_w) /* terminal count */ |
| r3867 | r3868 | |
| 348 | 348 | MDRV_CPU_IO_MAP(kc85_disc_hw_io, 0) |
| 349 | 349 | |
| 350 | 350 | MDRV_Z80CTC_ADD( "z80ctc_1", kc85_disc_ctc_intf ) |
| 351 | ||
| 352 | MDRV_NEC765A_ADD("nec765", kc_fdc_interface) | |
| 351 | 353 | MACHINE_DRIVER_END |
| 352 | 354 | |
| 353 | 355 |
| r3867 | r3868 | |
|---|---|---|
| 93 | 93 | |
| 94 | 94 | - Changed the I8271 implementation to be a device. [Miodrag Milanovic] |
| 95 | 95 | |
| 96 | - Changed the WD17XX implementation to be a device. [Miodrag Milanovic] | |
| 97 | ||
| 98 | - Changed the NEC765 implementation to be a device. [Miodrag Milanovic] | |
| 99 | ||
| 96 | 100 | - Various code cleanups. [Atari Ace] |
| 97 | 101 | |
| 98 | 102 | - Fixed regression that could cause hanging when creating an image from the |
| Previous | 15994 Revisions | Next |