src/mess/machine/wd17xx.c
| r6006 | r6007 | |
| 251 | 251 | int drq; /* data request */ |
| 252 | 252 | int intrq; /* interrupt request */ |
| 253 | 253 | |
| 254 | int stepping_rate[4]; /* track stepping rate in ms */ |
| 255 | |
| 254 | 256 | DENSITY density; /* FM/MFM, single / double density */ |
| 255 | 257 | wd17xx_type_t type; |
| 256 | 258 | UINT8 track_reg; /* value of track register */ |
| r6006 | r6007 | |
| 1739 | 1741 | MAME DEVICE INTERFACE |
| 1740 | 1742 | ***************************************************************************/ |
| 1741 | 1743 | |
| 1742 | | static void common_start(const device_config *device, wd17xx_type_t device_type) |
| 1744 | static DEVICE_START( wd1770 ) |
| 1743 | 1745 | { |
| 1744 | 1746 | wd17xx_t *w = get_safe_token(device); |
| 1745 | 1747 | |
| r6006 | r6007 | |
| 1748 | 1750 | w->intf = device->static_config; |
| 1749 | 1751 | |
| 1750 | 1752 | w->status = STA_1_TRACK0; |
| 1751 | | w->type = device_type; |
| 1752 | 1753 | w->density = DEN_MFM_LO; |
| 1753 | 1754 | w->busy_timer = timer_alloc(device->machine, wd17xx_busy_callback, (void*)device); |
| 1754 | 1755 | w->timer = timer_alloc(device->machine, wd17xx_misc_timer_callback, (void*)device); |
| r6006 | r6007 | |
| 1759 | 1760 | /* resolve callbacks */ |
| 1760 | 1761 | devcb_resolve_write_line(&w->out_intrq_func, &w->intf->out_intrq_func, device); |
| 1761 | 1762 | devcb_resolve_write_line(&w->out_drq_func, &w->intf->out_drq_func, device); |
| 1763 | |
| 1764 | /* model specific values */ |
| 1765 | w->type = WD_TYPE_1770; |
| 1766 | |
| 1767 | w->stepping_rate[0] = 6; |
| 1768 | w->stepping_rate[1] = 12; |
| 1769 | w->stepping_rate[2] = 20; |
| 1770 | w->stepping_rate[3] = 30; |
| 1762 | 1771 | } |
| 1763 | 1772 | |
| 1764 | | static DEVICE_RESET( wd17xx ) |
| 1773 | static DEVICE_START( wd1771 ) |
| 1765 | 1774 | { |
| 1766 | 1775 | wd17xx_t *w = get_safe_token(device); |
| 1767 | | int i; |
| 1768 | 1776 | |
| 1769 | | for (i = 0; i < 4; i++) |
| 1770 | | { |
| 1771 | | if(w->intf->floppy_drive_tags[i]!=NULL) { |
| 1772 | | const device_config *img = devtag_get_device(device->machine,w->intf->floppy_drive_tags[i]); |
| 1773 | | if (img!=NULL) { |
| 1774 | | floppy_drive_set_controller(img,device); |
| 1775 | | floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback); |
| 1776 | | floppy_drive_set_rpm( img, 300.); |
| 1777 | | } |
| 1778 | | } |
| 1779 | | } |
| 1777 | DEVICE_START_CALL(wd1770); |
| 1780 | 1778 | |
| 1781 | | wd17xx_set_drive(device, 0); |
| 1782 | | |
| 1783 | | w->hd = 0; |
| 1784 | | w->hld_count = 0; |
| 1785 | | |
| 1786 | | wd17xx_restore(device); |
| 1779 | w->type = WD_TYPE_1771; |
| 1787 | 1780 | } |
| 1788 | 1781 | |
| 1789 | | void wd17xx_reset(const device_config *device) |
| 1782 | static DEVICE_START( wd1772 ) |
| 1790 | 1783 | { |
| 1791 | | DEVICE_RESET_CALL( wd17xx ); |
| 1792 | | } |
| 1784 | wd17xx_t *w = get_safe_token(device); |
| 1793 | 1785 | |
| 1794 | | static DEVICE_START( wd1770 ) |
| 1795 | | { |
| 1796 | | common_start(device, WD_TYPE_1770); |
| 1786 | DEVICE_START_CALL(wd1770); |
| 1787 | |
| 1788 | w->type = WD_TYPE_1772; |
| 1789 | |
| 1790 | w->stepping_rate[0] = 6; |
| 1791 | w->stepping_rate[1] = 12; |
| 1792 | w->stepping_rate[2] = 20; |
| 1793 | w->stepping_rate[3] = 30; |
| 1797 | 1794 | } |
| 1798 | | static DEVICE_START( wd1771 ) |
| 1799 | | { |
| 1800 | | common_start(device, WD_TYPE_1771); |
| 1801 | | } |
| 1802 | | static DEVICE_START( wd1772 ) |
| 1803 | | { |
| 1804 | | common_start(device, WD_TYPE_1772); |
| 1805 | | } |
| 1795 | |
| 1806 | 1796 | static DEVICE_START( wd1773 ) |
| 1807 | 1797 | { |
| 1808 | | common_start(device, WD_TYPE_1773); |
| 1798 | wd17xx_t *w = get_safe_token(device); |
| 1799 | |
| 1800 | DEVICE_START_CALL(wd1770); |
| 1801 | |
| 1802 | w->type = WD_TYPE_1773; |
| 1803 | |
| 1804 | w->stepping_rate[0] = 6; |
| 1805 | w->stepping_rate[1] = 12; |
| 1806 | w->stepping_rate[2] = 2; |
| 1807 | w->stepping_rate[3] = 3; |
| 1809 | 1808 | } |
| 1809 | |
| 1810 | 1810 | static DEVICE_START( wd179x ) |
| 1811 | 1811 | { |
| 1812 | | common_start(device, WD_TYPE_179X); |
| 1812 | wd17xx_t *w = get_safe_token(device); |
| 1813 | |
| 1814 | DEVICE_START_CALL(wd1770); |
| 1815 | |
| 1816 | w->type = WD_TYPE_179X; |
| 1813 | 1817 | } |
| 1818 | |
| 1814 | 1819 | static DEVICE_START( wd1793 ) |
| 1815 | 1820 | { |
| 1816 | | common_start(device, WD_TYPE_1793); |
| 1817 | | } |
| 1818 | | static DEVICE_START( wd2793 ) |
| 1819 | | { |
| 1820 | | common_start(device, WD_TYPE_2793); |
| 1821 | | } |
| 1822 | | static DEVICE_START( wd177x ) |
| 1823 | | { |
| 1824 | | common_start(device, WD_TYPE_177X); |
| 1825 | | } |
| 1826 | | static DEVICE_START( mb8877 ) |
| 1827 | | { |
| 1828 | | common_start(device, WD_TYPE_MB8877); |
| 1829 | | } |
| 1821 | wd17xx_t *w = get_safe_token(device); |
| 1830 | 1822 | |
| 1831 | | DEVICE_GET_INFO( wd1770 ) |
| 1832 | | { |
| 1833 | | switch (state) |
| 1834 | | { |
| 1835 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1836 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(wd17xx_t); break; |
| 1837 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 1838 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 1823 | DEVICE_START_CALL(wd1770); |
| 1839 | 1824 | |
| 1840 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1841 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1770); break; |
| 1842 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1843 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(wd17xx); break; |
| 1844 | | |
| 1845 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1846 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD1770"); break; |
| 1847 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "WD17xx"); break; |
| 1848 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1849 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1850 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 1851 | | } |
| 1825 | w->type = WD_TYPE_1793; |
| 1852 | 1826 | } |
| 1853 | 1827 | |
| 1854 | | DEVICE_GET_INFO( wd1771 ) |
| 1828 | static DEVICE_START( wd2793 ) |
| 1855 | 1829 | { |
| 1856 | | switch (state) |
| 1857 | | { |
| 1858 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1859 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD1771"); break; |
| 1830 | wd17xx_t *w = get_safe_token(device); |
| 1860 | 1831 | |
| 1861 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1862 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1771); break; |
| 1832 | DEVICE_START_CALL(wd1770); |
| 1863 | 1833 | |
| 1864 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1865 | | } |
| 1834 | w->type = WD_TYPE_2793; |
| 1866 | 1835 | } |
| 1867 | 1836 | |
| 1868 | | DEVICE_GET_INFO( wd1772 ) |
| 1837 | static DEVICE_START( wd177x ) |
| 1869 | 1838 | { |
| 1870 | | switch (state) |
| 1871 | | { |
| 1872 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1873 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD1772"); break; |
| 1839 | wd17xx_t *w = get_safe_token(device); |
| 1874 | 1840 | |
| 1875 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1876 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1772); break; |
| 1841 | DEVICE_START_CALL(wd1770); |
| 1877 | 1842 | |
| 1878 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1879 | | } |
| 1843 | w->type = WD_TYPE_177X; |
| 1880 | 1844 | } |
| 1881 | 1845 | |
| 1882 | | DEVICE_GET_INFO( wd1773 ) |
| 1846 | static DEVICE_START( mb8877 ) |
| 1883 | 1847 | { |
| 1884 | | switch (state) |
| 1885 | | { |
| 1886 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1887 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD1773"); break; |
| 1848 | wd17xx_t *w = get_safe_token(device); |
| 1888 | 1849 | |
| 1889 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1890 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1773); break; |
| 1850 | DEVICE_START_CALL(wd1770); |
| 1891 | 1851 | |
| 1892 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1893 | | } |
| 1852 | w->type = WD_TYPE_MB8877; |
| 1894 | 1853 | } |
| 1895 | 1854 | |
| 1896 | | DEVICE_GET_INFO( wd179x ) |
| 1855 | static DEVICE_RESET( wd1770 ) |
| 1897 | 1856 | { |
| 1898 | | switch (state) |
| 1857 | wd17xx_t *w = get_safe_token(device); |
| 1858 | int i; |
| 1859 | |
| 1860 | for (i = 0; i < 4; i++) |
| 1899 | 1861 | { |
| 1900 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1901 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD179x"); break; |
| 1862 | if(w->intf->floppy_drive_tags[i]!=NULL) { |
| 1863 | const device_config *img = devtag_get_device(device->machine,w->intf->floppy_drive_tags[i]); |
| 1864 | if (img!=NULL) { |
| 1865 | floppy_drive_set_controller(img,device); |
| 1866 | floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback); |
| 1867 | floppy_drive_set_rpm( img, 300.); |
| 1868 | } |
| 1869 | } |
| 1870 | } |
| 1902 | 1871 | |
| 1903 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1904 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd179x); break; |
| 1872 | wd17xx_set_drive(device, 0); |
| 1905 | 1873 | |
| 1906 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1907 | | } |
| 1874 | w->hd = 0; |
| 1875 | w->hld_count = 0; |
| 1876 | |
| 1877 | wd17xx_restore(device); |
| 1908 | 1878 | } |
| 1909 | 1879 | |
| 1910 | | DEVICE_GET_INFO( wd1793 ) |
| 1880 | void wd17xx_reset(const device_config *device) |
| 1911 | 1881 | { |
| 1912 | | switch (state) |
| 1913 | | { |
| 1914 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1915 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD1793"); break; |
| 1882 | DEVICE_RESET_CALL( wd1770 ); |
| 1883 | } |
| 1916 | 1884 | |
| 1917 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1918 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd1793); break; |
| 1919 | 1885 | |
| 1920 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1921 | | } |
| 1922 | | } |
| 1886 | /*************************************************************************** |
| 1887 | DEVICE GETINFO |
| 1888 | ***************************************************************************/ |
| 1923 | 1889 | |
| 1924 | | DEVICE_GET_INFO( wd2793 ) |
| 1925 | | { |
| 1926 | | switch (state) |
| 1927 | | { |
| 1928 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1929 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD2793"); break; |
| 1890 | static const char DEVTEMPLATE_SOURCE[] = __FILE__; |
| 1930 | 1891 | |
| 1931 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1932 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd2793); break; |
| 1892 | #define DEVTEMPLATE_ID(p,s) p##wd1770##s |
| 1893 | #define DEVTEMPLATE_STATE wd17xx_t |
| 1894 | #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET |
| 1895 | #define DEVTEMPLATE_NAME "WD1770" |
| 1896 | #define DEVTEMPLATE_FAMILY "WD17xx" |
| 1897 | #define DEVTEMPLATE_VERSION "1.0" |
| 1898 | #define DEVTEMPLATE_CREDITS "Copyright MESS Team" |
| 1899 | #include "devtempl.h" |
| 1933 | 1900 | |
| 1934 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1935 | | } |
| 1936 | | } |
| 1901 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd1771##s |
| 1902 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1903 | #define DEVTEMPLATE_DERIVED_NAME "WD1771" |
| 1904 | #include "devtempl.h" |
| 1937 | 1905 | |
| 1938 | | DEVICE_GET_INFO( wd177x ) |
| 1939 | | { |
| 1940 | | switch (state) |
| 1941 | | { |
| 1942 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1943 | | case DEVINFO_STR_NAME: strcpy(info->s, "WD177x"); break; |
| 1906 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd1772##s |
| 1907 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1908 | #define DEVTEMPLATE_DERIVED_NAME "WD1772" |
| 1909 | #include "devtempl.h" |
| 1944 | 1910 | |
| 1945 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1946 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(wd177x); break; |
| 1911 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd1773##s |
| 1912 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1913 | #define DEVTEMPLATE_DERIVED_NAME "WD1773" |
| 1914 | #include "devtempl.h" |
| 1947 | 1915 | |
| 1948 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1949 | | } |
| 1950 | | } |
| 1916 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd179x##s |
| 1917 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1918 | #define DEVTEMPLATE_DERIVED_NAME "WD179x" |
| 1919 | #include "devtempl.h" |
| 1951 | 1920 | |
| 1952 | | DEVICE_GET_INFO( mb8877 ) |
| 1953 | | { |
| 1954 | | switch (state) |
| 1955 | | { |
| 1956 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1957 | | case DEVINFO_STR_NAME: strcpy(info->s, "MB8877"); break; |
| 1921 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd1793##s |
| 1922 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1923 | #define DEVTEMPLATE_DERIVED_NAME "WD1793" |
| 1924 | #include "devtempl.h" |
| 1958 | 1925 | |
| 1959 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1960 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mb8877); break; |
| 1926 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd2793##s |
| 1927 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1928 | #define DEVTEMPLATE_DERIVED_NAME "WD2793" |
| 1929 | #include "devtempl.h" |
| 1961 | 1930 | |
| 1962 | | default: DEVICE_GET_INFO_CALL(wd1770); break; |
| 1963 | | } |
| 1964 | | } |
| 1931 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##wd177x##s |
| 1932 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1933 | #define DEVTEMPLATE_DERIVED_NAME "WD179x" |
| 1934 | #include "devtempl.h" |
| 1935 | |
| 1936 | #define DEVTEMPLATE_DERIVED_ID(p,s) p##mb8877##s |
| 1937 | #define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START |
| 1938 | #define DEVTEMPLATE_DERIVED_NAME "MB8877" |
| 1939 | #include "devtempl.h" |