trunk/src/emu/cpu/amis2000/amis2000.c
| r243315 | r243316 | |
| 33 | 33 | |
| 34 | 34 | static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device) |
| 35 | 35 | AM_RANGE(0x0000, 0x03ff) AM_ROM |
| 36 | | AM_RANGE(0x0400, 0x05ff) AM_NOP |
| 36 | AM_RANGE(0x0400, 0x05ff) AM_NOP // 0x00 |
| 37 | 37 | AM_RANGE(0x0600, 0x07ff) AM_ROM |
| 38 | 38 | ADDRESS_MAP_END |
| 39 | 39 | |
| r243315 | r243316 | |
| 128 | 128 | m_program = &space(AS_PROGRAM); |
| 129 | 129 | m_data = &space(AS_DATA); |
| 130 | 130 | |
| 131 | | m_read_k.resolve_safe(0); |
| 132 | | m_read_i.resolve_safe(0); |
| 131 | m_read_k.resolve_safe(0xf); |
| 132 | m_read_i.resolve_safe(0xf); |
| 133 | 133 | m_read_d.resolve_safe(0); |
| 134 | 134 | m_write_d.resolve_safe(); |
| 135 | 135 | m_write_a.resolve_safe(); |
| r243315 | r243316 | |
| 209 | 209 | m_d_polarity = 0; |
| 210 | 210 | m_d = 0; d_latch_out(false); |
| 211 | 211 | m_a = 0; m_write_a(0, 0, 0xffff); |
| 212 | | m_i = 0; |
| 213 | | m_k = 0; |
| 212 | m_i = 0xf; |
| 213 | m_k = 0xf; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
trunk/src/mess/drivers/wildfire.c
| r243315 | r243316 | |
| 31 | 31 | required_device<cpu_device> m_maincpu; |
| 32 | 32 | required_device<speaker_sound_device> m_speaker; |
| 33 | 33 | |
| 34 | UINT8 m_d; |
| 35 | UINT16 m_a; |
| 36 | |
| 37 | UINT16 m_leds_state[0x10]; |
| 38 | UINT16 m_leds_cache[0x10]; |
| 39 | UINT8 m_leds_decay[0x100]; |
| 40 | |
| 34 | 41 | DECLARE_WRITE8_MEMBER(write_d); |
| 35 | 42 | DECLARE_WRITE16_MEMBER(write_a); |
| 36 | 43 | |
| 44 | TIMER_DEVICE_CALLBACK_MEMBER(leds_decay_tick); |
| 45 | void leds_update(); |
| 46 | bool index_is_7segled(int i); |
| 47 | |
| 37 | 48 | virtual void machine_start(); |
| 38 | 49 | }; |
| 39 | 50 | |
| 40 | 51 | |
| 52 | |
| 41 | 53 | /*************************************************************************** |
| 42 | 54 | |
| 55 | LEDs |
| 56 | |
| 57 | ***************************************************************************/ |
| 58 | |
| 59 | // The device strobes the outputs very fast, it is unnoticeable to the user. |
| 60 | // To prevent flickering here, we need to simulate a decay. |
| 61 | |
| 62 | // decay time, in steps of 10ms |
| 63 | #define LEDS_DECAY_TIME 4 |
| 64 | |
| 65 | bool wildfire_state::index_is_7segled(int i) |
| 66 | { |
| 67 | // first 3 A are 7segleds |
| 68 | return (i < 3); |
| 69 | } |
| 70 | |
| 71 | void wildfire_state::leds_update() |
| 72 | { |
| 73 | UINT16 active_state[0x10]; |
| 74 | |
| 75 | for (int i = 0; i < 0x10; i++) |
| 76 | { |
| 77 | // update current state |
| 78 | m_leds_state[i] = (~m_a >> i & 1) ? m_d : 0; |
| 79 | if (index_is_7segled(i)) |
| 80 | m_leds_state[i] = BITSWAP8(m_leds_state[i],7,0,1,2,3,4,5,6); |
| 81 | |
| 82 | active_state[i] = 0; |
| 83 | |
| 84 | for (int j = 0; j < 0x10; j++) |
| 85 | { |
| 86 | int di = j << 4 | i; |
| 87 | |
| 88 | // turn on powered leds |
| 89 | if (m_leds_state[i] >> j & 1) |
| 90 | m_leds_decay[di] = LEDS_DECAY_TIME; |
| 91 | |
| 92 | // determine active state |
| 93 | int ds = (m_leds_decay[di] != 0) ? 1 : 0; |
| 94 | active_state[i] |= (ds << j); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // on difference, send to output |
| 99 | for (int i = 0; i < 0x10; i++) |
| 100 | if (m_leds_cache[i] != active_state[i]) |
| 101 | { |
| 102 | if (index_is_7segled(i)) |
| 103 | output_set_digit_value(i, active_state[i] & 0x7f); |
| 104 | |
| 105 | for (int j = 0; j < 8; j++) |
| 106 | output_set_lamp_value(i*10 + j, active_state[i] >> j & 1); |
| 107 | } |
| 108 | |
| 109 | memcpy(m_leds_cache, active_state, sizeof(m_leds_cache)); |
| 110 | } |
| 111 | |
| 112 | TIMER_DEVICE_CALLBACK_MEMBER(wildfire_state::leds_decay_tick) |
| 113 | { |
| 114 | // slowly turn off unpowered leds |
| 115 | for (int i = 0; i < 0x100; i++) |
| 116 | if (!(m_leds_state[i & 0xf] >> (i>>4) & 1) && m_leds_decay[i]) |
| 117 | m_leds_decay[i]--; |
| 118 | |
| 119 | leds_update(); |
| 120 | } |
| 121 | |
| 122 | |
| 123 | |
| 124 | /*************************************************************************** |
| 125 | |
| 43 | 126 | I/O |
| 44 | 127 | |
| 45 | 128 | ***************************************************************************/ |
| 46 | 129 | |
| 47 | 130 | WRITE8_MEMBER(wildfire_state::write_d) |
| 48 | 131 | { |
| 132 | m_d = data; |
| 133 | leds_update(); |
| 49 | 134 | } |
| 50 | 135 | |
| 51 | 136 | WRITE16_MEMBER(wildfire_state::write_a) |
| 52 | 137 | { |
| 138 | m_a = data; |
| 139 | leds_update(); |
| 53 | 140 | } |
| 54 | 141 | |
| 55 | 142 | |
| r243315 | r243316 | |
| 62 | 149 | |
| 63 | 150 | static INPUT_PORTS_START( wildfire ) |
| 64 | 151 | PORT_START("IN1") // I |
| 65 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Shooter Button") |
| 66 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Left Flipper") |
| 67 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Right Flipper") |
| 68 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 152 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Shooter Button") |
| 153 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Left Flipper") |
| 154 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Right Flipper") |
| 155 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 69 | 156 | INPUT_PORTS_END |
| 70 | 157 | |
| 71 | 158 | |
| r243315 | r243316 | |
| 78 | 165 | |
| 79 | 166 | void wildfire_state::machine_start() |
| 80 | 167 | { |
| 168 | // zerofill |
| 169 | memset(m_leds_state, 0, sizeof(m_leds_state)); |
| 170 | memset(m_leds_cache, 0, sizeof(m_leds_cache)); |
| 171 | memset(m_leds_decay, 0, sizeof(m_leds_decay)); |
| 172 | |
| 173 | m_d = 0; |
| 174 | m_a = 0; |
| 175 | |
| 176 | // register for savestates |
| 177 | save_item(NAME(m_leds_state)); |
| 178 | save_item(NAME(m_leds_cache)); |
| 179 | save_item(NAME(m_leds_decay)); |
| 180 | |
| 181 | save_item(NAME(m_d)); |
| 182 | save_item(NAME(m_a)); |
| 81 | 183 | } |
| 82 | 184 | |
| 83 | 185 | |
| r243315 | r243316 | |
| 89 | 191 | MCFG_AMI_S2000_WRITE_D_CB(WRITE8(wildfire_state, write_d)) |
| 90 | 192 | MCFG_AMI_S2000_WRITE_A_CB(WRITE16(wildfire_state, write_a)) |
| 91 | 193 | |
| 194 | MCFG_TIMER_DRIVER_ADD_PERIODIC("leds_decay", wildfire_state, leds_decay_tick, attotime::from_msec(10)) |
| 195 | |
| 92 | 196 | MCFG_DEFAULT_LAYOUT(layout_wildfire) |
| 93 | 197 | |
| 94 | 198 | /* no video! */ |