Previous 15994 Revisions Next

r14996 Sunday 22nd April, 2012 at 09:00:02 UTC by Miodrag Milanović
Sync with MAME r16066 (no whatsnew)
[src/emu]crsshair.c devcb.c devcb.h device.c device.h ioport.c ioport.h machine.c machine.h memory.c ui.c uimain.c
[src/emu/sound]disc_inp.c
[src/emu/video]pc_cga.c polynew.h
[src/mame/drivers]amaticmg.c champbwl.c galaxian.c gumbo.c meyc8088.c namcos10.c namcos12.c paradise.c pokechmp.c sangho.c sliver.c
[src/mame/includes]alpha68k.h galpanic.h
[src/mame/machine]atari.c pckeybrd.c snes.c
[src/mame/video]dkong.c
[src/mess/drivers]a2600.c
[src/mess/machine]ay3600.c coco.c pc_joy.c
[src/mess/video]mc6847.c

src/mame/machine/pckeybrd.c
r14995r14996
336336   {
337337      astring buf;
338338      buf.printf("pc_keyboard_%d", i);
339      keyboard.ports[i] = machine.port(buf);
339      keyboard.ports[i] = machine.root_device().ioport(buf);
340340   }
341341
342342   inputx_setup_natural_keyboard(machine,
src/mame/machine/atari.c
r14995r14996
342342
343343   /* GTIA */
344344   memset(&gtia_intf, 0, sizeof(gtia_intf));
345   if (machine.port("console") != NULL)
345   if (machine.root_device().ioport("console") != NULL)
346346      gtia_intf.console_read = console_read;
347347   if (machine.device("dac") != NULL)
348348      gtia_intf.console_write = console_write;
src/mame/machine/snes.c
r14995r14996
577577
578578      case 0x4100:      /* NSS Dip-Switches */
579579         {
580            const input_port_config *port = space->machine().port("DSW");
580            const input_port_config *port = state->ioport("DSW");
581581            if (port != NULL)
582582               return input_port_read(space->machine(), "DSW");
583583            else
src/mame/includes/galpanic.h
r14995r14996
1313   required_shared_ptr<UINT16> m_fgvideoram;
1414   bitmap_ind16 m_bitmap;
1515   bitmap_ind16 m_sprites_bitmap;
16   required_shared_ptr<UINT16> m_spriteram;
16   optional_shared_ptr<UINT16> m_spriteram;
1717   DECLARE_WRITE16_MEMBER(galpanic_6295_bankswitch_w);
1818   DECLARE_WRITE16_MEMBER(galpanica_6295_bankswitch_w);
1919   DECLARE_WRITE16_MEMBER(galpanica_misc_w);
src/mame/includes/alpha68k.h
r14995r14996
1515      m_paletteram(*this, "paletteram"){ }
1616
1717   /* memory pointers */
18   required_shared_ptr<UINT16> m_shared_ram;
18   optional_shared_ptr<UINT16> m_shared_ram;
1919   required_shared_ptr<UINT16> m_spriteram;
20   required_shared_ptr<UINT16> m_videoram;
20   optional_shared_ptr<UINT16> m_videoram;
2121   optional_shared_ptr<UINT16> m_paletteram;
2222
2323   /* video-related */
src/mame/video/dkong.c
r14995r14996
883883   const input_port_config *port;
884884   int newset;
885885
886   port = machine.port("VIDHW");
886   port = state->ioport("VIDHW");
887887   if (port != NULL)
888888   {
889889      newset = input_port_read_direct(port);
src/mame/drivers/paradise.c
r14995r14996
3131penky: we need to delay the irqs at startup or it won't boot. Either one of
3232       ports 0x2003.r or 0x2005.w starts up the irq timer (confirmed via trojan)
3333
34Alternate dipswitch settings for Penky as found in scanned Pins & Dip manual:
35
36DIPSW-A
37--------------------------------------------------------------------
38    DipSwitch Title   |  Function  | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
39--------------------------------------------------------------------
40                      |   70 Sec   |off|off|                       |*
41      Game Time       |   60 Sec   |on |off|                       |
42                      |   50 Sec   |off|on |                       |
43                      |   40 Sec   |on |on |                       |
44--------------------------------------------------------------------
45     Strip-Tease      |     On     |       |off|                   |*
46                      |     Off    |       |on |                   |
47--------------------------------------------------------------------
48                      |    Easy    |           |off|off|           |
49      Difficulty      |   Normal   |           |on |off|           |*
50                      |    Hard    |           |off|on |           |
51                      | Very Hard  |           |on |on |           |
52--------------------------------------------------------------------
53                      |    99%     |                   |off|off|   |*
54 Minimum Percetage to |    90%     |                   |on |off|   |
55 Complete for Win or  |    80%     |                   |off|on |   |
56majority @ end of time|    70%     |                   |on |on |   |
57--------------------------------------------------------------------
58      Not Used                                                 |off|*
59--------------------------------------------------------------------
60
61DIPSW-B
62--------------------------------------------------------------------
63    DipSwitch Title   |  Function  | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
64--------------------------------------------------------------------
65                      | 1cn / 1pl  |off|off|                       |*
66        Coinage       | 1cn / 2pl  |on |off|                       |
67                      | 1cn / 3pl  |off|on |                       |
68                      | 2cn / 3pl  |on |on |                       |
69--------------------------------------------------------------------
70      Not Used                             |off|off|off|           |*
71--------------------------------------------------------------------
72  Competition Mode    | 1Bout 1Win |                   |off|       |*
73                      |3Bouts 2Wins|                   |on |       |
74--------------------------------------------------------------------
75    Demo Sounds       |    Yes     |                       |off|   |*
76                      |     No     |                       |on |   |
77--------------------------------------------------------------------
78       TV Test        |    Game    |                           |off|*
79    (Slide Show)      |    Test    |                           |on |
80--------------------------------------------------------------------
81
3482***************************************************************************/
3583
3684#include "emu.h"
r14995r14996
311359   PORT_DIPSETTING(    0x01, "0:50" )
312360   PORT_DIPSETTING(    0x02, "1:00" )
313361   PORT_DIPSETTING(    0x03, "1:10" )
314   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:3") /* One of these sets/pairs should be diffculty or timer speed */
315   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
316   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
317   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:4")
318   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
319   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
362   PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:3,4")
363   PORT_DIPSETTING(    0x0c, DEF_STR( Easy ) )
364   PORT_DIPSETTING(    0x08, DEF_STR( Normal ) )
365   PORT_DIPSETTING(    0x04, DEF_STR( Hard ) )
366   PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard ) )
320367   PORT_DIPNAME( 0x30, 0x30, "Fill % to Win" )      PORT_DIPLOCATION("SW1:5,6")
321368   PORT_DIPSETTING(    0x30, "Majority at Time or 99.9%" )
322369   PORT_DIPSETTING(    0x20, "Majority at Time or 90%" )
323370   PORT_DIPSETTING(    0x10, "Majority at Time or 85%" )
324371   PORT_DIPSETTING(    0x00, "Majority at Time or 80%" )
325   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:7")
372   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:7") /* One of these likely disables the nude pics */
326373   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
327374   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
328   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:8")
375   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:8") /* One of these likely disables the nude pics */
329376   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
330377   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
331378
r14995r14996
335382   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
336383   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
337384   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
338   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:3")
339   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
340   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
341   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:4")
342   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
343   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
385   PORT_DIPUNUSED_DIPLOC( 0x04, 0x04, "SW2:3" )      /* Listed as "Unused" */
386   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW2:4" )      /* Listed as "Unused" */
344387   PORT_DIPNAME( 0x10, 0x10, "Vs. Matches" )      PORT_DIPLOCATION("SW2:5")
345388   PORT_DIPSETTING(    0x00, "2" )
346389   PORT_DIPSETTING(    0x10, "3" )
src/mame/drivers/namcos10.c
r14995r14996
685685   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
686686   ROM_FILL( 0x0000000, 0x400000, 0x55 )
687687
688   ROM_REGION( 0x4200000, "user2", 0 ) /* main prg */
688   ROM_REGION16_LE( 0x4200000, "user2", 0 ) /* main prg */
689689   ROM_LOAD( "10011a_0.bin", 0x0000000, 0x1080000, CRC(df862033) SHA1(4141357ed315adb4de636d7bf752354e953e8cbf) )
690690   ROM_LOAD( "10011a_1.bin", 0x1080000, 0x1080000, CRC(734c7ac0) SHA1(2f325236a4e4f2dba886682e9a7e8e243b5fbb3d) )
691691   ROM_LOAD( "10011a_2.bin", 0x2100000, 0x1080000, CRC(3bbbc0b7) SHA1(ad02ec2e5f401f0f5d40a413038649ebd25d5343) )
r14995r14996
696696   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
697697   ROM_FILL( 0x0000000, 0x400000, 0x55 )
698698
699   ROM_REGION( 0x3180000, "user2", 0 ) /* main prg */
699   ROM_REGION16_LE( 0x3180000, "user2", 0 ) /* main prg */
700700   ROM_LOAD( "drg1a_0.bin",  0x0000000, 0x1080000, CRC(e0801878) SHA1(fbb771c1e76e0690f6dffed2287eb470b561ec20) )
701701   ROM_LOAD( "drg1a_1.bin",  0x1080000, 0x1080000, CRC(4d8cde73) SHA1(62a5fab8be8fd0a6bfeb101020d4cf58866a757c) )
702702   ROM_LOAD( "drg1a_2.bin",  0x2100000, 0x1080000, CRC(ccfabf7b) SHA1(0cbd91ce8abd6efca5d427b52279ce265f685aa9) )
r14995r14996
706706   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
707707   ROM_FILL( 0x0000000, 0x400000, 0x55 )
708708
709   ROM_REGION( 0x3180000, "user2", 0 ) /* main prg */
709   ROM_REGION16_LE( 0x3180000, "user2", 0 ) /* main prg */
710710   ROM_LOAD( "kpm1a_0.bin",  0x0000000, 0x1080000, CRC(b2947eb8) SHA1(fa941bf3598bb25d2c8f0a93154e32bf78a6507c) )
711711   ROM_LOAD( "kpm1a_1.bin",  0x1080000, 0x1080000, CRC(f3aa855a) SHA1(87b94e22db4bc4169324bbff93c4ea19c1d99b40) )
712712   ROM_LOAD( "kpm1a_2.bin",  0x2100000, 0x1080000, CRC(b297cc8d) SHA1(c3494e7a8a0b4e0c8c40b99121373effbfe848eb) )
r14995r14996
716716   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
717717   ROM_FILL( 0x0000000, 0x400000, 0x55 )
718718
719   ROM_REGION( 0x2100000, "user2", 0 ) /* main prg */
719   ROM_REGION16_LE( 0x2100000, "user2", 0 ) /* main prg */
720720   ROM_LOAD( "stt1a_0.bin",  0x0000000, 0x1080000, CRC(1e090644) SHA1(a7a293e2bd9eea2eb64a492a47272d9d9ee2c724) )
721721   ROM_LOAD( "stt1a_1.bin",  0x1080000, 0x1080000, CRC(aa527694) SHA1(a25dcbeca58a1443070848b3487a24d51d41a34b) )
722722ROM_END
r14995r14996
725725   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
726726   ROM_FILL( 0x0000000, 0x400000, 0x55 )
727727
728   ROM_REGION( 0x2100000, "user2", 0 ) /* main prg */
728   ROM_REGION16_LE( 0x2100000, "user2", 0 ) /* main prg */
729729   ROM_LOAD( "10021a.8e",    0x0000000, 0x1080000, CRC(6c0361fc) SHA1(7debf1f2e6bed31d59fb224a78a17a94fc573785) )
730730   ROM_LOAD( "10021a.8d",    0x1080000, 0x1080000, CRC(73669ff7) SHA1(eb8bbf931f1f8a049208d081d040512a3ffa9c00) )
731731ROM_END
r14995r14996
734734   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
735735   ROM_FILL( 0x0000000, 0x400000, 0x55 )
736736
737   ROM_REGION( 0x2100000, "user2", 0 ) /* main prg */
737   ROM_REGION16_LE( 0x2100000, "user2", 0 ) /* main prg */
738738   ROM_LOAD( "gnn2a.8e",         0x0000000, 0x1080000, CRC(31b39221) SHA1(7fcb14aaa26c531928a6cd704e746d0e3ae3e031) )
739739   ROM_LOAD( "gnn2a.8d",         0x1080000, 0x1080000, CRC(82d2cfb5) SHA1(4b5e713a55e74a7b32b1b9b5811892df2df86256) )
740740ROM_END
r14995r14996
743743   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
744744   ROM_FILL( 0x0000000, 0x400000, 0x55 )
745745
746   ROM_REGION( 0x2100000, "user2", 0 ) /* main prg */
746   ROM_REGION16_LE( 0x2100000, "user2", 0 ) /* main prg */
747747   ROM_LOAD( "gnn1a.8e",         0x0000000, 0x1080000, CRC(981b03d4) SHA1(1c55458f1b2964afe2cf4e9d84548c0699808e9f) )
748748   ROM_LOAD( "gnn1a.8d",         0x1080000, 0x1080000, CRC(6cd343e0) SHA1(dcec44abae1504025895f42fe574549e5010f7d5) )
749749ROM_END
r14995r14996
752752   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
753753   ROM_FILL( 0x0000000, 0x400000, 0x55 )
754754
755   ROM_REGION( 0x5280000, "user2", 0 ) /* main prg */
755   ROM_REGION16_LE( 0x5280000, "user2", 0 ) /* main prg */
756756   ROM_LOAD( "0.8e",         0x0000000, 0x1080000, BAD_DUMP CRC(f265b1b6) SHA1(f327e7bac0bc1bd31aa3362e36233130a6b240ea) )
757757   ROM_LOAD( "1.8d",         0x1080000, 0x1080000, CRC(05d01cd2) SHA1(e9947ebea24d618e8b9a69f582ef0b9d97bb4cad) )
758758   ROM_LOAD( "2.7e",         0x2100000, 0x1080000, CRC(2e308d20) SHA1(4ff072f0d488b12f77ef7d119822f89b5b5a6712) )
r14995r14996
764764   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
765765   ROM_FILL( 0x0000000, 0x400000, 0x55 )
766766
767   ROM_REGION( 0x3180000, "user2", 0 ) /* main prg */
767   ROM_REGION16_LE( 0x3180000, "user2", 0 ) /* main prg */
768768   ROM_LOAD( "0.8e",         0x0000000, 0x1080000, CRC(3aa66da4) SHA1(3f6ff164981e2c1825766c775442608fbf86d702) )
769769   ROM_LOAD( "1.8d",         0x1080000, 0x1080000, CRC(18e5135d) SHA1(a7b1533a1df71be5498718e301d1c9c548551fb4) )
770770   ROM_LOAD( "2.7e",         0x2100000, 0x1080000, CRC(cd3b25e0) SHA1(39dfebc59e71b8f1c28e718ee71032620f11440c) )
r14995r14996
774774   ROM_REGION32_LE( 0x400000, "user1", 0 ) /* bios */
775775   ROM_FILL( 0x0000000, 0x400000, 0x55 )
776776
777   ROM_REGION( 0x4200000, "user2", 0 ) /* main prg */
777   ROM_REGION16_LE( 0x4200000, "user2", 0 ) /* main prg */
778778   ROM_LOAD( "0.8e",         0x0000000, 0x1080000, CRC(b08d4270) SHA1(5f5dc1c2862292a9e597f6a21c0f9db2e5796ded) )
779779   ROM_LOAD( "1.8d",         0x1080000, 0x1080000, CRC(d3f519d8) SHA1(60d5f2fafd700e39245bed17e3cc6d608cc2c088) )
780780   ROM_LOAD( "2.7e",         0x2100000, 0x1080000, CRC(0c65fdc2) SHA1(fa5d41a7b10ae8f8d312b61cc6d34408123bda97) )
src/mame/drivers/amaticmg.c
r14995r14996
724724************************************/
725725
726726ROM_START( am_uslot )
727   ROM_REGION( 0x40000, "maincpu", 0 )   /* encrypted program ROM...*/
727   ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASE00 )
728
729   ROM_REGION( 0x20000, "mainprg", 0 )   /* encrypted program ROM...*/
728730   ROM_LOAD( "u3.bin",  0x00000, 0x20000, CRC(29bf4a95) SHA1(a73873f7cd1fdf5accc3e79f4619949f261400b8) )
729731
730732   ROM_REGION( 0x30000, "gfx1", 0 )
r14995r14996
772774*       Driver Initialization       *
773775************************************/
774776
775static void encf(UINT8 ciphertext, int address, UINT8& plaintext, int& newaddress)
777static void encf(UINT8 ciphertext, int address, UINT8 &plaintext, int &newaddress)
776778{
777779   int aux = address & 0xfff;
778780   aux = aux ^ (aux>>6);
r14995r14996
786788   newaddress = (address & ~0xfff) | aux;
787789}
788790
789static DRIVER_INIT( amaticmg )
791static void decrypt(running_machine &machine, int key1, int key2)
790792{
791
792}
793
794static DRIVER_INIT( amaticmg3 )
795{
796   const int key1 = 0x426;
797   const int key2 = 0x55;
798793   UINT8 plaintext;
799794   int newaddress;
800795   
r14995r14996
809804   }
810805}
811806
807static DRIVER_INIT( amaticmg )
808{
809   decrypt(machine, 0x4c2, 0xf5);
810}
812811
812static DRIVER_INIT( amaticmg3 )
813{
814   decrypt(machine, 0x426, 0x55);
815}
816
817
813818/************************************
814819*           Game Drivers            *
815820************************************/
src/mame/drivers/namcos12.c
r14995r14996
15731573
15741574READ8_MEMBER(namcos12_state::s12_mcu_gun_h_r)
15751575{
1576   const input_port_config *port = machine().port("LIGHT0_X");
1576   const input_port_config *port = ioport("LIGHT0_X");
15771577   if( port != NULL )
15781578   {
15791579      int rv = input_port_read_direct( port ) << 6;
r14995r14996
15921592
15931593READ8_MEMBER(namcos12_state::s12_mcu_gun_v_r)
15941594{
1595   const input_port_config *port = machine().port("LIGHT0_Y");
1595   const input_port_config *port = ioport("LIGHT0_Y");
15961596   if( port != NULL )
15971597   {
15981598      int rv = input_port_read_direct( port ) << 6;
src/mame/drivers/champbwl.c
r14995r14996
229229   coin_counter_w(machine(), 1, data & 2);   // gift out counter
230230
231231   coin_lockout_w(machine(), 0, ~data & 8);   // coin lockout
232   machine().device<ticket_dispenser_device>("hopper")->write(*&space, 0, (data & 0x04) ? 0x00 : 0x80);   // gift out motor
232   machine().device<ticket_dispenser_device>("hopper")->write(space, 0, (data & 0x04) ? 0x00 : 0x80);   // gift out motor
233233
234234   membank("bank1")->set_entry((data & 0x30) >> 4);
235235
src/mame/drivers/meyc8088.c
r14995r14996
1/*
1/****************************************************************
22
3Meyco 8088 based hardware
3  Meyco 8088 based hardware
44
5significant 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
68
7*/
89
10****************************************************************/
11
912#include "emu.h"
1013#include "cpu/i86/i86.h"
1114#include "machine/i8155.h"
r14995r14996
1619public:
1720   meyc8088_state(const machine_config &mconfig, device_type type, const char *tag)
1821      : driver_device(mconfig, type, tag) ,
22      m_maincpu(*this,"maincpu"),
1923      m_vram(*this, "vram")
2024   { }
2125
26   required_device<cpu_device> m_maincpu;
2227   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);
2336};
2437
2538
r14995r14996
5669
5770***************************************************************************/
5871
72// switch screen on/off on $b4000 access
73READ8_MEMBER(meyc8088_state::screen_flip_r)
74{
75   m_status ^= 2;
76   return 0;
77}
78
79WRITE8_MEMBER(meyc8088_state::screen_flip_w)
80{
81   m_status ^= 2;
82}
83
84// switch video5 (color prom d4) on/off on $b5000 access
85READ8_MEMBER(meyc8088_state::video5_flip_r)
86{
87   m_status ^= 4;
88   return 0;
89}
90
91WRITE8_MEMBER(meyc8088_state::video5_flip_w)
92{
93   m_status ^= 4;
94}
95
96
5997static 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
6299   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)
66103   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
73110ADDRESS_MAP_END
74111
75112
76static WRITE8_DEVICE_HANDLER(meyc8088_i8155_a_w)
113static WRITE8_DEVICE_HANDLER(meyc8088_lights1_w)
77114{
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);
79118}
80119
81static WRITE8_DEVICE_HANDLER(meyc8088_i8155_b_w)
120static WRITE8_DEVICE_HANDLER(meyc8088_lights2_w)
82121{
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);
84125}
85126
86static WRITE8_DEVICE_HANDLER(meyc8088_i8155_c_w)
127static WRITE8_DEVICE_HANDLER(meyc8088_common_w)
87128{
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
88139   logerror("i8155 Port C: %02X\n", data);
89140}
90141
91static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_0_timer_out)
142static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_1_timer_out)
92143{
93   //logerror("Timer 0 out %d\n", state);
144   // clock 8251A
145   //logerror("Timer 1 out %d\n", state);
94146}
95147
96static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_1_timer_out)
148static WRITE_LINE_DEVICE_HANDLER(meyc8088_i8155_2_timer_out)
97149{
98   //logerror("Timer 1 out %d\n", state);
150   // sound dac
151   //logerror("Timer 2 out %d\n", state);
99152}
100153
154
155static 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
101168static const i8155_interface i8155_intf[2] =
102169{
103170   {
104      // all ports set to output
171      // all ports set to input
172      DEVCB_INPUT_PORT("IN0"),
105173      DEVCB_NULL,
106      DEVCB_HANDLER(meyc8088_i8155_a_w),
174      DEVCB_INPUT_PORT("IN1"),
107175      DEVCB_NULL,
108      DEVCB_HANDLER(meyc8088_i8155_b_w),
176      DEVCB_HANDLER(meyc8088_status_r),
109177      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)
112179   },
113180   {
114      // all ports set to input
115      DEVCB_INPUT_PORT("IN0"),
181      // all ports set to output
116182      DEVCB_NULL,
117      DEVCB_INPUT_PORT("IN1"),
183      DEVCB_HANDLER(meyc8088_lights2_w),
118184      DEVCB_NULL,
119      DEVCB_INPUT_PORT("IN2"),
185      DEVCB_HANDLER(meyc8088_lights1_w),
120186      DEVCB_NULL,
121      DEVCB_LINE(meyc8088_i8155_1_timer_out)
187      DEVCB_HANDLER(meyc8088_common_w),
188      DEVCB_LINE(meyc8088_i8155_2_timer_out)
122189   }
123190};
124191
r14995r14996
157224   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
158225
159226   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 )
163228   PORT_DIPNAME( 0x02, 0x02, "IN1 2" )
164229   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
165230   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r14995r14996
216281
217282***************************************************************************/
218283
284static 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
219290static MACHINE_CONFIG_START( meyc8088, meyc8088_state )
220291
221292   /* basic machine hardware */
222   MCFG_CPU_ADD("maincpu", I8088, 5000000)
293   MCFG_CPU_ADD("maincpu", I8088, XTAL_15MHz / 3)
223294   MCFG_CPU_PROGRAM_MAP(meyc8088_map)
295   MCFG_CPU_VBLANK_INT("screen", meyc8088_irq)
224296
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])
227299
228300   /* video hardware */
229301   MCFG_SCREEN_ADD("screen", RASTER)
230302   MCFG_SCREEN_REFRESH_RATE(60)
231   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
303   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
232304   MCFG_SCREEN_SIZE(512,512)
233305   MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 512-1)
234306   MCFG_SCREEN_UPDATE_STATIC(meyc8088)
r14995r14996
240312
241313ROM_START( gldarrow )
242314   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
246321ROM_END
247322
248323
src/mame/drivers/pokechmp.c
r14995r14996
165165   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
166166
167167   PORT_START("DSW")   /* Dip switch */
168   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
169   PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
170   PORT_DIPSETTING(   0x03, DEF_STR( 1C_1C ) )
171   PORT_DIPSETTING(   0x02, DEF_STR( 1C_2C ) )
172   PORT_DIPSETTING(   0x01, DEF_STR( 1C_3C ) )
173   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Flip_Screen ) )
174   PORT_DIPSETTING(   0x04, DEF_STR( Off ) )
175   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
176   PORT_DIPNAME( 0x08, 0x08, "Allow 2 Players Game" )
177   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
178   PORT_DIPSETTING(   0x08, DEF_STR( Yes ) )
179   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )
180   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
181   PORT_DIPSETTING(   0x10, DEF_STR( On ) )
182   PORT_DIPNAME( 0x20, 0x20, "Time" )
183   PORT_DIPSETTING(   0x00, "100" )
184   PORT_DIPSETTING(   0x20, "120" )
185   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Lives ) )
186   PORT_DIPSETTING(   0x00, "3" )
187   PORT_DIPSETTING(   0x40, "4" )
188   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
189   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
190   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
168   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:8,7")
169   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
170   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
171   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
172   PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
173   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SW1:6")
174   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
175   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
176   PORT_DIPNAME( 0x08, 0x08, "Allow 2 Players Game" )   PORT_DIPLOCATION("SW1:5")
177   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
178   PORT_DIPSETTING(    0x08, DEF_STR( Yes ) )
179   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW1:4")
180   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
181   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
182   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:3") /* Affects Time: Normal=120 & Hardest=100 */
183   PORT_DIPSETTING(    0x20, DEF_STR( Normal ) )
184   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
185   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:2") /* Listed as "Number of Balls" in the manual */
186   PORT_DIPSETTING(    0x00, "3" ) /* Manual shows 2 */
187   PORT_DIPSETTING(    0x40, "4" ) /* Manual shows 3 */
188   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:1") /* Not shown or listed in the manual */
189   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
190   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
191191INPUT_PORTS_END
192192
193193/* this makes no sense at all!  it seems impossible to get the colours to align up in the korean flag ingame and everything else is slightly broken too */
src/mame/drivers/galaxian.c
r14995r14996
28132813   machine.root_device().membank("bank1")->configure_entries(0, 2, state->memregion("maincpu")->base() + 0x10000, 0x4000);
28142814
28152815   /* callback when the game select is toggled */
2816   state->gmgalax_game_changed(*machine.m_portlist.first()->fieldlist().first(), NULL, 0, 0);
2816   state->gmgalax_game_changed(*machine.ioport().first_port()->fieldlist().first(), NULL, 0, 0);
28172817   state_save_register_global(machine, state->m_gmgalax_selected_game);
28182818}
28192819
src/mame/drivers/sangho.c
r14995r14996
3434
3535*** the custom chip with the warning appears to control banking etc.
3636
37Sexy Boom's DSW setting verified via Z80 code by stephh
38
3739*/
3840
3941#include "emu.h"
r14995r14996
256258   AM_RANGE( 0xf8, 0xff) AM_WRITE(sexyboom_bank_w )
257259ADDRESS_MAP_END
258260
259
260static INPUT_PORTS_START( sangho )
261static INPUT_PORTS_START( sexyboom )
261262    PORT_START("P1")
262263   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
263264    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
r14995r14996
291292   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
292293
293294   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 )
314INPUT_PORTS_END
315
316
317static 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? */
297320    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
298321    PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
299322    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r14995r14996
303326    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
304327    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
305328    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 ) )
308338    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 ) )
311341    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 */
316371INPUT_PORTS_END
317372
318373
r14995r14996
466521   state->m_ram = auto_alloc_array(machine, UINT8, 0x20000);
467522}
468523
469GAME( 1991, pzlestar,  0,    pzlestar, sangho, sangho, ROT270, "Sang Ho Soft", "Puzzle Star (Sang Ho Soft)", GAME_NOT_WORKING )
470GAME( 1992, sexyboom,  0,    sexyboom, sangho, sangho, ROT270, "Sang Ho Soft", "Sexy Boom", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS )
524GAME( 1991, pzlestar,  0,    pzlestar, pzlestar, sangho, ROT270, "Sang Ho Soft", "Puzzle Star (Sang Ho Soft)", GAME_NOT_WORKING )
525GAME( 1992, sexyboom,  0,    sexyboom, sexyboom, sangho, ROT270, "Sang Ho Soft", "Sexy Boom", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS )
src/mame/drivers/sliver.c
r14995r14996
410410   PORT_BIT( 0xffa4, IP_ACTIVE_LOW, IPT_UNKNOWN )
411411
412412   PORT_START("DSW")
413   PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coin_A ) )
414   PORT_DIPSETTING(   0x000f, DEF_STR( 1C_1C ) )
415   PORT_DIPSETTING(   0x000e, DEF_STR( 1C_2C ) )
416   PORT_DIPSETTING(   0x000d, DEF_STR( 1C_3C ) )
417   PORT_DIPSETTING(   0x000c, DEF_STR( 1C_4C ) )
418   PORT_DIPSETTING(   0x000b, DEF_STR( 1C_5C ) )
419   PORT_DIPSETTING(   0x0000, DEF_STR( Free_Play ) )
420   PORT_DIPNAME( 0x0030, 0x0020, DEF_STR( Lives ) )
421   PORT_DIPSETTING(    0x0030, "2" )
422   PORT_DIPSETTING(    0x0020, "3" )
423   PORT_DIPSETTING(    0x0010, "4" )
424   PORT_DIPSETTING(    0x0000, "5" )
425   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
426   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
427   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
428   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
429   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
430   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
431   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
432   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
433   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
434   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
435   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
436   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
437   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
438   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
439   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
440   PORT_DIPNAME( 0x0800, 0x0800, "Demo_Sounds" )
413   PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coinage ) )   PORT_DIPLOCATION("SW1:1,2,3,4")
414   PORT_DIPSETTING(      0x0004, DEF_STR( 5C_1C ) )
415   PORT_DIPSETTING(      0x0003, DEF_STR( 4C_1C ) )
416   PORT_DIPSETTING(      0x0002, DEF_STR( 3C_1C ) )
417   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
418   PORT_DIPSETTING(      0x000f, DEF_STR( 1C_1C ) )
419   PORT_DIPSETTING(      0x000e, DEF_STR( 1C_2C ) )
420   PORT_DIPSETTING(      0x000d, DEF_STR( 1C_3C ) )
421   PORT_DIPSETTING(      0x000c, DEF_STR( 1C_4C ) )
422   PORT_DIPSETTING(      0x000b, DEF_STR( 1C_5C ) )
423   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
424   PORT_DIPNAME( 0x0030, 0x0020, DEF_STR( Lives ) )   PORT_DIPLOCATION("SW1:5,6")
425   PORT_DIPSETTING(      0x0030, "2" )
426   PORT_DIPSETTING(      0x0020, "3" )
427   PORT_DIPSETTING(      0x0010, "4" )
428   PORT_DIPSETTING(      0x0000, "5" )
429   PORT_DIPNAME( 0x00c0, 0x00c0, DEF_STR( Game_Time ) )   PORT_DIPLOCATION("SW1:7,8")
430   PORT_DIPSETTING(      0x0000, "Longer" )
431   PORT_DIPSETTING(      0x0040, "Long" )
432   PORT_DIPSETTING(      0x00c0, DEF_STR( Normal ) )
433   PORT_DIPSETTING(      0x0080, "Short" )
434   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:1,2")
435   PORT_DIPSETTING(      0x0200, DEF_STR( Easy ) )
436   PORT_DIPSETTING(      0x0300, DEF_STR( Normal ) )
437   PORT_DIPSETTING(      0x0100, DEF_STR( Hard ) )
438   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
439   PORT_DIPNAME( 0x0400, 0x0400, "2 Player Mode" )      PORT_DIPLOCATION("SW2:3")
440   PORT_DIPSETTING(      0x0400, DEF_STR( Yes ) )
441   PORT_DIPSETTING(      0x0000, DEF_STR( No ) )
442   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW2:4")
441443   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
442444   PORT_DIPSETTING(      0x0800, DEF_STR( On ) )
443   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
444   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
445   PORT_DIPNAME( 0x1000, 0x1000, "Draw Insert" )      PORT_DIPLOCATION("SW2:5")
446   PORT_DIPSETTING(      0x1000, DEF_STR( Yes ) )
447   PORT_DIPSETTING(      0x0000, DEF_STR( No ) )
448   PORT_DIPNAME( 0x2000, 0x2000, "Joystick Input Mode" )   PORT_DIPLOCATION("SW2:6")
449   PORT_DIPSETTING(      0x2000, "Step" )
450   PORT_DIPSETTING(      0x0000, "Continuous" )
451   PORT_DIPNAME( 0x4000, 0x4000, "Game Paused (Test)" )   PORT_DIPLOCATION("SW2:7")
452   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
445453   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
446   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
447   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
448   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
449   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // unknown
450   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
451   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
452   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
454   PORT_DIPUNUSED_DIPLOC( 0x8000, 0x0000, "SW2:8" )   /* Listed as "UNUSED (MUST ON)" */
453455INPUT_PORTS_END
454456
455457static ADDRESS_MAP_START( ramdac_map, AS_0, 8, sliver_state )
src/mame/drivers/gumbo.c
r14995r14996
102102
103103   PORT_START("DSW")
104104   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")
106106   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
107107   PORT_DIPSETTING(      0x0100, DEF_STR( 2C_1C ) )
108108   PORT_DIPSETTING(      0x0300, DEF_STR( 1C_1C ) )
109109   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
111111   PORT_DIPSETTING(      0x0000, "0" )
112112   PORT_DIPSETTING(      0x0400, "1" )
113   PORT_DIPNAME( 0x0800, 0x0800, "Bonus Bar Level" )
113   PORT_DIPNAME( 0x0800, 0x0800, "Bonus Bar Level" )   PORT_DIPLOCATION("SW1:4")
114114   PORT_DIPSETTING(      0x0800, DEF_STR( Normal ) )
115115   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")
117117   PORT_DIPSETTING(      0x2000, DEF_STR( Easy ) )
118118   PORT_DIPSETTING(      0x3000, DEF_STR( Normal ) )
119119   PORT_DIPSETTING(      0x1000, DEF_STR( Hard ) )
120120   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
121   PORT_DIPNAME( 0x4000, 0x4000, "Picture View" )
121   PORT_DIPNAME( 0x4000, 0x4000, "Picture View" )      PORT_DIPLOCATION("SW1:7")
122122   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
123123   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
124   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
124   PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" )
125125INPUT_PORTS_END
126126
127127static INPUT_PORTS_START( msbingo )
128128   PORT_INCLUDE( gumbo )
129129
130130   PORT_MODIFY("DSW")
131   PORT_DIPNAME( 0x0c00, 0x0c00, "Chance Count" )
131   PORT_DIPNAME( 0x0c00, 0x0c00, "Chance Count" )      PORT_DIPLOCATION("SW1:3,4")
132132   PORT_DIPSETTING(      0x0c00, "0" )
133133   PORT_DIPSETTING(      0x0800, "1" )
134134   PORT_DIPSETTING(      0x0400, "2" )
135135   PORT_DIPSETTING(      0x0000, "3" )
136   PORT_DIPNAME( 0x1000, 0x1000, "Play Level" )
136   PORT_DIPNAME( 0x1000, 0x1000, "Play Level" )      PORT_DIPLOCATION("SW1:5")
137137   PORT_DIPSETTING(      0x1000, DEF_STR( Normal ) )
138138   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
139   PORT_DIPNAME( 0x2000, 0x2000, "Play Speed" )
139   PORT_DIPNAME( 0x2000, 0x2000, "Play Speed" )      PORT_DIPLOCATION("SW1:6")
140140   PORT_DIPSETTING(      0x2000, DEF_STR( Normal ) )
141141   PORT_DIPSETTING(      0x0000, DEF_STR( High ) )
142   PORT_DIPNAME( 0x4000, 0x4000, "Left Count" )
142   PORT_DIPNAME( 0x4000, 0x4000, "Left Count" )      PORT_DIPLOCATION("SW1:7")
143143   PORT_DIPSETTING(      0x4000, DEF_STR( Normal ) )
144144   PORT_DIPSETTING(      0x0000, DEF_STR( Low ) )
145   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
145   PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" )
146146INPUT_PORTS_END
147147
148148static INPUT_PORTS_START( mspuzzle )
r14995r14996
150150
151151   PORT_MODIFY("DSW")
152152   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 */
154154   PORT_DIPSETTING(      0x0300, "0" )
155155   PORT_DIPSETTING(      0x0200, "1" )
156156   PORT_DIPSETTING(      0x0100, "2" )
157157   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")
159159   PORT_DIPSETTING(      0x0000, DEF_STR( 2C_1C ) )
160160   PORT_DIPSETTING(      0x0c00, DEF_STR( 1C_1C ) )
161161   PORT_DIPSETTING(      0x0800, DEF_STR( 1C_2C ) )
162162   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")
164164   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
165165   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")
167167   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
168168   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
169   PORT_DIPNAME( 0x4000, 0x4000, "Picture View" )
169   PORT_DIPNAME( 0x4000, 0x4000, "Picture View" )      PORT_DIPLOCATION("SW1:7")
170170   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
171171   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
172   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
172   PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" )
173173INPUT_PORTS_END
174174
175175static INPUT_PORTS_START( dblpoint )
r14995r14996
184184   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
185185
186186   PORT_MODIFY("DSW")
187   PORT_DIPNAME( 0x0c00, 0x0800, DEF_STR( Difficulty ) )
187   PORT_DIPNAME( 0x0c00, 0x0800, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:3,4")
188188   PORT_DIPSETTING(      0x0c00, DEF_STR( Easy ) )
189189   PORT_DIPSETTING(      0x0800, DEF_STR( Normal ) )
190190   PORT_DIPSETTING(      0x0400, DEF_STR( Hard ) )
191191   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")
193193   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
194194   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
195   PORT_DIPNAME( 0x2000, 0x2000, "Picture View" )
195   PORT_DIPNAME( 0x2000, 0x2000, "Picture View" )      PORT_DIPLOCATION("SW1:6")
196196   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
197197   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" )
200200INPUT_PORTS_END
201201
202202static const gfx_layout gumbo_layout =
src/emu/devcb.c
r14995r14996
8383const input_port_config *devcb_resolver::resolve_port(const char *tag, device_t &current)
8484{
8585   astring fullname;
86   const input_port_config *result = current.machine().port(current.siblingtag(fullname, tag));
86   const input_port_config *result = current.ioport(current.siblingtag(fullname, tag));
8787   if (result == NULL)
8888      throw emu_fatalerror("Unable to find input port '%s' (requested by %s '%s')", fullname.cstr(), current.name(), current.tag());
8989   return result;
src/emu/video/pc_cga.c
r14995r14996
299299   state_save_register_item(machine, "pccga", NULL, 0, cga.status);
300300   state_save_register_item(machine, "pccga", NULL, 0, cga.plantronics);
301301
302   cga.config_input_port = machine.m_portlist.find(":pcvideo_cga_config" );
302   cga.config_input_port = machine.root_device().ioport(":pcvideo_cga_config" );
303303
304304   return 0;
305305}
src/emu/video/polynew.h
r14995r14996
11121112         const vertex_t &v1 = v[(vertnum == 0) ? (numverts - 1) : (vertnum - 1)];
11131113         const vertex_t &v2 = v[vertnum];
11141114         _BaseType frac = (clipval - v1.p[0]) / (v2.p[0] - v1.p[0]);
1115         nextout.x = v1.x + frac * (v2.x - v1.x);
1116         nextout.y = v1.y + frac * (v2.y - v1.y);
1115         nextout->x = v1.x + frac * (v2.x - v1.x);
1116         nextout->y = v1.y + frac * (v2.y - v1.y);
11171117         for (int paramnum = 0; paramnum < paramcount; paramnum++)
1118            nextout.p[paramnum] = v1.p[paramnum] + frac * (v2.p[paramnum] - v1.p[paramnum]);
1118            nextout->p[paramnum] = v1.p[paramnum] + frac * (v2.p[paramnum] - v1.p[paramnum]);
11191119         nextout++;
11201120      }
11211121
src/emu/devcb.h
r14995r14996
117117
118118// static template for a read16 stub function that calls through a given READ16_MEMBER
119119template<class _Class, UINT16 (_Class::*_Function)(address_space &, offs_t, UINT16)>
120UINT16 devcb_stub(device_t *device, offs_t offset, UINT16 mask=0xffff)
120UINT16 devcb_stub16(device_t *device, offs_t offset, UINT16 mask=0xffff)
121121{
122122   _Class *target = downcast<_Class *>(device);
123123   return (target->*_Function)(*device->machine().memory().first_space(), offset, mask);
r14995r14996
141141
142142// static template for a write16 stub function that calls through a given WRITE16_MEMBER
143143template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT16, UINT16)>
144void devcb_stub(device_t *device, offs_t offset, UINT16 data, UINT16 mask=0xffff)
144void devcb_stub16(device_t *device, offs_t offset, UINT16 data, UINT16 mask=0xffff)
145145{
146146   _Class *target = downcast<_Class *>(device);
147147   (target->*_Function)(*device->machine().memory().first_space(), offset, data, mask);
r14995r14996
154154#define DEVCB_LINE_MEMBER(cls,memb)            { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, &devcb_line_stub<cls, &cls::memb>, NULL, NULL }
155155#define DEVCB_HANDLER(func)                  { DEVCB_TYPE_DEVICE, 0, "", #func, NULL, func, NULL }
156156#define DEVCB_MEMBER(cls,memb)               { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb>, NULL }
157#define DEVCB_MEMBER16(cls,memb)            { DEVCB_TYPE_DEVICE, 0, "", #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb>, NULL }
157158
158159// line or read/write handlers for the driver device
159160#define DEVCB_DRIVER_LINE_MEMBER(cls,memb)      { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, &devcb_line_stub<cls, &cls::memb>, NULL, NULL }
160161#define DEVCB_DRIVER_MEMBER(cls,memb)         { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb>, NULL }
162#define DEVCB_DRIVER_MEMBER16(cls,memb)         { DEVCB_TYPE_DEVICE, 0, ":", #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb>, NULL }
161163
162164// line or read/write handlers for another device
163165#define DEVCB_DEVICE_LINE(tag,func)            { DEVCB_TYPE_DEVICE, 0, tag, #func, func, NULL, NULL }
164166#define DEVCB_DEVICE_LINE_MEMBER(tag,cls,memb)   { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, &devcb_line_stub<cls, &cls::memb>, NULL, NULL }
165167#define DEVCB_DEVICE_HANDLER(tag,func)         { DEVCB_TYPE_DEVICE, 0, tag, #func, NULL, func, NULL }
166168#define DEVCB_DEVICE_MEMBER(tag,cls,memb)      { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub<cls, &cls::memb>, NULL }
169#define DEVCB_DEVICE_MEMBER16(tag,cls,memb)      { DEVCB_TYPE_DEVICE, 0, tag, #cls "::" #memb, NULL, &devcb_stub16<cls, &cls::memb>, NULL }
167170
168171// constant values
169172#define DEVCB_CONSTANT(value)               { DEVCB_TYPE_CONSTANT, value, NULL, NULL, NULL, NULL }
src/emu/machine.c
r14995r14996
142142     debug_flags(0),
143143     palette_data(NULL),
144144     romload_data(NULL),
145     input_port_data(NULL),
146145     ui_input_data(NULL),
147146     debugcpu_data(NULL),
148147     generic_machine_data(NULL),
r14995r14996
176175
177176     m_save(*this),
178177     m_memory(*this),
178     m_ioport(*this),
179179     m_scheduler(*this)
180180{
181181   memset(gfx, 0, sizeof(gfx));
r14995r14996
263263   // initialize the input system and input ports for the game
264264   // this must be done before memory_init in order to allow specifying
265265   // callbacks based on input port tags
266   time_t newbase = input_port_init(*this);
266   time_t newbase = m_ioport.initialize();
267267   if (newbase != 0)
268268      m_base_time = newbase;
269269
src/emu/sound/disc_inp.c
r14995r14996
7676   double min, max;
7777
7878   astring fulltag;
79   m_port = m_device->machine().m_portlist.find(m_device->siblingtag(fulltag, (const char *)this->custom_data()).cstr());
79   m_port = m_device->machine().root_device().ioport(m_device->siblingtag(fulltag, (const char *)this->custom_data()).cstr());
8080   if (m_port == NULL)
8181      fatalerror("DISCRETE_ADJUSTMENT - NODE_%d has invalid tag", this->index());
8282
src/emu/machine.h
r14995r14996
154154
155155typedef struct _palette_private palette_private;
156156typedef struct _romload_private romload_private;
157typedef struct _input_port_private input_port_private;
158157typedef struct _ui_input_private ui_input_private;
159158typedef struct _debugcpu_private debugcpu_private;
160159typedef struct _generic_machine_private generic_machine_private;
r14995r14996
222221   device_scheduler &scheduler() { return m_scheduler; }
223222   save_manager &save() { return m_save; }
224223   memory_manager &memory() { return m_memory; }
224   ioport_manager &ioport() { return m_ioport; }
225225   cheat_manager &cheat() const { assert(m_cheat != NULL); return *m_cheat; }
226226   render_manager &render() const { assert(m_render != NULL); return *m_render; }
227227   input_manager &input() const { assert(m_input != NULL); return *m_input; }
r14995r14996
250250   // fetch items by name
251251   inline device_t *device(const char *tag) { return root_device().subdevice(tag); }
252252   template<class _DeviceClass> inline _DeviceClass *device(const char *tag) { return downcast<_DeviceClass *>(device(tag)); }
253   inline const input_port_config *port(const char *tag);
254253
255254   // configuration helpers
256255   device_t &add_dynamic_device(device_t &owner, device_type type, const char *tag, UINT32 clock);
r14995r14996
287286   UINT32 rand();
288287   const char *describe_context();
289288
290   // internals
291   ioport_list            m_portlist;         // points to a list of input port configurations
292
293289   // CPU information
294290   cpu_device *         firstcpu;         // first CPU
295291
r14995r14996
310306   // internal core information
311307   palette_private *      palette_data;      // internal data from palette.c
312308   romload_private *      romload_data;      // internal data from romload.c
313   input_port_private *   input_port_data;   // internal data from inptport.c
314309   ui_input_private *      ui_input_data;      // internal data from uiinput.c
315310   debugcpu_private *      debugcpu_data;      // internal data from debugcpu.c
316311   generic_machine_private *generic_machine_data; // internal data from machine/generic.c
r14995r14996
418413   // embedded managers and objects
419414   save_manager         m_save;               // save manager
420415   memory_manager         m_memory;            // memory manager
416   ioport_manager         m_ioport;            // I/O port manager
421417   device_scheduler      m_scheduler;         // scheduler object
422418};
423419
424420
425
426//**************************************************************************
427//  INLINE FUNCTIONS
428//**************************************************************************
429
430inline const input_port_config *running_machine::port(const char *tag)
431{
432   // if tag begins with a :, it's absolute
433   if (tag[0] == ':')
434      return m_portlist.find(tag);
435
436   // otherwise, compute it relative to the root device
437   astring fulltag;
438   return m_portlist.find(root_device().subtag(fulltag, tag).cstr());
439}
440
441
442421#endif   /* __MACHINE_H__ */
src/emu/ioport.c
r14995r14996
113113    CONSTANTS
114114***************************************************************************/
115115
116#define DIGITAL_JOYSTICKS_PER_PLAYER   3
117
118116/* these constants must match the order of the joystick directions in the IPT definition */
119117#define JOYDIR_UP         0
120118#define JOYDIR_DOWN         1
r14995r14996
126124#define JOYDIR_LEFT_BIT      (1 << JOYDIR_LEFT)
127125#define JOYDIR_RIGHT_BIT   (1 << JOYDIR_RIGHT)
128126
129#define NUM_SIMUL_KEYS   (UCHAR_SHIFT_END - UCHAR_SHIFT_BEGIN + 1)
130127#define LOG_INPUTX      0
131128#define SPACE_COUNT      3
132129#define INVALID_CHAR   '?'
r14995r14996
184181};
185182
186183
187/* shared digital joystick state */
188typedef struct _digital_joystick_state digital_joystick_state;
189struct _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
199184/* live device field information */
200185typedef struct _device_field_info device_field_info;
201186struct _device_field_info
r14995r14996
235220};
236221
237222
238typedef struct _inputx_code inputx_code;
239struct _inputx_code
240{
241   unicode_char ch;
242   const input_field_config * field[NUM_SIMUL_KEYS];
243};
244
245223#define KEY_BUFFER_SIZE   4096
246224
247typedef struct _key_buffer key_buffer;
248struct _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
257225typedef struct _char_info char_info;
258226struct _char_info
259227{
r14995r14996
263231};
264232
265233
266/* private input port state */
267struct _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
300234/***************************************************************************
301235    MACROS
302236***************************************************************************/
r14995r14996
889823    system
890824-------------------------------------------------*/
891825
892time_t input_port_init(running_machine &machine)
826ioport_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)
893841{
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}
896845
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
846time_t ioport_manager::initialize()
847{
901848   /* 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()));
904851
905852   /* initialize the default port info from the OSD */
906   init_port_types(machine);
853   init_port_types(machine());
907854
908855   /* if we have a token list, proceed */
909   device_iterator iter(machine.root_device());
856   device_iterator iter(machine().root_device());
910857   for (device_t *device = iter.first(); device != NULL; device = iter.next())
911858   {
912859      astring errors;
913      input_port_list_init(*device, machine.m_portlist, errors);
860      input_port_list_init(*device, m_portlist, errors);
914861      if (errors)
915862         mame_printf_error("Input port errors:\n%s", errors.cstr());
916863   }
917864
918   init_port_state(machine);
865   init_port_state(machine());
919866   /* 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()));
921868
922869   /* 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());
925872
926873   return basetime;
927874}
r14995r14996
978925
979926const input_field_config *input_field_by_tag_and_mask(running_machine &machine, const char *tag, input_port_value mask)
980927{
981   const input_port_config *port = machine.port(tag);
928   const input_port_config *port = machine.root_device().ioport(tag);
982929
983930   /* if we got the port, look for the field */
984931   if (port != NULL)
r14995r14996
12751222const char *input_type_name(running_machine &machine, int type, int player)
12761223{
12771224   /* 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];
12801227   if (entry != NULL)
12811228      return entry->name;
12821229
r14995r14996
12921239
12931240int input_type_group(running_machine &machine, int type, int player)
12941241{
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];
12971244   if (entry != NULL)
12981245      return entry->group;
12991246
r14995r14996
13131260   assert(player >= 0 && player < MAX_PLAYERS);
13141261
13151262   /* 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];
13181265   if (entry != NULL)
13191266      return entry->seq[seqtype];
13201267
r14995r14996
13301277
13311278void input_type_set_seq(running_machine &machine, int type, int player, input_seq_type seqtype, const input_seq *newseq)
13321279{
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];
13351282   if (entry != NULL)
13361283      entry->seq[seqtype] = *newseq;
13371284}
r14995r14996
13551302
13561303const simple_list<input_type_entry> &input_type_list(running_machine &machine)
13571304{
1358   input_port_private *portdata = machine.input_port_data;
1359   return portdata->typelist;
1305   ioport_manager &portdata = machine.ioport();
1306   return portdata.typelist;
13601307}
13611308
13621309
r14995r14996
13731320
13741321bool input_port_exists(running_machine &machine, const char *tag)
13751322{
1376   return machine.port(tag) != 0;
1323   return machine.root_device().ioport(tag) != 0;
13771324}
13781325
13791326
r14995r14996
13851332
13861333input_port_value input_port_active(running_machine &machine, const char *tag)
13871334{
1388   const input_port_config *port = machine.port(tag);
1335   const input_port_config *port = machine.root_device().ioport(tag);
13891336   if (port == NULL)
13901337      fatalerror("Unable to locate input port '%s'", tag);
13911338   return port->active;
r14995r14996
14011348
14021349input_port_value input_port_active_safe(running_machine &machine, const char *tag, input_port_value defvalue)
14031350{
1404   const input_port_config *port = machine.port(tag);
1351   const input_port_config *port = machine.root_device().ioport(tag);
14051352   return port == NULL ? defvalue : port->active;
14061353}
14071354
r14995r14996
14201367{
14211368   assert(port != NULL);
14221369
1423   input_port_private *portdata = port->machine().input_port_data;
1370   ioport_manager &portdata = port->machine().ioport();
14241371   analog_field_state *analog;
14251372   device_field_info *device_field;
14261373   input_port_value result;
14271374
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!");
14291376
14301377   /* start with the digital */
14311378   result = port->state->digital;
r14995r14996
14601407         INT32 value = analog->accum;
14611408
14621409         /* 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)
14641411         {
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);
14671414         }
14681415
14691416         /* apply standard analog settings */
r14995r14996
14921439
14931440input_port_value input_port_read(running_machine &machine, const char *tag)
14941441{
1495   const input_port_config *port = machine.port(tag);
1442   const input_port_config *port = machine.root_device().ioport(tag);
14961443   if (port == NULL)
14971444      fatalerror("Unable to locate input port '%s'", tag);
14981445   return input_port_read_direct(port);
r14995r14996
15061453
15071454input_port_value input_port_read(device_t &device, const char *tag)
15081455{
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);
15111457   if (port == NULL)
15121458      fatalerror("Unable to locate input port '%s'", tag);
15131459   return input_port_read_direct(port);
r14995r14996
15221468
15231469input_port_value input_port_read_safe(running_machine &machine, const char *tag, UINT32 defvalue)
15241470{
1525   const input_port_config *port = machine.port(tag);
1471   const input_port_config *port = machine.root_device().ioport(tag);
15261472   return (port == NULL) ? defvalue : input_port_read_direct(port);
15271473}
15281474
r14995r14996
15401486   int gotx = FALSE, goty = FALSE;
15411487
15421488   /* 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())
15441490      for (field = port->first_field(); field != NULL; field = field->next())
15451491         if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE)
15461492            if (input_condition_true(machine, &field->condition, port->owner()))
r14995r14996
16091555      const input_port_config *port;
16101556
16111557      /* 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())
16131559      {
16141560         const input_field_config *field;
16151561
r14995r14996
16951641
16961642void input_port_write(running_machine &machine, const char *tag, input_port_value value, input_port_value mask)
16971643{
1698   const input_port_config *port = machine.port(tag);
1644   const input_port_config *port = machine.root_device().ioport(tag);
16991645   if (port == NULL)
17001646      fatalerror("Unable to locate input port '%s'", tag);
17011647   input_port_write_direct(port, value, mask);
r14995r14996
17091655
17101656void input_port_write_safe(running_machine &machine, const char *tag, input_port_value value, input_port_value mask)
17111657{
1712   const input_port_config *port = machine.port(tag);
1658   const input_port_config *port = machine.root_device().ioport(tag);
17131659   if (port != NULL)
17141660      input_port_write_direct(port, value, mask);
17151661}
r14995r14996
18091755
18101756static void init_port_types(running_machine &machine)
18111757{
1812   input_port_private *portdata = machine.input_port_data;
1758   ioport_manager &portdata = machine.ioport();
18131759
18141760   /* 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);
18161762
18171763   /* 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);
18191765
18201766   /* 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())
18221768   {
18231769      /* first copy all the OSD-updated sequences into our current state */
18241770      for (int seqtype = 0; seqtype < ARRAY_LENGTH(curtype->seq); seqtype++)
18251771         curtype->seq[seqtype] = curtype->defseq[seqtype];
18261772
18271773      /* 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;
18291775   }
18301776}
18311777
r14995r14996
19461892static void init_port_state(running_machine &machine)
19471893{
19481894   const char *joystick_map_default = machine.options().joystick_map();
1949   input_port_private *portdata = machine.input_port_data;
1895   ioport_manager &portdata = machine.ioport();
19501896   input_field_config *field;
19511897   input_port_config *port;
19521898
19531899   /* 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())
19551901   {
19561902      analog_field_state **analogstatetail;
19571903      device_field_info **readdevicetail;
r14995r14996
19921938         /* if this is a digital joystick field, make a note of it */
19931939         if (field->type >= __ipt_digital_joystick_start && field->type <= __ipt_digital_joystick_end)
19941940         {
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];
19961942            fieldstate->joydir = (field->type - __ipt_digital_joystick_start) % 4;
19971943            fieldstate->joystick->field[fieldstate->joydir] = field;
19981944            fieldstate->joystick->inuse = TRUE;
r14995r14996
20471993
20481994   /* look for 4-way joysticks and change the default map if we find any */
20491995   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())
20511997         for (field = port->first_field(); field != NULL; field = field->next())
20521998            if (field->state->joystick != NULL && field->way == 4)
20531999            {
r14995r14996
20652011
20662012static void init_autoselect_devices(running_machine &machine, int type1, int type2, int type3, const char *option, const char *ananame)
20672013{
2068   const ioport_list &portlist = machine.m_portlist;
20692014   const char *stemp = machine.options().value(option);
20702015   input_device_class autoenable = DEVICE_CLASS_KEYBOARD;
20712016   const char *autostring = "keyboard";
r14995r14996
21012046      mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp);
21022047
21032048   /* 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())
21062051         for (field = port->first_field(); field != NULL; field = field->next())
21072052
21082053            /* if this port type is in use, apply the autoselect criteria */
r14995r14996
23362281
23372282static key_buffer *get_buffer(running_machine &machine)
23382283{
2339   input_port_private *portdata = machine.input_port_data;
2284   ioport_manager &portdata = machine.ioport();
23402285   assert(inputx_can_post(machine));
2341   return (key_buffer *)&portdata->keybuffer;
2286   return (key_buffer *)&portdata.keybuffer;
23422287}
23432288
23442289
r14995r14996
23632308
23642309static void input_port_update_hook(running_machine &machine, const input_port_config *port, input_port_value *digital)
23652310{
2366   input_port_private *portdata = machine.input_port_data;
2311   ioport_manager &portdata = machine.ioport();
23672312   const key_buffer *keybuf;
23682313   const inputx_code *code;
23692314   unicode_char ch;
r14995r14996
23792324      {
23802325         /* identify the character that is down right now, and its component codes */
23812326         ch = keybuf->buffer[keybuf->begin_pos];
2382         code = find_code(portdata->codes, ch);
2327         code = find_code(portdata.codes, ch);
23832328
23842329         /* loop through this character's component codes */
23852330         if (code != NULL)
r14995r14996
24052350
24062351static void frame_update(running_machine &machine)
24072352{
2408   input_port_private *portdata = machine.input_port_data;
2353   ioport_manager &portdata = machine.ioport();
24092354   const input_field_config *mouse_field = NULL;
24102355   int ui_visible = ui_is_menu_active();
24112356   attotime curtime = machine.time();
r14995r14996
24222367   record_frame(machine, curtime);
24232368
24242369   /* 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;
24272372
24282373   /* update the digital joysticks */
24292374   frame_update_digital_joysticks(machine);
r14995r14996
24432388   }
24442389
24452390   /* 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())
24472392   {
24482393      const input_field_config *field;
24492394      device_field_info *device_field;
r14995r14996
25062451
25072452static void frame_update_digital_joysticks(running_machine &machine)
25082453{
2509   input_port_private *portdata = machine.input_port_data;
2454   ioport_manager &portdata = machine.ioport();
25102455   int player, joyindex;
25112456
25122457   /* loop over all the joysticks */
25132458   for (player = 0; player < MAX_PLAYERS; player++)
25142459      for (joyindex = 0; joyindex < DIGITAL_JOYSTICKS_PER_PLAYER; joyindex++)
25152460      {
2516         digital_joystick_state *joystick = &portdata->joystick_info[player][joyindex];
2461         digital_joystick_state *joystick = &portdata.joystick_info[player][joyindex];
25172462         if (joystick->inuse)
25182463         {
25192464            joystick->previous = joystick->current;
r14995r14996
30943039
30953040static int token_to_input_field_type(running_machine &machine, const char *string, int *player)
30963041{
3097   input_port_private *portdata = machine.input_port_data;
3042   ioport_manager &portdata = machine.ioport();
30983043   int ipnum;
30993044
31003045   /* check for our failsafe case first */
r14995r14996
31023047      return ipnum;
31033048
31043049   /* 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())
31063051      if (entry->token != NULL && !strcmp(entry->token, string))
31073052      {
31083053         *player = entry->player;
r14995r14996
31223067
31233068static const char *input_field_type_to_token(running_machine &machine, int type, int player)
31243069{
3125   input_port_private *portdata = machine.input_port_data;
3070   ioport_manager &portdata = machine.ioport();
31263071   static char tempbuf[32];
31273072
31283073   /* 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];
31303075   if (entry != NULL)
31313076      return entry->token;
31323077
r14995r14996
31663111
31673112static void load_config_callback(running_machine &machine, int config_type, xml_data_node *parentnode)
31683113{
3169   input_port_private *portdata = machine.input_port_data;
3114   ioport_manager &portdata = machine.ioport();
31703115   xml_data_node *portnode;
31713116   int seqtype;
31723117
31733118   /* in the completion phase, we finish the initialization with the final ports */
31743119   if (config_type == CONFIG_TYPE_FINAL)
31753120   {
3176      portdata->safe_to_read = TRUE;
3121      portdata.safe_to_read = TRUE;
31773122      frame_update(machine);
31783123   }
31793124
r14995r14996
32233168   /* after applying the controller config, push that back into the backup, since that is */
32243169   /* what we will diff against */
32253170   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())
32273172         for (seqtype = 0; seqtype < ARRAY_LENGTH(entry->seq); seqtype++)
32283173            entry->defseq[seqtype] = entry->seq[seqtype];
32293174}
r14995r14996
32363181
32373182static void load_remap_table(running_machine &machine, xml_data_node *parentnode)
32383183{
3239   input_port_private *portdata = machine.input_port_data;
3184   ioport_manager &portdata = machine.ioport();
32403185   input_code *oldtable, *newtable;
32413186   xml_data_node *remapnode;
32423187   int count;
r14995r14996
32763221         input_code newcode = newtable[remapnum];
32773222
32783223         /* 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())
32803225         {
32813226            /* remap anything in the default sequences */
32823227            for (int seqtype = 0; seqtype < ARRAY_LENGTH(entry->seq); seqtype++)
r14995r14996
32983243
32993244static int load_default_config(running_machine &machine, xml_data_node *portnode, int type, int player, const input_seq *newseq)
33003245{
3301   input_port_private *portdata = machine.input_port_data;
3246   ioport_manager &portdata = machine.ioport();
33023247
33033248   /* 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())
33053250      if (entry->type == type && entry->player == player)
33063251      {
33073252         for (int seqtype = 0; seqtype < ARRAY_LENGTH(entry->seq); seqtype++)
r14995r14996
33333278   defvalue = xml_get_attribute_int(portnode, "defvalue", 0);
33343279
33353280   /* 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())
33373282      if (tag == NULL || strcmp(get_port_tag(port, tempbuffer), tag) == 0)
33383283         for (field = port->first_field(); field != NULL; field = field->next())
33393284
r14995r14996
34473392
34483393static void save_default_inputs(running_machine &machine, xml_data_node *parentnode)
34493394{
3450   input_port_private *portdata = machine.input_port_data;
3395   ioport_manager &portdata = machine.ioport();
34513396   input_type_entry *entry;
34523397
34533398   /* 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())
34553400   {
34563401      /* only save if this port is a type we save */
34573402      if (save_this_input_field_type(entry->type))
r14995r14996
34953440   const input_port_config *port;
34963441
34973442   /* 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())
34993444      for (field = port->first_field(); field != NULL; field = field->next())
35003445         if (save_this_input_field_type(field->type))
35013446         {
r14995r14996
35763521
35773522static UINT8 playback_read_uint8(running_machine &machine)
35783523{
3579   input_port_private *portdata = machine.input_port_data;
3524   ioport_manager &portdata = machine.ioport();
35803525   UINT8 result;
35813526
35823527   /* protect against NULL handles if previous reads fail */
3583   if (portdata->playback_file == NULL)
3528   if (portdata.playback_file == NULL)
35843529      return 0;
35853530
35863531   /* 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))
35883533   {
35893534      playback_end(machine, "End of file");
35903535      return 0;
r14995r14996
36023547
36033548static UINT32 playback_read_uint32(running_machine &machine)
36043549{
3605   input_port_private *portdata = machine.input_port_data;
3550   ioport_manager &portdata = machine.ioport();
36063551   UINT32 result;
36073552
36083553   /* protect against NULL handles if previous reads fail */
3609   if (portdata->playback_file == NULL)
3554   if (portdata.playback_file == NULL)
36103555      return 0;
36113556
36123557   /* 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))
36143559   {
36153560      playback_end(machine, "End of file");
36163561      return 0;
r14995r14996
36283573
36293574static UINT64 playback_read_uint64(running_machine &machine)
36303575{
3631   input_port_private *portdata = machine.input_port_data;
3576   ioport_manager &portdata = machine.ioport();
36323577   UINT64 result;
36333578
36343579   /* protect against NULL handles if previous reads fail */
3635   if (portdata->playback_file == NULL)
3580   if (portdata.playback_file == NULL)
36363581      return 0;
36373582
36383583   /* 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))
36403585   {
36413586      playback_end(machine, "End of file");
36423587      return 0;
r14995r14996
36543599static time_t playback_init(running_machine &machine)
36553600{
36563601   const char *filename = machine.options().playback();
3657   input_port_private *portdata = machine.input_port_data;
3602   ioport_manager &portdata = machine.ioport();
36583603   UINT8 header[INP_HEADER_SIZE];
36593604   time_t basetime;
36603605
r14995r14996
36633608      return 0;
36643609
36653610   /* 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);
36683613   assert_always(filerr == FILERR_NONE, "Failed to open file for playback");
36693614
36703615   /* 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))
36723617      fatalerror("Input file is corrupt or invalid (missing header)");
36733618   if (memcmp(header, "MAMEINP\0", 8) != 0)
36743619      fatalerror("Input file invalid or in an older, unsupported format");
r14995r14996
36883633      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);
36893634
36903635   /* enable compression */
3691   portdata->playback_file->compress(FCOMPRESS_MEDIUM);
3636   portdata.playback_file->compress(FCOMPRESS_MEDIUM);
36923637
36933638   return basetime;
36943639}
r14995r14996
37003645
37013646static void playback_end(running_machine &machine, const char *message)
37023647{
3703   input_port_private *portdata = machine.input_port_data;
3648   ioport_manager &portdata = machine.ioport();
37043649
37053650   /* only applies if we have a live file */
3706   if (portdata->playback_file != NULL)
3651   if (portdata.playback_file != NULL)
37073652   {
37083653      /* 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;
37113656
37123657      /* pop a message */
37133658      if (message != NULL)
37143659         popmessage("Playback Ended\nReason: %s", message);
37153660
37163661      /* 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));
37203665   }
37213666}
37223667
r14995r14996
37283673
37293674static void playback_frame(running_machine &machine, attotime curtime)
37303675{
3731   input_port_private *portdata = machine.input_port_data;
3676   ioport_manager &portdata = machine.ioport();
37323677
37333678   /* if playing back, fetch the information and verify */
3734   if (portdata->playback_file != NULL)
3679   if (portdata.playback_file != NULL)
37353680   {
37363681      attotime readtime;
37373682
r14995r14996
37423687         playback_end(machine, "Out of sync");
37433688
37443689      /* 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++;
37473692   }
37483693}
37493694
r14995r14996
37543699
37553700static void playback_port(const input_port_config *port)
37563701{
3757   input_port_private *portdata = port->machine().input_port_data;
3702   ioport_manager &portdata = port->machine().ioport();
37583703
37593704   /* if playing back, fetch information about this port */
3760   if (portdata->playback_file != NULL)
3705   if (portdata.playback_file != NULL)
37613706   {
37623707      analog_field_state *analog;
37633708
r14995r14996
37923737
37933738static void record_write_uint8(running_machine &machine, UINT8 data)
37943739{
3795   input_port_private *portdata = machine.input_port_data;
3740   ioport_manager &portdata = machine.ioport();
37963741   UINT8 result = data;
37973742
37983743   /* protect against NULL handles if previous reads fail */
3799   if (portdata->record_file == NULL)
3744   if (portdata.record_file == NULL)
38003745      return;
38013746
38023747   /* 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))
38043749      record_end(machine, "Out of space");
38053750}
38063751
r14995r14996
38123757
38133758static void record_write_uint32(running_machine &machine, UINT32 data)
38143759{
3815   input_port_private *portdata = machine.input_port_data;
3760   ioport_manager &portdata = machine.ioport();
38163761   UINT32 result = LITTLE_ENDIANIZE_INT32(data);
38173762
38183763   /* protect against NULL handles if previous reads fail */
3819   if (portdata->record_file == NULL)
3764   if (portdata.record_file == NULL)
38203765      return;
38213766
38223767   /* 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))
38243769      record_end(machine, "Out of space");
38253770}
38263771
r14995r14996
38323777
38333778static void record_write_uint64(running_machine &machine, UINT64 data)
38343779{
3835   input_port_private *portdata = machine.input_port_data;
3780   ioport_manager &portdata = machine.ioport();
38363781   UINT64 result = LITTLE_ENDIANIZE_INT64(data);
38373782
38383783   /* protect against NULL handles if previous reads fail */
3839   if (portdata->record_file == NULL)
3784   if (portdata.record_file == NULL)
38403785      return;
38413786
38423787   /* 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))
38443789      record_end(machine, "Out of space");
38453790}
38463791
r14995r14996
38523797static void record_init(running_machine &machine)
38533798{
38543799   const char *filename = machine.options().record();
3855   input_port_private *portdata = machine.input_port_data;
3800   ioport_manager &portdata = machine.ioport();
38563801   UINT8 header[INP_HEADER_SIZE];
38573802   system_time systime;
38583803
r14995r14996
38613806      return;
38623807
38633808   /* 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);
38663811   assert_always(filerr == FILERR_NONE, "Failed to open file for recording");
38673812
38683813   /* get the base time */
r14995r14996
38853830   sprintf((char *)header + 0x20, "%s %s", emulator_info::get_appname(), build_version);
38863831
38873832   /* write it */
3888   portdata->record_file->write(header, sizeof(header));
3833   portdata.record_file->write(header, sizeof(header));
38893834
38903835   /* enable compression */
3891   portdata->record_file->compress(FCOMPRESS_MEDIUM);
3836   portdata.record_file->compress(FCOMPRESS_MEDIUM);
38923837}
38933838
38943839
r14995r14996
38983843
38993844static void record_end(running_machine &machine, const char *message)
39003845{
3901   input_port_private *portdata = machine.input_port_data;
3846   ioport_manager &portdata = machine.ioport();
39023847
39033848   /* only applies if we have a live file */
3904   if (portdata->record_file != NULL)
3849   if (portdata.record_file != NULL)
39053850   {
39063851      /* 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;
39093854
39103855      /* pop a message */
39113856      if (message != NULL)
r14995r14996
39213866
39223867static void record_frame(running_machine &machine, attotime curtime)
39233868{
3924   input_port_private *portdata = machine.input_port_data;
3869   ioport_manager &portdata = machine.ioport();
39253870
39263871   /* if recording, record information about the current frame */
3927   if (portdata->record_file != NULL)
3872   if (portdata.record_file != NULL)
39283873   {
39293874      /* first the absolute time */
39303875      record_write_uint32(machine, curtime.seconds);
r14995r14996
39423887
39433888static void record_port(const input_port_config *port)
39443889{
3945   input_port_private *portdata = port->machine().input_port_data;
3890   ioport_manager &portdata = port->machine().ioport();
39463891
39473892   /* if recording, store information about this port */
3948   if (portdata->record_file != NULL)
3893   if (portdata.record_file != NULL)
39493894   {
39503895      analog_field_state *analog;
39513896
r14995r14996
39723917   int have_keyboard = FALSE;
39733918   const input_field_config *field;
39743919   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())
39763921   {
39773922      for (field = port->first_field(); field != NULL; field = field->next())
39783923      {
39793924         // 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)
39813926         {
39823927            have_keyboard = TRUE;
39833928            break;
r14995r14996
41824127
41834128static void clear_keybuffer(running_machine &machine)
41844129{
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;
41894134}
41904135
41914136
41924137
41934138static void setup_keybuffer(running_machine &machine)
41944139{
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);
42024147   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(clear_keybuffer), &machine));
42034148}
42044149
r14995r14996
42064151
42074152void inputx_init(running_machine &machine)
42084153{
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;
42134158   clear_keybuffer(machine);
42144159
42154160   if (machine.debug_flags & DEBUG_FLAG_ENABLED)
r14995r14996
42214166   /* posting keys directly only makes sense for a computer */
42224167   if (input_machine_has_keyboard(machine))
42234168   {
4224      portdata->codes = build_codes(machine, machine.m_portlist.first());
4169      portdata.codes = build_codes(machine, machine.ioport().first_port());
42254170      setup_keybuffer(machine);
42264171   }
42274172}
r14995r14996
42344179   int (*accept_char)(running_machine &machine, unicode_char ch),
42354180   int (*charqueue_empty)(running_machine &machine))
42364181{
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;
42414186}
42424187
42434188int inputx_can_post(running_machine &machine)
42444189{
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;
42474192}
42484193
42494194
42504195static int can_post_key_directly(running_machine &machine, unicode_char ch)
42514196{
4252   input_port_private *portdata = machine.input_port_data;
4197   ioport_manager &portdata = machine.ioport();
42534198   int rc = FALSE;
42544199   const inputx_code *code;
42554200
4256   if (portdata->queue_chars)
4201   if (portdata.queue_chars)
42574202   {
4258      rc = portdata->accept_char ? (*portdata->accept_char)(machine, ch) : TRUE;
4203      rc = portdata.accept_char ? (*portdata.accept_char)(machine, ch) : TRUE;
42594204   }
42604205   else
42614206   {
4262      code = find_code(portdata->codes, ch);
4207      code = find_code(portdata.codes, ch);
42634208      if (code)
42644209         rc = code->field[0] != NULL;
42654210   }
r14995r14996
42924237   return 1;
42934238}
42944239
4295static attotime choose_delay(input_port_private *portdata, unicode_char ch)
4240static attotime choose_delay(ioport_manager &portdata, unicode_char ch)
42964241{
4297   if (portdata->current_rate != attotime::zero)
4298      return portdata->current_rate;
4242   if (portdata.current_rate != attotime::zero)
4243      return portdata.current_rate;
42994244
43004245   attotime delay = attotime::zero;
4301   if (portdata->queue_chars)
4246   if (portdata.queue_chars)
43024247   {
43034248      /* systems with queue_chars can afford a much smaller delay */
43044249      delay = attotime::from_msec(10);
r14995r14996
43224267
43234268static void internal_post_key(running_machine &machine, unicode_char ch)
43244269{
4325   input_port_private *portdata = machine.input_port_data;
4270   ioport_manager &portdata = machine.ioport();
43264271   key_buffer *keybuf;
43274272
43284273   keybuf = get_buffer(machine);
r14995r14996
43304275   /* need to start up the timer? */
43314276   if (keybuf->begin_pos == keybuf->end_pos)
43324277   {
4333      portdata->inputx_timer->adjust(choose_delay(portdata, ch));
4278      portdata.inputx_timer->adjust(choose_delay(portdata, ch));
43344279      keybuf->status_keydown = 0;
43354280   }
43364281
r14995r14996
43634308
43644309static void inputx_postn_rate(running_machine &machine, const unicode_char *text, size_t text_len, attotime rate)
43654310{
4366   input_port_private *portdata = machine.input_port_data;
4311   ioport_manager &portdata = machine.ioport();
43674312   int last_cr = 0;
43684313   unicode_char ch;
43694314   const char *s;
43704315   const char_info *ci;
43714316   const inputx_code *code;
43724317
4373   portdata->current_rate = rate;
4318   portdata.current_rate = rate;
43744319
43754320   if (inputx_can_post(machine))
43764321   {
r14995r14996
43894334
43904335            if (LOG_INPUTX)
43914336            {
4392               code = find_code(portdata->codes, ch);
4337               code = find_code(portdata.codes, ch);
43934338               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>");
43944339            }
43954340
r14995r14996
44234368
44244369static TIMER_CALLBACK(inputx_timerproc)
44254370{
4426   input_port_private *portdata = machine.input_port_data;
4371   ioport_manager &portdata = machine.ioport();
44274372   key_buffer *keybuf;
44284373   attotime delay;
44294374
44304375   keybuf = get_buffer(machine);
44314376
4432   if (portdata->queue_chars)
4377   if (portdata.queue_chars)
44334378   {
44344379      /* 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))
44364381      {
44374382         keybuf->begin_pos++;
44384383         keybuf->begin_pos %= keybuf->size;
44394384
4440         if (portdata->current_rate != attotime::zero)
4385         if (portdata.current_rate != attotime::zero)
44414386            break;
44424387      }
44434388   }
r14995r14996
44604405   if (keybuf->begin_pos != keybuf->end_pos)
44614406   {
44624407      delay = choose_delay(portdata, keybuf->buffer[keybuf->begin_pos]);
4463      portdata->inputx_timer->adjust(delay);
4408      portdata.inputx_timer->adjust(delay);
44644409   }
44654410}
44664411
44674412int inputx_is_posting(running_machine &machine)
44684413{
4469   input_port_private *portdata = machine.input_port_data;
4414   ioport_manager &portdata = machine.ioport();
44704415   const key_buffer *keybuf;
44714416   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));
44734418}
44744419
44754420/***************************************************************************
r14995r14996
46994644   const input_port_config *port;
47004645   const input_field_config *field;
47014646
4702   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
4647   for (port = machine.ioport().first_port(); port != NULL; port = port->next())
47034648   {
47044649      for (field = port->first_field(); field != NULL; field = field->next())
47054650      {
r14995r14996
47244669   int joystick_count;
47254670
47264671   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())
47284673   {
47294674      for (field = port->first_field(); field != NULL; field = field->next())
47304675      {
r14995r14996
47634708
47644709static void execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[])
47654710{
4766   inputx_code *codes = machine.input_port_data->codes;
4711   inputx_code *codes = machine.ioport().codes;
47674712   const char *filename;
47684713   FILE *file = NULL;
47694714   const inputx_code *code;
src/emu/ui.c
r14995r14996
16681668   }
16691669
16701670   /* add analog adjusters */
1671   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1671   for (port = machine.ioport().first_port(); port != NULL; port = port->next())
16721672      for (field = port->fieldlist().first(); field != NULL; field = field->next())
16731673         if (field->type == IPT_ADJUSTER)
16741674         {
r14995r14996
17741774
17751775#ifdef MAME_DEBUG
17761776   /* add crosshair adjusters */
1777   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1777   for (port = machine.ioport().first_port(); port != NULL; port = port->next())
17781778      for (field = port->fieldlist().first(); field != NULL; field = field->next())
17791779         if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0)
17801780         {
src/emu/crsshair.c
r14995r14996
221221   global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
222222
223223   /* determine who needs crosshairs */
224   for (input_port_config *port = machine.m_portlist.first(); port != NULL; port = port->next())
224   for (input_port_config *port = machine.ioport().first_port(); port != NULL; port = port->next())
225225      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
226226         if (field->crossaxis != CROSSHAIR_AXIS_NONE)
227227         {
src/emu/ioport.h
r14995r14996
664664/* forward declarations */
665665class input_port_config;
666666class input_field_config;
667class emu_timer;
667668
668
669669/* template specializations */
670670typedef tagged_list<input_port_config> ioport_list;
671671
r14995r14996
890890};
891891
892892
893struct digital_joystick_state
894{
895   const input_field_config *   field[4];         /* input field for up, down, left, right respectively */
896   UINT8                  inuse;            /* is this joystick used? */
897   UINT8                  current;         /* current value */
898   UINT8                  current4way;      /* current 4-way value */
899   UINT8                  previous;         /* previous value */
900};
893901
902#define DIGITAL_JOYSTICKS_PER_PLAYER   3
903
904#define NUM_SIMUL_KEYS   (UCHAR_SHIFT_END - UCHAR_SHIFT_BEGIN + 1)
905struct inputx_code
906{
907   unicode_char ch;
908   const input_field_config * field[NUM_SIMUL_KEYS];
909};
910
911struct key_buffer
912{
913   int begin_pos;
914   int end_pos;
915   unsigned int status_keydown : 1;
916   int size;
917   unicode_char *buffer;
918};
919
920/* private input port state */
921class ioport_manager
922{
923   friend class device_t;
924
925public:
926   // construction/destruction
927   ioport_manager(running_machine &machine);
928   time_t initialize();
929   
930   // getters
931   running_machine &machine() const { return m_machine; }
932   input_port_config *first_port() const { return m_portlist.first(); }
933
934   /* global state */
935   UINT8                  safe_to_read;      /* clear at start; set after state is loaded */
936
937   /* types */
938   simple_list<input_type_entry> typelist;      /* list of live type states */
939   input_type_entry *         type_to_entry[__ipt_max][MAX_PLAYERS]; /* map from type/player to type state */
940
941   /* specific special global input states */
942   digital_joystick_state      joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; /* joystick states */
943
944   /* frame time tracking */
945   attotime               last_frame_time;   /* time of the last frame callback */
946   attoseconds_t            last_delta_nsec;   /* nanoseconds that passed since the previous callback */
947
948   /* playback/record information */
949   emu_file *               record_file;      /* recording file (NULL if not recording) */
950   emu_file *               playback_file;      /* playback file (NULL if not recording) */
951   UINT64                  playback_accumulated_speed;/* accumulated speed during playback */
952   UINT32                  playback_accumulated_frames;/* accumulated frames during playback */
953
954   /* inputx */
955   inputx_code *codes;
956   key_buffer keybuffer;
957   emu_timer *inputx_timer;
958   int (*queue_chars)(running_machine &machine, const unicode_char *text, size_t text_len);
959   int (*accept_char)(running_machine &machine, unicode_char ch);
960   int (*charqueue_empty)(running_machine &machine);
961   attotime current_rate;
962
963private:
964   input_port_config *port(const char *tag) const { return m_portlist.find(tag); }
965
966   // internals
967   ioport_list            m_portlist;         // points to a list of input port configurations
968
969   // internal state
970   running_machine &      m_machine;
971};
972
973
894974/***************************************************************************
895975    MACROS
896976***************************************************************************/
r14995r14996
12401320***************************************************************************/
12411321
12421322
1243/* ----- core system management ----- */
1244
1245/* initialize the input ports, processing the given token list */
1246time_t input_port_init(running_machine &machine);
1247
1248
1249
12501323/* ----- port configurations ----- */
12511324
12521325/* initialize an input port list structure and allocate ports according to the given tokens */
src/emu/uimain.c
r14995r14996
116116   int has_dips = false;
117117   astring menu_text;
118118   /* scan the input port array to see what options we need to enable */
119   for (port = machine().m_portlist.first(); port != NULL; port = port->next())
119   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
120120      for (field = port->fieldlist().first(); field != NULL; field = field->next())
121121      {
122122         if (field->type == IPT_DIPSWITCH)
r14995r14996
651651   suborder[SEQ_TYPE_INCREMENT] = 2;
652652
653653   /* iterate over the input ports and add menu items */
654   for (port = machine().m_portlist.first(); port != NULL; port = port->next())
654   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
655655      for (field = port->fieldlist().first(); field != NULL; field = field->next())
656656      {
657657         const char *name = input_field_name(field);
r14995r14996
10201020   diplist_tailptr = &diplist;
10211021
10221022   /* loop over input ports and set up the current values */
1023   for (port = machine().m_portlist.first(); port != NULL; port = port->next())
1023   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
10241024      for (field = port->fieldlist().first(); field != NULL; field = field->next())
10251025         if (field->type == type && input_condition_true(machine(), &field->condition, port->owner()))
10261026         {
r14995r14996
12761276   astring text;
12771277
12781278   /* loop over input ports and add the items */
1279   for (port = machine().m_portlist.first(); port != NULL; port = port->next())
1279   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
12801280      for (field = port->fieldlist().first(); field != NULL; field = field->next())
12811281         if (input_type_is_analog(field->type) && input_condition_true(machine(), &field->condition, port->owner()))
12821282         {
src/emu/device.c
r14995r14996
235235
236236
237237//-------------------------------------------------
238//  ioport - return a pointer to the I/O port
239//  object for a given port name
240//-------------------------------------------------
241
242input_port_config *device_t::ioport(const char *tag) const
243{
244   // safety first
245   if (this == NULL)
246      return NULL;
247
248   // build a fully-qualified name and look it up
249   astring fullpath;
250   return machine().ioport().port(subtag(fullpath, tag));
251}
252
253
254//-------------------------------------------------
238255//  static_set_clock - set/change the clock on
239256//  a device
240257//-------------------------------------------------
r14995r14996
907924   // check the width and warn if not correct
908925   if (width != 0 && share->width() != width)
909926   {
910      mame_printf_warning("Shared ptr '%s' found but is width %d, not %d as requested\n", m_tag, share->width(), width);
927      if (required)
928         mame_printf_warning("Shared ptr '%s' found but is width %d, not %d as requested\n", m_tag, share->width(), width);
911929      return NULL;
912930   }
913931   
src/emu/device.h
r14995r14996
186186   memory_region *memregion(const char *tag) const;
187187   memory_share *memshare(const char *tag) const;
188188   memory_bank *membank(const char *tag) const;
189   input_port_config *ioport(const char *tag) const;
189190   device_t *subdevice(const char *tag) const;
190191   device_t *siblingdevice(const char *tag) const;
191192   template<class _DeviceClass> inline _DeviceClass *subdevice(const char *tag) const { return downcast<_DeviceClass *>(subdevice(tag)); }
r14995r14996
241242   template<bool _Required> class memory_bank_finder;
242243   class optional_memory_bank;
243244   class required_memory_bank;
245   template<bool _Required> class ioport_finder;
246   class optional_ioport;
247   class required_ioport;
244248   template<typename _PointerType, bool _Required> class shared_ptr_finder;
245249   template<typename _PointerType> class optional_shared_ptr;
246250   template<typename _PointerType> class required_shared_ptr;
r14995r14996
492496};
493497
494498
499// ======================> ioport_finder
500
501// device finder template
502template<bool _Required>
503class device_t::ioport_finder : public device_t::object_finder_base<input_port_config>
504{
505public:
506   // construction/destruction
507   ioport_finder(device_t &base, const char *tag)
508      : object_finder_base(base, tag) { }
509
510   // finder
511   virtual bool findit()
512   {
513      m_target = m_base.ioport(m_tag);
514      return this->report_missing(m_target != NULL, "I/O port", _Required);
515   }
516};
517
518// optional device finder
519class device_t::optional_ioport : public device_t::ioport_finder<false>
520{
521public:
522   optional_ioport(device_t &base, const char *tag) : ioport_finder<false>(base, tag) { }
523};
524
525// required devices are similar but throw an error if they are not found
526class device_t::required_ioport : public device_t::ioport_finder<true>
527{
528public:
529   required_ioport(device_t &base, const char *tag) : ioport_finder<true>(base, tag) { }
530};
531
532
495533// ======================> shared_ptr_finder
496534
497535// shared pointer finder template
src/emu/memory.c
r14995r14996
23232323   {
23242324      // find the port
23252325      astring fulltag;
2326      device().siblingtag(fulltag, rtag);
2327      const input_port_config *port = machine().port(fulltag);
2326      input_port_config *port = machine().root_device().ioport(device().siblingtag(fulltag, rtag));
23282327      if (port == NULL)
23292328         throw emu_fatalerror("Attempted to map non-existent port '%s' for read in space %s of device '%s'\n", rtag, m_name, m_device.tag());
23302329
r14995r14996
23362335   {
23372336      // find the port
23382337      astring fulltag;
2339      device().siblingtag(fulltag, wtag);
2340      const input_port_config *port = machine().port(fulltag);
2338      input_port_config *port = machine().root_device().ioport(device().siblingtag(fulltag, wtag));
23412339      if (port == NULL)
23422340         fatalerror("Attempted to map non-existent port '%s' for write in space %s of device '%s'\n", wtag, m_name, m_device.tag());
23432341
src/mess/machine/ay3600.c
r14995r14996
282282
283283INLINE int a2_has_keypad(running_machine &machine)
284284{
285   return machine.m_portlist.find("keypad_1") != NULL;
285   return machine.root_device().ioport("keypad_1") != NULL;
286286}
287287
288288INLINE int a2_has_reset_dip(running_machine &machine)
289289{
290   return machine.m_portlist.find("reset_dip") != NULL;
290   return machine.root_device().ioport("reset_dip") != NULL;
291291}
292292
293293INLINE int a2_has_repeat(running_machine &machine)
294294{
295   return machine.m_portlist.find("keyb_repeat") != NULL;
295   return machine.root_device().ioport("keyb_repeat") != NULL;
296296}
297297
298298INLINE int a2_has_capslock(running_machine &machine)
src/mess/machine/pc_joy.c
r14995r14996
1919   UINT8 data = 0xf;
2020   int delta;
2121   attotime new_time = space->machine().time();
22   const input_port_config *joystick_port = space->machine().m_portlist.find("pc_joy");
22   const input_port_config *joystick_port = space->machine().root_device().ioport("pc_joy");
2323   delta = ((new_time - JOY_time) * 256 * 1000).seconds;
2424
2525   if (joystick_port != NULL)
src/mess/machine/coco.c
r14995r14996
102102
103103void coco_state::analog_port_start(analog_input_t *analog, const char *rx_tag, const char *ry_tag, const char *lx_tag, const char *ly_tag, const char *buttons_tag)
104104{
105   analog->m_input[0][0] = machine().port(rx_tag);
106   analog->m_input[0][1] = machine().port(ry_tag);
107   analog->m_input[1][0] = machine().port(lx_tag);
108   analog->m_input[1][1] = machine().port(ly_tag);
109   analog->m_buttons = machine().port(buttons_tag);
105   analog->m_input[0][0] =  machine().root_device().ioport(rx_tag);
106   analog->m_input[0][1] =  machine().root_device().ioport(ry_tag);
107   analog->m_input[1][0] =  machine().root_device().ioport(lx_tag);
108   analog->m_input[1][1] =  machine().root_device().ioport(ly_tag);
109   analog->m_buttons =  machine().root_device().ioport(buttons_tag);
110110}
111111
112112
r14995r14996
125125   {
126126      char name[32];
127127      snprintf(name, sizeof(name) / sizeof(name[0]), "row%d", i);
128      m_keyboard[i] = machine().port(name);
128      m_keyboard[i] = machine().root_device().ioport(name);
129129   }
130130
131131   /* look up analog ports */
r14995r14996
137137      DIECOM_LIGHTGUN_LX_TAG, DIECOM_LIGHTGUN_LY_TAG, DIECOM_LIGHTGUN_BUTTONS_TAG);
138138
139139   /* look up miscellaneous controls */
140   m_joystick_type_control = machine().port(CTRL_SEL_TAG);
141   m_joystick_hires_control = machine().port(HIRES_INTF_TAG);
140   m_joystick_type_control =  machine().root_device().ioport(CTRL_SEL_TAG);
141   m_joystick_hires_control =  machine().root_device().ioport(HIRES_INTF_TAG);
142142
143143   /* timers */
144144   m_hiresjoy_transition_timer[0] = timer_alloc(TIMER_HIRES_JOYSTICK_X);
src/mess/video/mc6847.c
r14995r14996
14481448{
14491449   char port_name[32];
14501450   snprintf(port_name, ARRAY_LENGTH(port_name), "%s:%s", device->tag(), ARTIFACTING_TAG);
1451   m_config = device->machine().port(port_name);
1451   m_config = device->ioport(port_name);
14521452}
14531453 
14541454 
src/mess/drivers/a2600.c
r14995r14996
15661566
15671567static const tia_interface a2600_tia_interface =
15681568{
1569   DEVCB_DRIVER_MEMBER(a2600_state, a2600_read_input_port),
1569   DEVCB_DRIVER_MEMBER16(a2600_state, a2600_read_input_port),
15701570   DEVCB_DRIVER_MEMBER(a2600_state, a2600_get_databus_contents),
1571   DEVCB_DRIVER_MEMBER(a2600_state, a2600_tia_vsync_callback)
1571   DEVCB_DRIVER_MEMBER16(a2600_state, a2600_tia_vsync_callback)
15721572};
15731573
15741574static const tia_interface a2600_tia_interface_pal =
15751575{
1576   DEVCB_DRIVER_MEMBER(a2600_state, a2600_read_input_port),
1576   DEVCB_DRIVER_MEMBER16(a2600_state, a2600_read_input_port),
15771577   DEVCB_DRIVER_MEMBER(a2600_state, a2600_get_databus_contents),
1578   DEVCB_DRIVER_MEMBER(a2600_state, a2600_tia_vsync_callback_pal)
1578   DEVCB_DRIVER_MEMBER16(a2600_state, a2600_tia_vsync_callback_pal)
15791579};
15801580
15811581

Previous 15994 Revisions Next


© 1998-2018 The MESS Team