src/mess/drivers/mk1.c
| r845 | r846 | |
| 1 | 1 | /****************************************************************************** |
| 2 | | PeT mess@utanet.at 2000,2001 |
| 3 | | ******************************************************************************/ |
| 4 | 2 | |
| 5 | | #include "driver.h" |
| 3 | mk1.c |
| 6 | 4 | |
| 7 | | #include "cpu/f8/f8.h" |
| 8 | | #include "cpu/f8/f3853.h" |
| 9 | | #include "mk1.lh" |
| 5 | Driver file to handle emulation of the Novag/Videomaster Chess Champion MK 1 |
| 6 | by PeT mess@utanet.at 2000,2001. |
| 10 | 7 | |
| 11 | | /* |
| 12 | | chess champion mk i |
| 8 | Minor updates by Wilbert Pol - 2007 |
| 13 | 9 | |
| 10 | Hardware descriptions: |
| 11 | - An F8 3850 CPU accompanied by a 3853 memory interface |
| 12 | Variations seen: |
| 13 | - MOSTEK MK 3853N 7915 Philippines ( static memory interface for f8) |
| 14 | - MOSTEK MK 3850N-3 7917 Philipines (fairchild f8 cpu) |
| 15 | - 3850PK F7901 SINGAPORE (Fairchild F8 CPU) |
| 16 | - 3853PK F7851 SINGAPORE (static memory interface for F8) |
| 17 | - 2KB 2316 compatible ROM |
| 18 | Variations seen: |
| 19 | - Signetics 7916E C48091 82S210-1 COPYRIGHT |
| 20 | - RO-3-8316A 8316A-4480 7904 TAIWAN |
| 21 | - 2 x 2111 256x4 SRAM to provide 256 bytes of RAM |
| 22 | Variations seen: |
| 23 | - AM9111 BPC / P2111A-4 7851 |
| 24 | - 16 keys placed in a 4 x 4 matrix |
| 25 | - Power on switch |
| 26 | - L/S switch. This switch is directly tied to the RESET pin of the F8 CPU. |
| 27 | This allows the user to reset the CPU without destroying he RAM contents. |
| 28 | - A 4 character 11 segment digit display using a 15 pin interface. Of the 15 |
| 29 | pins 3 pins are not connected, so three segments are never used and this |
| 30 | leaves a standard 7 segments display with a dot in the lower right. |
| 31 | - The digit display is driven by two other components: |
| 32 | - SN75492N MALAYSIA 7840B |
| 33 | - ULN2033A 7847 |
| 34 | - Hardware addressing is controlled by a NBF4001AE. |
| 35 | - Unknown if there is a speaker. |
| 14 | 36 | |
| 15 | | Signetics 7916E C48091 82S210-1 COPYRIGHT |
| 16 | | 2 KB rom? 2716 kompatible? |
| 37 | TODO: |
| 38 | - Figure out exact clock frequency |
| 17 | 39 | |
| 18 | | 4 11 segment displays (2. point up left, verticals in the mid ) |
| 40 | ******************************************************************************/ |
| 19 | 41 | |
| 20 | | 2 x 2111 256x4 SRAM |
| 42 | #include "driver.h" |
| 21 | 43 | |
| 22 | | MOSTEK MK 3853N 7915 Philippines ( static memory interface for f8) |
| 44 | #include "cpu/f8/f8.h" |
| 45 | #include "cpu/f8/f3853.h" |
| 46 | #include "mk1.lh" |
| 23 | 47 | |
| 24 | | MOSTEK MK 3850N-3 7917 Philipines (fairchild f8 cpu) |
| 48 | #define MAIN_CLOCK 1000000 |
| 25 | 49 | |
| 26 | | 16 keys (4x4 matrix) |
| 27 | | |
| 28 | | switch s/l (dark, light) pure hardware? |
| 29 | | (power on switch) |
| 30 | | |
| 31 | | speaker? |
| 32 | | |
| 33 | | */ |
| 34 | | |
| 35 | | #ifdef MAME_DEBUG |
| 36 | | #define VERBOSE 1 |
| 37 | | #else |
| 38 | | #define VERBOSE 0 |
| 39 | | #endif |
| 40 | | |
| 41 | 50 | static UINT8 mk1_f8[2]; |
| 42 | 51 | static UINT8 mk1_led[4]; |
| 43 | 52 | |
| 44 | | static READ8_HANDLER(mk1_f8_r) |
| 45 | | { |
| 53 | static READ8_HANDLER( mk1_f8_r ) { |
| 46 | 54 | UINT8 data = mk1_f8[offset]; |
| 47 | 55 | |
| 48 | | if (VERBOSE) |
| 49 | | logerror ("f8 %.6f r %x %x\n", mame_time_to_double(mame_timer_get_time()), offset, data); |
| 50 | | |
| 51 | | if (offset==0) |
| 52 | | { |
| 53 | | if (data&1) data|=readinputport(1); |
| 54 | | if (data&2) data|=readinputport(2); |
| 55 | | if (data&4) data|=readinputport(3); |
| 56 | | if (data&8) data|=readinputport(4); |
| 57 | | if (data&0x10) |
| 58 | | { |
| 59 | | if (readinputport(1)&0x10) data|=1; |
| 60 | | if (readinputport(2)&0x10) data|=2; |
| 61 | | if (readinputport(3)&0x10) data|=4; |
| 62 | | if (readinputport(4)&0x10) data|=8; |
| 56 | if ( offset == 0 ) { |
| 57 | if ( data & 1 ) data |= readinputport(1); |
| 58 | if ( data & 2 ) data |= readinputport(2); |
| 59 | if ( data & 4 ) data |= readinputport(3); |
| 60 | if ( data & 8 ) data |= readinputport(4); |
| 61 | if ( data & 0x10 ) { |
| 62 | if ( readinputport(1) & 0x10 ) data |= 1; |
| 63 | if ( readinputport(2) & 0x10 ) data |= 2; |
| 64 | if ( readinputport(3) & 0x10 ) data |= 4; |
| 65 | if ( readinputport(4) & 0x10 ) data |= 8; |
| 63 | 66 | } |
| 64 | | if (data&0x20) |
| 65 | | { |
| 66 | | if (readinputport(1)&0x20) data|=1; |
| 67 | | if (readinputport(2)&0x20) data|=2; |
| 68 | | if (readinputport(3)&0x20) data|=4; |
| 69 | | if (readinputport(4)&0x20) data|=8; |
| 67 | if ( data & 0x20 ) { |
| 68 | if ( readinputport(1) & 0x20 ) data |= 1; |
| 69 | if ( readinputport(2) & 0x20 ) data |= 2; |
| 70 | if ( readinputport(3) & 0x20 ) data |= 4; |
| 71 | if ( readinputport(4) & 0x20 ) data |= 8; |
| 70 | 72 | } |
| 71 | | if (data&0x40) |
| 72 | | { |
| 73 | | if (readinputport(1)&0x40) data|=1; |
| 74 | | if (readinputport(2)&0x40) data|=2; |
| 75 | | if (readinputport(3)&0x40) data|=4; |
| 76 | | if (readinputport(4)&0x40) data|=8; |
| 73 | if ( data & 0x40 ) { |
| 74 | if ( readinputport(1) & 0x40 ) data |= 1; |
| 75 | if ( readinputport(2) & 0x40 ) data |= 2; |
| 76 | if ( readinputport(3) & 0x40 ) data |= 4; |
| 77 | if ( readinputport(4) & 0x40 ) data |= 8; |
| 77 | 78 | } |
| 78 | | if (data&0x80) |
| 79 | | { |
| 80 | | if (readinputport(1)&0x80) data|=1; |
| 81 | | if (readinputport(2)&0x80) data|=2; |
| 82 | | if (readinputport(3)&0x80) data|=4; |
| 83 | | if (readinputport(4)&0x80) data|=8; |
| 79 | if ( data & 0x80 ) { |
| 80 | if ( readinputport(1) & 0x80 ) data |= 1; |
| 81 | if ( readinputport(2) & 0x80 ) data |= 2; |
| 82 | if ( readinputport(3) & 0x80 ) data |= 4; |
| 83 | if ( readinputport(4) & 0x80 ) data |= 8; |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | return data; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | | static WRITE8_HANDLER(mk1_f8_w) |
| 90 | | { |
| 89 | static WRITE8_HANDLER( mk1_f8_w ) { |
| 91 | 90 | /* 0 is high and allows also input */ |
| 92 | | mk1_f8[offset]=data; |
| 91 | mk1_f8[offset] = data; |
| 93 | 92 | |
| 94 | | if (VERBOSE) |
| 95 | | logerror("f8 %.6f w %x %x\n", mame_time_to_double(mame_timer_get_time()), offset, data); |
| 96 | | |
| 97 | | if (!(mk1_f8[1]&1)) mk1_led[0]= BITSWAP8(mk1_f8[0],2,1,3,4,5,6,7,0); |
| 98 | | if (!(mk1_f8[1]&2)) mk1_led[1]= BITSWAP8(mk1_f8[0],2,1,3,4,5,6,7,0); |
| 99 | | if (!(mk1_f8[1]&4)) mk1_led[2]= BITSWAP8(mk1_f8[0],2,1,3,4,5,6,7,0); |
| 100 | | if (!(mk1_f8[1]&8)) mk1_led[3]= BITSWAP8(mk1_f8[0],2,1,3,4,5,6,7,0); |
| 93 | if ( ! ( mk1_f8[1] & 1 ) ) mk1_led[0] = BITSWAP8( mk1_f8[0],2,1,3,4,5,6,7,0 ); |
| 94 | if ( ! ( mk1_f8[1] & 2 ) ) mk1_led[1] = BITSWAP8( mk1_f8[0],2,1,3,4,5,6,7,0 ); |
| 95 | if ( ! ( mk1_f8[1] & 4 ) ) mk1_led[2] = BITSWAP8( mk1_f8[0],2,1,3,4,5,6,7,0 ); |
| 96 | if ( ! ( mk1_f8[1] & 8 ) ) mk1_led[3] = BITSWAP8( mk1_f8[0],2,1,3,4,5,6,7,0 ); |
| 101 | 97 | } |
| 102 | 98 | |
| 103 | | static ADDRESS_MAP_START( mk1_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 104 | | AM_RANGE(0x0000, 0x07ff) AM_ROM |
| 105 | | AM_RANGE(0x1800, 0x18ff) AM_RAM |
| 99 | static ADDRESS_MAP_START( mk1_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 100 | AM_RANGE( 0x0000, 0x07ff ) AM_ROM |
| 101 | AM_RANGE( 0x1800, 0x18ff ) AM_RAM |
| 106 | 102 | ADDRESS_MAP_END |
| 107 | 103 | |
| 108 | 104 | |
| 109 | | static ADDRESS_MAP_START( mk1_io, ADDRESS_SPACE_IO, 8) |
| 110 | | AM_RANGE(0x0, 0x1) AM_READWRITE( mk1_f8_r, mk1_f8_w ) |
| 111 | | AM_RANGE(0xc, 0xf) AM_READWRITE( f3853_r, f3853_w ) |
| 105 | static ADDRESS_MAP_START( mk1_io, ADDRESS_SPACE_IO, 8 ) |
| 106 | AM_RANGE( 0x0, 0x1 ) AM_READWRITE( mk1_f8_r, mk1_f8_w ) |
| 107 | AM_RANGE( 0xc, 0xf ) AM_READWRITE( f3853_r, f3853_w ) |
| 112 | 108 | ADDRESS_MAP_END |
| 113 | 109 | |
| 114 | 110 | INPUT_PORTS_START( mk1 ) |
| 115 | | PORT_START |
| 111 | PORT_START /* 0 */ |
| 116 | 112 | PORT_DIPNAME ( 0x01, 0x01, "Switch") |
| 117 | 113 | PORT_DIPSETTING( 0, "L" ) |
| 118 | 114 | PORT_DIPSETTING( 1, "S" ) |
| 119 | | PORT_START |
| 115 | |
| 116 | PORT_START /* 1 */ |
| 120 | 117 | PORT_BIT ( 0x0f, 0x0, IPT_UNUSED ) |
| 121 | 118 | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White A King") PORT_CODE(KEYCODE_A) |
| 122 | 119 | PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White B Queen") PORT_CODE(KEYCODE_B) |
| 123 | 120 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White C Bishop") PORT_CODE(KEYCODE_C) |
| 124 | 121 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White D PLAY") PORT_CODE(KEYCODE_D) |
| 125 | | PORT_START |
| 122 | |
| 123 | PORT_START /* 2 */ |
| 126 | 124 | PORT_BIT ( 0x0f, 0x0, IPT_UNUSED ) |
| 127 | 125 | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White E Knight") PORT_CODE(KEYCODE_E) |
| 128 | 126 | PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White F Castle") PORT_CODE(KEYCODE_F) |
| 129 | 127 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White G Pawn") PORT_CODE(KEYCODE_G) |
| 130 | 128 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("White H md") PORT_CODE(KEYCODE_H) |
| 131 | | PORT_START |
| 129 | |
| 130 | PORT_START /* 3 */ |
| 132 | 131 | PORT_BIT ( 0x0f, 0x0, IPT_UNUSED ) |
| 133 | 132 | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 1 King") PORT_CODE(KEYCODE_1) |
| 134 | 133 | PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 2 Queen") PORT_CODE(KEYCODE_2) |
| 135 | 134 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 3 Bishop") PORT_CODE(KEYCODE_3) |
| 136 | 135 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 4 fp") PORT_CODE(KEYCODE_4) |
| 137 | | PORT_START |
| 136 | |
| 137 | PORT_START /* 4 */ |
| 138 | 138 | PORT_BIT ( 0x0f, 0x0, IPT_UNUSED ) |
| 139 | 139 | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 5 Knight") PORT_CODE(KEYCODE_5) |
| 140 | 140 | PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 6 Castle") PORT_CODE(KEYCODE_6) |
| r845 | r846 | |
| 142 | 142 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Black 8 ep") PORT_CODE(KEYCODE_8) |
| 143 | 143 | INPUT_PORTS_END |
| 144 | 144 | |
| 145 | | static MACHINE_RESET( mk1 ) |
| 146 | | { |
| 145 | static MACHINE_RESET( mk1 ) { |
| 147 | 146 | f3853_reset(); |
| 148 | 147 | } |
| 149 | 148 | |
| r845 | r846 | |
| 157 | 156 | } |
| 158 | 157 | } |
| 159 | 158 | |
| 159 | |
| 160 | 160 | static MACHINE_START( mk1 ) { |
| 161 | 161 | mame_timer_pulse( MAME_TIME_IN_HZ(30), 0, mk1_update_leds ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | static MACHINE_DRIVER_START( mk1 ) |
| 165 | 165 | /* basic machine hardware */ |
| 166 | | MDRV_CPU_ADD(F8, 1000000) /* MK3850 */ |
| 167 | | MDRV_CPU_PROGRAM_MAP(mk1_mem, 0) |
| 168 | | MDRV_CPU_IO_MAP(mk1_io, 0) |
| 169 | | MDRV_SCREEN_REFRESH_RATE(LCD_FRAMES_PER_SECOND) |
| 170 | | MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION) |
| 171 | | MDRV_INTERLEAVE(1) |
| 166 | MDRV_CPU_ADD( F8, MAIN_CLOCK ) /* MK3850 */ |
| 167 | MDRV_CPU_PROGRAM_MAP( mk1_mem, 0 ) |
| 168 | MDRV_CPU_IO_MAP( mk1_io, 0 ) |
| 169 | MDRV_SCREEN_REFRESH_RATE( LCD_FRAMES_PER_SECOND ) |
| 170 | MDRV_SCREEN_VBLANK_TIME( DEFAULT_REAL_60HZ_VBLANK_DURATION ) |
| 171 | MDRV_INTERLEAVE( 1 ) |
| 172 | 172 | |
| 173 | 173 | MDRV_MACHINE_START( mk1 ) |
| 174 | 174 | MDRV_MACHINE_RESET( mk1 ) |
| 175 | 175 | |
| 176 | 176 | /* video hardware */ |
| 177 | | MDRV_DEFAULT_LAYOUT(layout_mk1) |
| 177 | MDRV_DEFAULT_LAYOUT( layout_mk1 ) |
| 178 | 178 | MACHINE_DRIVER_END |
| 179 | 179 | |
| 180 | | ROM_START(mk1) |
| 180 | ROM_START( mk1 ) |
| 181 | 181 | ROM_REGION(0x10000,REGION_CPU1,0) |
| 182 | 182 | ROM_LOAD("82c210-1", 0x0000, 0x800, CRC(278f7bf3) SHA1(b384c95ba691d52dfdddd35987a71e9746a46170)) |
| 183 | 183 | ROM_END |
| 184 | 184 | |
| 185 | | static void mk1_interrupt(UINT16 addr, int level) |
| 186 | | { |
| 187 | | cpunum_set_input_line_vector(0, 0, addr); |
| 188 | | cpunum_set_input_line(0, 0, level ? F8_INT_INTR : F8_INT_NONE); |
| 185 | static void mk1_interrupt( UINT16 addr, int level ) { |
| 186 | cpunum_set_input_line_vector( 0, 0, addr ); |
| 187 | cpunum_set_input_line( 0, 0, level ? F8_INT_INTR : F8_INT_NONE ); |
| 189 | 188 | } |
| 190 | 189 | |
| 191 | | F3853_CONFIG mk1_config = { |
| 192 | | 1000000, |
| 190 | static F3853_CONFIG mk1_config = { |
| 191 | MAIN_CLOCK, |
| 193 | 192 | mk1_interrupt |
| 194 | 193 | }; |
| 195 | 194 | |
| 196 | | static DRIVER_INIT( mk1 ) |
| 197 | | { |
| 198 | | f3853_init(&mk1_config); |
| 195 | static DRIVER_INIT( mk1 ) { |
| 196 | f3853_init( &mk1_config ); |
| 199 | 197 | } |
| 200 | 198 | |
| 201 | 199 | /*************************************************************************** |