src/mame/drivers/meyc8088.c
| r14995 | r14996 | |
| 1 | | /* |
| 1 | /**************************************************************** |
| 2 | 2 | |
| 3 | | Meyco 8088 based hardware |
| 3 | Meyco 8088 based hardware |
| 4 | 4 | |
| 5 | | significant chips: i8088 CPU, two i8155, ??? |
| 5 | i8088 CPU @ 5MHz (15MHz XTAL + i8284A clock generator), |
| 6 | 3 x 8KB EPROM (max 4), 3 x 8KB RAM (max 4), 2KB battery RAM, |
| 7 | 2 x i8155, optional i8251A for factory debug |
| 6 | 8 | |
| 7 | | */ |
| 8 | 9 | |
| 10 | ****************************************************************/ |
| 11 | |
| 9 | 12 | #include "emu.h" |
| 10 | 13 | #include "cpu/i86/i86.h" |
| 11 | 14 | #include "machine/i8155.h" |
| r14995 | r14996 | |
| 16 | 19 | public: |
| 17 | 20 | meyc8088_state(const machine_config &mconfig, device_type type, const char *tag) |
| 18 | 21 | : driver_device(mconfig, type, tag) , |
| 22 | m_maincpu(*this,"maincpu"), |
| 19 | 23 | m_vram(*this, "vram") |
| 20 | 24 | { } |
| 21 | 25 | |
| 26 | required_device<cpu_device> m_maincpu; |
| 22 | 27 | required_shared_ptr<UINT8> m_vram; |
| 28 | |
| 29 | UINT8 m_status; |
| 30 | UINT8 m_common; |
| 31 | |
| 32 | DECLARE_WRITE8_MEMBER(video5_flip_w); |
| 33 | DECLARE_READ8_MEMBER(video5_flip_r); |
| 34 | DECLARE_WRITE8_MEMBER(screen_flip_w); |
| 35 | DECLARE_READ8_MEMBER(screen_flip_r); |
| 23 | 36 | }; |
| 24 | 37 | |
| 25 | 38 | |
| r14995 | r14996 | |
| 56 | 69 | |
| 57 | 70 | ***************************************************************************/ |
| 58 | 71 | |
| 72 | // switch screen on/off on $b4000 access |
| 73 | READ8_MEMBER(meyc8088_state::screen_flip_r) |
| 74 | { |
| 75 | m_status ^= 2; |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | WRITE8_MEMBER(meyc8088_state::screen_flip_w) |
| 80 | { |
| 81 | m_status ^= 2; |
| 82 | } |
| 83 | |
| 84 | // switch video5 (color prom d4) on/off on $b5000 access |
| 85 | READ8_MEMBER(meyc8088_state::video5_flip_r) |
| 86 | { |
| 87 | m_status ^= 4; |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | WRITE8_MEMBER(meyc8088_state::video5_flip_w) |
| 92 | { |
| 93 | m_status ^= 4; |
| 94 | } |
| 95 | |
| 96 | |
| 59 | 97 | static ADDRESS_MAP_START( meyc8088_map, AS_PROGRAM, 8, meyc8088_state ) |
| 60 | | AM_RANGE(0x00000, 0x003ff) AM_RAM |
| 61 | | AM_RANGE(0x00400, 0x007ff) AM_RAM |
| 98 | AM_RANGE(0x00000, 0x007ff) AM_RAM |
| 62 | 99 | AM_RANGE(0x70000, 0x77fff) AM_RAM AM_SHARE("vram") |
| 63 | | // AM_RANGE(0xb0000, 0xb0000) AM_NOP |
| 64 | | AM_RANGE(0xb0800, 0xb0807) AM_DEVREADWRITE("i8155_0", i8155_device, io_r, io_w) |
| 65 | | // AM_RANGE(0xb1000, 0xb1000) AM_NOP |
| 100 | AM_RANGE(0xb0000, 0xb00ff) AM_DEVREADWRITE("i8155_2", i8155_device, memory_r, memory_w) |
| 101 | AM_RANGE(0xb0800, 0xb0807) AM_DEVREADWRITE("i8155_2", i8155_device, io_r, io_w) |
| 102 | AM_RANGE(0xb1000, 0xb10ff) AM_DEVREADWRITE("i8155_1", i8155_device, memory_r, memory_w) |
| 66 | 103 | AM_RANGE(0xb1800, 0xb1807) AM_DEVREADWRITE("i8155_1", i8155_device, io_r, io_w) |
| 67 | | // AM_RANGE(0xb2000, 0xb2000) AM_NOP |
| 68 | | // AM_RANGE(0xb3000, 0xb3000) AM_NOP |
| 69 | | // AM_RANGE(0xb3800, 0xb3800) AM_NOP |
| 70 | | // AM_RANGE(0xb4000, 0xb4000) AM_NOP |
| 71 | | // AM_RANGE(0xb5000, 0xb5000) AM_NOP |
| 72 | | AM_RANGE(0xfa000, 0xfffff) AM_ROM |
| 104 | // AM_RANGE(0xb2000, 0xb2000) AM_NOP // drive motor? |
| 105 | // AM_RANGE(0xb3000, 0xb3000) AM_RAM // 8251A, debug related |
| 106 | // AM_RANGE(0xb3800, 0xb3800) AM_RAM // " |
| 107 | AM_RANGE(0xb4000, 0xb4000) AM_READWRITE(screen_flip_r, screen_flip_w) |
| 108 | AM_RANGE(0xb5000, 0xb5000) AM_READWRITE(video5_flip_r, video5_flip_w) |
| 109 | AM_RANGE(0xf8000, 0xfffff) AM_ROM |
| 73 | 110 | ADDRESS_MAP_END |
| 74 | 111 | |
| 75 | 112 | |
| 76 | | static WRITE8_DEVICE_HANDLER(meyc8088_i8155_a_w) |
| 113 | static WRITE8_DEVICE_HANDLER(meyc8088_lights1_w) |
| 77 | 114 | { |
| 78 | | logerror("i8155 Port A: %02X\n", data); |
| 115 | // lite 1-8 |
| 116 | for (int i = 0; i < 8; i++) |
| 117 | output_set_lamp_value(i, data >> i & 1); |
| 79 | 118 | } |
| 80 | 119 | |
| 81 | | static WRITE8_DEVICE_HANDLER(meyc8088_i8155_b_w) |
| 120 | static WRITE8_DEVICE_HANDLER(meyc8088_lights2_w) |
| 82 | 121 | { |
| 83 | | logerror("i8155 Port B: %02X\n", data); |
| 122 | // lite 9-16 |
| 123 | for (int i = 0; i < 8; i++) |
| 124 | output_set_lamp_value(i + 8, data >> i & 1); |
| 84 | 125 | } |
| 85 | 126 | |
| 86 | | static WRITE8_DEVICE_HANDLER(meyc8088_i8155_c_w) |
| 127 | static WRITE8_DEVICE_HANDLER(meyc8088_common_w) |
| 87 | 128 | { |
| 129 | meyc8088_state *state = device->machine().driver_data<meyc8088_state>(); |
| 130 | |
| 131 | // d0: /CR2 |
| 132 | state->m_status = (state->m_status & ~1) | (data & 1); |
| 133 | |
| 134 | // d1: battery on |
| 135 | |
| 136 | // d2-d5: /common |
| 137 | state->m_common = data >> 2 & 0xf; |
| 138 | |
| 88 | 139 | logerror("i8155 Port C: %02X\n", data); |
| 89 | 140 | } |
| 90 | 141 | |
| 91 | | static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_0_timer_out) |
| 142 | static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_1_timer_out) |
| 92 | 143 | { |
| 93 | | //logerror("Timer 0 out %d\n", state); |
| 144 | // clock 8251A |
| 145 | //logerror("Timer 1 out %d\n", state); |
| 94 | 146 | } |
| 95 | 147 | |
| 96 | | static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_1_timer_out) |
| 148 | static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_2_timer_out) |
| 97 | 149 | { |
| 98 | | //logerror("Timer 1 out %d\n", state); |
| 150 | // sound dac |
| 151 | //logerror("Timer 2 out %d\n", state); |
| 99 | 152 | } |
| 100 | 153 | |
| 154 | |
| 155 | static READ8_DEVICE_HANDLER(meyc8088_status_r) |
| 156 | { |
| 157 | meyc8088_state *state = device->machine().driver_data<meyc8088_state>(); |
| 158 | |
| 159 | // d0: /CR2 |
| 160 | // d1: screen on |
| 161 | // d2: video5 |
| 162 | // d3: N/C |
| 163 | // d4: battery ok |
| 164 | // d5: /drive on |
| 165 | return (state->m_status & 7) | 0x38; |
| 166 | } |
| 167 | |
| 101 | 168 | static const i8155_interface i8155_intf[2] = |
| 102 | 169 | { |
| 103 | 170 | { |
| 104 | | // all ports set to output |
| 171 | // all ports set to input |
| 172 | DEVCB_INPUT_PORT("IN0"), |
| 105 | 173 | DEVCB_NULL, |
| 106 | | DEVCB_HANDLER(meyc8088_i8155_a_w), |
| 174 | DEVCB_INPUT_PORT("IN1"), |
| 107 | 175 | DEVCB_NULL, |
| 108 | | DEVCB_HANDLER(meyc8088_i8155_b_w), |
| 176 | DEVCB_HANDLER(meyc8088_status_r), |
| 109 | 177 | DEVCB_NULL, |
| 110 | | DEVCB_HANDLER(meyc8088_i8155_c_w), |
| 111 | | DEVCB_LINE(meyc8088_i8155_0_timer_out) |
| 178 | DEVCB_LINE(meyc8088_i8155_1_timer_out) |
| 112 | 179 | }, |
| 113 | 180 | { |
| 114 | | // all ports set to input |
| 115 | | DEVCB_INPUT_PORT("IN0"), |
| 181 | // all ports set to output |
| 116 | 182 | DEVCB_NULL, |
| 117 | | DEVCB_INPUT_PORT("IN1"), |
| 183 | DEVCB_HANDLER(meyc8088_lights2_w), |
| 118 | 184 | DEVCB_NULL, |
| 119 | | DEVCB_INPUT_PORT("IN2"), |
| 185 | DEVCB_HANDLER(meyc8088_lights1_w), |
| 120 | 186 | DEVCB_NULL, |
| 121 | | DEVCB_LINE(meyc8088_i8155_1_timer_out) |
| 187 | DEVCB_HANDLER(meyc8088_common_w), |
| 188 | DEVCB_LINE(meyc8088_i8155_2_timer_out) |
| 122 | 189 | } |
| 123 | 190 | }; |
| 124 | 191 | |
| r14995 | r14996 | |
| 157 | 224 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 158 | 225 | |
| 159 | 226 | PORT_START("IN1") |
| 160 | | PORT_DIPNAME( 0x01, 0x01, "IN1 1" ) |
| 161 | | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) |
| 162 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 227 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK ) |
| 163 | 228 | PORT_DIPNAME( 0x02, 0x02, "IN1 2" ) |
| 164 | 229 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 165 | 230 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| r14995 | r14996 | |
| 216 | 281 | |
| 217 | 282 | ***************************************************************************/ |
| 218 | 283 | |
| 284 | static INTERRUPT_GEN( meyc8088_irq ) |
| 285 | { |
| 286 | // INTR on LC255, INTA hardwired to $20 |
| 287 | device_set_input_line_and_vector(device, 0, HOLD_LINE, 0x20); |
| 288 | } |
| 289 | |
| 219 | 290 | static MACHINE_CONFIG_START( meyc8088, meyc8088_state ) |
| 220 | 291 | |
| 221 | 292 | /* basic machine hardware */ |
| 222 | | MCFG_CPU_ADD("maincpu", I8088, 5000000) |
| 293 | MCFG_CPU_ADD("maincpu", I8088, XTAL_15MHz / 3) |
| 223 | 294 | MCFG_CPU_PROGRAM_MAP(meyc8088_map) |
| 295 | MCFG_CPU_VBLANK_INT("screen", meyc8088_irq) |
| 224 | 296 | |
| 225 | | MCFG_I8155_ADD("i8155_0", 5000000, i8155_intf[0]) |
| 226 | | MCFG_I8155_ADD("i8155_1", 5000000, i8155_intf[1]) |
| 297 | MCFG_I8155_ADD("i8155_1", XTAL_15MHz / 3, i8155_intf[0]) |
| 298 | MCFG_I8155_ADD("i8155_2", XTAL_15MHz / 3, i8155_intf[1]) |
| 227 | 299 | |
| 228 | 300 | /* video hardware */ |
| 229 | 301 | MCFG_SCREEN_ADD("screen", RASTER) |
| 230 | 302 | MCFG_SCREEN_REFRESH_RATE(60) |
| 231 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 303 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 232 | 304 | MCFG_SCREEN_SIZE(512,512) |
| 233 | 305 | MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 512-1) |
| 234 | 306 | MCFG_SCREEN_UPDATE_STATIC(meyc8088) |
| r14995 | r14996 | |
| 240 | 312 | |
| 241 | 313 | ROM_START( gldarrow ) |
| 242 | 314 | ROM_REGION( 0x100000, "maincpu", 0 ) |
| 243 | | ROM_LOAD( "3.bin", 0x0fa000, 0x002000, CRC(a4acc6df) SHA1(b25f2cf8154932834100615e2e9c44ef47a15fea) ) |
| 244 | | ROM_LOAD( "2.bin", 0x0fc000, 0x002000, CRC(595e380d) SHA1(6f8e58f646106d33cb651d97ca6a1133f7b05373) ) |
| 245 | | ROM_LOAD( "1.bin", 0x0fe000, 0x002000, CRC(71bd0e39) SHA1(15345f5726cd33ecb1b2da05f2852b6cc3ac7747) ) |
| 315 | ROM_LOAD( "3.14h", 0x0fa000, 0x002000, CRC(a4acc6df) SHA1(b25f2cf8154932834100615e2e9c44ef47a15fea) ) |
| 316 | ROM_LOAD( "2.13h", 0x0fc000, 0x002000, CRC(595e380d) SHA1(6f8e58f646106d33cb651d97ca6a1133f7b05373) ) |
| 317 | ROM_LOAD( "1.12h", 0x0fe000, 0x002000, CRC(71bd0e39) SHA1(15345f5726cd33ecb1b2da05f2852b6cc3ac7747) ) |
| 318 | |
| 319 | ROM_REGION( 0x20, "proms", 0 ) |
| 320 | ROM_LOAD( "prom.2c", 0x00, 0x20, NO_DUMP ) // M3-7602-5 color prom |
| 246 | 321 | ROM_END |
| 247 | 322 | |
| 248 | 323 | |
src/mame/drivers/sangho.c
| r14995 | r14996 | |
| 34 | 34 | |
| 35 | 35 | *** the custom chip with the warning appears to control banking etc. |
| 36 | 36 | |
| 37 | Sexy Boom's DSW setting verified via Z80 code by stephh |
| 38 | |
| 37 | 39 | */ |
| 38 | 40 | |
| 39 | 41 | #include "emu.h" |
| r14995 | r14996 | |
| 256 | 258 | AM_RANGE( 0xf8, 0xff) AM_WRITE(sexyboom_bank_w ) |
| 257 | 259 | ADDRESS_MAP_END |
| 258 | 260 | |
| 259 | | |
| 260 | | static INPUT_PORTS_START( sangho ) |
| 261 | static INPUT_PORTS_START( sexyboom ) |
| 261 | 262 | PORT_START("P1") |
| 262 | 263 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) |
| 263 | 264 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) |
| r14995 | r14996 | |
| 291 | 292 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) |
| 292 | 293 | |
| 293 | 294 | PORT_START("DSW") |
| 294 | | PORT_DIPNAME( 0x01, 0x01, "DIPS" ) /* coinage etc. */ |
| 295 | | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) |
| 296 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 295 | PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:8,7,6") |
| 296 | PORT_DIPSETTING( 0x03, DEF_STR( Easiest ) ) |
| 297 | PORT_DIPSETTING( 0x05, "Easiest (duplicate)" ) |
| 298 | PORT_DIPSETTING( 0x01, DEF_STR( Easy ) ) |
| 299 | PORT_DIPSETTING( 0x02, "Easy (duplicate)" ) |
| 300 | PORT_DIPSETTING( 0x07, DEF_STR( Normal ) ) |
| 301 | PORT_DIPSETTING( 0x06, DEF_STR( Hard ) ) |
| 302 | PORT_DIPSETTING( 0x04, DEF_STR( Harder ) ) |
| 303 | PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) |
| 304 | PORT_DIPNAME( 0x18, 0x18, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:5,4") /* Determined by effect, but matches Puzzle Star's manual listings */ |
| 305 | PORT_DIPSETTING( 0x08, DEF_STR( 3C_1C ) ) |
| 306 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) |
| 307 | PORT_DIPSETTING( 0x18, DEF_STR( 1C_1C ) ) |
| 308 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_2C ) ) |
| 309 | PORT_DIPUNUSED_DIPLOC( 0x20, IP_ACTIVE_LOW, "SW1:3" ) /* Not shown in manual */ |
| 310 | PORT_DIPNAME( 0x40, 0x00, "Display Numbers on Tiles" ) PORT_DIPLOCATION("SW1:2") /* As per manual */ |
| 311 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 312 | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 313 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 314 | INPUT_PORTS_END |
| 315 | |
| 316 | |
| 317 | static INPUT_PORTS_START( pzlestar ) |
| 318 | PORT_START("P1") |
| 319 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) /* Start buttons don't work for Puzzle Star... not correct? */ |
| 297 | 320 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) |
| 298 | 321 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 299 | 322 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| r14995 | r14996 | |
| 303 | 326 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) |
| 304 | 327 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 305 | 328 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 306 | | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) |
| 307 | | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 329 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) |
| 330 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) |
| 331 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) |
| 332 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) |
| 333 | |
| 334 | PORT_START("P2") |
| 335 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 ) /* Start buttons don't work for Puzzle Star... not correct? */ |
| 336 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) |
| 337 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 308 | 338 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 309 | | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) |
| 310 | | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) |
| 339 | PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) |
| 340 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) |
| 311 | 341 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 312 | | PORT_DIPNAME( 0x40, 0x40, "Display Numbers on Tiles" ) |
| 313 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 314 | | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 315 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 342 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) |
| 343 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 344 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 345 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) |
| 346 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) |
| 347 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) |
| 348 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) |
| 349 | |
| 350 | PORT_START("DSW") |
| 351 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:8,7") /* Will need verification, as other dips don't match manual */ |
| 352 | PORT_DIPSETTING( 0x03, DEF_STR( Easy ) ) |
| 353 | PORT_DIPSETTING( 0x02, DEF_STR( Normal ) ) |
| 354 | PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) |
| 355 | PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) |
| 356 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:6,5") /* Shown as SW1:4 & SW1:5 in manual */ |
| 357 | PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) ) /* Actual effect on game, manual shows 1C / 2C */ |
| 358 | PORT_DIPSETTING( 0x04, DEF_STR( 2C_1C ) ) /* Actual effect on game, manual shows 3C / 1C */ |
| 359 | PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) ) /* Actual effect on game & manual are the same */ |
| 360 | PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) /* Actual effect on game, manual shows 2C / 1C */ |
| 361 | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:4") /* Not shown in manual */ |
| 362 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 363 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 364 | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:3") /* Not shown in manual */ |
| 365 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) |
| 366 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 367 | PORT_DIPNAME( 0x40, 0x00, "Display Numbers on Tiles" ) PORT_DIPLOCATION("SW1:2") /* As per manual */ |
| 368 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 369 | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 370 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) /* Dipswitch 1:1 Not shown in manual */ |
| 316 | 371 | INPUT_PORTS_END |
| 317 | 372 | |
| 318 | 373 | |
| r14995 | r14996 | |
| 466 | 521 | state->m_ram = auto_alloc_array(machine, UINT8, 0x20000); |
| 467 | 522 | } |
| 468 | 523 | |
| 469 | | GAME( 1991, pzlestar, 0, pzlestar, sangho, sangho, ROT270, "Sang Ho Soft", "Puzzle Star (Sang Ho Soft)", GAME_NOT_WORKING ) |
| 470 | | GAME( 1992, sexyboom, 0, sexyboom, sangho, sangho, ROT270, "Sang Ho Soft", "Sexy Boom", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS ) |
| 524 | GAME( 1991, pzlestar, 0, pzlestar, pzlestar, sangho, ROT270, "Sang Ho Soft", "Puzzle Star (Sang Ho Soft)", GAME_NOT_WORKING ) |
| 525 | GAME( 1992, sexyboom, 0, sexyboom, sexyboom, sangho, ROT270, "Sang Ho Soft", "Sexy Boom", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS ) |
src/mame/drivers/gumbo.c
| r14995 | r14996 | |
| 102 | 102 | |
| 103 | 103 | PORT_START("DSW") |
| 104 | 104 | PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 105 | | PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Coinage ) ) |
| 105 | PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:1,2") |
| 106 | 106 | PORT_DIPSETTING( 0x0000, DEF_STR( 3C_1C ) ) |
| 107 | 107 | PORT_DIPSETTING( 0x0100, DEF_STR( 2C_1C ) ) |
| 108 | 108 | PORT_DIPSETTING( 0x0300, DEF_STR( 1C_1C ) ) |
| 109 | 109 | PORT_DIPSETTING( 0x0200, DEF_STR( 1C_2C ) ) |
| 110 | | PORT_DIPNAME( 0x0400, 0x0400, "Helps" ) // "Power Count" in test mode |
| 110 | PORT_DIPNAME( 0x0400, 0x0400, "Helps" ) PORT_DIPLOCATION("SW1:3") // "Power Count" in test mode |
| 111 | 111 | PORT_DIPSETTING( 0x0000, "0" ) |
| 112 | 112 | PORT_DIPSETTING( 0x0400, "1" ) |
| 113 | | PORT_DIPNAME( 0x0800, 0x0800, "Bonus Bar Level" ) |
| 113 | PORT_DIPNAME( 0x0800, 0x0800, "Bonus Bar Level" ) PORT_DIPLOCATION("SW1:4") |
| 114 | 114 | PORT_DIPSETTING( 0x0800, DEF_STR( Normal ) ) |
| 115 | 115 | PORT_DIPSETTING( 0x0000, DEF_STR( High ) ) |
| 116 | | PORT_DIPNAME( 0x3000, 0x3000, DEF_STR( Difficulty ) ) |
| 116 | PORT_DIPNAME( 0x3000, 0x3000, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:5,6") |
| 117 | 117 | PORT_DIPSETTING( 0x2000, DEF_STR( Easy ) ) |
| 118 | 118 | PORT_DIPSETTING( 0x3000, DEF_STR( Normal ) ) |
| 119 | 119 | PORT_DIPSETTING( 0x1000, DEF_STR( Hard ) ) |
| 120 | 120 | PORT_DIPSETTING( 0x0000, DEF_STR( Hardest ) ) |
| 121 | | PORT_DIPNAME( 0x4000, 0x4000, "Picture View" ) |
| 121 | PORT_DIPNAME( 0x4000, 0x4000, "Picture View" ) PORT_DIPLOCATION("SW1:7") |
| 122 | 122 | PORT_DIPSETTING( 0x4000, DEF_STR( Off ) ) |
| 123 | 123 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 124 | | PORT_SERVICE( 0x8000, IP_ACTIVE_LOW ) |
| 124 | PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" ) |
| 125 | 125 | INPUT_PORTS_END |
| 126 | 126 | |
| 127 | 127 | static INPUT_PORTS_START( msbingo ) |
| 128 | 128 | PORT_INCLUDE( gumbo ) |
| 129 | 129 | |
| 130 | 130 | PORT_MODIFY("DSW") |
| 131 | | PORT_DIPNAME( 0x0c00, 0x0c00, "Chance Count" ) |
| 131 | PORT_DIPNAME( 0x0c00, 0x0c00, "Chance Count" ) PORT_DIPLOCATION("SW1:3,4") |
| 132 | 132 | PORT_DIPSETTING( 0x0c00, "0" ) |
| 133 | 133 | PORT_DIPSETTING( 0x0800, "1" ) |
| 134 | 134 | PORT_DIPSETTING( 0x0400, "2" ) |
| 135 | 135 | PORT_DIPSETTING( 0x0000, "3" ) |
| 136 | | PORT_DIPNAME( 0x1000, 0x1000, "Play Level" ) |
| 136 | PORT_DIPNAME( 0x1000, 0x1000, "Play Level" ) PORT_DIPLOCATION("SW1:5") |
| 137 | 137 | PORT_DIPSETTING( 0x1000, DEF_STR( Normal ) ) |
| 138 | 138 | PORT_DIPSETTING( 0x0000, DEF_STR( Easy ) ) |
| 139 | | PORT_DIPNAME( 0x2000, 0x2000, "Play Speed" ) |
| 139 | PORT_DIPNAME( 0x2000, 0x2000, "Play Speed" ) PORT_DIPLOCATION("SW1:6") |
| 140 | 140 | PORT_DIPSETTING( 0x2000, DEF_STR( Normal ) ) |
| 141 | 141 | PORT_DIPSETTING( 0x0000, DEF_STR( High ) ) |
| 142 | | PORT_DIPNAME( 0x4000, 0x4000, "Left Count" ) |
| 142 | PORT_DIPNAME( 0x4000, 0x4000, "Left Count" ) PORT_DIPLOCATION("SW1:7") |
| 143 | 143 | PORT_DIPSETTING( 0x4000, DEF_STR( Normal ) ) |
| 144 | 144 | PORT_DIPSETTING( 0x0000, DEF_STR( Low ) ) |
| 145 | | PORT_SERVICE( 0x8000, IP_ACTIVE_LOW ) |
| 145 | PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" ) |
| 146 | 146 | INPUT_PORTS_END |
| 147 | 147 | |
| 148 | 148 | static INPUT_PORTS_START( mspuzzle ) |
| r14995 | r14996 | |
| 150 | 150 | |
| 151 | 151 | PORT_MODIFY("DSW") |
| 152 | 152 | PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 153 | | PORT_DIPNAME( 0x0300, 0x0200, "Time Mode" ) |
| 153 | PORT_DIPNAME( 0x0300, 0x0200, "Time Mode" ) PORT_DIPLOCATION("SW1:1,2") /* Manual list this as "Game Level" with Levels 1 through 4 */ |
| 154 | 154 | PORT_DIPSETTING( 0x0300, "0" ) |
| 155 | 155 | PORT_DIPSETTING( 0x0200, "1" ) |
| 156 | 156 | PORT_DIPSETTING( 0x0100, "2" ) |
| 157 | 157 | PORT_DIPSETTING( 0x0000, "3" ) |
| 158 | | PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Coinage ) ) |
| 158 | PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:3,4") |
| 159 | 159 | PORT_DIPSETTING( 0x0000, DEF_STR( 2C_1C ) ) |
| 160 | 160 | PORT_DIPSETTING( 0x0c00, DEF_STR( 1C_1C ) ) |
| 161 | 161 | PORT_DIPSETTING( 0x0800, DEF_STR( 1C_2C ) ) |
| 162 | 162 | PORT_DIPSETTING( 0x0400, DEF_STR( 1C_3C ) ) |
| 163 | | PORT_DIPNAME( 0x1000, 0x1000, "Sound Test" ) |
| 163 | PORT_DIPNAME( 0x1000, 0x1000, "Sound Test" ) PORT_DIPLOCATION("SW1:5") |
| 164 | 164 | PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) |
| 165 | 165 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 166 | | PORT_DIPNAME( 0x2000, 0x2000, "View Staff Credits" ) |
| 166 | PORT_DIPNAME( 0x2000, 0x2000, "View Staff Credits" ) PORT_DIPLOCATION("SW1:6") |
| 167 | 167 | PORT_DIPSETTING( 0x2000, DEF_STR( Off ) ) |
| 168 | 168 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 169 | | PORT_DIPNAME( 0x4000, 0x4000, "Picture View" ) |
| 169 | PORT_DIPNAME( 0x4000, 0x4000, "Picture View" ) PORT_DIPLOCATION("SW1:7") |
| 170 | 170 | PORT_DIPSETTING( 0x4000, DEF_STR( Off ) ) |
| 171 | 171 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 172 | | PORT_SERVICE( 0x8000, IP_ACTIVE_LOW ) |
| 172 | PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" ) |
| 173 | 173 | INPUT_PORTS_END |
| 174 | 174 | |
| 175 | 175 | static INPUT_PORTS_START( dblpoint ) |
| r14995 | r14996 | |
| 184 | 184 | PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) |
| 185 | 185 | |
| 186 | 186 | PORT_MODIFY("DSW") |
| 187 | | PORT_DIPNAME( 0x0c00, 0x0800, DEF_STR( Difficulty ) ) |
| 187 | PORT_DIPNAME( 0x0c00, 0x0800, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:3,4") |
| 188 | 188 | PORT_DIPSETTING( 0x0c00, DEF_STR( Easy ) ) |
| 189 | 189 | PORT_DIPSETTING( 0x0800, DEF_STR( Normal ) ) |
| 190 | 190 | PORT_DIPSETTING( 0x0400, DEF_STR( Hard ) ) |
| 191 | 191 | PORT_DIPSETTING( 0x0000, DEF_STR( Very_Hard ) ) |
| 192 | | PORT_DIPNAME( 0x1000, 0x1000, "Sound Test" ) |
| 192 | PORT_DIPNAME( 0x1000, 0x1000, "Sound Test" ) PORT_DIPLOCATION("SW1:5") |
| 193 | 193 | PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) |
| 194 | 194 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 195 | | PORT_DIPNAME( 0x2000, 0x2000, "Picture View" ) |
| 195 | PORT_DIPNAME( 0x2000, 0x2000, "Picture View" ) PORT_DIPLOCATION("SW1:6") |
| 196 | 196 | PORT_DIPSETTING( 0x2000, DEF_STR( Off ) ) |
| 197 | 197 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 198 | | PORT_DIPUNUSED( 0x4000, IP_ACTIVE_LOW ) |
| 199 | | PORT_SERVICE( 0x8000, IP_ACTIVE_LOW ) |
| 198 | PORT_DIPUNUSED_DIPLOC( 0x4000, IP_ACTIVE_LOW, "SW1:7" ) |
| 199 | PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" ) |
| 200 | 200 | INPUT_PORTS_END |
| 201 | 201 | |
| 202 | 202 | static const gfx_layout gumbo_layout = |
src/emu/ioport.c
| r14995 | r14996 | |
| 113 | 113 | CONSTANTS |
| 114 | 114 | ***************************************************************************/ |
| 115 | 115 | |
| 116 | | #define DIGITAL_JOYSTICKS_PER_PLAYER 3 |
| 117 | | |
| 118 | 116 | /* these constants must match the order of the joystick directions in the IPT definition */ |
| 119 | 117 | #define JOYDIR_UP 0 |
| 120 | 118 | #define JOYDIR_DOWN 1 |
| r14995 | r14996 | |
| 126 | 124 | #define JOYDIR_LEFT_BIT (1 << JOYDIR_LEFT) |
| 127 | 125 | #define JOYDIR_RIGHT_BIT (1 << JOYDIR_RIGHT) |
| 128 | 126 | |
| 129 | | #define NUM_SIMUL_KEYS (UCHAR_SHIFT_END - UCHAR_SHIFT_BEGIN + 1) |
| 130 | 127 | #define LOG_INPUTX 0 |
| 131 | 128 | #define SPACE_COUNT 3 |
| 132 | 129 | #define INVALID_CHAR '?' |
| r14995 | r14996 | |
| 184 | 181 | }; |
| 185 | 182 | |
| 186 | 183 | |
| 187 | | /* shared digital joystick state */ |
| 188 | | typedef struct _digital_joystick_state digital_joystick_state; |
| 189 | | struct _digital_joystick_state |
| 190 | | { |
| 191 | | const input_field_config * field[4]; /* input field for up, down, left, right respectively */ |
| 192 | | UINT8 inuse; /* is this joystick used? */ |
| 193 | | UINT8 current; /* current value */ |
| 194 | | UINT8 current4way; /* current 4-way value */ |
| 195 | | UINT8 previous; /* previous value */ |
| 196 | | }; |
| 197 | | |
| 198 | | |
| 199 | 184 | /* live device field information */ |
| 200 | 185 | typedef struct _device_field_info device_field_info; |
| 201 | 186 | struct _device_field_info |
| r14995 | r14996 | |
| 235 | 220 | }; |
| 236 | 221 | |
| 237 | 222 | |
| 238 | | typedef struct _inputx_code inputx_code; |
| 239 | | struct _inputx_code |
| 240 | | { |
| 241 | | unicode_char ch; |
| 242 | | const input_field_config * field[NUM_SIMUL_KEYS]; |
| 243 | | }; |
| 244 | | |
| 245 | 223 | #define KEY_BUFFER_SIZE 4096 |
| 246 | 224 | |
| 247 | | typedef struct _key_buffer key_buffer; |
| 248 | | struct _key_buffer |
| 249 | | { |
| 250 | | int begin_pos; |
| 251 | | int end_pos; |
| 252 | | unsigned int status_keydown : 1; |
| 253 | | int size; |
| 254 | | unicode_char *buffer; |
| 255 | | }; |
| 256 | | |
| 257 | 225 | typedef struct _char_info char_info; |
| 258 | 226 | struct _char_info |
| 259 | 227 | { |
| r14995 | r14996 | |
| 263 | 231 | }; |
| 264 | 232 | |
| 265 | 233 | |
| 266 | | /* private input port state */ |
| 267 | | struct _input_port_private |
| 268 | | { |
| 269 | | /* global state */ |
| 270 | | UINT8 safe_to_read; /* clear at start; set after state is loaded */ |
| 271 | | |
| 272 | | /* types */ |
| 273 | | simple_list<input_type_entry> typelist; /* list of live type states */ |
| 274 | | input_type_entry * type_to_entry[__ipt_max][MAX_PLAYERS]; /* map from type/player to type state */ |
| 275 | | |
| 276 | | /* specific special global input states */ |
| 277 | | digital_joystick_state joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; /* joystick states */ |
| 278 | | |
| 279 | | /* frame time tracking */ |
| 280 | | attotime last_frame_time; /* time of the last frame callback */ |
| 281 | | attoseconds_t last_delta_nsec; /* nanoseconds that passed since the previous callback */ |
| 282 | | |
| 283 | | /* playback/record information */ |
| 284 | | emu_file * record_file; /* recording file (NULL if not recording) */ |
| 285 | | emu_file * playback_file; /* playback file (NULL if not recording) */ |
| 286 | | UINT64 playback_accumulated_speed;/* accumulated speed during playback */ |
| 287 | | UINT32 playback_accumulated_frames;/* accumulated frames during playback */ |
| 288 | | |
| 289 | | /* inputx */ |
| 290 | | inputx_code *codes; |
| 291 | | key_buffer keybuffer; |
| 292 | | emu_timer *inputx_timer; |
| 293 | | int (*queue_chars)(running_machine &machine, const unicode_char *text, size_t text_len); |
| 294 | | int (*accept_char)(running_machine &machine, unicode_char ch); |
| 295 | | int (*charqueue_empty)(running_machine &machine); |
| 296 | | attotime current_rate; |
| 297 | | }; |
| 298 | | |
| 299 | | |
| 300 | 234 | /*************************************************************************** |
| 301 | 235 | MACROS |
| 302 | 236 | ***************************************************************************/ |
| r14995 | r14996 | |
| 889 | 823 | system |
| 890 | 824 | -------------------------------------------------*/ |
| 891 | 825 | |
| 892 | | time_t input_port_init(running_machine &machine) |
| 826 | ioport_manager::ioport_manager(running_machine &machine) |
| 827 | : safe_to_read(false), |
| 828 | last_frame_time(attotime::zero), |
| 829 | last_delta_nsec(0), |
| 830 | record_file(NULL), |
| 831 | playback_file(NULL), |
| 832 | playback_accumulated_speed(0), |
| 833 | playback_accumulated_frames(0), |
| 834 | codes(NULL), |
| 835 | inputx_timer(NULL), |
| 836 | queue_chars(NULL), |
| 837 | accept_char(NULL), |
| 838 | charqueue_empty(NULL), |
| 839 | current_rate(attotime::zero), |
| 840 | m_machine(machine) |
| 893 | 841 | { |
| 894 | | //input_port_private *portdata; |
| 895 | | time_t basetime; |
| 842 | memset(type_to_entry, 0, sizeof(type_to_entry)); |
| 843 | memset(joystick_info, 0, sizeof(joystick_info)); |
| 844 | } |
| 896 | 845 | |
| 897 | | /* allocate memory for our data structure */ |
| 898 | | machine.input_port_data = auto_alloc_clear(machine, input_port_private); |
| 899 | | //portdata = machine.input_port_data; |
| 900 | | |
| 846 | time_t ioport_manager::initialize() |
| 847 | { |
| 901 | 848 | /* add an exit callback and a frame callback */ |
| 902 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(input_port_exit), &machine)); |
| 903 | | machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(frame_update_callback), &machine)); |
| 849 | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(input_port_exit), &machine())); |
| 850 | machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(frame_update_callback), &machine())); |
| 904 | 851 | |
| 905 | 852 | /* initialize the default port info from the OSD */ |
| 906 | | init_port_types(machine); |
| 853 | init_port_types(machine()); |
| 907 | 854 | |
| 908 | 855 | /* if we have a token list, proceed */ |
| 909 | | device_iterator iter(machine.root_device()); |
| 856 | device_iterator iter(machine().root_device()); |
| 910 | 857 | for (device_t *device = iter.first(); device != NULL; device = iter.next()) |
| 911 | 858 | { |
| 912 | 859 | astring errors; |
| 913 | | input_port_list_init(*device, machine.m_portlist, errors); |
| 860 | input_port_list_init(*device, m_portlist, errors); |
| 914 | 861 | if (errors) |
| 915 | 862 | mame_printf_error("Input port errors:\n%s", errors.cstr()); |
| 916 | 863 | } |
| 917 | 864 | |
| 918 | | init_port_state(machine); |
| 865 | init_port_state(machine()); |
| 919 | 866 | /* register callbacks for when we load configurations */ |
| 920 | | config_register(machine, "input", config_saveload_delegate(FUNC(load_config_callback), &machine), config_saveload_delegate(FUNC(save_config_callback), &machine)); |
| 867 | config_register(machine(), "input", config_saveload_delegate(FUNC(load_config_callback), &machine()), config_saveload_delegate(FUNC(save_config_callback), &machine())); |
| 921 | 868 | |
| 922 | 869 | /* open playback and record files if specified */ |
| 923 | | basetime = playback_init(machine); |
| 924 | | record_init(machine); |
| 870 | time_t basetime = playback_init(machine()); |
| 871 | record_init(machine()); |
| 925 | 872 | |
| 926 | 873 | return basetime; |
| 927 | 874 | } |
| r14995 | r14996 | |
| 978 | 925 | |
| 979 | 926 | const input_field_config *input_field_by_tag_and_mask(running_machine &machine, const char *tag, input_port_value mask) |
| 980 | 927 | { |
| 981 | | const input_port_config *port = machine.port(tag); |
| 928 | const input_port_config *port = machine.root_device().ioport(tag); |
| 982 | 929 | |
| 983 | 930 | /* if we got the port, look for the field */ |
| 984 | 931 | if (port != NULL) |
| r14995 | r14996 | |
| 1275 | 1222 | const char *input_type_name(running_machine &machine, int type, int player) |
| 1276 | 1223 | { |
| 1277 | 1224 | /* if we have a machine, use the live state and quick lookup */ |
| 1278 | | input_port_private *portdata = machine.input_port_data; |
| 1279 | | input_type_entry *entry = portdata->type_to_entry[type][player]; |
| 1225 | ioport_manager &portdata = machine.ioport(); |
| 1226 | input_type_entry *entry = portdata.type_to_entry[type][player]; |
| 1280 | 1227 | if (entry != NULL) |
| 1281 | 1228 | return entry->name; |
| 1282 | 1229 | |
| r14995 | r14996 | |
| 1292 | 1239 | |
| 1293 | 1240 | int input_type_group(running_machine &machine, int type, int player) |
| 1294 | 1241 | { |
| 1295 | | input_port_private *portdata = machine.input_port_data; |
| 1296 | | input_type_entry *entry = portdata->type_to_entry[type][player]; |
| 1242 | ioport_manager &portdata = machine.ioport(); |
| 1243 | input_type_entry *entry = portdata.type_to_entry[type][player]; |
| 1297 | 1244 | if (entry != NULL) |
| 1298 | 1245 | return entry->group; |
| 1299 | 1246 | |
| r14995 | r14996 | |
| 1313 | 1260 | assert(player >= 0 && player < MAX_PLAYERS); |
| 1314 | 1261 | |
| 1315 | 1262 | /* if we have a machine, use the live state and quick lookup */ |
| 1316 | | input_port_private *portdata = machine.input_port_data; |
| 1317 | | input_type_entry *entry = portdata->type_to_entry[type][player]; |
| 1263 | ioport_manager &portdata = machine.ioport(); |
| 1264 | input_type_entry *entry = portdata.type_to_entry[type][player]; |
| 1318 | 1265 | if (entry != NULL) |
| 1319 | 1266 | return entry->seq[seqtype]; |
| 1320 | 1267 | |
| r14995 | r14996 | |
| 1330 | 1277 | |
| 1331 | 1278 | void input_type_set_seq(running_machine &machine, int type, int player, input_seq_type seqtype, const input_seq *newseq) |
| 1332 | 1279 | { |
| 1333 | | input_port_private *portdata = machine.input_port_data; |
| 1334 | | input_type_entry *entry = portdata->type_to_entry[type][player]; |
| 1280 | ioport_manager &portdata = machine.ioport(); |
| 1281 | input_type_entry *entry = portdata.type_to_entry[type][player]; |
| 1335 | 1282 | if (entry != NULL) |
| 1336 | 1283 | entry->seq[seqtype] = *newseq; |
| 1337 | 1284 | } |
| r14995 | r14996 | |
| 1355 | 1302 | |
| 1356 | 1303 | const simple_list<input_type_entry> &input_type_list(running_machine &machine) |
| 1357 | 1304 | { |
| 1358 | | input_port_private *portdata = machine.input_port_data; |
| 1359 | | return portdata->typelist; |
| 1305 | ioport_manager &portdata = machine.ioport(); |
| 1306 | return portdata.typelist; |
| 1360 | 1307 | } |
| 1361 | 1308 | |
| 1362 | 1309 | |
| r14995 | r14996 | |
| 1373 | 1320 | |
| 1374 | 1321 | bool input_port_exists(running_machine &machine, const char *tag) |
| 1375 | 1322 | { |
| 1376 | | return machine.port(tag) != 0; |
| 1323 | return machine.root_device().ioport(tag) != 0; |
| 1377 | 1324 | } |
| 1378 | 1325 | |
| 1379 | 1326 | |
| r14995 | r14996 | |
| 1385 | 1332 | |
| 1386 | 1333 | input_port_value input_port_active(running_machine &machine, const char *tag) |
| 1387 | 1334 | { |
| 1388 | | const input_port_config *port = machine.port(tag); |
| 1335 | const input_port_config *port = machine.root_device().ioport(tag); |
| 1389 | 1336 | if (port == NULL) |
| 1390 | 1337 | fatalerror("Unable to locate input port '%s'", tag); |
| 1391 | 1338 | return port->active; |
| r14995 | r14996 | |
| 1401 | 1348 | |
| 1402 | 1349 | input_port_value input_port_active_safe(running_machine &machine, const char *tag, input_port_value defvalue) |
| 1403 | 1350 | { |
| 1404 | | const input_port_config *port = machine.port(tag); |
| 1351 | const input_port_config *port = machine.root_device().ioport(tag); |
| 1405 | 1352 | return port == NULL ? defvalue : port->active; |
| 1406 | 1353 | } |
| 1407 | 1354 | |
| r14995 | r14996 | |
| 1420 | 1367 | { |
| 1421 | 1368 | assert(port != NULL); |
| 1422 | 1369 | |
| 1423 | | input_port_private *portdata = port->machine().input_port_data; |
| 1370 | ioport_manager &portdata = port->machine().ioport(); |
| 1424 | 1371 | analog_field_state *analog; |
| 1425 | 1372 | device_field_info *device_field; |
| 1426 | 1373 | input_port_value result; |
| 1427 | 1374 | |
| 1428 | | assert_always(portdata->safe_to_read, "Input ports cannot be read at init time!"); |
| 1375 | assert_always(portdata.safe_to_read, "Input ports cannot be read at init time!"); |
| 1429 | 1376 | |
| 1430 | 1377 | /* start with the digital */ |
| 1431 | 1378 | result = port->state->digital; |
| r14995 | r14996 | |
| 1460 | 1407 | INT32 value = analog->accum; |
| 1461 | 1408 | |
| 1462 | 1409 | /* interpolate if appropriate and if time has passed since the last update */ |
| 1463 | | if (analog->interpolate && !(analog->field->flags & ANALOG_FLAG_RESET) && portdata->last_delta_nsec != 0) |
| 1410 | if (analog->interpolate && !(analog->field->flags & ANALOG_FLAG_RESET) && portdata.last_delta_nsec != 0) |
| 1464 | 1411 | { |
| 1465 | | attoseconds_t nsec_since_last = (port->machine().time() - portdata->last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; |
| 1466 | | value = analog->previous + ((INT64)(analog->accum - analog->previous) * nsec_since_last / portdata->last_delta_nsec); |
| 1412 | attoseconds_t nsec_since_last = (port->machine().time() - portdata.last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; |
| 1413 | value = analog->previous + ((INT64)(analog->accum - analog->previous) * nsec_since_last / portdata.last_delta_nsec); |
| 1467 | 1414 | } |
| 1468 | 1415 | |
| 1469 | 1416 | /* apply standard analog settings */ |
| r14995 | r14996 | |
| 1492 | 1439 | |
| 1493 | 1440 | input_port_value input_port_read(running_machine &machine, const char *tag) |
| 1494 | 1441 | { |
| 1495 | | const input_port_config *port = machine.port(tag); |
| 1442 | const input_port_config *port = machine.root_device().ioport(tag); |
| 1496 | 1443 | if (port == NULL) |
| 1497 | 1444 | fatalerror("Unable to locate input port '%s'", tag); |
| 1498 | 1445 | return input_port_read_direct(port); |
| r14995 | r14996 | |
| 1506 | 1453 | |
| 1507 | 1454 | input_port_value input_port_read(device_t &device, const char *tag) |
| 1508 | 1455 | { |
| 1509 | | astring fullpath; |
| 1510 | | const input_port_config *port = device.machine().port(device.subtag(fullpath, tag)); |
| 1456 | const input_port_config *port = device.ioport(tag); |
| 1511 | 1457 | if (port == NULL) |
| 1512 | 1458 | fatalerror("Unable to locate input port '%s'", tag); |
| 1513 | 1459 | return input_port_read_direct(port); |
| r14995 | r14996 | |
| 1522 | 1468 | |
| 1523 | 1469 | input_port_value input_port_read_safe(running_machine &machine, const char *tag, UINT32 defvalue) |
| 1524 | 1470 | { |
| 1525 | | const input_port_config *port = machine.port(tag); |
| 1471 | const input_port_config *port = machine.root_device().ioport(tag); |
| 1526 | 1472 | return (port == NULL) ? defvalue : input_port_read_direct(port); |
| 1527 | 1473 | } |
| 1528 | 1474 | |
| r14995 | r14996 | |
| 1540 | 1486 | int gotx = FALSE, goty = FALSE; |
| 1541 | 1487 | |
| 1542 | 1488 | /* read all the lightgun values */ |
| 1543 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1489 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 1544 | 1490 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 1545 | 1491 | if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE) |
| 1546 | 1492 | if (input_condition_true(machine, &field->condition, port->owner())) |
| r14995 | r14996 | |
| 1609 | 1555 | const input_port_config *port; |
| 1610 | 1556 | |
| 1611 | 1557 | /* loop over all input ports */ |
| 1612 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1558 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 1613 | 1559 | { |
| 1614 | 1560 | const input_field_config *field; |
| 1615 | 1561 | |
| r14995 | r14996 | |
| 1695 | 1641 | |
| 1696 | 1642 | void input_port_write(running_machine &machine, const char *tag, input_port_value value, input_port_value mask) |
| 1697 | 1643 | { |
| 1698 | | const input_port_config *port = machine.port(tag); |
| 1644 | const input_port_config *port = machine.root_device().ioport(tag); |
| 1699 | 1645 | if (port == NULL) |
| 1700 | 1646 | fatalerror("Unable to locate input port '%s'", tag); |
| 1701 | 1647 | input_port_write_direct(port, value, mask); |
| r14995 | r14996 | |
| 1709 | 1655 | |
| 1710 | 1656 | void input_port_write_safe(running_machine &machine, const char *tag, input_port_value value, input_port_value mask) |
| 1711 | 1657 | { |
| 1712 | | const input_port_config *port = machine.port(tag); |
| 1658 | const input_port_config *port = machine.root_device().ioport(tag); |
| 1713 | 1659 | if (port != NULL) |
| 1714 | 1660 | input_port_write_direct(port, value, mask); |
| 1715 | 1661 | } |
| r14995 | r14996 | |
| 1809 | 1755 | |
| 1810 | 1756 | static void init_port_types(running_machine &machine) |
| 1811 | 1757 | { |
| 1812 | | input_port_private *portdata = machine.input_port_data; |
| 1758 | ioport_manager &portdata = machine.ioport(); |
| 1813 | 1759 | |
| 1814 | 1760 | /* convert the array into a list of type states that can be modified */ |
| 1815 | | construct_core_types(portdata->typelist); |
| 1761 | construct_core_types(portdata.typelist); |
| 1816 | 1762 | |
| 1817 | 1763 | /* ask the OSD to customize the list */ |
| 1818 | | machine.osd().customize_input_type_list(portdata->typelist); |
| 1764 | machine.osd().customize_input_type_list(portdata.typelist); |
| 1819 | 1765 | |
| 1820 | 1766 | /* now iterate over the OSD-modified types */ |
| 1821 | | for (input_type_entry *curtype = portdata->typelist.first(); curtype != NULL; curtype = curtype->next()) |
| 1767 | for (input_type_entry *curtype = portdata.typelist.first(); curtype != NULL; curtype = curtype->next()) |
| 1822 | 1768 | { |
| 1823 | 1769 | /* first copy all the OSD-updated sequences into our current state */ |
| 1824 | 1770 | for (int seqtype = 0; seqtype < ARRAY_LENGTH(curtype->seq); seqtype++) |
| 1825 | 1771 | curtype->seq[seqtype] = curtype->defseq[seqtype]; |
| 1826 | 1772 | |
| 1827 | 1773 | /* also make a lookup table mapping type/player to the appropriate type list entry */ |
| 1828 | | portdata->type_to_entry[curtype->type][curtype->player] = curtype; |
| 1774 | portdata.type_to_entry[curtype->type][curtype->player] = curtype; |
| 1829 | 1775 | } |
| 1830 | 1776 | } |
| 1831 | 1777 | |
| r14995 | r14996 | |
| 1946 | 1892 | static void init_port_state(running_machine &machine) |
| 1947 | 1893 | { |
| 1948 | 1894 | const char *joystick_map_default = machine.options().joystick_map(); |
| 1949 | | input_port_private *portdata = machine.input_port_data; |
| 1895 | ioport_manager &portdata = machine.ioport(); |
| 1950 | 1896 | input_field_config *field; |
| 1951 | 1897 | input_port_config *port; |
| 1952 | 1898 | |
| 1953 | 1899 | /* allocate live structures to mirror the configuration */ |
| 1954 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1900 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 1955 | 1901 | { |
| 1956 | 1902 | analog_field_state **analogstatetail; |
| 1957 | 1903 | device_field_info **readdevicetail; |
| r14995 | r14996 | |
| 1992 | 1938 | /* if this is a digital joystick field, make a note of it */ |
| 1993 | 1939 | if (field->type >= __ipt_digital_joystick_start && field->type <= __ipt_digital_joystick_end) |
| 1994 | 1940 | { |
| 1995 | | fieldstate->joystick = &portdata->joystick_info[field->player][(field->type - __ipt_digital_joystick_start) / 4]; |
| 1941 | fieldstate->joystick = &portdata.joystick_info[field->player][(field->type - __ipt_digital_joystick_start) / 4]; |
| 1996 | 1942 | fieldstate->joydir = (field->type - __ipt_digital_joystick_start) % 4; |
| 1997 | 1943 | fieldstate->joystick->field[fieldstate->joydir] = field; |
| 1998 | 1944 | fieldstate->joystick->inuse = TRUE; |
| r14995 | r14996 | |
| 2047 | 1993 | |
| 2048 | 1994 | /* look for 4-way joysticks and change the default map if we find any */ |
| 2049 | 1995 | if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) |
| 2050 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1996 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 2051 | 1997 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 2052 | 1998 | if (field->state->joystick != NULL && field->way == 4) |
| 2053 | 1999 | { |
| r14995 | r14996 | |
| 2065 | 2011 | |
| 2066 | 2012 | static void init_autoselect_devices(running_machine &machine, int type1, int type2, int type3, const char *option, const char *ananame) |
| 2067 | 2013 | { |
| 2068 | | const ioport_list &portlist = machine.m_portlist; |
| 2069 | 2014 | const char *stemp = machine.options().value(option); |
| 2070 | 2015 | input_device_class autoenable = DEVICE_CLASS_KEYBOARD; |
| 2071 | 2016 | const char *autostring = "keyboard"; |
| r14995 | r14996 | |
| 2101 | 2046 | mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp); |
| 2102 | 2047 | |
| 2103 | 2048 | /* only scan the list if we haven't already enabled this class of control */ |
| 2104 | | if (portlist.first() != NULL && !machine.input().device_class(autoenable).enabled()) |
| 2105 | | for (port = portlist.first(); port != NULL; port = port->next()) |
| 2049 | if (machine.ioport().first_port() != NULL && !machine.input().device_class(autoenable).enabled()) |
| 2050 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 2106 | 2051 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 2107 | 2052 | |
| 2108 | 2053 | /* if this port type is in use, apply the autoselect criteria */ |
| r14995 | r14996 | |
| 2336 | 2281 | |
| 2337 | 2282 | static key_buffer *get_buffer(running_machine &machine) |
| 2338 | 2283 | { |
| 2339 | | input_port_private *portdata = machine.input_port_data; |
| 2284 | ioport_manager &portdata = machine.ioport(); |
| 2340 | 2285 | assert(inputx_can_post(machine)); |
| 2341 | | return (key_buffer *)&portdata->keybuffer; |
| 2286 | return (key_buffer *)&portdata.keybuffer; |
| 2342 | 2287 | } |
| 2343 | 2288 | |
| 2344 | 2289 | |
| r14995 | r14996 | |
| 2363 | 2308 | |
| 2364 | 2309 | static void input_port_update_hook(running_machine &machine, const input_port_config *port, input_port_value *digital) |
| 2365 | 2310 | { |
| 2366 | | input_port_private *portdata = machine.input_port_data; |
| 2311 | ioport_manager &portdata = machine.ioport(); |
| 2367 | 2312 | const key_buffer *keybuf; |
| 2368 | 2313 | const inputx_code *code; |
| 2369 | 2314 | unicode_char ch; |
| r14995 | r14996 | |
| 2379 | 2324 | { |
| 2380 | 2325 | /* identify the character that is down right now, and its component codes */ |
| 2381 | 2326 | ch = keybuf->buffer[keybuf->begin_pos]; |
| 2382 | | code = find_code(portdata->codes, ch); |
| 2327 | code = find_code(portdata.codes, ch); |
| 2383 | 2328 | |
| 2384 | 2329 | /* loop through this character's component codes */ |
| 2385 | 2330 | if (code != NULL) |
| r14995 | r14996 | |
| 2405 | 2350 | |
| 2406 | 2351 | static void frame_update(running_machine &machine) |
| 2407 | 2352 | { |
| 2408 | | input_port_private *portdata = machine.input_port_data; |
| 2353 | ioport_manager &portdata = machine.ioport(); |
| 2409 | 2354 | const input_field_config *mouse_field = NULL; |
| 2410 | 2355 | int ui_visible = ui_is_menu_active(); |
| 2411 | 2356 | attotime curtime = machine.time(); |
| r14995 | r14996 | |
| 2422 | 2367 | record_frame(machine, curtime); |
| 2423 | 2368 | |
| 2424 | 2369 | /* track the duration of the previous frame */ |
| 2425 | | portdata->last_delta_nsec = (curtime - portdata->last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; |
| 2426 | | portdata->last_frame_time = curtime; |
| 2370 | portdata.last_delta_nsec = (curtime - portdata.last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; |
| 2371 | portdata.last_frame_time = curtime; |
| 2427 | 2372 | |
| 2428 | 2373 | /* update the digital joysticks */ |
| 2429 | 2374 | frame_update_digital_joysticks(machine); |
| r14995 | r14996 | |
| 2443 | 2388 | } |
| 2444 | 2389 | |
| 2445 | 2390 | /* loop over all input ports */ |
| 2446 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 2391 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 2447 | 2392 | { |
| 2448 | 2393 | const input_field_config *field; |
| 2449 | 2394 | device_field_info *device_field; |
| r14995 | r14996 | |
| 2506 | 2451 | |
| 2507 | 2452 | static void frame_update_digital_joysticks(running_machine &machine) |
| 2508 | 2453 | { |
| 2509 | | input_port_private *portdata = machine.input_port_data; |
| 2454 | ioport_manager &portdata = machine.ioport(); |
| 2510 | 2455 | int player, joyindex; |
| 2511 | 2456 | |
| 2512 | 2457 | /* loop over all the joysticks */ |
| 2513 | 2458 | for (player = 0; player < MAX_PLAYERS; player++) |
| 2514 | 2459 | for (joyindex = 0; joyindex < DIGITAL_JOYSTICKS_PER_PLAYER; joyindex++) |
| 2515 | 2460 | { |
| 2516 | | digital_joystick_state *joystick = &portdata->joystick_info[player][joyindex]; |
| 2461 | digital_joystick_state *joystick = &portdata.joystick_info[player][joyindex]; |
| 2517 | 2462 | if (joystick->inuse) |
| 2518 | 2463 | { |
| 2519 | 2464 | joystick->previous = joystick->current; |
| r14995 | r14996 | |
| 3094 | 3039 | |
| 3095 | 3040 | static int token_to_input_field_type(running_machine &machine, const char *string, int *player) |
| 3096 | 3041 | { |
| 3097 | | input_port_private *portdata = machine.input_port_data; |
| 3042 | ioport_manager &portdata = machine.ioport(); |
| 3098 | 3043 | int ipnum; |
| 3099 | 3044 | |
| 3100 | 3045 | /* check for our failsafe case first */ |
| r14995 | r14996 | |
| 3102 | 3047 | return ipnum; |
| 3103 | 3048 | |
| 3104 | 3049 | /* find the token in the list */ |
| 3105 | | for (input_type_entry *entry = portdata->typelist.first(); entry != NULL; entry = entry->next()) |
| 3050 | for (input_type_entry *entry = portdata.typelist.first(); entry != NULL; entry = entry->next()) |
| 3106 | 3051 | if (entry->token != NULL && !strcmp(entry->token, string)) |
| 3107 | 3052 | { |
| 3108 | 3053 | *player = entry->player; |
| r14995 | r14996 | |
| 3122 | 3067 | |
| 3123 | 3068 | static const char *input_field_type_to_token(running_machine &machine, int type, int player) |
| 3124 | 3069 | { |
| 3125 | | input_port_private *portdata = machine.input_port_data; |
| 3070 | ioport_manager &portdata = machine.ioport(); |
| 3126 | 3071 | static char tempbuf[32]; |
| 3127 | 3072 | |
| 3128 | 3073 | /* look up the port and return the token */ |
| 3129 | | input_type_entry *entry = portdata->type_to_entry[type][player]; |
| 3074 | input_type_entry *entry = portdata.type_to_entry[type][player]; |
| 3130 | 3075 | if (entry != NULL) |
| 3131 | 3076 | return entry->token; |
| 3132 | 3077 | |
| r14995 | r14996 | |
| 3166 | 3111 | |
| 3167 | 3112 | static void load_config_callback(running_machine &machine, int config_type, xml_data_node *parentnode) |
| 3168 | 3113 | { |
| 3169 | | input_port_private *portdata = machine.input_port_data; |
| 3114 | ioport_manager &portdata = machine.ioport(); |
| 3170 | 3115 | xml_data_node *portnode; |
| 3171 | 3116 | int seqtype; |
| 3172 | 3117 | |
| 3173 | 3118 | /* in the completion phase, we finish the initialization with the final ports */ |
| 3174 | 3119 | if (config_type == CONFIG_TYPE_FINAL) |
| 3175 | 3120 | { |
| 3176 | | portdata->safe_to_read = TRUE; |
| 3121 | portdata.safe_to_read = TRUE; |
| 3177 | 3122 | frame_update(machine); |
| 3178 | 3123 | } |
| 3179 | 3124 | |
| r14995 | r14996 | |
| 3223 | 3168 | /* after applying the controller config, push that back into the backup, since that is */ |
| 3224 | 3169 | /* what we will diff against */ |
| 3225 | 3170 | if (config_type == CONFIG_TYPE_CONTROLLER) |
| 3226 | | for (input_type_entry *entry = portdata->typelist.first(); entry != NULL; entry = entry->next()) |
| 3171 | for (input_type_entry *entry = portdata.typelist.first(); entry != NULL; entry = entry->next()) |
| 3227 | 3172 | for (seqtype = 0; seqtype < ARRAY_LENGTH(entry->seq); seqtype++) |
| 3228 | 3173 | entry->defseq[seqtype] = entry->seq[seqtype]; |
| 3229 | 3174 | } |
| r14995 | r14996 | |
| 3236 | 3181 | |
| 3237 | 3182 | static void load_remap_table(running_machine &machine, xml_data_node *parentnode) |
| 3238 | 3183 | { |
| 3239 | | input_port_private *portdata = machine.input_port_data; |
| 3184 | ioport_manager &portdata = machine.ioport(); |
| 3240 | 3185 | input_code *oldtable, *newtable; |
| 3241 | 3186 | xml_data_node *remapnode; |
| 3242 | 3187 | int count; |
| r14995 | r14996 | |
| 3276 | 3221 | input_code newcode = newtable[remapnum]; |
| 3277 | 3222 | |
| 3278 | 3223 | /* loop over all default ports, remapping the requested keys */ |
| 3279 | | for (input_type_entry *entry = portdata->typelist.first(); entry != NULL; entry = entry->next()) |
| 3224 | for (input_type_entry *entry = portdata.typelist.first(); entry != NULL; entry = entry->next()) |
| 3280 | 3225 | { |
| 3281 | 3226 | /* remap anything in the default sequences */ |
| 3282 | 3227 | for (int seqtype = 0; seqtype < ARRAY_LENGTH(entry->seq); seqtype++) |
| r14995 | r14996 | |
| 3298 | 3243 | |
| 3299 | 3244 | static int load_default_config(running_machine &machine, xml_data_node *portnode, int type, int player, const input_seq *newseq) |
| 3300 | 3245 | { |
| 3301 | | input_port_private *portdata = machine.input_port_data; |
| 3246 | ioport_manager &portdata = machine.ioport(); |
| 3302 | 3247 | |
| 3303 | 3248 | /* find a matching port in the list */ |
| 3304 | | for (input_type_entry *entry = portdata->typelist.first(); entry != NULL; entry = entry->next()) |
| 3249 | for (input_type_entry *entry = portdata.typelist.first(); entry != NULL; entry = entry->next()) |
| 3305 | 3250 | if (entry->type == type && entry->player == player) |
| 3306 | 3251 | { |
| 3307 | 3252 | for (int seqtype = 0; seqtype < ARRAY_LENGTH(entry->seq); seqtype++) |
| r14995 | r14996 | |
| 3333 | 3278 | defvalue = xml_get_attribute_int(portnode, "defvalue", 0); |
| 3334 | 3279 | |
| 3335 | 3280 | /* find the port we want; if no tag, search them all */ |
| 3336 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 3281 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 3337 | 3282 | if (tag == NULL || strcmp(get_port_tag(port, tempbuffer), tag) == 0) |
| 3338 | 3283 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 3339 | 3284 | |
| r14995 | r14996 | |
| 3447 | 3392 | |
| 3448 | 3393 | static void save_default_inputs(running_machine &machine, xml_data_node *parentnode) |
| 3449 | 3394 | { |
| 3450 | | input_port_private *portdata = machine.input_port_data; |
| 3395 | ioport_manager &portdata = machine.ioport(); |
| 3451 | 3396 | input_type_entry *entry; |
| 3452 | 3397 | |
| 3453 | 3398 | /* iterate over ports */ |
| 3454 | | for (entry = portdata->typelist.first(); entry != NULL; entry = entry->next()) |
| 3399 | for (entry = portdata.typelist.first(); entry != NULL; entry = entry->next()) |
| 3455 | 3400 | { |
| 3456 | 3401 | /* only save if this port is a type we save */ |
| 3457 | 3402 | if (save_this_input_field_type(entry->type)) |
| r14995 | r14996 | |
| 3495 | 3440 | const input_port_config *port; |
| 3496 | 3441 | |
| 3497 | 3442 | /* iterate over ports */ |
| 3498 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 3443 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 3499 | 3444 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 3500 | 3445 | if (save_this_input_field_type(field->type)) |
| 3501 | 3446 | { |
| r14995 | r14996 | |
| 3576 | 3521 | |
| 3577 | 3522 | static UINT8 playback_read_uint8(running_machine &machine) |
| 3578 | 3523 | { |
| 3579 | | input_port_private *portdata = machine.input_port_data; |
| 3524 | ioport_manager &portdata = machine.ioport(); |
| 3580 | 3525 | UINT8 result; |
| 3581 | 3526 | |
| 3582 | 3527 | /* protect against NULL handles if previous reads fail */ |
| 3583 | | if (portdata->playback_file == NULL) |
| 3528 | if (portdata.playback_file == NULL) |
| 3584 | 3529 | return 0; |
| 3585 | 3530 | |
| 3586 | 3531 | /* read the value; if we fail, end playback */ |
| 3587 | | if (portdata->playback_file->read(&result, sizeof(result)) != sizeof(result)) |
| 3532 | if (portdata.playback_file->read(&result, sizeof(result)) != sizeof(result)) |
| 3588 | 3533 | { |
| 3589 | 3534 | playback_end(machine, "End of file"); |
| 3590 | 3535 | return 0; |
| r14995 | r14996 | |
| 3602 | 3547 | |
| 3603 | 3548 | static UINT32 playback_read_uint32(running_machine &machine) |
| 3604 | 3549 | { |
| 3605 | | input_port_private *portdata = machine.input_port_data; |
| 3550 | ioport_manager &portdata = machine.ioport(); |
| 3606 | 3551 | UINT32 result; |
| 3607 | 3552 | |
| 3608 | 3553 | /* protect against NULL handles if previous reads fail */ |
| 3609 | | if (portdata->playback_file == NULL) |
| 3554 | if (portdata.playback_file == NULL) |
| 3610 | 3555 | return 0; |
| 3611 | 3556 | |
| 3612 | 3557 | /* read the value; if we fail, end playback */ |
| 3613 | | if (portdata->playback_file->read(&result, sizeof(result)) != sizeof(result)) |
| 3558 | if (portdata.playback_file->read(&result, sizeof(result)) != sizeof(result)) |
| 3614 | 3559 | { |
| 3615 | 3560 | playback_end(machine, "End of file"); |
| 3616 | 3561 | return 0; |
| r14995 | r14996 | |
| 3628 | 3573 | |
| 3629 | 3574 | static UINT64 playback_read_uint64(running_machine &machine) |
| 3630 | 3575 | { |
| 3631 | | input_port_private *portdata = machine.input_port_data; |
| 3576 | ioport_manager &portdata = machine.ioport(); |
| 3632 | 3577 | UINT64 result; |
| 3633 | 3578 | |
| 3634 | 3579 | /* protect against NULL handles if previous reads fail */ |
| 3635 | | if (portdata->playback_file == NULL) |
| 3580 | if (portdata.playback_file == NULL) |
| 3636 | 3581 | return 0; |
| 3637 | 3582 | |
| 3638 | 3583 | /* read the value; if we fail, end playback */ |
| 3639 | | if (portdata->playback_file->read(&result, sizeof(result)) != sizeof(result)) |
| 3584 | if (portdata.playback_file->read(&result, sizeof(result)) != sizeof(result)) |
| 3640 | 3585 | { |
| 3641 | 3586 | playback_end(machine, "End of file"); |
| 3642 | 3587 | return 0; |
| r14995 | r14996 | |
| 3654 | 3599 | static time_t playback_init(running_machine &machine) |
| 3655 | 3600 | { |
| 3656 | 3601 | const char *filename = machine.options().playback(); |
| 3657 | | input_port_private *portdata = machine.input_port_data; |
| 3602 | ioport_manager &portdata = machine.ioport(); |
| 3658 | 3603 | UINT8 header[INP_HEADER_SIZE]; |
| 3659 | 3604 | time_t basetime; |
| 3660 | 3605 | |
| r14995 | r14996 | |
| 3663 | 3608 | return 0; |
| 3664 | 3609 | |
| 3665 | 3610 | /* open the playback file */ |
| 3666 | | portdata->playback_file = auto_alloc(machine, emu_file(machine.options().input_directory(), OPEN_FLAG_READ)); |
| 3667 | | file_error filerr = portdata->playback_file->open(filename); |
| 3611 | portdata.playback_file = auto_alloc(machine, emu_file(machine.options().input_directory(), OPEN_FLAG_READ)); |
| 3612 | file_error filerr = portdata.playback_file->open(filename); |
| 3668 | 3613 | assert_always(filerr == FILERR_NONE, "Failed to open file for playback"); |
| 3669 | 3614 | |
| 3670 | 3615 | /* read the header and verify that it is a modern version; if not, print an error */ |
| 3671 | | if (portdata->playback_file->read(header, sizeof(header)) != sizeof(header)) |
| 3616 | if (portdata.playback_file->read(header, sizeof(header)) != sizeof(header)) |
| 3672 | 3617 | fatalerror("Input file is corrupt or invalid (missing header)"); |
| 3673 | 3618 | if (memcmp(header, "MAMEINP\0", 8) != 0) |
| 3674 | 3619 | fatalerror("Input file invalid or in an older, unsupported format"); |
| r14995 | r14996 | |
| 3688 | 3633 | mame_printf_info("Input file is for %s '%s', not for current %s '%s'\n", emulator_info::get_gamenoun(), header + 0x14, emulator_info::get_gamenoun(), machine.system().name); |
| 3689 | 3634 | |
| 3690 | 3635 | /* enable compression */ |
| 3691 | | portdata->playback_file->compress(FCOMPRESS_MEDIUM); |
| 3636 | portdata.playback_file->compress(FCOMPRESS_MEDIUM); |
| 3692 | 3637 | |
| 3693 | 3638 | return basetime; |
| 3694 | 3639 | } |
| r14995 | r14996 | |
| 3700 | 3645 | |
| 3701 | 3646 | static void playback_end(running_machine &machine, const char *message) |
| 3702 | 3647 | { |
| 3703 | | input_port_private *portdata = machine.input_port_data; |
| 3648 | ioport_manager &portdata = machine.ioport(); |
| 3704 | 3649 | |
| 3705 | 3650 | /* only applies if we have a live file */ |
| 3706 | | if (portdata->playback_file != NULL) |
| 3651 | if (portdata.playback_file != NULL) |
| 3707 | 3652 | { |
| 3708 | 3653 | /* close the file */ |
| 3709 | | auto_free(machine, portdata->playback_file); |
| 3710 | | portdata->playback_file = NULL; |
| 3654 | auto_free(machine, portdata.playback_file); |
| 3655 | portdata.playback_file = NULL; |
| 3711 | 3656 | |
| 3712 | 3657 | /* pop a message */ |
| 3713 | 3658 | if (message != NULL) |
| 3714 | 3659 | popmessage("Playback Ended\nReason: %s", message); |
| 3715 | 3660 | |
| 3716 | 3661 | /* display speed stats */ |
| 3717 | | portdata->playback_accumulated_speed /= portdata->playback_accumulated_frames; |
| 3718 | | mame_printf_info("Total playback frames: %d\n", (UINT32)portdata->playback_accumulated_frames); |
| 3719 | | mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((portdata->playback_accumulated_speed * 200 + 1) >> 21)); |
| 3662 | portdata.playback_accumulated_speed /= portdata.playback_accumulated_frames; |
| 3663 | mame_printf_info("Total playback frames: %d\n", (UINT32)portdata.playback_accumulated_frames); |
| 3664 | mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((portdata.playback_accumulated_speed * 200 + 1) >> 21)); |
| 3720 | 3665 | } |
| 3721 | 3666 | } |
| 3722 | 3667 | |
| r14995 | r14996 | |
| 3728 | 3673 | |
| 3729 | 3674 | static void playback_frame(running_machine &machine, attotime curtime) |
| 3730 | 3675 | { |
| 3731 | | input_port_private *portdata = machine.input_port_data; |
| 3676 | ioport_manager &portdata = machine.ioport(); |
| 3732 | 3677 | |
| 3733 | 3678 | /* if playing back, fetch the information and verify */ |
| 3734 | | if (portdata->playback_file != NULL) |
| 3679 | if (portdata.playback_file != NULL) |
| 3735 | 3680 | { |
| 3736 | 3681 | attotime readtime; |
| 3737 | 3682 | |
| r14995 | r14996 | |
| 3742 | 3687 | playback_end(machine, "Out of sync"); |
| 3743 | 3688 | |
| 3744 | 3689 | /* then the speed */ |
| 3745 | | portdata->playback_accumulated_speed += playback_read_uint32(machine); |
| 3746 | | portdata->playback_accumulated_frames++; |
| 3690 | portdata.playback_accumulated_speed += playback_read_uint32(machine); |
| 3691 | portdata.playback_accumulated_frames++; |
| 3747 | 3692 | } |
| 3748 | 3693 | } |
| 3749 | 3694 | |
| r14995 | r14996 | |
| 3754 | 3699 | |
| 3755 | 3700 | static void playback_port(const input_port_config *port) |
| 3756 | 3701 | { |
| 3757 | | input_port_private *portdata = port->machine().input_port_data; |
| 3702 | ioport_manager &portdata = port->machine().ioport(); |
| 3758 | 3703 | |
| 3759 | 3704 | /* if playing back, fetch information about this port */ |
| 3760 | | if (portdata->playback_file != NULL) |
| 3705 | if (portdata.playback_file != NULL) |
| 3761 | 3706 | { |
| 3762 | 3707 | analog_field_state *analog; |
| 3763 | 3708 | |
| r14995 | r14996 | |
| 3792 | 3737 | |
| 3793 | 3738 | static void record_write_uint8(running_machine &machine, UINT8 data) |
| 3794 | 3739 | { |
| 3795 | | input_port_private *portdata = machine.input_port_data; |
| 3740 | ioport_manager &portdata = machine.ioport(); |
| 3796 | 3741 | UINT8 result = data; |
| 3797 | 3742 | |
| 3798 | 3743 | /* protect against NULL handles if previous reads fail */ |
| 3799 | | if (portdata->record_file == NULL) |
| 3744 | if (portdata.record_file == NULL) |
| 3800 | 3745 | return; |
| 3801 | 3746 | |
| 3802 | 3747 | /* read the value; if we fail, end playback */ |
| 3803 | | if (portdata->record_file->write(&result, sizeof(result)) != sizeof(result)) |
| 3748 | if (portdata.record_file->write(&result, sizeof(result)) != sizeof(result)) |
| 3804 | 3749 | record_end(machine, "Out of space"); |
| 3805 | 3750 | } |
| 3806 | 3751 | |
| r14995 | r14996 | |
| 3812 | 3757 | |
| 3813 | 3758 | static void record_write_uint32(running_machine &machine, UINT32 data) |
| 3814 | 3759 | { |
| 3815 | | input_port_private *portdata = machine.input_port_data; |
| 3760 | ioport_manager &portdata = machine.ioport(); |
| 3816 | 3761 | UINT32 result = LITTLE_ENDIANIZE_INT32(data); |
| 3817 | 3762 | |
| 3818 | 3763 | /* protect against NULL handles if previous reads fail */ |
| 3819 | | if (portdata->record_file == NULL) |
| 3764 | if (portdata.record_file == NULL) |
| 3820 | 3765 | return; |
| 3821 | 3766 | |
| 3822 | 3767 | /* read the value; if we fail, end playback */ |
| 3823 | | if (portdata->record_file->write(&result, sizeof(result)) != sizeof(result)) |
| 3768 | if (portdata.record_file->write(&result, sizeof(result)) != sizeof(result)) |
| 3824 | 3769 | record_end(machine, "Out of space"); |
| 3825 | 3770 | } |
| 3826 | 3771 | |
| r14995 | r14996 | |
| 3832 | 3777 | |
| 3833 | 3778 | static void record_write_uint64(running_machine &machine, UINT64 data) |
| 3834 | 3779 | { |
| 3835 | | input_port_private *portdata = machine.input_port_data; |
| 3780 | ioport_manager &portdata = machine.ioport(); |
| 3836 | 3781 | UINT64 result = LITTLE_ENDIANIZE_INT64(data); |
| 3837 | 3782 | |
| 3838 | 3783 | /* protect against NULL handles if previous reads fail */ |
| 3839 | | if (portdata->record_file == NULL) |
| 3784 | if (portdata.record_file == NULL) |
| 3840 | 3785 | return; |
| 3841 | 3786 | |
| 3842 | 3787 | /* read the value; if we fail, end playback */ |
| 3843 | | if (portdata->record_file->write(&result, sizeof(result)) != sizeof(result)) |
| 3788 | if (portdata.record_file->write(&result, sizeof(result)) != sizeof(result)) |
| 3844 | 3789 | record_end(machine, "Out of space"); |
| 3845 | 3790 | } |
| 3846 | 3791 | |
| r14995 | r14996 | |
| 3852 | 3797 | static void record_init(running_machine &machine) |
| 3853 | 3798 | { |
| 3854 | 3799 | const char *filename = machine.options().record(); |
| 3855 | | input_port_private *portdata = machine.input_port_data; |
| 3800 | ioport_manager &portdata = machine.ioport(); |
| 3856 | 3801 | UINT8 header[INP_HEADER_SIZE]; |
| 3857 | 3802 | system_time systime; |
| 3858 | 3803 | |
| r14995 | r14996 | |
| 3861 | 3806 | return; |
| 3862 | 3807 | |
| 3863 | 3808 | /* open the record file */ |
| 3864 | | portdata->record_file = auto_alloc(machine, emu_file(machine.options().input_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)); |
| 3865 | | file_error filerr = portdata->record_file->open(filename); |
| 3809 | portdata.record_file = auto_alloc(machine, emu_file(machine.options().input_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)); |
| 3810 | file_error filerr = portdata.record_file->open(filename); |
| 3866 | 3811 | assert_always(filerr == FILERR_NONE, "Failed to open file for recording"); |
| 3867 | 3812 | |
| 3868 | 3813 | /* get the base time */ |
| r14995 | r14996 | |
| 3885 | 3830 | sprintf((char *)header + 0x20, "%s %s", emulator_info::get_appname(), build_version); |
| 3886 | 3831 | |
| 3887 | 3832 | /* write it */ |
| 3888 | | portdata->record_file->write(header, sizeof(header)); |
| 3833 | portdata.record_file->write(header, sizeof(header)); |
| 3889 | 3834 | |
| 3890 | 3835 | /* enable compression */ |
| 3891 | | portdata->record_file->compress(FCOMPRESS_MEDIUM); |
| 3836 | portdata.record_file->compress(FCOMPRESS_MEDIUM); |
| 3892 | 3837 | } |
| 3893 | 3838 | |
| 3894 | 3839 | |
| r14995 | r14996 | |
| 3898 | 3843 | |
| 3899 | 3844 | static void record_end(running_machine &machine, const char *message) |
| 3900 | 3845 | { |
| 3901 | | input_port_private *portdata = machine.input_port_data; |
| 3846 | ioport_manager &portdata = machine.ioport(); |
| 3902 | 3847 | |
| 3903 | 3848 | /* only applies if we have a live file */ |
| 3904 | | if (portdata->record_file != NULL) |
| 3849 | if (portdata.record_file != NULL) |
| 3905 | 3850 | { |
| 3906 | 3851 | /* close the file */ |
| 3907 | | auto_free(machine, portdata->record_file); |
| 3908 | | portdata->record_file = NULL; |
| 3852 | auto_free(machine, portdata.record_file); |
| 3853 | portdata.record_file = NULL; |
| 3909 | 3854 | |
| 3910 | 3855 | /* pop a message */ |
| 3911 | 3856 | if (message != NULL) |
| r14995 | r14996 | |
| 3921 | 3866 | |
| 3922 | 3867 | static void record_frame(running_machine &machine, attotime curtime) |
| 3923 | 3868 | { |
| 3924 | | input_port_private *portdata = machine.input_port_data; |
| 3869 | ioport_manager &portdata = machine.ioport(); |
| 3925 | 3870 | |
| 3926 | 3871 | /* if recording, record information about the current frame */ |
| 3927 | | if (portdata->record_file != NULL) |
| 3872 | if (portdata.record_file != NULL) |
| 3928 | 3873 | { |
| 3929 | 3874 | /* first the absolute time */ |
| 3930 | 3875 | record_write_uint32(machine, curtime.seconds); |
| r14995 | r14996 | |
| 3942 | 3887 | |
| 3943 | 3888 | static void record_port(const input_port_config *port) |
| 3944 | 3889 | { |
| 3945 | | input_port_private *portdata = port->machine().input_port_data; |
| 3890 | ioport_manager &portdata = port->machine().ioport(); |
| 3946 | 3891 | |
| 3947 | 3892 | /* if recording, store information about this port */ |
| 3948 | | if (portdata->record_file != NULL) |
| 3893 | if (portdata.record_file != NULL) |
| 3949 | 3894 | { |
| 3950 | 3895 | analog_field_state *analog; |
| 3951 | 3896 | |
| r14995 | r14996 | |
| 3972 | 3917 | int have_keyboard = FALSE; |
| 3973 | 3918 | const input_field_config *field; |
| 3974 | 3919 | const input_port_config *port; |
| 3975 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 3920 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 3976 | 3921 | { |
| 3977 | 3922 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 3978 | 3923 | { |
| 3979 | 3924 | // if we are at init, check IPT_KEYBOARD for inputx_init |
| 3980 | | if (!port->machine().input_port_data->safe_to_read && field->type == IPT_KEYBOARD) |
| 3925 | if (!port->machine().ioport().safe_to_read && field->type == IPT_KEYBOARD) |
| 3981 | 3926 | { |
| 3982 | 3927 | have_keyboard = TRUE; |
| 3983 | 3928 | break; |
| r14995 | r14996 | |
| 4182 | 4127 | |
| 4183 | 4128 | static void clear_keybuffer(running_machine &machine) |
| 4184 | 4129 | { |
| 4185 | | input_port_private *portdata = machine.input_port_data; |
| 4186 | | portdata->keybuffer.buffer = NULL; |
| 4187 | | portdata->queue_chars = NULL; |
| 4188 | | portdata->codes = NULL; |
| 4130 | ioport_manager &portdata = machine.ioport(); |
| 4131 | portdata.keybuffer.buffer = NULL; |
| 4132 | portdata.queue_chars = NULL; |
| 4133 | portdata.codes = NULL; |
| 4189 | 4134 | } |
| 4190 | 4135 | |
| 4191 | 4136 | |
| 4192 | 4137 | |
| 4193 | 4138 | static void setup_keybuffer(running_machine &machine) |
| 4194 | 4139 | { |
| 4195 | | input_port_private *portdata = machine.input_port_data; |
| 4196 | | portdata->inputx_timer = machine.scheduler().timer_alloc(FUNC(inputx_timerproc)); |
| 4197 | | portdata->keybuffer.begin_pos = 0; |
| 4198 | | portdata->keybuffer.end_pos = 0; |
| 4199 | | portdata->keybuffer.status_keydown = 0; |
| 4200 | | portdata->keybuffer.size = KEY_BUFFER_SIZE; |
| 4201 | | portdata->keybuffer.buffer = auto_alloc_array(machine, unicode_char, portdata->keybuffer.size); |
| 4140 | ioport_manager &portdata = machine.ioport(); |
| 4141 | portdata.inputx_timer = machine.scheduler().timer_alloc(FUNC(inputx_timerproc)); |
| 4142 | portdata.keybuffer.begin_pos = 0; |
| 4143 | portdata.keybuffer.end_pos = 0; |
| 4144 | portdata.keybuffer.status_keydown = 0; |
| 4145 | portdata.keybuffer.size = KEY_BUFFER_SIZE; |
| 4146 | portdata.keybuffer.buffer = auto_alloc_array(machine, unicode_char, portdata.keybuffer.size); |
| 4202 | 4147 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(clear_keybuffer), &machine)); |
| 4203 | 4148 | } |
| 4204 | 4149 | |
| r14995 | r14996 | |
| 4206 | 4151 | |
| 4207 | 4152 | void inputx_init(running_machine &machine) |
| 4208 | 4153 | { |
| 4209 | | input_port_private *portdata = machine.input_port_data; |
| 4210 | | portdata->inputx_timer = NULL; |
| 4211 | | portdata->accept_char = NULL; |
| 4212 | | portdata->charqueue_empty = NULL; |
| 4154 | ioport_manager &portdata = machine.ioport(); |
| 4155 | portdata.inputx_timer = NULL; |
| 4156 | portdata.accept_char = NULL; |
| 4157 | portdata.charqueue_empty = NULL; |
| 4213 | 4158 | clear_keybuffer(machine); |
| 4214 | 4159 | |
| 4215 | 4160 | if (machine.debug_flags & DEBUG_FLAG_ENABLED) |
| r14995 | r14996 | |
| 4221 | 4166 | /* posting keys directly only makes sense for a computer */ |
| 4222 | 4167 | if (input_machine_has_keyboard(machine)) |
| 4223 | 4168 | { |
| 4224 | | portdata->codes = build_codes(machine, machine.m_portlist.first()); |
| 4169 | portdata.codes = build_codes(machine, machine.ioport().first_port()); |
| 4225 | 4170 | setup_keybuffer(machine); |
| 4226 | 4171 | } |
| 4227 | 4172 | } |
| r14995 | r14996 | |
| 4234 | 4179 | int (*accept_char)(running_machine &machine, unicode_char ch), |
| 4235 | 4180 | int (*charqueue_empty)(running_machine &machine)) |
| 4236 | 4181 | { |
| 4237 | | input_port_private *portdata = machine.input_port_data; |
| 4238 | | portdata->queue_chars = queue_chars; |
| 4239 | | portdata->accept_char = accept_char; |
| 4240 | | portdata->charqueue_empty = charqueue_empty; |
| 4182 | ioport_manager &portdata = machine.ioport(); |
| 4183 | portdata.queue_chars = queue_chars; |
| 4184 | portdata.accept_char = accept_char; |
| 4185 | portdata.charqueue_empty = charqueue_empty; |
| 4241 | 4186 | } |
| 4242 | 4187 | |
| 4243 | 4188 | int inputx_can_post(running_machine &machine) |
| 4244 | 4189 | { |
| 4245 | | input_port_private *portdata = machine.input_port_data; |
| 4246 | | return portdata->queue_chars || portdata->codes; |
| 4190 | ioport_manager &portdata = machine.ioport(); |
| 4191 | return portdata.queue_chars || portdata.codes; |
| 4247 | 4192 | } |
| 4248 | 4193 | |
| 4249 | 4194 | |
| 4250 | 4195 | static int can_post_key_directly(running_machine &machine, unicode_char ch) |
| 4251 | 4196 | { |
| 4252 | | input_port_private *portdata = machine.input_port_data; |
| 4197 | ioport_manager &portdata = machine.ioport(); |
| 4253 | 4198 | int rc = FALSE; |
| 4254 | 4199 | const inputx_code *code; |
| 4255 | 4200 | |
| 4256 | | if (portdata->queue_chars) |
| 4201 | if (portdata.queue_chars) |
| 4257 | 4202 | { |
| 4258 | | rc = portdata->accept_char ? (*portdata->accept_char)(machine, ch) : TRUE; |
| 4203 | rc = portdata.accept_char ? (*portdata.accept_char)(machine, ch) : TRUE; |
| 4259 | 4204 | } |
| 4260 | 4205 | else |
| 4261 | 4206 | { |
| 4262 | | code = find_code(portdata->codes, ch); |
| 4207 | code = find_code(portdata.codes, ch); |
| 4263 | 4208 | if (code) |
| 4264 | 4209 | rc = code->field[0] != NULL; |
| 4265 | 4210 | } |
| r14995 | r14996 | |
| 4292 | 4237 | return 1; |
| 4293 | 4238 | } |
| 4294 | 4239 | |
| 4295 | | static attotime choose_delay(input_port_private *portdata, unicode_char ch) |
| 4240 | static attotime choose_delay(ioport_manager &portdata, unicode_char ch) |
| 4296 | 4241 | { |
| 4297 | | if (portdata->current_rate != attotime::zero) |
| 4298 | | return portdata->current_rate; |
| 4242 | if (portdata.current_rate != attotime::zero) |
| 4243 | return portdata.current_rate; |
| 4299 | 4244 | |
| 4300 | 4245 | attotime delay = attotime::zero; |
| 4301 | | if (portdata->queue_chars) |
| 4246 | if (portdata.queue_chars) |
| 4302 | 4247 | { |
| 4303 | 4248 | /* systems with queue_chars can afford a much smaller delay */ |
| 4304 | 4249 | delay = attotime::from_msec(10); |
| r14995 | r14996 | |
| 4322 | 4267 | |
| 4323 | 4268 | static void internal_post_key(running_machine &machine, unicode_char ch) |
| 4324 | 4269 | { |
| 4325 | | input_port_private *portdata = machine.input_port_data; |
| 4270 | ioport_manager &portdata = machine.ioport(); |
| 4326 | 4271 | key_buffer *keybuf; |
| 4327 | 4272 | |
| 4328 | 4273 | keybuf = get_buffer(machine); |
| r14995 | r14996 | |
| 4330 | 4275 | /* need to start up the timer? */ |
| 4331 | 4276 | if (keybuf->begin_pos == keybuf->end_pos) |
| 4332 | 4277 | { |
| 4333 | | portdata->inputx_timer->adjust(choose_delay(portdata, ch)); |
| 4278 | portdata.inputx_timer->adjust(choose_delay(portdata, ch)); |
| 4334 | 4279 | keybuf->status_keydown = 0; |
| 4335 | 4280 | } |
| 4336 | 4281 | |
| r14995 | r14996 | |
| 4363 | 4308 | |
| 4364 | 4309 | static void inputx_postn_rate(running_machine &machine, const unicode_char *text, size_t text_len, attotime rate) |
| 4365 | 4310 | { |
| 4366 | | input_port_private *portdata = machine.input_port_data; |
| 4311 | ioport_manager &portdata = machine.ioport(); |
| 4367 | 4312 | int last_cr = 0; |
| 4368 | 4313 | unicode_char ch; |
| 4369 | 4314 | const char *s; |
| 4370 | 4315 | const char_info *ci; |
| 4371 | 4316 | const inputx_code *code; |
| 4372 | 4317 | |
| 4373 | | portdata->current_rate = rate; |
| 4318 | portdata.current_rate = rate; |
| 4374 | 4319 | |
| 4375 | 4320 | if (inputx_can_post(machine)) |
| 4376 | 4321 | { |
| r14995 | r14996 | |
| 4389 | 4334 | |
| 4390 | 4335 | if (LOG_INPUTX) |
| 4391 | 4336 | { |
| 4392 | | code = find_code(portdata->codes, ch); |
| 4337 | code = find_code(portdata.codes, ch); |
| 4393 | 4338 | logerror("inputx_postn(): code=%i (%s) field->name='%s'\n", (int) ch, code_point_string(machine, ch), (code && code->field[0]) ? code->field[0]->name : "<null>"); |
| 4394 | 4339 | } |
| 4395 | 4340 | |
| r14995 | r14996 | |
| 4423 | 4368 | |
| 4424 | 4369 | static TIMER_CALLBACK(inputx_timerproc) |
| 4425 | 4370 | { |
| 4426 | | input_port_private *portdata = machine.input_port_data; |
| 4371 | ioport_manager &portdata = machine.ioport(); |
| 4427 | 4372 | key_buffer *keybuf; |
| 4428 | 4373 | attotime delay; |
| 4429 | 4374 | |
| 4430 | 4375 | keybuf = get_buffer(machine); |
| 4431 | 4376 | |
| 4432 | | if (portdata->queue_chars) |
| 4377 | if (portdata.queue_chars) |
| 4433 | 4378 | { |
| 4434 | 4379 | /* the driver has a queue_chars handler */ |
| 4435 | | while((keybuf->begin_pos != keybuf->end_pos) && (*portdata->queue_chars)(machine, &keybuf->buffer[keybuf->begin_pos], 1)) |
| 4380 | while((keybuf->begin_pos != keybuf->end_pos) && (*portdata.queue_chars)(machine, &keybuf->buffer[keybuf->begin_pos], 1)) |
| 4436 | 4381 | { |
| 4437 | 4382 | keybuf->begin_pos++; |
| 4438 | 4383 | keybuf->begin_pos %= keybuf->size; |
| 4439 | 4384 | |
| 4440 | | if (portdata->current_rate != attotime::zero) |
| 4385 | if (portdata.current_rate != attotime::zero) |
| 4441 | 4386 | break; |
| 4442 | 4387 | } |
| 4443 | 4388 | } |
| r14995 | r14996 | |
| 4460 | 4405 | if (keybuf->begin_pos != keybuf->end_pos) |
| 4461 | 4406 | { |
| 4462 | 4407 | delay = choose_delay(portdata, keybuf->buffer[keybuf->begin_pos]); |
| 4463 | | portdata->inputx_timer->adjust(delay); |
| 4408 | portdata.inputx_timer->adjust(delay); |
| 4464 | 4409 | } |
| 4465 | 4410 | } |
| 4466 | 4411 | |
| 4467 | 4412 | int inputx_is_posting(running_machine &machine) |
| 4468 | 4413 | { |
| 4469 | | input_port_private *portdata = machine.input_port_data; |
| 4414 | ioport_manager &portdata = machine.ioport(); |
| 4470 | 4415 | const key_buffer *keybuf; |
| 4471 | 4416 | keybuf = get_buffer(machine); |
| 4472 | | return (keybuf->begin_pos != keybuf->end_pos) || (portdata->charqueue_empty && !(*portdata->charqueue_empty)(machine)); |
| 4417 | return (keybuf->begin_pos != keybuf->end_pos) || (portdata.charqueue_empty && !(*portdata.charqueue_empty)(machine)); |
| 4473 | 4418 | } |
| 4474 | 4419 | |
| 4475 | 4420 | /*************************************************************************** |
| r14995 | r14996 | |
| 4699 | 4644 | const input_port_config *port; |
| 4700 | 4645 | const input_field_config *field; |
| 4701 | 4646 | |
| 4702 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 4647 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 4703 | 4648 | { |
| 4704 | 4649 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 4705 | 4650 | { |
| r14995 | r14996 | |
| 4724 | 4669 | int joystick_count; |
| 4725 | 4670 | |
| 4726 | 4671 | joystick_count = 0; |
| 4727 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 4672 | for (port = machine.ioport().first_port(); port != NULL; port = port->next()) |
| 4728 | 4673 | { |
| 4729 | 4674 | for (field = port->first_field(); field != NULL; field = field->next()) |
| 4730 | 4675 | { |
| r14995 | r14996 | |
| 4763 | 4708 | |
| 4764 | 4709 | static void execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[]) |
| 4765 | 4710 | { |
| 4766 | | inputx_code *codes = machine.input_port_data->codes; |
| 4711 | inputx_code *codes = machine.ioport().codes; |
| 4767 | 4712 | const char *filename; |
| 4768 | 4713 | FILE *file = NULL; |
| 4769 | 4714 | const inputx_code *code; |