Previous 199869 Revisions Next

r36168 Sunday 1st March, 2015 at 17:31:53 UTC by Couriersud
Aligned monitor handling between sdl and baseline. [Couriersud]
[hash]pasogo.xml
[src/mame/drivers]hng64.c mitchell.c suna8.c suprgolf.c suprslam.c tankbust.c thunderx.c tryout.c usgames.c vigilant.c
[src/mame/includes]hng64.h tankbust.h thunderx.h tryout.h usgames.h vigilant.h
[src/mame/video]hng64.c
[src/mess/audio]gamate.c
[src/mess/drivers]gamate.c hh_ucom4.c
[src/mess/includes]gamate.h
[src/osd/modules]osdwindow.h
[src/osd/modules/render]drawd3d.c drawdd.c drawsdl.c
[src/osd/sdl]video.c video.h window.c window.h
[src/osd/windows]video.c video.h window.c window.h

trunk/hash/pasogo.xml
r244679r244680
33<softwarelist name="pasogo" description="Koei PasoGo cartridges">
44
55<!--
6  Koei PasoGo (パソ碁) possible undumped games
6  Koei PasoGo (パソ碁) undumped games
77
8  Unknown title [cart KS-1005]
9  Unknown title [cart KS-1006]
10  Unknown title [cart KS-1007]
11  Unknown title [cart KS-1008]
12 
8  Taikyoku-kun I ~ 対局くん I [KS-1001]
9  Tanoshii Tsumego Dai-1-kan ~ 楽しい詰碁・第1巻 [KS-1002]
10  Tanoshii Tsumego Dai-2-kan ~ 楽しい詰碁・第2巻 [KS-1003]
11
1312-->
1413
15   <!-- KS-1001: Contains 8M SOP44 ROM, 62256 SOP32 RAM, Microchip 1081N (reset IC?watchdog?battery-power-switcher?) and 3V battery. -->
16   <software name="taikyoku">
17      <description>Taikyoku-kun I</description>
14   <!-- Contians 8M SOP44 ROM, 62256 SOP32 RAM, Microchip 1081N (reset IC?watchdog?battery-power-switcher?) and 3V battery. -->
15   <software name="dgoban">
16      <description>Denshi Goban</description>
1817      <year>1996</year>
1918      <publisher>Koei</publisher>
20      <info name="serial" value="KS-1001"/>
21      <info name="alt_title" value="対局くん I"/>
19      <info name="serial" value="KS-1009"/>
20      <info name="alt_title" value="電子碁盤"/>
2221      <part name="cart" interface="pasogo_cart">
2322         <dataarea name="rom" width="16" endianness="little" size="1048576">
24            <rom name="ks-1001.ic4" size="1048576" crc="b6a3f97c" sha1="2de63b05ec93a4ba3ea55ba131c0706927a5bf39" offset="00000000" />
23            <rom name="ks-1010.ic4" size="1048576" crc="b6a3f97c" sha1="2de63b05ec93a4ba3ea55ba131c0706927a5bf39" offset="00000000" />
2524         </dataarea>
2625      </part>
2726   </software>
2827
29   <!-- KS-1002: Contains 4M SOP40 ROM only. -->
30   <software name="tanostd1">
31      <description>Tanoshii Tsumego Dai-1-kan</description>
32      <year>1996</year>
33      <publisher>Koei</publisher>
34      <info name="serial" value="KS-1002"/>
35      <info name="alt_title" value="楽しい詰碁・第1巻"/>
36      <part name="cart" interface="pasogo_cart">
37         <dataarea name="rom" width="16" endianness="little" size="524288">
38            <rom name="ks-1002.ic4" size="524288" crc="32f9c38a" sha1="1be82afcdf5e2d1a0e873fda4161e663d7a53a85" offset="00000000" />
39         </dataarea>
40      </part>
41   </software>
4228
43   <!-- KS-1003: Contains 4M SOP40 ROM only. -->
44   <software name="tanostd2">
45      <description>Tanoshii Tsumego Dai-2-kan</description>
46      <year>1996</year>
47      <publisher>Koei</publisher>
48      <info name="serial" value="KS-1003"/>
49      <info name="alt_title" value="楽しい詰碁・第2巻"/>
50      <part name="cart" interface="pasogo_cart">
51         <dataarea name="rom" width="16" endianness="little" size="524288">
52            <rom name="ks-1003.ic4" size="524288" crc="32f9c38a" sha1="1be82afcdf5e2d1a0e873fda4161e663d7a53a85" offset="00000000" />
53         </dataarea>
54      </part>
55   </software>
56
57   <!-- KS-1004: Contains 4M SOP40 ROM only. -->
29   <!-- Contains 4M SOP40 ROM only. -->
5830   <software name="igmks1">
5931      <description>Igo Meikyokushuu - Dai-1-kan</description>
6032      <year>1996</year>
r244679r244680
6335      <info name="alt_title" value="囲碁名局集 第1巻"/>
6436      <part name="cart" interface="pasogo_cart">
6537         <dataarea name="rom" width="16" endianness="little" size="524288">
66            <rom name="ks-1004.ic4" size="524288" crc="32f9c38a" sha1="1be82afcdf5e2d1a0e873fda4161e663d7a53a85" offset="00000000" />
38            <rom name="yrm0442m-184s" size="524288" crc="32f9c38a" sha1="1be82afcdf5e2d1a0e873fda4161e663d7a53a85" offset="00000000" />
6739         </dataarea>
6840      </part>
6941   </software>
7042
71   <!-- KS-1009: Contains 8M SOP44 ROM, 62256 SOP32 RAM, Microchip 1081N (reset IC?watchdog?battery-power-switcher?) and 3V battery. -->
72   <software name="dgoban">
73      <description>Denshi Goban</description>
74      <year>1996</year>
75      <publisher>Koei</publisher>
76      <info name="serial" value="KS-1009"/>
77      <info name="alt_title" value="電子碁盤"/>
78      <part name="cart" interface="pasogo_cart">
79         <dataarea name="rom" width="16" endianness="little" size="1048576">
80            <rom name="ks-1009.ic4" size="1048576" crc="b6a3f97c" sha1="2de63b05ec93a4ba3ea55ba131c0706927a5bf39" offset="00000000" />
81         </dataarea>
82      </part>
83   </software>
84
85   <!-- KS-1010: Contains 4M SOP40 ROM only. -->
43   <!-- Contains 4M SOP40 ROM only. -->
8644   <software name="tnt1">
8745      <description>Tsuyoku Naru Tesuji - Dai-1-kan</description>
8846      <year>1996</year>
r244679r244680
9149      <info name="alt_title" value="強くなる手筋・第1巻"/>
9250      <part name="cart" interface="pasogo_cart">
9351         <dataarea name="rom" width="16" endianness="little" size="524288">
94            <rom name="ks-1010.ic4" size="524288" crc="3e70fca6" sha1="c46cdc9e01f2f5c66b2523e1d30355e51c839f27" offset="00000000" />
52            <rom name="ks-1009.ic4" size="524288" crc="3e70fca6" sha1="c46cdc9e01f2f5c66b2523e1d30355e51c839f27" offset="00000000" />
9553         </dataarea>
9654      </part>
9755   </software>
trunk/src/mame/drivers/hng64.c
r244679r244680
867867      }
868868
869869      // Send it off to the 3d subsystem.
870      hng64_command3d( packet3d);
870      hng64_command3d(machine(), packet3d);
871871   }
872872#endif
873873}
r244679r244680
892892{
893893   // this handles 3d to fb upload
894894   UINT16 packet3d[16];
895//   printf("dl_upload_w %08x %08x\n", data, mem_mask);
896895
897
898896   for(int packetStart=0;packetStart<0x200/4;packetStart+=8)
899897   {
900898      // Create a 3d packet
r244679r244680
908906      }
909907
910908      // Send it off to the 3d subsystem.
911      hng64_command3d( packet3d);
909      hng64_command3d(machine(), packet3d);
912910   }
913911
914912   machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(0x200*8), timer_expired_delegate(FUNC(hng64_state::hng64_3dfifo_processed),this));
r244679r244680
917915/* Note: Samurai Shodown games never calls bit 1, so it can't be framebuffer clear. It also calls bit 3 at start-up, meaning unknown */
918916WRITE32_MEMBER(hng64_state::dl_control_w) // This handles framebuffers
919917{
920//   printf("dl_control_w %08x %08x\n", data, mem_mask);
921
922918   //if(data & 2) // swap buffers
923919   //{
924920   //  clear3d();
r244679r244680
11771173<ElSemi> 0xBF800000-0xBF808000 S-RAM
11781174<ElSemi> 0x60000000-0x60001000 Comm dualport ram
11791175*/
1180
1181WRITE32_MEMBER(hng64_state::hng64_vregs_w)
1182{
1183//   printf("hng64_vregs_w %02x, %08x %08x\n", offset * 4, data, mem_mask);
1184   COMBINE_DATA(&m_videoregs[offset]);
1185}
1186
11871176static ADDRESS_MAP_START( hng_map, AS_PROGRAM, 32, hng64_state )
11881177
11891178   AM_RANGE(0x00000000, 0x00ffffff) AM_RAM AM_SHARE("mainram")
r244679r244680
12071196   AM_RANGE(0x2000e400, 0x2000efff) AM_WRITE(hng64_sprite_clear_odd_w)
12081197   AM_RANGE(0x20010000, 0x20010013) AM_RAM AM_SHARE("spriteregs")
12091198   AM_RANGE(0x20100000, 0x2017ffff) AM_RAM_WRITE(hng64_videoram_w) AM_SHARE("videoram")    // Tilemap
1210   AM_RANGE(0x20190000, 0x20190037) AM_RAM_WRITE(hng64_vregs_w) AM_SHARE("videoregs")
1199   AM_RANGE(0x20190000, 0x20190037) AM_RAM AM_SHARE("videoregs")
12111200   AM_RANGE(0x20200000, 0x20203fff) AM_RAM_WRITE(hng64_pal_w) AM_SHARE("paletteram")
12121201   AM_RANGE(0x20208000, 0x2020805f) AM_READWRITE(tcram_r, tcram_w) AM_SHARE("tcram")   // Transition Control
12131202   AM_RANGE(0x20300000, 0x203001ff) AM_RAM_WRITE(dl_w) AM_SHARE("dl")  // 3d Display List
r244679r244680
17411730   GFXDECODE_ENTRY( "textures", 0, hng64_texlayout,     0x0, 0x10 )  /* textures */
17421731GFXDECODE_END
17431732
1744static void hng64_reorder( UINT8* gfxregion, size_t gfxregionsize)
1733static void hng64_reorder(running_machine &machine, UINT8* gfxregion, size_t gfxregionsize)
17451734{
17461735   // by default 2 4bpp tiles are stored in each 8bpp tile, this makes decoding in MAME harder than it needs to be
17471736   // reorder them
r244679r244680
17611750
17621751DRIVER_INIT_MEMBER(hng64_state,hng64_reorder_gfx)
17631752{
1764   hng64_reorder(memregion("scrtile")->base(), memregion("scrtile")->bytes());
1753   hng64_reorder(machine(), memregion("scrtile")->base(), memregion("scrtile")->bytes());
17651754}
17661755
17671756#define HACK_REGION
17681757#ifdef HACK_REGION
1769void hng64_state::hng64_patch_bios_region(int region)
1758static void hng64_patch_bios_region(running_machine& machine, int region)
17701759{
1771   UINT8 *rom = memregion("user1")->base();
1760   UINT8 *rom = machine.root_device().memregion("user1")->base();
17721761
17731762   if ((rom[0x4000]==0xff) && (rom[0x4001] == 0xff))
17741763   {
r244679r244680
17851774   // region hacking, english error messages are more useful to us, but no english bios is dumped...
17861775#ifdef HACK_REGION
17871776// versions according to fatal fury test mode
1788//  hng64_patch_bios_region( 0); // 'Others Ver' (invalid?)
1789   hng64_patch_bios_region( 1); // Japan
1790//  hng64_patch_bios_region( 2); // USA
1791//  hng64_patch_bios_region( 3); // Korea
1792//  hng64_patch_bios_region( 4); // 'Others'
1777//  hng64_patch_bios_region(machine(), 0); // 'Others Ver' (invalid?)
1778   hng64_patch_bios_region(machine(), 1); // Japan
1779//  hng64_patch_bios_region(machine(), 2); // USA
1780//  hng64_patch_bios_region(machine(), 3); // Korea
1781//  hng64_patch_bios_region(machine(), 4); // 'Others'
17931782#endif
17941783
17951784   /* 1 meg of virtual address space for the com cpu */
r244679r244680
19131902
19141903   m_comm_rom = memregion("user2")->base();
19151904   m_comm_ram = auto_alloc_array(machine(),UINT8,0x10000);
1916
1917
1918   for (int i = 0; i < 0x38 / 4; i++)
1919   {
1920      m_videoregs[i] = 0xdeadbeef;
1921   }
1922     
19231905}
19241906
19251907
trunk/src/mame/drivers/mitchell.c
r244679r244680
15871587   ROM_LOAD( "pang_03.bin",  0x10000, 0x20000, CRC(0c8477ae) SHA1(a31a8c00407dfc3017d56e29fac6114b73248030) )   /* Decrypted data */
15881588
15891589   ROM_REGION( 0x100000, "gfx1", ROMREGION_ERASEFF )
1590   ROM_LOAD( "pang_9.bin",      0x000000, 0x20000, CRC(3a5883f5) SHA1(a8a33071e10f5992e80afdb782c334829f9ae27f) ) /* chars */
1590   ROM_LOAD( "bb9.bin",      0x000000, 0x20000, CRC(3a5883f5) SHA1(a8a33071e10f5992e80afdb782c334829f9ae27f) ) /* chars */
15911591   ROM_LOAD( "bb3.bin",      0x020000, 0x20000, CRC(79a8ed08) SHA1(c1e43889e29b80c7fe2c09b11eecde24450a1ff5) )
15921592   /* 40000-7ffff empty */
15931593   ROM_LOAD( "bb11.bin",     0x080000, 0x20000, CRC(166a16ae) SHA1(7f907c78b7ac8c99e3d79761a6ae689c77e3a1f5) )
r244679r244680
16101610   ROM_CONTINUE(0x10000, 0x20000 )   /* Decrypted data */
16111611
16121612   ROM_REGION( 0x100000, "gfx1", ROMREGION_ERASEFF )
1613   ROM_LOAD( "pang_9.bin",      0x000000, 0x20000, CRC(3a5883f5) SHA1(a8a33071e10f5992e80afdb782c334829f9ae27f) ) /* chars */
1613   ROM_LOAD( "bb9.bin",      0x000000, 0x20000, CRC(3a5883f5) SHA1(a8a33071e10f5992e80afdb782c334829f9ae27f) ) /* chars */
16141614   ROM_LOAD( "bb3.bin",      0x020000, 0x20000, CRC(79a8ed08) SHA1(c1e43889e29b80c7fe2c09b11eecde24450a1ff5) )
16151615   /* 40000-7ffff empty */
16161616   ROM_LOAD( "bb11.bin",     0x080000, 0x20000, CRC(166a16ae) SHA1(7f907c78b7ac8c99e3d79761a6ae689c77e3a1f5) )
trunk/src/mame/drivers/suna8.c
r244679r244680
25382538
25392539ROM_START( brickzn )
25402540   ROM_REGION( 0x50000 + 0x40000, "maincpu", 0 )       /* Main Z80 Code */
2541   ROM_LOAD( "p9.m7", 0x00000, 0x08000, CRC(bd7a3c01) SHA1(05fb2836f1c8d8818847ccb76e7b477f13a9929b) )  // V6.0 1992,3,16
2542   ROM_LOAD( "p8.k7", 0x10000, 0x20000, CRC(ec3e266d) SHA1(4441a5ae88e51353f6d1eb22c00becb0a7ecea6e) )
2543   ROM_LOAD( "p7.i7", 0x30000, 0x20000, CRC(4dd88631) SHA1(0dbcaf3420dad82c3ed94d231948fe69b044b786) )
2541   ROM_LOAD( "P9.M7", 0x00000, 0x08000, CRC(bd7a3c01) SHA1(05fb2836f1c8d8818847ccb76e7b477f13a9929b) )  // V6.0 1992,3,16
2542   ROM_LOAD( "P8.K7", 0x10000, 0x20000, CRC(ec3e266d) SHA1(4441a5ae88e51353f6d1eb22c00becb0a7ecea6e) )
2543   ROM_LOAD( "P7.I7", 0x30000, 0x20000, CRC(4dd88631) SHA1(0dbcaf3420dad82c3ed94d231948fe69b044b786) )
25442544
25452545   ROM_REGION( 0x10000, "audiocpu", 0 )        /* Music Z80 Code */
2546   ROM_LOAD( "10.o8", 0x00000, 0x10000, CRC(4eba8178) SHA1(9a214a1acacdc124529bc9dde73a8e884fc70293) )  // BRICK MUSIC XILINX PROGRAM 3020 1991,11,14 MUSIC PROGRAM V 2,0 1990.12.14
2546   ROM_LOAD( "10.O8", 0x00000, 0x10000, CRC(4eba8178) SHA1(9a214a1acacdc124529bc9dde73a8e884fc70293) )  // BRICK MUSIC XILINX PROGRAM 3020 1991,11,14 MUSIC PROGRAM V 2,0 1990.12.14
25472547
25482548   ROM_REGION( 0x10000, "pcm", 0 )     /* PCM Z80 Code */
2549   ROM_LOAD( "11.n10", 0x00000, 0x10000, CRC(6c54161a) SHA1(ea216d9f45b441acd56b9fed81a83e3bfe299fbd) )
2549   ROM_LOAD( "11.N10", 0x00000, 0x10000, CRC(6c54161a) SHA1(ea216d9f45b441acd56b9fed81a83e3bfe299fbd) )
25502550
25512551   ROM_REGION( 0xc0000, "gfx1", ROMREGION_INVERT ) /* Sprites */
2552   ROM_LOAD( "p5.m5", 0x00000, 0x20000, CRC(ca59e2f7) SHA1(dbb9f2b316a44f760768f0430798e0c4e9e8f3ff) )
2553   ROM_LOAD( "p4.l5", 0x20000, 0x20000, CRC(cc8fb330) SHA1(fd263f65b81acbfc00fe339c461068ab160c04af) )
2554   ROM_LOAD( "p3.k5", 0x40000, 0x20000, CRC(2e4f194b) SHA1(86da1a582ea274f2af96d3e3e2ac72bcaf3638cb) )
2555   ROM_LOAD( "p2.i5", 0x60000, 0x20000, CRC(592d45ce) SHA1(8ce9236b7deba6cf00999680314ac04eff624a6d) )
2556   ROM_LOAD( "p1.h5", 0x80000, 0x20000, CRC(7a6bb583) SHA1(ff7018c07182fce0ff6954bbe3b08fa5105f6be0) )
2557   ROM_LOAD( "p6.h7", 0xa0000, 0x20000, CRC(bbf31081) SHA1(1fdbd0e0853082345225e18df340184a7a604b78) )
2552   ROM_LOAD( "P5.M5", 0x00000, 0x20000, CRC(ca59e2f7) SHA1(dbb9f2b316a44f760768f0430798e0c4e9e8f3ff) )
2553   ROM_LOAD( "P4.L5", 0x20000, 0x20000, CRC(cc8fb330) SHA1(fd263f65b81acbfc00fe339c461068ab160c04af) )
2554   ROM_LOAD( "P3.K5", 0x40000, 0x20000, CRC(2e4f194b) SHA1(86da1a582ea274f2af96d3e3e2ac72bcaf3638cb) )
2555   ROM_LOAD( "P2.I5", 0x60000, 0x20000, CRC(592d45ce) SHA1(8ce9236b7deba6cf00999680314ac04eff624a6d) )
2556   ROM_LOAD( "P1.H5", 0x80000, 0x20000, CRC(7a6bb583) SHA1(ff7018c07182fce0ff6954bbe3b08fa5105f6be0) )
2557   ROM_LOAD( "P6.H7", 0xa0000, 0x20000, CRC(bbf31081) SHA1(1fdbd0e0853082345225e18df340184a7a604b78) )
25582558ROM_END
25592559
25602560
r244679r244680
26032603
26042604ROM_START( brickzn11 )
26052605   ROM_REGION( 0x50000 + 0x40000, "maincpu", 0 )       /* Main Z80 Code */
2606   ROM_LOAD( "9.bin", 0x00000, 0x08000, CRC(24f88cfd) SHA1(dfa7313ab6696042bab2e6cc8ff97b331d526c6b) )  // V1.1 1992,1,13
2606   ROM_LOAD( "9.bin", 0x00000, 0x08000, CRC(24f88cfd) SHA1(dfa7313ab6696042bab2e6cc8ff97b331d526c6b) )
26072607   ROM_LOAD( "8.bin", 0x10000, 0x20000, CRC(e2c7f7ac) SHA1(43377daf6957829ef9bb7a81708c2f18f5d7ced6) )
26082608   ROM_LOAD( "7.bin", 0x30000, 0x20000, CRC(7af5b25c) SHA1(9e98e99bdc5be1602144c83f40b2ccf6b90a729a) )
26092609
r244679r244680
28812881
28822882GAME( 1991, hardhea2,  0,        hardhea2, hardhea2, suna8_state, hardhea2,  ROT0,  "SunA",                       "Hard Head 2 (v2.0)",          0 )
28832883
2884// is meant to sound like this https://www.youtube.com/watch?v=yfU1C7A3iZI (recorded from v6.0, Joystick version)
2885GAME( 1992, brickzn,   0,        brickzn,  brickzn,  suna8_state, brickzn,   ROT90, "SunA",                       "Brick Zone (v6.0, Joystick)", GAME_IMPERFECT_SOUND )
2886GAME( 1992, brickznv5, brickzn,  brickzn,  brickzn,  suna8_state, brickznv5, ROT90, "SunA",                       "Brick Zone (v5.0, Joystick)", GAME_IMPERFECT_SOUND )
2887GAME( 1992, brickznv4, brickzn,  brickzn,  brickzn,  suna8_state, brickznv4, ROT90, "SunA",                       "Brick Zone (v4.0, Spinner)",  GAME_IMPERFECT_SOUND )
2884GAME( 1992, brickzn,   0,        brickzn,  brickzn,  suna8_state, brickzn,   ROT90, "SunA",                       "Brick Zone (v6.0, Joystick)", 0 )
2885GAME( 1992, brickznv5, brickzn,  brickzn,  brickzn,  suna8_state, brickznv5, ROT90, "SunA",                       "Brick Zone (v5.0, Joystick)", 0 )
2886GAME( 1992, brickznv4, brickzn,  brickzn,  brickzn,  suna8_state, brickznv4, ROT90, "SunA",                       "Brick Zone (v4.0, Spinner)",  0 )
28882887GAME( 1992, brickzn11, brickzn,  brickzn,  brickzn,  suna8_state, brickzn11, ROT90, "SunA",                       "Brick Zone (v1.1)",  GAME_NOT_WORKING )
trunk/src/mame/drivers/suprgolf.c
r244679r244680
7272   DECLARE_WRITE8_MEMBER(suprgolf_writeB);
7373   DECLARE_DRIVER_INIT(suprgolf);
7474   TILE_GET_INFO_MEMBER(get_tile_info);
75    virtual void machine_start();
7675   virtual void machine_reset();
7776   virtual void video_start();
7877   UINT32 screen_update_suprgolf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
r244679r244680
250249   }
251250}
252251
253void suprgolf_state::machine_start()
254{
255    membank("bank1")->configure_entries(0, 16, memregion("user2")->base(), 0x4000);
256    membank("bank2")->configure_entries(0, 64, memregion("user1")->base(), 0x4000);
257}
258
259252WRITE8_MEMBER(suprgolf_state::suprgolf_pen_w)
260253{
261254   m_vreg_pen = data;
r244679r244680
273266
274267WRITE8_MEMBER(suprgolf_state::rom_bank_select_w)
275268{
276    m_rom_bank = data;
269   UINT8 *region_base = memregion("user1")->base();
277270
278    //popmessage("%08x %02x",((data & 0x3f) * 0x4000),data);
279    //osd_printf_debug("ROM_BANK 0x8000 - %X @%X\n",data,space.device().safe_pcbase());
280    membank("bank2")->set_entry(data & 0x3f);
271   m_rom_bank = data;
281272
273   //popmessage("%08x %02x",((data & 0x3f) * 0x4000),data);
274
275//  osd_printf_debug("ROM_BANK 0x8000 - %X @%X\n",data,space.device().safe_pcbase());
276   membank("bank2")->set_base(region_base + (data&0x3f ) * 0x4000);
277
282278   m_msm_nmi_mask = data & 0x40;
283279   flip_screen_set(data & 0x80);
284280}
285281
286282WRITE8_MEMBER(suprgolf_state::rom2_bank_select_w)
287283{
288    //osd_printf_debug("ROM_BANK 0x4000 - %X @%X\n",data,space.device().safe_pcbase());
289    membank("bank1")->set_entry(data & 0x0f);
290   
284   UINT8 *region_base = memregion("user2")->base();
285//  osd_printf_debug("ROM_BANK 0x4000 - %X @%X\n",data,space.device().safe_pcbase());
286
287   membank("bank1")->set_base(region_base + (data&0x0f) * 0x4000);
288
291289   if(data & 0xf0)
292290      printf("Rom bank select 2 with data %02x activated\n",data);
293291}
trunk/src/mame/drivers/suprslam.c
r244679r244680
115115
116116WRITE8_MEMBER(suprslam_state::suprslam_sh_bankswitch_w)
117117{
118    membank("bank1")->set_entry(data & 0x03);
118   UINT8 *RAM = memregion("audiocpu")->base();
119   int bankaddress;
120
121   bankaddress = 0x10000 + (data & 0x03) * 0x8000;
122   membank("bank1")->set_base(&RAM[bankaddress]);
119123}
120124
121125/*** MEMORY MAPS *************************************************************/
r244679r244680
284288   save_item(NAME(m_screen_bank));
285289   save_item(NAME(m_bg_bank));
286290   save_item(NAME(m_pending_command));
287
288    membank("bank1")->configure_entries(0, 4, memregion("audiocpu")->base() + 0x10000, 0x8000);
289291}
290292
291293void suprslam_state::machine_reset()
trunk/src/mame/drivers/tankbust.c
r244679r244680
2222#include "includes/tankbust.h"
2323
2424
25void tankbust_state::machine_start()
26{
27    membank("bank1")->configure_entries(0, 2, memregion("maincpu")->base() + 0x10000, 0x4000);
28    membank("bank2")->configure_entries(0, 2, memregion("maincpu")->base() + 0x18000, 0x2000);
29}
30
3125//port A of ay8910#0
3226
3327TIMER_CALLBACK_MEMBER(tankbust_state::soundlatch_callback)
r244679r244680
10195
10296   case 7: /* 0xe007 bankswitch */
10397      /* bank 1 at 0x6000-9fff = from 0x10000 when bit0=0 else from 0x14000 */
104        membank("bank1")->set_entry(data & 1);
105
10698      /* bank 2 at 0xa000-bfff = from 0x18000 when bit0=0 else from 0x1a000 */
107      membank("bank2")->set_entry(data & 1); /* verified (the game will reset after the "game over" otherwise) */
99      membank("bank1")->set_base(memregion("maincpu")->base() + 0x10000 + ((data&1) * 0x4000) );
100      membank("bank2")->set_base(memregion("maincpu")->base() + 0x18000 + ((data&1) * 0x2000) ); /* verified (the game will reset after the "game over" otherwise) */
108101      break;
109102   }
110103}
trunk/src/mame/drivers/thunderx.c
r244679r244680
312312
313313WRITE8_MEMBER(thunderx_state::scontra_bankswitch_w)
314314{
315    // logerror("%04x: bank switch %02x\n", space.device().safe_pc(), data & 0x0f);
316    membank("bank1")->set_entry(data & 0x0f);
315   UINT8 *RAM = memregion("maincpu")->base();
316   int offs;
317317
318//logerror("%04x: bank switch %02x\n",space.device().safe_pc(),data);
319
320   /* bits 0-3 ROM bank */
321   offs = 0x10000 + (data & 0x0f)*0x2000;
322   membank("bank1")->set_base(&RAM[offs] );
323
318324   /* bit 4 select work RAM or palette RAM at 5800-5fff */
319325   m_palette_selected = ~data & 0x10;
320326
r244679r244680
579585   save_item(NAME(m_palette_selected));
580586   save_item(NAME(m_rambank));
581587   save_item(NAME(m_pmcbank));
582   
583    membank("bank1")->configure_entries(0, 16, memregion("maincpu")->base() + 0x10000, 0x2000);
584588}
585589
586590MACHINE_START_MEMBER(thunderx_state,thunderx)
trunk/src/mame/drivers/tryout.c
r244679r244680
4343//  m_audiocpu->set_input_line(0, CLEAR_LINE);
4444}
4545
46void tryout_state::machine_start()
47{
48    membank("bank1")->configure_entries(0, 2, memregion("maincpu")->base() + 0x10000, 0x2000);
49}
50
5146WRITE8_MEMBER(tryout_state::tryout_bankswitch_w)
5247{
53    membank("bank1")->set_entry(data & 0x01);
48   UINT8 *RAM = memregion("maincpu")->base();
49   int bankaddress;
50
51   bankaddress = 0x10000 + (data & 0x01) * 0x2000;
52   membank("bank1")->set_base(&RAM[bankaddress]);
5453}
5554
5655static ADDRESS_MAP_START( main_cpu, AS_PROGRAM, 8, tryout_state )
trunk/src/mame/drivers/usgames.c
r244679r244680
3030#include "includes/usgames.h"
3131#include "machine/nvram.h"
3232
33void usgames_state::machine_start()
34{
35    membank("bank1")->configure_entries(0, 16, memregion("maincpu")->base() + 0x10000, 0x4000);
36}
3733
3834WRITE8_MEMBER(usgames_state::usgames_rombank_w)
3935{
40    membank("bank1")->set_entry(data);
36   UINT8 *RAM = memregion("maincpu")->base();
37
38//  logerror ("BANK WRITE? -%02x-\n",data);
39//popmessage("%02x",data);
40
41   membank("bank1")->set_base(&RAM[ 0x10000 + 0x4000 * data] );
4142}
4243
4344WRITE8_MEMBER(usgames_state::lamps1_w)
trunk/src/mame/drivers/vigilant.c
r244679r244680
2222#include "includes/vigilant.h"
2323#include "includes/iremipt.h"
2424
25void vigilant_state::machine_start()
26{
27    membank("bank1")->configure_entries(0, 8, memregion("maincpu")->base() + 0x10000, 0x4000);
28}
29
3025WRITE8_MEMBER(vigilant_state::vigilant_bank_select_w)
3126{
32    membank("bank1")->set_entry(data & 0x07);
27   int bankaddress;
28   UINT8 *RAM = memregion("maincpu")->base();
29
30   bankaddress = 0x10000 + (data & 0x07) * 0x4000;
31   membank("bank1")->set_base(&RAM[bankaddress]);
3332}
3433
3534/***************************************************************************
trunk/src/mame/includes/hng64.h
r244679r244680
1010   BURIKI_MCU
1111};
1212
13enum hng64trans_t
14{
15   HNG64_TILEMAP_NORMAL = 1,
16   HNG64_TILEMAP_ADDITIVE,
17   HNG64_TILEMAP_ALPHA
18};
1913
2014
21struct blit_parameters
22{
23   bitmap_rgb32 *          bitmap;
24   rectangle           cliprect;
25   UINT32              tilemap_priority_code;
26   UINT8               mask;
27   UINT8               value;
28   UINT8               alpha;
29   hng64trans_t        drawformat;
30};
31
32
33
34///////////////////////
35// polygon rendering //
36///////////////////////
37
38struct polygonRasterOptions
39{
40   UINT8 texType;
41   UINT8 texIndex;
42   UINT8 texPageSmall;
43   UINT8 texPageHorizOffset;
44   UINT8 texPageVertOffset;
45   int palOffset;
46   int palPageSize;
47   int debugColor;
48};
49
5015class hng64_state : public driver_device
5116{
5217public:
r244679r244680
7540      m_screen(*this, "screen"),
7641      m_palette(*this, "palette"),
7742      m_generic_paletteram_32(*this, "paletteram")
43      { }
7844
79   { }
80   
8145   required_device<mips3_device> m_maincpu;
8246   required_device<cpu_device> m_audiocpu;
8347   required_device<cpu_device> m_comm;
r244679r244680
10670   required_device<palette_device> m_palette;
10771   required_shared_ptr<UINT32> m_generic_paletteram_32;
10872
109
11073   int m_mcu_type;
11174
11275   UINT16 *m_soundram;
r244679r244680
13497
13598   UINT8 m_screen_dis;
13699
137   struct hng64_tilemap {
138      tilemap_t *m_tilemap_8x8;
139      tilemap_t *m_tilemap_16x16;
140      tilemap_t *m_tilemap_16x16_alt;
141   };
100   tilemap_t *m_tilemap0_8x8;
101   tilemap_t *m_tilemap1_8x8;
102   tilemap_t *m_tilemap2_8x8;
103   tilemap_t *m_tilemap3_8x8;
142104
143   hng64_tilemap m_tilemap[4];
105   tilemap_t *m_tilemap0_16x16;
106   tilemap_t *m_tilemap1_16x16;
107   tilemap_t *m_tilemap2_16x16;
108   tilemap_t *m_tilemap3_16x16;
144109
110   tilemap_t *m_tilemap0_16x16_alt;
111   tilemap_t *m_tilemap1_16x16_alt;
112   tilemap_t *m_tilemap2_16x16_alt;
113   tilemap_t *m_tilemap3_16x16_alt;
114
145115   UINT8 m_additive_tilemap_debug;
146116
147117   // 3d display buffers
r244679r244680
151121
152122   UINT32 m_old_animmask;
153123   UINT32 m_old_animbits;
154   UINT16 m_old_tileflags[4];
124   UINT16 m_old_tileflags0;
125   UINT16 m_old_tileflags1;
126   UINT16 m_old_tileflags2;
127   UINT16 m_old_tileflags3;
155128
156129   UINT32 m_dls[2][0x81];
157130
r244679r244680
193166   DECLARE_READ32_MEMBER(unk_vreg_r);
194167   DECLARE_WRITE32_MEMBER(hng64_soundram_w);
195168   DECLARE_READ32_MEMBER(hng64_soundram_r);
196   DECLARE_WRITE32_MEMBER(hng64_vregs_w);
197169
198170   // not actually used, but left in code so you can turn it and see the (possibly undesired?) behavior, see notes in memory map
199171   DECLARE_WRITE32_MEMBER(hng64_soundram2_w);
r244679r244680
254226   DECLARE_CUSTOM_INPUT_MEMBER(brake_down_r);
255227   void clear3d();
256228   TIMER_CALLBACK_MEMBER(hng64_3dfifo_processed);
257
258   void FillSmoothTexPCHorizontalLine(
259      const polygonRasterOptions& prOptions,
260      int x_start, int x_end, int y, float z_start, float z_delta,
261      float w_start, float w_delta, float r_start, float r_delta,
262      float g_start, float g_delta, float b_start, float b_delta,
263      float s_start, float s_delta, float t_start, float t_delta);
264
265   void hng64_command3d(const UINT16* packet);
266   void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
267   void transition_control( bitmap_rgb32 &bitmap, const rectangle &cliprect);
268   void hng64_tilemap_draw_roz_core(screen_device &screen, tilemap_t *tmap, const blit_parameters *blit,
269      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound);
270   void hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm);
271   void setCameraTransformation(const UINT16* packet);
272   void setLighting(const UINT16* packet);
273   void set3dFlags(const UINT16* packet);
274   void setCameraProjectionMatrix(const UINT16* packet);
275   void recoverPolygonBlock(const UINT16* packet, struct polygon* polys, int* numPolys);
276   void hng64_mark_all_tiles_dirty(int tilemap);
277   void hng64_mark_tile_dirty(int tilemap, int tile_index);
278
279   void hng64_tilemap_draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
280      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
281      int wraparound, UINT32 flags, UINT8 priority, hng64trans_t drawformat);
282
283   void hng64_tilemap_draw_roz_primask(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
284      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
285      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask, hng64trans_t drawformat);
286
287   void RasterizeTriangle_SMOOTH_TEX_PC(
288      float A[4], float B[4], float C[4],
289      float Ca[3], float Cb[3], float Cc[3], // PER-VERTEX RGB COLORS
290      float Ta[2], float Tb[2], float Tc[2], // PER-VERTEX (S,T) TEX-COORDS
291      const polygonRasterOptions& prOptions);
292
293   void drawShaded( struct polygon *p);
294
295   void hng64_patch_bios_region(int region);
296
297229};
298230
231/*----------- defined in video/hng64.c -----------*/
232void hng64_command3d(running_machine& machine, const UINT16* packet);
trunk/src/mame/includes/tankbust.h
r244679r244680
4343   DECLARE_READ8_MEMBER(tankbust_soundtimer_r);
4444   TILE_GET_INFO_MEMBER(get_bg_tile_info);
4545   TILE_GET_INFO_MEMBER(get_txt_tile_info);
46    virtual void machine_start();
47    virtual void machine_reset();
46   virtual void machine_reset();
4847   virtual void video_start();
4948   DECLARE_PALETTE_INIT(tankbust);
5049   UINT32 screen_update_tankbust(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
trunk/src/mame/includes/thunderx.h
r244679r244680
6363   DECLARE_READ8_MEMBER(k052109_051960_r);
6464   DECLARE_WRITE8_MEMBER(k052109_051960_w);
6565   DECLARE_WRITE8_MEMBER(scontra_snd_bankswitch_w);
66    virtual void video_start();
66   virtual void video_start();
6767   DECLARE_MACHINE_START(scontra);
6868   DECLARE_MACHINE_RESET(scontra);
6969   DECLARE_MACHINE_START(thunderx);
trunk/src/mame/includes/tryout.h
r244679r244680
3636   TILE_GET_INFO_MEMBER(get_bg_tile_info);
3737   TILEMAP_MAPPER_MEMBER(get_fg_memory_offset);
3838   TILEMAP_MAPPER_MEMBER(get_bg_memory_offset);
39    virtual void machine_start();
40    virtual void video_start();
39   virtual void video_start();
4140   DECLARE_PALETTE_INIT(tryout);
4241   UINT32 screen_update_tryout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4342   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
trunk/src/mame/includes/usgames.h
r244679r244680
1717   DECLARE_WRITE8_MEMBER(usgames_videoram_w);
1818   DECLARE_WRITE8_MEMBER(usgames_charram_w);
1919   TILE_GET_INFO_MEMBER(get_usgames_tile_info);
20    virtual void machine_start();
21    virtual void video_start();
20   virtual void video_start();
2221   DECLARE_PALETTE_INIT(usgames);
2322   UINT32 screen_update_usgames(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2423   required_device<cpu_device> m_maincpu;
trunk/src/mame/includes/vigilant.h
r244679r244680
3838   DECLARE_WRITE8_MEMBER(vigilant_horiz_scroll_w);
3939   DECLARE_WRITE8_MEMBER(vigilant_rear_horiz_scroll_w);
4040   DECLARE_WRITE8_MEMBER(vigilant_rear_color_w);
41    virtual void machine_start();
42    virtual void video_start();
41   virtual void video_start();
4342   virtual void video_reset();
4443   UINT32 screen_update_vigilant(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4544   UINT32 screen_update_kikcubic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
trunk/src/mame/video/hng64.c
r244679r244680
77
88
99
10void hng64_state::hng64_mark_all_tiles_dirty( int tilemap )
10static void hng64_mark_all_tiles_dirty( hng64_state *state, int tilemap )
1111{
12   m_tilemap[tilemap].m_tilemap_8x8->mark_all_dirty();
13   m_tilemap[tilemap].m_tilemap_16x16->mark_all_dirty();
14   m_tilemap[tilemap].m_tilemap_16x16_alt->mark_all_dirty();
12   if (tilemap == 0)
13   {
14      state->m_tilemap0_8x8->mark_all_dirty();
15      state->m_tilemap0_16x16->mark_all_dirty();
16      state->m_tilemap0_16x16_alt->mark_all_dirty();
17   }
18   else if (tilemap == 1)
19   {
20      state->m_tilemap1_8x8->mark_all_dirty();
21      state->m_tilemap1_16x16->mark_all_dirty();
22      state->m_tilemap1_16x16_alt->mark_all_dirty();
23   }
24   else if (tilemap == 2)
25   {
26      state->m_tilemap2_8x8->mark_all_dirty();
27      state->m_tilemap2_16x16->mark_all_dirty();
28      state->m_tilemap2_16x16_alt->mark_all_dirty();
29   }
30   else if (tilemap == 3)
31   {
32      state->m_tilemap3_8x8->mark_all_dirty();
33      state->m_tilemap3_16x16->mark_all_dirty();
34      state->m_tilemap3_16x16_alt->mark_all_dirty();
35   }
1536}
1637
17void hng64_state::hng64_mark_tile_dirty( int tilemap, int tile_index )
38static void hng64_mark_tile_dirty( hng64_state *state, int tilemap, int tile_index )
1839{
19   m_tilemap[tilemap].m_tilemap_8x8->mark_tile_dirty(tile_index);
20   m_tilemap[tilemap].m_tilemap_16x16->mark_tile_dirty(tile_index);
21   m_tilemap[tilemap].m_tilemap_16x16_alt->mark_tile_dirty(tile_index);
40   if (tilemap == 0)
41   {
42      state->m_tilemap0_8x8->mark_tile_dirty(tile_index);
43      state->m_tilemap0_16x16->mark_tile_dirty(tile_index);
44      state->m_tilemap0_16x16_alt->mark_tile_dirty(tile_index);
45   }
46   else if (tilemap == 1)
47   {
48      state->m_tilemap1_8x8->mark_tile_dirty(tile_index);
49      state->m_tilemap1_16x16->mark_tile_dirty(tile_index);
50      state->m_tilemap1_16x16_alt->mark_tile_dirty(tile_index);
51   }
52   else if (tilemap == 2)
53   {
54      state->m_tilemap2_8x8->mark_tile_dirty(tile_index);
55      state->m_tilemap2_16x16->mark_tile_dirty(tile_index);
56      state->m_tilemap2_16x16_alt->mark_tile_dirty(tile_index);
57   }
58   else if (tilemap == 3)
59   {
60      state->m_tilemap3_8x8->mark_tile_dirty(tile_index);
61      state->m_tilemap3_16x16->mark_tile_dirty(tile_index);
62      state->m_tilemap3_16x16_alt->mark_tile_dirty(tile_index);
63   }
2264}
2365
2466
r244679r244680
63105 * 0x0e0 in Samurai Shodown/Xrally games, 0x1c0 in all the others, zooming factor?
64106 */
65107
66void hng64_state::draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
108static void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
67109{
110   hng64_state *state = screen.machine().driver_data<hng64_state>();
68111   gfx_element *gfx;
69   UINT32 *source = m_spriteram;
70   UINT32 *finish = m_spriteram + 0xc000/4;
112   UINT32 *source = state->m_spriteram;
113   UINT32 *finish = state->m_spriteram + 0xc000/4;
71114
72115   // global offsets in sprite regs
73   int spriteoffsx = (m_spriteregs[1]>>0)&0xffff;
74   int spriteoffsy = (m_spriteregs[1]>>16)&0xffff;
116   int spriteoffsx = (state->m_spriteregs[1]>>0)&0xffff;
117   int spriteoffsy = (state->m_spriteregs[1]>>16)&0xffff;
75118
76119#if 0
77120   for (int iii = 0; iii < 0x0f; iii++)
78      osd_printf_debug("%.8x ", m_videoregs[iii]);
121      osd_printf_debug("%.8x ", state->m_videoregs[iii]);
79122   osd_printf_debug("\n");
80123#endif
81124
r244679r244680
139182         int zoom_factor;
140183
141184         /* FIXME: regular zoom mode has precision bugs, can be easily seen in Samurai Shodown 64 intro */
142         zoom_factor = (m_spriteregs[0] & 0x08000000) ? 0x1000 : 0x100;
185         zoom_factor = (state->m_spriteregs[0] & 0x08000000) ? 0x1000 : 0x100;
143186         if(!zoomx) zoomx=zoom_factor;
144187         if(!zoomy) zoomy=zoom_factor;
145188
r244679r244680
154197         zoomy += (int)((foomY - floor(foomY)) * (float)0x10000);
155198      }
156199
157      if (m_spriteregs[0] & 0x00800000) //bpp switch
200      if (state->m_spriteregs[0] & 0x00800000) //bpp switch
158201      {
159         gfx= m_gfxdecode->gfx(4);
202         gfx= state->m_gfxdecode->gfx(4);
160203      }
161204      else
162205      {
163         gfx= m_gfxdecode->gfx(5);
206         gfx= state->m_gfxdecode->gfx(5);
164207         tileno>>=1;
165208         pal&=0xf;
166209      }
r244679r244680
219262               tileno=(source[4]&0x0007ffff);
220263               pal =(source[3]&0x00ff0000)>>16;
221264
222               if (m_spriteregs[0] & 0x00800000) //bpp switch
265               if (state->m_spriteregs[0] & 0x00800000) //bpp switch
223266               {
224                  gfx= m_gfxdecode->gfx(4);
267                  gfx= state->m_gfxdecode->gfx(4);
225268               }
226269               else
227270               {
228                  gfx= m_gfxdecode->gfx(5);
271                  gfx= state->m_gfxdecode->gfx(5);
229272                  tileno>>=1;
230273                  pal&=0xf;
231274               }
r244679r244680
285328 */
286329
287330/* this is broken for the 'How to Play' screen in Buriki after attract, disabled for now */
288void hng64_state::transition_control( bitmap_rgb32 &bitmap, const rectangle &cliprect)
331static void transition_control(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
289332{
290   UINT32 *hng64_tcram = m_tcram;
333   hng64_state *state = machine.driver_data<hng64_state>();
334   UINT32 *hng64_tcram = state->m_tcram;
291335   int i, j;
292336
293337//  float colorScaleR, colorScaleG, colorScaleB;
r244679r244680
504548WRITE32_MEMBER(hng64_state::hng64_videoram_w)
505549{
506550   int realoff;
551   hng64_state *state = machine().driver_data<hng64_state>();
507552   COMBINE_DATA(&m_videoram[offset]);
508553
509554   realoff = offset*4;
510555
511556   if ((realoff>=0) && (realoff<0x10000))
512557   {
513      hng64_mark_tile_dirty(0, offset&0x3fff);
558      hng64_mark_tile_dirty(state, 0, offset&0x3fff);
514559   }
515560   else if ((realoff>=0x10000) && (realoff<0x20000))
516561   {
517      hng64_mark_tile_dirty(1, offset&0x3fff);
562      hng64_mark_tile_dirty(state, 1, offset&0x3fff);
518563   }
519564   else if ((realoff>=0x20000) && (realoff<0x30000))
520565   {
521      hng64_mark_tile_dirty(2, offset&0x3fff);
566      hng64_mark_tile_dirty(state, 2, offset&0x3fff);
522567   }
523568   else if ((realoff>=0x30000) && (realoff<0x40000))
524569   {
525      hng64_mark_tile_dirty(3, offset&0x3fff);
570      hng64_mark_tile_dirty(state, 3, offset&0x3fff);
526571   }
527572
528573//  if ((realoff>=0x40000)) osd_printf_debug("offsw %08x %08x\n",realoff,data);
r244679r244680
531576}
532577
533578/* internal set of transparency states for rendering */
579enum hng64trans_t
580{
581   HNG64_TILEMAP_NORMAL = 1,
582   HNG64_TILEMAP_ADDITIVE,
583   HNG64_TILEMAP_ALPHA
584};
534585
535586
587struct blit_parameters
588{
589   bitmap_rgb32 *          bitmap;
590   rectangle           cliprect;
591   UINT32              tilemap_priority_code;
592   UINT8               mask;
593   UINT8               value;
594   UINT8               alpha;
595   hng64trans_t        drawformat;
596};
597
598
599
536600static void hng64_configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 flags, UINT8 priority, UINT8 priority_mask, hng64trans_t drawformat)
537601{
538602   /* start with nothing */
r244679r244680
609673      *(UINT32 *)dest = alpha_blend_r32(*(UINT32 *)dest, clut[INPUT_VAL], alpha); \
610674} while (0)
611675
612void hng64_state::hng64_tilemap_draw_roz_core(screen_device &screen, tilemap_t *tmap, const blit_parameters *blit,
676static void hng64_tilemap_draw_roz_core(screen_device &screen, tilemap_t *tmap, const blit_parameters *blit,
613677      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound)
614678{
615   const pen_t *clut = &m_palette->pen(blit->tilemap_priority_code >> 16);
679   hng64_state *state = screen.machine().driver_data<hng64_state>();
680   const pen_t *clut = &state->m_palette->pen(blit->tilemap_priority_code >> 16);
616681   bitmap_ind8 &priority_bitmap = screen.priority();
617682   bitmap_rgb32 &destbitmap = *blit->bitmap;
618683   bitmap_ind16 &srcbitmap = tmap->pixmap();
r244679r244680
786851
787852
788853
789void hng64_state::hng64_tilemap_draw_roz_primask(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
854static void hng64_tilemap_draw_roz_primask(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
790855      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
791856      int wraparound, UINT32 flags, UINT8 priority, UINT8 priority_mask, hng64trans_t drawformat)
792857{
r244679r244680
814879}
815880
816881
817inline void hng64_state::hng64_tilemap_draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
882INLINE void hng64_tilemap_draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap,
818883      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy,
819884      int wraparound, UINT32 flags, UINT8 priority, hng64trans_t drawformat)
820885{
r244679r244680
823888
824889
825890
826void hng64_state::hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm )
891static void hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm )
827892{
828   UINT32 *hng64_videoregs = m_videoregs;
829   UINT32 *hng64_videoram = m_videoram;
893   hng64_state *state = screen.machine().driver_data<hng64_state>();
894   UINT32 *hng64_videoregs = state->m_videoregs;
895   UINT32 *hng64_videoram = state->m_videoram;
830896   tilemap_t* tilemap = 0;
831897   UINT32 scrollbase = 0;
832898   UINT32 tileregs = 0;
r244679r244680
837903
838904   int global_dimensions = (global_tileregs&0x03000000)>>24;
839905
840   if ( (m_additive_tilemap_debug&(1 << tm)))
906   if ( (state->m_additive_tilemap_debug&(1 << tm)))
841907      debug_blend_enabled = 1;
842908
843909   if ((global_dimensions != 0) && (global_dimensions != 3))
r244679r244680
847913   {
848914      scrollbase = (hng64_videoregs[0x04]&0x3fff0000)>>16;
849915      tileregs   = (hng64_videoregs[0x02]&0xffff0000)>>16;
916
917      if (global_dimensions==0)
918      {
919         if (tileregs&0x0200)    tilemap = state->m_tilemap0_16x16;
920         else tilemap = state->m_tilemap0_8x8;
921      }
922      else
923      {
924         if (tileregs&0x0200)    tilemap = state->m_tilemap0_16x16_alt;
925         else tilemap = state->m_tilemap0_8x8; // _alt
926      }
850927   }
851928   else if (tm==1)
852929   {
853930      scrollbase = (hng64_videoregs[0x04]&0x00003fff)>>0;
854931      tileregs   = (hng64_videoregs[0x02]&0x0000ffff)>>0;
932
933      if (global_dimensions==0)
934      {
935         if (tileregs&0x0200)    tilemap = state->m_tilemap1_16x16;
936         else tilemap = state->m_tilemap1_8x8;
937      }
938      else
939      {
940         if (tileregs&0x0200)    tilemap = state->m_tilemap1_16x16_alt;
941         else tilemap = state->m_tilemap1_8x8; // _alt
942      }
855943   }
856944   else if (tm==2)
857945   {
858946      scrollbase = (hng64_videoregs[0x05]&0x3fff0000)>>16;
859947      tileregs   = (hng64_videoregs[0x03]&0xffff0000)>>16;
948
949      if (global_dimensions==0)
950      {
951         if (tileregs&0x0200)    tilemap = state->m_tilemap2_16x16;
952         else tilemap = state->m_tilemap2_8x8;
953      }
954      else
955      {
956         if (tileregs&0x0200)    tilemap = state->m_tilemap2_16x16_alt;
957         else tilemap = state->m_tilemap2_8x8; // _alt
958      }
860959   }
861960   else if (tm==3)
862961   {
863962      scrollbase = (hng64_videoregs[0x05]&0x00003fff)>>0;
864963      tileregs   = (hng64_videoregs[0x03]&0x0000ffff)>>0;
865   }
866964
867   if (global_dimensions==0)
868   {
869      if (tileregs&0x0200)    tilemap = m_tilemap[tm].m_tilemap_16x16;
870      else tilemap = m_tilemap[tm].m_tilemap_8x8;
965      if (global_dimensions==0)
966      {
967         if (tileregs&0x0200)    tilemap = state->m_tilemap3_16x16;
968         else tilemap = state->m_tilemap3_8x8;
969      }
970      else
971      {
972         if (tileregs&0x0200)    tilemap = state->m_tilemap3_16x16_alt;
973         else tilemap = state->m_tilemap3_8x8; // _alt
974      }
871975   }
872   else
873   {
874      if (tileregs&0x0200)    tilemap = m_tilemap[tm].m_tilemap_16x16_alt;
875      else tilemap = m_tilemap[tm].m_tilemap_8x8; // _alt
876   }
877976
878977   // xrally's pink tilemaps make me think this is a tilemap enable bit.
879978   // fatfurwa makes me think otherwise.
880//   if (!(tileregs & 0x0040)) return;
979   //if (!(tileregs & 0x0040)) return;
881980
882981   // set the transmask so our manual copy is correct
883982   if (tileregs & 0x0400)
r244679r244680
10271126            bitmap_ind16 &bm = tilemap->pixmap();
10281127            int bmheight = bm.height();
10291128            int bmwidth = bm.width();
1030            const pen_t *paldata = m_palette->pens();
1129            const pen_t *paldata = state->m_palette->pens();
10311130            UINT32* dstptr;
10321131            UINT16* srcptr;
10331132            int xx,yy;
r244679r244680
11231222            bitmap_ind16 &bm = tilemap->pixmap();
11241223            int bmheight = bm.height();
11251224            int bmwidth = bm.width();
1126            const pen_t *paldata = m_palette->pens();
1225            const pen_t *paldata = state->m_palette->pens();
11271226            UINT32* dstptr;
11281227            UINT16* srcptr;
11291228            int xx,yy;
r244679r244680
12121311    // 0940 - samurai shodown 64
12131312    // 0880 - buriki
12141313
1215    // mmmm dbrz zzzz zzzz
1314    // mmmm dbr? ??e? ????
12161315    // m = mosaic related?
12171316    //  -- they seem to enable mosaic at the same time as rowscroll in several cases (floor in buriki / ff)
12181317    //     and also on the rotating logo in buriki.. does it cause some kind of aliasing side-effect, or.. ?
12191318    // r = tile size (seems correct)
12201319    // b = 4bpp/8bpp (seems correct) (beast busters, samsh64, sasm64 2, xrally switch it for some screens)
12211320    // d = line (floor) mode - buriki, fatafurwa, some backgrounds in ss64_2
1222    // z = z depth? tilemaps might also be affected by min / max clip values somewhere? (debug layer on buriki has priority 0x020, which would be highest)
1321    // e = enable according to sams64_2 debug mode, buriki and xrally.. but NOT fatal fury :-(
12231322
12241323
12251324 */
r244679r244680
12351334   UINT32 *hng64_tcram = m_tcram;
12361335   UINT32 animmask;
12371336   UINT32 animbits;
1238   UINT16 tileflags[4];
1337   UINT16 tileflags0, tileflags1;
1338   UINT16 tileflags2, tileflags3;
12391339
12401340#if 0
12411341   // press in sams64_2 attract mode for a nice debug screen from the game
r244679r244680
12561356
12571357   animmask = hng64_videoregs[0x0b];
12581358   animbits = hng64_videoregs[0x0c];
1259   tileflags[0] = hng64_videoregs[0x02]>>16;
1260   tileflags[1] = hng64_videoregs[0x02]&0xffff;
1261   tileflags[2] = hng64_videoregs[0x03]>>16;
1262   tileflags[3] = hng64_videoregs[0x03]&0xffff;
1359   tileflags0 = hng64_videoregs[0x02]>>16;
1360   tileflags1 = hng64_videoregs[0x02]&0xffff;
1361   tileflags2 = hng64_videoregs[0x03]>>16;
1362   tileflags3 = hng64_videoregs[0x03]&0xffff;
12631363
12641364   /* if the auto-animation mask or bits have changed search for tiles using them and mark as dirty */
12651365   if ((m_old_animmask != animmask) || (m_old_animbits != animbits))
r244679r244680
12691369      {
12701370         if (hng64_videoram[tile_index+(0x00000/4)]&0x200000)
12711371         {
1272            hng64_mark_tile_dirty(0, tile_index);
1372            hng64_mark_tile_dirty(this, 0, tile_index);
12731373         }
12741374         if (hng64_videoram[tile_index+(0x10000/4)]&0x200000)
12751375         {
1276            hng64_mark_tile_dirty(1, tile_index);
1376            hng64_mark_tile_dirty(this, 1, tile_index);
12771377         }
12781378         if (hng64_videoram[tile_index+(0x20000/4)]&0x200000)
12791379         {
1280            hng64_mark_tile_dirty(2, tile_index);
1380            hng64_mark_tile_dirty(this, 2, tile_index);
12811381         }
12821382         if (hng64_videoram[tile_index+(0x30000/4)]&0x200000)
12831383         {
1284            hng64_mark_tile_dirty(3, tile_index);
1384            hng64_mark_tile_dirty(this, 3, tile_index);
12851385         }
12861386      }
12871387
r244679r244680
12891389      m_old_animbits = animbits;
12901390   }
12911391
1292   for (int i = 0; i < 4; i++)
1392   if ((m_old_tileflags0&IMPORTANT_DIRTY_TILEFLAG_MASK)!=(tileflags0&IMPORTANT_DIRTY_TILEFLAG_MASK))
12931393   {
1294      if ((m_old_tileflags[i]&IMPORTANT_DIRTY_TILEFLAG_MASK)!=(tileflags[i]&IMPORTANT_DIRTY_TILEFLAG_MASK))
1295      {
1296         hng64_mark_all_tiles_dirty(i);
1297         m_old_tileflags[i] = tileflags[i];
1298      }
1394      hng64_mark_all_tiles_dirty(this, 0);
1395      m_old_tileflags0 = tileflags0;
12991396   }
13001397
1398   if ((m_old_tileflags1&IMPORTANT_DIRTY_TILEFLAG_MASK)!=(tileflags1&IMPORTANT_DIRTY_TILEFLAG_MASK))
1399   {
1400      hng64_mark_all_tiles_dirty(this, 1);
1401      m_old_tileflags1 = tileflags1;
1402   }
13011403
1404   if ((m_old_tileflags2&IMPORTANT_DIRTY_TILEFLAG_MASK)!=(tileflags2&IMPORTANT_DIRTY_TILEFLAG_MASK))
1405   {
1406      hng64_mark_all_tiles_dirty(this, 2);
1407      m_old_tileflags2 = tileflags2;
1408   }
1409
1410   if ((m_old_tileflags3&IMPORTANT_DIRTY_TILEFLAG_MASK)!=(tileflags3&IMPORTANT_DIRTY_TILEFLAG_MASK))
1411   {
1412      hng64_mark_all_tiles_dirty(this, 3);
1413      m_old_tileflags3 = tileflags3;
1414   }
1415
1416   // mark all frames as dirty if for some reason we don't trust the above code
1417   //hng64_mark_all_tiles_dirty(this, 0);
1418   //hng64_mark_all_tiles_dirty(this, 1);
1419   //hng64_mark_all_tiles_dirty(this, 2);
1420   //hng64_mark_all_tiles_dirty(this, 3);
1421
13021422   hng64_drawtilemap(screen,bitmap,cliprect, 3);
13031423   hng64_drawtilemap(screen,bitmap,cliprect, 2);
13041424   hng64_drawtilemap(screen,bitmap,cliprect, 1);
r244679r244680
13301450   draw_sprites(screen, bitmap,cliprect);
13311451
13321452   if(0)
1333      transition_control(bitmap, cliprect);
1453      transition_control(machine(), bitmap, cliprect);
13341454
13351455   if (0)
13361456      popmessage("%08x %08x %08x %08x %08x", m_spriteregs[0], m_spriteregs[1], m_spriteregs[2], m_spriteregs[3], m_spriteregs[4]);
13371457
1338   if (1)
1339   popmessage("%08x %08x TR(%04x %04x %04x %04x) SB(%04x %04x %04x %04x) %08x %08x %08x %08x %08x AA(%08x %08x) %08x",
1458   if (0)
1459   popmessage("%08x %08x TR(%04x %04x %04x %04x) SB(%04x %04x %04x %04x) %08x %08x %08x %08x %08x AA(%08x %08x) %08x %08x",
13401460      hng64_videoregs[0x00],
13411461      hng64_videoregs[0x01],
1342   (hng64_videoregs[0x02]>>16)&0x01ff, // ----  bits we're sure about are masked out
1343   (hng64_videoregs[0x02]>>0)&0x01ff,  //  ss64_2 debug mode indicates that 0x0040 is enable!
1344   (hng64_videoregs[0x03]>>16)&0x01ff, //   buriki agrees (debug data on text layer) xrally agress (pink layer)
1345   (hng64_videoregs[0x03]>>0)&0x01ff,  //   fatal fury doesn't (all backgrounds have it set) joy
1462   (hng64_videoregs[0x02]>>16)&0xf9ff, // ----  bits we're sure about are masked out
1463   (hng64_videoregs[0x02]>>0)&0xf9ff,  //  ss64_2 debug mode indicates that 0x0040 is enable!
1464   (hng64_videoregs[0x03]>>16)&0xf9ff, //   buriki agrees (debug data on text layer) xrally agress (pink layer)
1465   (hng64_videoregs[0x03]>>0)&0xf9ff,  //   fatal fury doesn't (all backgrounds have it set) joy
13461466   (hng64_videoregs[0x04]>>16)&0xffff,
13471467   (hng64_videoregs[0x04]>>0)&0xffff,
13481468   (hng64_videoregs[0x05]>>16)&0xffff,
r244679r244680
13541474      hng64_videoregs[0x0a],
13551475      hng64_videoregs[0x0b],
13561476      hng64_videoregs[0x0c],
1357      hng64_videoregs[0x0d]);
1477      hng64_videoregs[0x0d],
1478      hng64_videoregs[0x0e]);
13581479
13591480   if (0)
13601481   popmessage("3D: %08x %08x %08x %08x : %08x %08x %08x %08x : %08x %08x %08x %08x",
r244679r244680
14261547
14271548   m_old_animmask = -1;
14281549   m_old_animbits = -1;
1429   m_old_tileflags[0] = -1;
1430   m_old_tileflags[1] = -1;
1431   m_old_tileflags[2] = -1;
1432   m_old_tileflags[3] = -1;
1550   m_old_tileflags0 = -1;
1551   m_old_tileflags1 = -1;
1552   m_old_tileflags2 = -1;
1553   m_old_tileflags3 = -1;
14331554
1434   m_tilemap[0].m_tilemap_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile0_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1435   m_tilemap[0].m_tilemap_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile0_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1436   m_tilemap[0].m_tilemap_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile0_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
1555   m_tilemap0_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile0_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1556   m_tilemap0_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile0_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1557   m_tilemap0_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile0_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
14371558
1438   m_tilemap[1].m_tilemap_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile1_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1439   m_tilemap[1].m_tilemap_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile1_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1440   m_tilemap[1].m_tilemap_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile1_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
1559   m_tilemap1_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile1_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1560   m_tilemap1_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile1_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1561   m_tilemap1_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile1_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
14411562
1442   m_tilemap[2].m_tilemap_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile2_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1443   m_tilemap[2].m_tilemap_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile2_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1444   m_tilemap[2].m_tilemap_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile2_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
1563   m_tilemap2_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile2_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1564   m_tilemap2_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile2_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1565   m_tilemap2_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile2_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
14451566
1446   m_tilemap[3].m_tilemap_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1447   m_tilemap[3].m_tilemap_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1448   m_tilemap[3].m_tilemap_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
1567   m_tilemap3_8x8       = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_8x8_info),this),   TILEMAP_SCAN_ROWS,  8,   8, 128, 128); /* 128x128x4 = 0x10000 */
1568   m_tilemap3_16x16     = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 128, 128); /* 128x128x4 = 0x10000 */
1569   m_tilemap3_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_16x16_info),this), TILEMAP_SCAN_ROWS,  16, 16, 256,  64); /* 128x128x4 = 0x10000 */
14491570
1450   for (int i = 0; i < 4; i++)
1451   {
1452      m_tilemap[i].m_tilemap_8x8->set_transparent_pen(0);
1453      m_tilemap[i].m_tilemap_16x16->set_transparent_pen(0);
1454      m_tilemap[i].m_tilemap_16x16_alt->set_transparent_pen(0);
1455   }
1571   m_tilemap0_8x8->set_transparent_pen(0);
1572   m_tilemap0_16x16->set_transparent_pen(0);
1573   m_tilemap0_16x16_alt->set_transparent_pen(0);
14561574
1575   m_tilemap1_8x8->set_transparent_pen(0);
1576   m_tilemap1_16x16->set_transparent_pen(0);
1577   m_tilemap1_16x16_alt->set_transparent_pen(0);
1578
1579   m_tilemap2_8x8->set_transparent_pen(0);
1580   m_tilemap2_16x16->set_transparent_pen(0);
1581   m_tilemap2_16x16_alt->set_transparent_pen(0);
1582
1583   m_tilemap3_8x8->set_transparent_pen(0);
1584   m_tilemap3_16x16->set_transparent_pen(0);
1585   m_tilemap3_16x16_alt->set_transparent_pen(0);
1586
14571587   // Debug switch, turn on / off additive blending on a per-tilemap basis
14581588   m_additive_tilemap_debug = 0;
14591589
r244679r244680
15041634static void vecmatmul4(float *product, const float *a, const float *b);
15051635static float vecDotProduct(const float *a, const float *b);
15061636static void normalize(float* x);
1637
15071638static void performFrustumClip(struct polygon *p);
1639static void drawShaded(running_machine &machine, struct polygon *p);
1640//static void plot(running_machine &machine, INT32 x, INT32 y, UINT32 color);
1641//static void drawline2d(running_machine &machine, INT32 x0, INT32 y0, INT32 x1, INT32 y1, UINT32 color);
1642//static void DrawWireframe(running_machine &machine, struct polygon *p);
1643
15081644static float uToF(UINT16 input);
15091645
15101646
r244679r244680
15421678
15431679// Operation 0001
15441680// Camera transformation.
1545void hng64_state::setCameraTransformation(const UINT16* packet)
1681static void setCameraTransformation(hng64_state *state, const UINT16* packet)
15461682{
1547   float *cameraMatrix = m_cameraMatrix;
1683   float *cameraMatrix = state->m_cameraMatrix;
15481684
15491685   /*//////////////
15501686   // PACKET FORMAT
r244679r244680
15891725
15901726// Operation 0010
15911727// Lighting information
1592void hng64_state::setLighting(const UINT16* packet)
1728static void setLighting(hng64_state *state, const UINT16* packet)
15931729{
1594   float *lightVector = m_lightVector;
1730   float *lightVector = state->m_lightVector;
15951731
15961732   /*//////////////
15971733   // PACKET FORMAT
r244679r244680
16181754   lightVector[0] = uToF(packet[3]);
16191755   lightVector[1] = uToF(packet[4]);
16201756   lightVector[2] = uToF(packet[5]);
1621   m_lightStrength = uToF(packet[9]);
1757   state->m_lightStrength = uToF(packet[9]);
16221758}
16231759
16241760// Operation 0011
16251761// Palette / Model flags?
1626void hng64_state::set3dFlags(const UINT16* packet)
1762static void set3dFlags(hng64_state *state, const UINT16* packet)
16271763{
16281764   /*//////////////
16291765   // PACKET FORMAT
r244679r244680
16441780   // [14] - ???? ... ? ''  ''
16451781   // [15] - ???? ... ? ''  ''
16461782   ////////////*/
1647   m_paletteState3d = (packet[8] & 0xff00) >> 8;
1783   state->m_paletteState3d = (packet[8] & 0xff00) >> 8;
16481784}
16491785
16501786// Operation 0012
16511787// Projection Matrix.
1652void hng64_state::setCameraProjectionMatrix(const UINT16* packet)
1788static void setCameraProjectionMatrix(hng64_state *state, const UINT16* packet)
16531789{
1654   float *projectionMatrix = m_projectionMatrix;
1790   float *projectionMatrix = state->m_projectionMatrix;
16551791
16561792   /*//////////////
16571793   // PACKET FORMAT
r244679r244680
17071843
17081844// Operation 0100
17091845// Polygon rasterization.
1710void hng64_state::recoverPolygonBlock(const UINT16* packet, struct polygon* polys, int* numPolys)
1846static void recoverPolygonBlock(running_machine& machine, const UINT16* packet, struct polygon* polys, int* numPolys)
17111847{
17121848   /*//////////////
17131849   // PACKET FORMAT
r244679r244680
17441880   // [15] - xxxx ... Transformation matrix
17451881   ////////////*/
17461882
1883   hng64_state *state = machine.driver_data<hng64_state>();
17471884   UINT32 size[4];
17481885   UINT32 address[4];
17491886   UINT32 megaOffset;
r244679r244680
17571894   setIdentity(objectMatrix);
17581895
17591896   struct polygon lastPoly = { 0 };
1760   const rectangle &visarea = m_screen->visible_area();
1897   const rectangle &visarea = machine.first_screen()->visible_area();
17611898
17621899   /////////////////
17631900   // HEADER INFO //
r244679r244680
18131950   //////////////////////////////////////////////*/
18141951
18151952   // 3d ROM Offset
1816   UINT16* threeDRoms = (UINT16*)memregion("verts")->base();
1953   UINT16* threeDRoms = (UINT16*)(machine.root_device().memregion("verts")->base());
18171954   UINT32  threeDOffset = (((UINT32)packet[2]) << 16) | ((UINT32)packet[3]);
18181955   UINT16* threeDPointer = &threeDRoms[threeDOffset * 3];
18191956
1820   if (threeDOffset >= memregion("verts")->bytes())
1957   if (threeDOffset >= machine.root_device().memregion("verts")->bytes())
18211958   {
18221959      printf("Strange geometry packet: (ignoring)\n");
18231960      printPacket(packet, 1);
r244679r244680
19422079         /* FIXME: This isn't correct.
19432080                   Buriki & Xrally need this line.  Roads Edge needs it removed.
19442081                   So instead we're looking for a bit that is on for XRally & Buriki, but noone else. */
1945         if (m_3dregs[0x00/4] & 0x2000)
2082         if (state->m_3dregs[0x00/4] & 0x2000)
19462083         {
1947            if (strcmp(machine().basename(), "roadedge"))
2084            if (strcmp(machine.basename(), "roadedge"))
19482085               polys[*numPolys].palOffset += 0x800;
19492086         }
19502087
r244679r244680
19582095         // Apply the dynamic palette offset if its flag is set, otherwise stick with the fixed one
19592096         if ((packet[1] & 0x0100))
19602097         {
1961            explicitPaletteValue1 = m_paletteState3d * 0x80;
2098            explicitPaletteValue1 = state->m_paletteState3d * 0x80;
19622099            explicitPaletteValue2 = 0;      // This is probably hiding somewhere in operation 0011
19632100         }
19642101
r244679r244680
21522289         ////////////////////////////////////
21532290         // Perform the world transformations...
21542291         // !! Can eliminate this step with a matrix stack (maybe necessary?) !!
2155         setIdentity(m_modelViewMatrix);
2156         if (m_mcu_type != SAMSHO_MCU)
2292         setIdentity(state->m_modelViewMatrix);
2293         if (state->m_mcu_type != SAMSHO_MCU)
21572294         {
21582295            // The sams64 games transform the geometry in front of a stationary camera.
21592296            // This is fine in sams64_2, since it never calls the 'camera transformation' function
21602297            // (thus using the identity matrix for this transform), but sams64 calls the
21612298            // camera transformation function with rotation values.
21622299            // It remains to be seen what those might do...
2163            matmul4(m_modelViewMatrix, m_modelViewMatrix, m_cameraMatrix);
2300            matmul4(state->m_modelViewMatrix, state->m_modelViewMatrix, state->m_cameraMatrix);
21642301         }
2165         matmul4(m_modelViewMatrix, m_modelViewMatrix, objectMatrix);
2302         matmul4(state->m_modelViewMatrix, state->m_modelViewMatrix, objectMatrix);
21662303
21672304         // LIGHTING
2168         if (packet[1] & 0x0008 && m_lightStrength > 0.0f)
2305         if (packet[1] & 0x0008 && state->m_lightStrength > 0.0f)
21692306         {
21702307            for (int v = 0; v < 3; v++)
21712308            {
21722309               float transformedNormal[4];
21732310               vecmatmul4(transformedNormal, objectMatrix, polys[*numPolys].vert[v].normal);
21742311               normalize(transformedNormal);
2175               normalize(m_lightVector);
2312               normalize(state->m_lightVector);
21762313
2177               float intensity = vecDotProduct(transformedNormal, m_lightVector) * -1.0f;
2314               float intensity = vecDotProduct(transformedNormal, state->m_lightVector) * -1.0f;
21782315               intensity = (intensity <= 0.0f) ? (0.0f) : (intensity);
2179               intensity *= m_lightStrength * 128.0f;    // Turns 0x0100 into 1.0
2316               intensity *= state->m_lightStrength * 128.0f;    // Turns 0x0100 into 1.0
21802317               intensity *= 128.0;                     // Maps intensity to the range [0.0, 2.0]
21812318               if (intensity >= 255.0f) intensity = 255.0f;
21822319
r244679r244680
22192356
22202357
22212358         // BEHIND-THE-CAMERA CULL //
2222         vecmatmul4(cullRay, m_modelViewMatrix, polys[*numPolys].vert[0].worldCoords);
2359         vecmatmul4(cullRay, state->m_modelViewMatrix, polys[*numPolys].vert[0].worldCoords);
22232360         if (cullRay[2] > 0.0f)              // Camera is pointing down -Z
22242361         {
22252362            polys[*numPolys].visible = 0;
r244679r244680
22322369            for (int m = 0; m < polys[*numPolys].n; m++)
22332370            {
22342371               // Transform and project the vertex into pre-divided homogeneous coordinates...
2235               vecmatmul4(eyeCoords, m_modelViewMatrix, polys[*numPolys].vert[m].worldCoords);
2236               vecmatmul4(polys[*numPolys].vert[m].clipCoords, m_projectionMatrix, eyeCoords);
2372               vecmatmul4(eyeCoords, state->m_modelViewMatrix, polys[*numPolys].vert[m].worldCoords);
2373               vecmatmul4(polys[*numPolys].vert[m].clipCoords, state->m_projectionMatrix, eyeCoords);
22372374            }
22382375
22392376            if (polys[*numPolys].visible)
r244679r244680
22732410   }
22742411}
22752412
2276void hng64_state::hng64_command3d(const UINT16* packet)
2413void hng64_command3d(running_machine& machine, const UINT16* packet)
22772414{
2415   hng64_state *state = machine.driver_data<hng64_state>();
22782416
22792417   /* A temporary place to put some polygons.  This will optimize away if the compiler's any good. */
22802418   int numPolys = 0;
22812419   dynamic_array<polygon> polys(1024*5);
22822420
2283   //printf("packet type : %04x %04x|%04x %04x|%04x %04x|%04x %04x  | %04x %04x %04x %04x %04x %04x %04x %04x\n", packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7],     packet[8], packet[9], packet[10], packet[11], packet[12], packet[13], packet[14], packet[15]);
2284   
2421   //printf("packet type : %04x %04x|%04x %04x|%04x %04x|%04x %04x\n", packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7]);
22852422   switch (packet[0])
22862423   {
22872424   case 0x0000:    // Appears to be a NOP.
22882425      break;
22892426
22902427   case 0x0001:    // Camera transformation.
2291      setCameraTransformation(packet);
2428      setCameraTransformation(state, packet);
22922429      break;
22932430
22942431   case 0x0010:    // Lighting information.
22952432      //if (packet[9]) printPacket(packet, 1);
2296      setLighting(packet);
2433      setLighting(state, packet);
22972434      break;
22982435
22992436   case 0x0011:    // Palette / Model flags?
23002437      //printPacket(packet, 1); printf("\n");
2301      set3dFlags(packet);
2438      set3dFlags(state, packet);
23022439      break;
23032440
23042441   case 0x0012:    // Projection Matrix
23052442      //printPacket(packet, 1);
2306      setCameraProjectionMatrix(packet);
2443      setCameraProjectionMatrix(state, packet);
23072444      break;
23082445
23092446   case 0x0100:
23102447   case 0x0101:    // Geometry with full transformations
23112448      // HACK.  Masks out a piece of geo bbust2's drawShaded() crashes on.
2312      if (packet[2] == 0x0003 && packet[3] == 0x8f37 && m_mcu_type == SHOOT_MCU)
2449      if (packet[2] == 0x0003 && packet[3] == 0x8f37 && state->m_mcu_type == SHOOT_MCU)
23132450         break;
23142451
2315      recoverPolygonBlock( packet, polys, &numPolys);
2452      recoverPolygonBlock(machine, packet, polys, &numPolys);
23162453      break;
23172454
23182455   case 0x0102:    // Geometry with only translation
r244679r244680
23322469      miniPacket[7] = 0x7fff;
23332470      miniPacket[11] = 0x7fff;
23342471      miniPacket[15] = 0x7fff;
2335      recoverPolygonBlock( miniPacket, polys, &numPolys);
2472      recoverPolygonBlock(machine, miniPacket, polys, &numPolys);
23362473
23372474      memset(miniPacket, 0, sizeof(UINT16)*16);
23382475      for (int i = 0; i < 7; i++) miniPacket[i] = packet[i+8];
2339      for (int i = 0; i < 7; i++) miniPacket[i] = packet[i+8];
23402476      miniPacket[7] = 0x7fff;
23412477      miniPacket[11] = 0x7fff;
23422478      miniPacket[15] = 0x7fff;
2343      recoverPolygonBlock( miniPacket, polys, &numPolys);
2479      recoverPolygonBlock(machine, miniPacket, polys, &numPolys);
23442480      break;
23452481
23462482   case 0x1000:    // Unknown: Some sort of global flags?
r244679r244680
23612497   {
23622498      if (polys[i].visible)
23632499      {
2364         //DrawWireframe( &polys[i]);
2365         drawShaded( &polys[i]);
2500         //DrawWireframe(machine, &polys[i]);
2501         drawShaded(machine, &polys[i]);
23662502      }
23672503   }
23682504}
r244679r244680
26482784// wireframe rendering //
26492785/////////////////////////
26502786#ifdef UNUSED_FUNCTION
2651static void plot( INT32 x, INT32 y, UINT32 color)
2787static void plot(running_machine &machine, INT32 x, INT32 y, UINT32 color)
26522788{
26532789   UINT32* cb = &(colorBuffer3d[(y * machine.first_screen()->visible_area().max_x) + x]);
26542790   *cb = color;
26552791}
26562792
26572793// Stolen from http://en.wikipedia.org/wiki/Bresenham's_line_algorithm (no copyright denoted) - the non-optimized version
2658static void drawline2d( INT32 x0, INT32 y0, INT32 x1, INT32 y1, UINT32 color)
2794static void drawline2d(running_machine &machine, INT32 x0, INT32 y0, INT32 x1, INT32 y1, UINT32 color)
26592795{
26602796#define SWAP(a,b) tmpswap = a; a = b; b = tmpswap;
26612797
r244679r244680
26932829   {
26942830      if (steep)
26952831      {
2696         plot( x0, y0, color);
2832         plot(machine, x0, y0, color);
26972833      }
26982834      else
26992835      {
2700         plot( y0, x0, color);
2836         plot(machine, y0, x0, color);
27012837      }
27022838      while (e >= 0)
27032839      {
r244679r244680
27112847#undef SWAP
27122848}
27132849
2714static void DrawWireframe( struct polygon *p)
2850static void DrawWireframe(running_machine &machine, struct polygon *p)
27152851{
27162852   int j;
27172853   for (j = 0; j < p->n; j++)
r244679r244680
27192855      // osd_printf_debug("now drawing : %f %f %f, %f %f %f\n", p->vert[j].clipCoords[0], p->vert[j].clipCoords[1], p->vert[j].clipCoords[2], p->vert[(j+1)%p->n].clipCoords[0], p->vert[(j+1)%p->n].clipCoords[1], p->vert[(j+1)%p->n].clipCoords[2]);
27202856      // osd_printf_debug("%f %f %f %f\n", p->vert[j].clipCoords[0], p->vert[j].clipCoords[1], p->vert[(j+1)%p->n].clipCoords[0], p->vert[(j+1)%p->n].clipCoords[1]);
27212857      UINT32 color = rgb_t((UINT8)255, (UINT8)255, (UINT8)0, (UINT8)0);
2722      drawline2d( p->vert[j].clipCoords[0], p->vert[j].clipCoords[1], p->vert[(j+1)%p->n].clipCoords[0], p->vert[(j+1)%p->n].clipCoords[1], color);
2858      drawline2d(machine, p->vert[j].clipCoords[0], p->vert[j].clipCoords[1], p->vert[(j+1)%p->n].clipCoords[0], p->vert[(j+1)%p->n].clipCoords[1], color);
27232859   }
27242860
27252861   // SHOWS THE CLIPPING //
r244679r244680
27342870}
27352871#endif
27362872
2873///////////////////////
2874// polygon rendering //
2875///////////////////////
27372876
2877struct polygonRasterOptions
2878{
2879   UINT8 texType;
2880   UINT8 texIndex;
2881   UINT8 texPageSmall;
2882   UINT8 texPageHorizOffset;
2883   UINT8 texPageVertOffset;
2884   int palOffset;
2885   int palPageSize;
2886   int debugColor;
2887};
2888
27382889/*********************************************************************/
27392890/**   FillSmoothTexPCHorizontalLine                                 **/
27402891/**     Input: Color Buffer (framebuffer), depth buffer, width and  **/
r244679r244680
27442895/**                                                                 **/
27452896/**     Output: none                                                **/
27462897/*********************************************************************/
2747inline void hng64_state::FillSmoothTexPCHorizontalLine(
2898INLINE void FillSmoothTexPCHorizontalLine(running_machine &machine,
27482899                                 const polygonRasterOptions& prOptions,
27492900                                 int x_start, int x_end, int y, float z_start, float z_delta,
27502901                                 float w_start, float w_delta, float r_start, float r_delta,
27512902                                 float g_start, float g_delta, float b_start, float b_delta,
27522903                                 float s_start, float s_delta, float t_start, float t_delta)
27532904{
2754   float*  db = &(m_depthBuffer3d[(y * m_screen->visible_area().max_x) + x_start]);
2755   UINT32* cb = &(m_colorBuffer3d[(y * m_screen->visible_area().max_x) + x_start]);
2905   hng64_state *state = machine.driver_data<hng64_state>();
2906   float*  db = &(state->m_depthBuffer3d[(y * machine.first_screen()->visible_area().max_x) + x_start]);
2907   UINT32* cb = &(state->m_colorBuffer3d[(y * machine.first_screen()->visible_area().max_x) + x_start]);
27562908
27572909   UINT8 paletteEntry = 0;
27582910   float t_coord, s_coord;
2759   const UINT8 *gfx = memregion("textures")->base();
2911   const UINT8 *gfx = state->memregion("textures")->base();
27602912   const UINT8 *textureOffset = &gfx[prOptions.texIndex * 1024 * 1024];
27612913
27622914   for (; x_start <= x_end; x_start++)
r244679r244680
28182970            {
28192971               // The color out of the texture
28202972               paletteEntry %= prOptions.palPageSize;
2821               rgb_t color = m_palette->pen(prOptions.palOffset + paletteEntry);
2973               rgb_t color = state->m_palette->pen(prOptions.palOffset + paletteEntry);
28222974
28232975               // Apply the lighting
28242976               float rIntensity = (r_start/w_start) / 255.0f;
r244679r244680
28863038//   nearest and bilinear filtering: Filtering={0,1}
28873039//   replace and modulate application modes: Function={0,1}
28883040//---------------------------------------------------------------------------
2889void hng64_state::RasterizeTriangle_SMOOTH_TEX_PC(
3041static void RasterizeTriangle_SMOOTH_TEX_PC(running_machine &machine,
28903042                                 float A[4], float B[4], float C[4],
28913043                                 float Ca[3], float Cb[3], float Cc[3], // PER-VERTEX RGB COLORS
28923044                                 float Ta[2], float Tb[2], float Tc[2], // PER-VERTEX (S,T) TEX-COORDS
r244679r244680
30803232
30813233      // Pass the horizontal line to the filler, this could be put in the routine
30823234      // then interpolate for the next values of x and z
3083      FillSmoothTexPCHorizontalLine( prOptions,
3235      FillSmoothTexPCHorizontalLine(machine, prOptions,
30843236         x_start, x_end, y_min, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
30853237         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
30863238         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
r244679r244680
31593311
31603312      // Pass the horizontal line to the filler, this could be put in the routine
31613313      // then interpolate for the next values of x and z
3162      FillSmoothTexPCHorizontalLine( prOptions,
3314      FillSmoothTexPCHorizontalLine(machine, prOptions,
31633315         x_start, x_end, y_mid, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
31643316         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
31653317         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
r244679r244680
31743326   }
31753327}
31763328
3177void hng64_state::drawShaded( struct polygon *p)
3329static void drawShaded(running_machine &machine, struct polygon *p)
31783330{
31793331   // The perspective-correct texture divide...
31803332   // !!! There is a very good chance the HNG64 hardware does not do perspective-correct texture-mapping !!!
r244679r244680
32023354
32033355   for (j = 1; j < p->n-1; j++)
32043356   {
3205      RasterizeTriangle_SMOOTH_TEX_PC(
3357      RasterizeTriangle_SMOOTH_TEX_PC(machine,
32063358                              p->vert[0].clipCoords, p->vert[j].clipCoords, p->vert[j+1].clipCoords,
32073359                              p->vert[0].light,      p->vert[j].light,      p->vert[j+1].light,
32083360                              p->vert[0].texCoords,  p->vert[j].texCoords,  p->vert[j+1].texCoords,
trunk/src/mess/audio/gamate.c
r244679r244680
11/***************************************************************************
22 gamate sound hardware
33
4 PeT mess@utanet.at 2015
4 PeT mess@utanet.at
55***************************************************************************/
66
77#include "emu.h"
88#include "includes/gamate.h"
9#include "ui/ui.h"
109
1110
12enum { ClockDelay=32 };
13
1411// device type definition
1512const device_type GAMATE_SND = &device_creator<gamate_sound_device>;
1613
17const int gamate_sound_device::DAConverter[]={ 0, 3, 7, 13,  23, 41, 75, 137,  249, 453, 825, 1499,  2726, 4956, 9011, 16383 }; // (*.55) on the real below index 8 bareless measureable
18const UINT8 Mask[]={ 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0x1f, 0x3f,  0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xf };
19const int EnvelopeVolumes[]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0  };
14
2015//**************************************************************************
2116//  LIVE DEVICE
2217//**************************************************************************
r244679r244680
3227{
3328}
3429
30
3531//-------------------------------------------------
3632//  device_start - device-specific startup
3733//-------------------------------------------------
r244679r244680
3935void gamate_sound_device::device_start()
4036{
4137   // bind callbacks
42//   m_irq_cb.bind_relative_to(*owner());
38//  m_irq_cb.bind_relative_to(*owner());
4339
4440   memset(m_channels, 0, sizeof(m_channels));
4541   memset(reg, 0, sizeof(reg));
r244679r244680
5652{
5753   stream_sample_t *left=outputs[0], *right=outputs[1];
5854   int i, j;
59   Tone *channel;
60   
55   GAMATE_CHANNEL *channel;
56
6157   for (i = 0; i < samples; i++, left++, right++)
6258   {
63      noise.pos += noise.step;
64      while (noise.pos >= 1.0) {
65        // guess (white noise register taken from supervision)
66        noise.level = noise.state & 0x40 ? 1 : 0;
67        bool b1 = (noise.state & 0x40) != 0, b2 = (noise.state & 0x20) != 0;
68        noise.state=(noise.state<<1)+(b1!=b2?1:0);
69        noise.pos -= 1;
70      }
71
72      envelope.pos += envelope.step;
73      while (envelope.pos >= 1.0) {
74        envelope.pos -= 1;
75        envelope.index++;
76        switch (envelope.control) {
77          case 0: case 1: case 2: case 3:
78          case 4: case 5: case 6: case 7:
79          case 8: case 9: case 0xb:
80          case 0xd: case 0xf:
81            if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)/2) {
82         envelope.index=0;
83         envelope.first=false;
84            }
85            break;
86          default:
87            if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)) {
88         envelope.index=0;
89         envelope.first=false;
90            }
91            break;
92        }
93       
94      }
95
9659      *left = 0;
9760      *right = 0;
9861      for (channel=m_channels, j=0; j<ARRAY_LENGTH(m_channels); j++, channel++)
9962      {
10063         if (channel->size != 0)
10164         {
102           channel->level= channel->pos <= channel->size / 2;
103            bool l= channel->full_cycle? true: channel->level;
104            if (!channel->tone) l= l && noise.level;
105            int volume=0;
106            if (l) {
107              if (channel->envelope_on) {
108                switch (envelope.control) {
109                case 0: case 1: case 2: case 3:
110                case 0x9: // one time falling, low
111                  if (envelope.first && channel->level) volume=0xf-EnvelopeVolumes[envelope.index];
112                  break;
113                case 4: case 5: case 6: case 7:
114                case 0xf: // one time rising, low
115                  if (envelope.first && channel->level) volume=EnvelopeVolumes[envelope.index];
116                  break;
117                case 8: // falling
118                  if (channel->level) volume=0xf-EnvelopeVolumes[envelope.index];
119                  break;
120                case 0xa: // rising, falling
121                  if (channel->level) volume=EnvelopeVolumes[envelope.index];
122                  break;
123                case 0xb: // one time falling, high
124                  if (channel->level) volume=envelope.first? 0xf-EnvelopeVolumes[envelope.index]: 0xf;
125                  break;
126                case 0xc: // rising, low
127                  if (channel->level) volume=envelope.index<ARRAY_LENGTH(EnvelopeVolumes)/2? EnvelopeVolumes[envelope.index]: 0;
128                  break;
129                case 0xd: // one time rising, high
130                  if (channel->level) volume=envelope.first? EnvelopeVolumes[envelope.index]: 0xf;
131                  break;
132                case 0xe: // falling, rising
133                  if (channel->level) volume=0xf-EnvelopeVolumes[envelope.index];
134                  break;
135                }
136              } else {
137                volume=channel->volume;
138              }
65            if (channel->on)//||channel->count)
66            {
67               int on = FALSE;
68               on = channel->pos <= channel->size / 2;
69               {
70                  INT16 s = on ? channel->volume << 8 : 0;
71                  if (j == 0)
72                     *right += s;
73                  else if (j==1)
74                     *left += s;
75                  else {
76                     *right += s;
77                     *left += s;
78                  }
79               }
13980            }
140            if (j == Right)
141              *right += Value2Volume(volume);
142            else if (j==Left)
143              *left += Value2Volume(volume);
144            else {
145              *right += Value2Volume(volume);
146              *left += Value2Volume(volume);
147            }
14881            channel->pos++;
14982            if (channel->pos >= channel->size)
15083               channel->pos = 0;
r244679r244680
16194   reg[offset] = data;
16295   int chan=-1;
16396
164   switch (offset&0xf)
97   switch (offset)
16598   {
16699      case 0:
167100      case 1:
r244679r244680
169102      case 3:
170103      case 4:
171104      case 5:
172        chan=offset/2;
105         chan=offset/2;
173106         size = reg[chan*2] | ((reg[chan*2+1] & 0xf) << 8);
174107         if (size)
175108         {
176            m_channels[chan].size= (int) (machine().sample_rate() * size*ClockDelay / machine().device("maincpu")->unscaled_clock());
109            m_channels[chan].size= (int) (machine().sample_rate() * (size << 5) / machine().device("maincpu")->unscaled_clock());
177110         }
178111         else
179112         {
r244679r244680
182115         m_channels[chan].pos = 0;
183116         break;
184117      case 6:
185        size=data&0x1f;
186        if (size==0) size=1;
187        noise.step= machine().device("maincpu")->unscaled_clock() / (1.0*ClockDelay*machine().sample_rate()*size);
188        break;
189118      case 7:
190        m_channels[Right].full_cycle=data&1;
191        m_channels[Right].tone=data&8;
192        m_channels[Left].full_cycle=data&2;
193        m_channels[Left].tone=data&0x10;
194        m_channels[Both].full_cycle=data&4;
195        m_channels[Both].tone=data&0x20;
196        noise.state=1;
197        noise.pos=0.0;
198        noise.level=false;
199        break;
200119      case 8:
201      case 9:
202      case 0xa:
203        chan=offset-8;
204         m_channels[chan].envelope_on = data & 0x10; // buggy aussetzer cube up
120         chan=offset-6;
121//          m_channels[chan]->on = data & 0x40;
122//          channel->waveform = (data & 0x30) >> 4;
205123         m_channels[chan].volume = data & 0xf;
206124         break;
207      case 0xb: case 0xc:
208         size = reg[0xb] | ((reg[0xc]) << 8);
209        if (size==0) size=1;
210        envelope.step= machine().device("maincpu")->unscaled_clock() / (1.0*ClockDelay*machine().sample_rate()*size);
211        break;
212      case 0xd:
213        envelope.control=data&0xf;
214        envelope.pos=0;
215        envelope.index=0;
216        envelope.first=true;
217        break;
218       
219125   }
220   envelope.pos=0; // guess
221   envelope.index=0;
222   envelope.first=true;
126   if (chan!=-1) m_channels[chan].on=m_channels[chan].volume!=0 && m_channels[chan].size>3/* avoid speed loss for unhearable >=23khz*/;
223127}
224
225READ8_MEMBER( gamate_sound_device::device_r )
226{
227  UINT8 data=0;
228  if ((offset&0xf)<ARRAY_LENGTH(Mask)) data=reg[offset&0xf]&Mask[offset&0xf]; // unused bits set to last write value? in this area
229  return data;
230}
trunk/src/mess/drivers/gamate.c
r244679r244680
33 Peter Wilhelmsen peter.wilhelmsen@gmail.com
44 Morten Shearman Kirkegaard morten+gamate@afdelingp.dk
55 Juan F??lix Mateos vectrex@hackermesh.org
6******************************************************************************/
67
7 nmi unknown
8 cube up audio sometimes missing
9 bomb blast top status line missing
10 ******************************************************************************/
11
128#include "emu.h"
139#include "cpu/m6502/m6502.h"
1410#include "bus/generic/slot.h"
r244679r244680
4036   DECLARE_WRITE8_MEMBER(cart_bankswitch_w);
4137   DECLARE_READ8_MEMBER(gamate_video_r);
4238   DECLARE_READ8_MEMBER(gamate_pad_r);
43   DECLARE_READ8_MEMBER(gamate_nmi_r);
4439   DECLARE_WRITE8_MEMBER(gamate_video_w);
4540   DECLARE_READ8_MEMBER(gamate_audio_r);
4641   DECLARE_WRITE8_MEMBER(gamate_audio_w);
r244679r244680
5651
5752   struct
5853   {
59     UINT8 reg[8];
60     struct {
61       bool page2; // else page1
54   UINT8 reg[8];
55   struct {
56      bool write;
57      bool page2; // else page1
6258   UINT8 ypos, xpos/*tennis*/;
63       UINT8 data[2][0x100][0x20];
64     } bitmap;
65     UINT8 x, y;
59      UINT8 data[2][0x100][0x20];
60      } bitmap;
61   UINT8 x, y;
6662      bool y_increment;
6763   } video;
6864
6965   struct {
70     bool set;
66      bool set;
7167      int bit_shifter;
7268      UINT8 cartridge_byte;
7369      UINT16 address; // in reality something more like short local cartridge address offset
7470      bool unprotected;
7571      bool failed;
76     
72
7773   } card_protection;
7874
7975   required_device<cpu_device> m_maincpu;
r244679r244680
8480   required_shared_ptr<UINT8> m_bios;
8581   emu_timer *timer1;
8682   emu_timer *timer2;
87   UINT8 bank_multi; 
83   UINT8 bank_multi;
8884};
8985
9086WRITE8_MEMBER( gamate_state::gamate_cart_protection_w )
9187{
92        logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
93 
88      logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
89
9490   switch (offset) {
9591   case 0:
9692      card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0);
r244679r244680
104100}
105101READ8_MEMBER( gamate_state::gamate_cart_protection_r )
106102{
107
108  UINT8 ret=1;
109  if (card_protection.bit_shifter==7 && card_protection.unprotected) {
110    ret=m_cart->get_rom_base()[bank_multi*0x4000];
111  } else {
103   UINT8 ret=1;
104   if (card_protection.bit_shifter==7 && card_protection.unprotected) {
105   ret=m_cart->get_rom_base()[bank_multi*0x4000];
106   } else {
112107   card_protection.bit_shifter++;
113108   if (card_protection.bit_shifter==8) {
114109      card_protection.bit_shifter=0;
r244679r244680
117112   }
118113   ret=(card_protection.cartridge_byte&0x80)?2:0;
119114   if (card_protection.bit_shifter==7 && !card_protection.failed) { // now protection chip on cartridge activates cartridge chip select on cpu accesses
120//        m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
115//        m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
121116   }
122117   card_protection.cartridge_byte<<=1;
123  }
124  logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
125  return ret;
118   }
119   logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
120   return ret;
126121}
127122
128123READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked
129124
130125WRITE8_MEMBER( gamate_state::protection_reset )
131126{
132  // writes 0x20
133  card_protection.address=0x6005-0x6001;
134  card_protection.bit_shifter=0;
135  card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++];
136  card_protection.failed=false;
137  card_protection.unprotected=false;
127   // writes 0x20
128   card_protection.address=0x6005-0x6001;
129   card_protection.bit_shifter=0;
130   card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++];
131   card_protection.failed=false;
132   card_protection.unprotected=false;
138133}
139134
140135READ8_MEMBER( gamate_state::newer_protection_set )
141136{
142  card_protection.set=true;
143  return 0;
137   card_protection.set=true;
138   return 0;
144139}
145140
146141
147142WRITE8_MEMBER( gamate_state::gamate_video_w )
148143{
149  video.reg[offset]=data;
150  switch (offset) {
151  case 1:
152    if (data&0xf) printf("lcd mode %x\n", data);
153    video.y_increment=data&0x40;
154    break;
155  case 2: video.bitmap.xpos=data;break;
156  case 3:
157    if (data>=200) printf("lcd ypos: %x\n", data);
158    video.bitmap.ypos=data;
159    break;
160  case 4: video.bitmap.page2=data&0x80;video.x=data&0x1f;break;
161  case 5: video.y=data;break;
162  case 7:
163    video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
164    if (video.y_increment) video.y++;
165    else video.x++; // overruns
166  }
144   video.reg[offset]=data;
145   switch (offset) {
146   case 1:
147      if (data&0xf) printf("lcd mode %x\n", data);
148      video.bitmap.write=data&0xc0; // more addressing mode
149      video.y_increment=data&0x40;
150      break;
151   case 2: video.bitmap.xpos=data;break;
152   case 3:
153      if (data>=200) printf("lcd ypos: %x\n", data);
154      video.bitmap.ypos=data;
155      break;
156   case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break;
157   case 5: video.y=data;break;
158   case 7:
159   if (video.y>=200)
160   machine().ui().popup_time(2, "bitmap write to x:%x y:%x mode:%x data:%x\n", video.x, video.y, video.reg[1], data);
161   if (video.bitmap.write) {
162      video.bitmap.data[video.bitmap.page2][video.y][video.x]=data;
163   } else {
164      video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
165   }
166   if (video.y_increment) video.y++;
167      else video.x++;
168   }
167169}
168170
169171WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w )
170172{
171  bank_multi=data;
172  membank("bankmulti")->set_base(m_cart->get_rom_base()+0x4000*data+1);
173   bank_multi=data;
174   membank("bankmulti")->set_base(m_cart->get_rom_base()+0x4000*data+1);
173175}
174176
175177WRITE8_MEMBER( gamate_state::cart_bankswitch_w )
r244679r244680
179181
180182READ8_MEMBER( gamate_state::gamate_video_r )
181183{
182  if (offset!=6) return 0;
183  UINT8 data=0;
184    data=video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
184   if (offset!=6) return 0;
185   UINT8 data=0;
186   if (video.bitmap.write) {
187   data=video.bitmap.data[video.bitmap.page2][video.y][video.x];
188   } else {
189   data=video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
190   }
185191//  if (m_maincpu->pc()<0xf000)
186192//    machine().ui().popup_time(2, "lcd read x:%x y:%x mode:%x data:%x\n", video.x, video.y, video.reg[1], data);
187    if (video.y_increment) video.y++;
188    else video.x++; // overruns?
189
190    return data;
193   return data;
191194}
192195
193196WRITE8_MEMBER( gamate_state::gamate_audio_w )
194197{
195198//  printf("audio write %x:%x\n", offset, data);//logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data);
196  m_sound->device_w(space, offset, data);
199   m_sound->device_w(space, offset, data);
197200}
198201
199202READ8_MEMBER( gamate_state::gamate_audio_r )
200203{
201  UINT8 data=m_sound->device_r(space, offset);
202  return data;
204// legend of dragon knight
205//  machine().ui().popup_time(2, "%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset);
206   return 0;
203207}
204208
205209
206210READ8_MEMBER( gamate_state::gamate_pad_r )
207211{
208  UINT8 data=m_io_joy->read();
209  return data;
212   UINT8 data=m_io_joy->read();
213   return data;
210214}
211215
212READ8_MEMBER( gamate_state::gamate_nmi_r )
213{
214  UINT8 data=0;
215  machine().ui().popup_time(2, "nmi/4800 read\n");
216  return data;
217}
218
219216static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state )
220    AM_RANGE(0x0000, 0x03ff) AM_RAM
221  AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
222  AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
223  AM_RANGE(0x4800, 0x4800) AM_READ(gamate_nmi_r)
224  AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
225  AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
226  AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
227  AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
217   AM_RANGE(0x0000, 0x03ff) AM_RAM
218   AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
219   AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
220   AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
221   AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
222   AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
223   AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
228224
229  AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
230  AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
225   AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
226   AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
231227
232228   AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w)
233229   AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w)
234230   AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w)
235231
236  AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
232   AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
237233ADDRESS_MAP_END
238234
239235
r244679r244680
249245   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("Select")
250246INPUT_PORTS_END
251247
252static const unsigned short gamate_palette[4] =
248ATTR_UNUSED static const unsigned short gamate_palette[4] =
253249{
254250   0,1,2,3
255251};
r244679r244680
258254/* palette in red, green, blue tribles */
259255static const unsigned char gamate_colors[4][3] =
260256{
261  { 255,255,255 },
262  { 0xa0, 0xa0, 0xa0 },
263  { 0x60, 0x60, 0x60 },
264  { 0, 0, 0 }
257   { 255,255,255 },
258   { 0xa0, 0xa0, 0xa0 },
259   { 0x60, 0x60, 0x60 },
260   { 0, 0, 0 }
265261};
266262
267263PALETTE_INIT_MEMBER(gamate_state, gamate)
r244679r244680
284280
285281UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
286282{
287  int x, y, j;
288  for (y=0;y<152;y++) {
289    for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {     
290      UINT8 d1, d2;
291      if (video.bitmap.ypos<200) {
283   int x, y, j;
284   for (y=0;y<152;y++) {
285   for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {
286      UINT8 d1, d2;
287      if (video.bitmap.ypos<200) {
292288   d1=video.bitmap.data[0][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
293289   d2=video.bitmap.data[1][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
294      } else if ((video.bitmap.ypos&0xf)<8) { // lcdtest, of course still some registers not known, my gamate doesn't display bottom lines; most likely problematic 200 warp around hardware! no real usage
290      } else if ((video.bitmap.ypos&0xf)<8) { // lcdtest, of course still some registers not known, my gamate doesn't display bottom lines
295291   int yi=(y+(video.bitmap.ypos&0xf)-8);
296292   if (yi<0) yi=video.bitmap.ypos+y; // in this case only 2nd plane used!?, source of first plane?
297293   d1=video.bitmap.data[0][yi][(j+video.bitmap.xpos/8)&0x1f]; // value of lines bevor 0 chaos
298294   d2=video.bitmap.data[1][yi][(j+video.bitmap.xpos/8)&0x1f];
299      } else {
295      } else {
300296   d1=video.bitmap.data[0][y][(j+video.bitmap.xpos/8)&0x1f];
301   d2=video.bitmap.data[1][y][(j+video.bitmap.xpos/8)&0x1f];   
302      }
303      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
304      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
305    }
306  }
307  return 0;
297   d2=video.bitmap.data[1][y][(j+video.bitmap.xpos/8)&0x1f];
298      }
299      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
300      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
301   }
302   }
303   return 0;
308304}
309305
310306DRIVER_INIT_MEMBER(gamate_state,gamate)
r244679r244680
318314void gamate_state::machine_start()
319315{
320316   if (m_cart->exists()) {
321//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
317//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
322318      membank("bankmulti")->set_base(m_cart->get_rom_base()+1);
323319      membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset
324320   }
325//   m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
321//  m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
326322   card_protection.set=false;
327323   bank_multi=0;
328324   card_protection.unprotected=false;
r244679r244680
382378   MCFG_SOUND_ADD("custom", GAMATE_SND, 0)
383379   MCFG_SOUND_ROUTE(0, "lspeaker", 0.50)
384380   MCFG_SOUND_ROUTE(1, "rspeaker", 0.50)
385   
381
386382   MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_linear_slot, "gamate_cart")
387383   MCFG_GENERIC_MANDATORY
388384
r244679r244680
400396
401397
402398/*    YEAR  NAME      PARENT  COMPAT    MACHINE   INPUT    CLASS          INIT      COMPANY    FULLNAME */
403CONS( 19??, gamate,  0,      0,        gamate,  gamate, gamate_state, gamate, "Bit Corp", "Gamate", 0)
404
405
399CONS( 19??, gamate,  0,      0,        gamate,  gamate, gamate_state, gamate, "Bit Corp", "Gamate", GAME_IMPERFECT_SOUND)
trunk/src/mess/drivers/hh_ucom4.c
r244679r244680
8787   DECLARE_INPUT_CHANGED_MEMBER(tmtennis_difficulty_switch);
8888   DECLARE_MACHINE_RESET(tmtennis);
8989
90   void tmpacman_display();
9190   DECLARE_WRITE8_MEMBER(tmpacman_grid_w);
9291   DECLARE_WRITE8_MEMBER(tmpacman_plate_w);
9392   DECLARE_WRITE8_MEMBER(tmpacman_port_e_w);
r244679r244680
237236
238237WRITE8_MEMBER(hh_ucom4_state::edracula_grid_w)
239238{
240   // C,D: vfd matrix grid
239   // ports C,D: vfd matrix grid
241240   int shift = (offset - NEC_UCOM4_PORTC) * 4;
242241   m_grid = (m_grid & ~(0xf << shift)) | (data << shift);
243242
r244679r244680
246245
247246WRITE8_MEMBER(hh_ucom4_state::edracula_plate_w)
248247{
249   // E-H,I01: vfd matrix plate
248   // ports E-H,I01: vfd matrix plate
250249   int shift = (offset - NEC_UCOM4_PORTE) * 4;
251250   m_plate = (m_plate & ~(0xf << shift)) | (data << shift);
252251
r244679r244680
326325
327326READ8_MEMBER(hh_ucom4_state::tmtennis_input_r)
328327{
329   // A,B: buttons
328   // ports A,B: buttons
330329   return ~read_inputs(2) >> (offset*4);
331330}
332331
333332WRITE8_MEMBER(hh_ucom4_state::tmtennis_grid_w)
334333{
335   // G-I: vfd matrix grid
334   // ports G-I: vfd matrix grid
336335   int shift = (offset - NEC_UCOM4_PORTG) * 4;
337336   m_grid = (m_grid & ~(0xf << shift)) | (data << shift);
338337
r244679r244680
341340
342341WRITE8_MEMBER(hh_ucom4_state::tmtennis_plate_w)
343342{
344   // C-F: vfd matrix plate
343   // ports C-F: vfd matrix plate
345344   if (offset == NEC_UCOM4_PORTF) offset--;
346345   int shift = (offset - NEC_UCOM4_PORTC) * 4;
347346   m_plate = (m_plate & ~(0xf << shift)) | (data << shift);
r244679r244680
453452  known releases:
454453  - Japan: Puck Man
455454  - USA: Pac Man
456  - UK: Puckman (Tomy), and also published by Grandstand as Munchman
455  - UK: Puckman (Tomy), and also as Munchman, published by Grandstand
457456  - Australia: Pac Man-1, published by Futuretronics
458457
459458  NOTE!: MESS external artwork is recommended
460459
461460***************************************************************************/
462461
463void hh_ucom4_state::tmpacman_display()
464{
465   UINT8 grid = BITSWAP8((UINT8)m_grid,0,1,2,3,4,5,6,7);
466   UINT32 plate = BITSWAP24(m_plate,23,22,21,20,19,16,17,18,11,10,9,8,0,2,3,1,4,5,6,7,12,13,14,15);
467   
468   display_matrix(19, 8, plate | 0x100, grid);
469}
470
471462WRITE8_MEMBER(hh_ucom4_state::tmpacman_grid_w)
472463{
473   // C,D: vfd matrix grid
464   // ports C,D: vfd matrix grid
474465   int shift = (offset - NEC_UCOM4_PORTC) * 4;
475466   m_grid = (m_grid & ~(0xf << shift)) | (data << shift);
476467
477   tmpacman_display();
468   display_matrix(19, 8, m_plate, m_grid);
478469}
479470
480471WRITE8_MEMBER(hh_ucom4_state::tmpacman_plate_w)
481472{
482   // E023,F-I: vfd matrix plate
473   // ports E-I: vfd matrix plate
483474   int shift = (offset - NEC_UCOM4_PORTE) * 4;
484475   m_plate = (m_plate & ~(0xf << shift)) | (data << shift);
485476
486   tmpacman_display();
477   display_matrix(19, 8, m_plate, m_grid);
487478}
488479
489480WRITE8_MEMBER(hh_ucom4_state::tmpacman_port_e_w)
r244679r244680
503494   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_16WAY
504495
505496   PORT_START("IN.1") // port B
506   PORT_CONFNAME( 0x01, 0x00, DEF_STR( Difficulty ) )
497   PORT_CONFNAME( 0x00, 0x00, DEF_STR( Difficulty ) )
507498   PORT_CONFSETTING(    0x00, "Amateur" )
508499   PORT_CONFSETTING(    0x01, "Professional" )
509500   PORT_BIT( 0x0e, IP_ACTIVE_HIGH, IPT_UNUSED )
r244679r244680
557548
558549READ8_MEMBER(hh_ucom4_state::alnchase_input_r)
559550{
560   // A: buttons
551   // port A: buttons
561552   return read_inputs(2);
562553}
563554
r244679r244680
565556{
566557   if (offset <= NEC_UCOM4_PORTE)
567558   {
568      // C,D,E0: vfd matrix grid
559      // ports C,D,E0: vfd matrix grid
569560      int shift = (offset - NEC_UCOM4_PORTC) * 4;
570561      m_grid = (m_grid & ~(0xf << shift)) | (data << shift);
571562
r244679r244680
576567
577568   if (offset >= NEC_UCOM4_PORTE)
578569   {
579      // E23,F-I: vfd matrix plate
570      // ports F-I,E23: vfd matrix plate
580571      int shift = (offset - NEC_UCOM4_PORTE) * 4;
581572      m_plate = ((m_plate << 2 & ~(0xf << shift)) | (data << shift)) >> 2;
582573   }
r244679r244680
693684CONS( 1982, edracula, 0, 0, edracula, edracula, driver_device, 0, "Epoch", "Dracula (Epoch)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK )
694685
695686CONS( 1980, tmtennis, 0, 0, tmtennis, tmtennis, driver_device, 0, "Tomy", "Tennis (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK )
696CONS( 1982, tmpacman, 0, 0, tmpacman, tmpacman, driver_device, 0, "Tomy", "Pac Man (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK )
687CONS( 1982, tmpacman, 0, 0, tmpacman, tmpacman, driver_device, 0, "Tomy", "Pac Man (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK | GAME_NOT_WORKING )
697688CONS( 1984, alnchase, 0, 0, alnchase, alnchase, driver_device, 0, "Tomy", "Alien Chase", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK )
trunk/src/mess/includes/gamate.h
r244679r244680
1111#include "bus/generic/slot.h"
1212#include "bus/generic/carts.h"
1313
14struct GAMATE_CHANNEL
15{
16   GAMATE_CHANNEL() :
17//      on(0),
18//      waveform(0),
19      volume(0),
20      pos(0),
21      size(0)
22//      count(0)
23   {
24   }
1425
26   int on;
27   int /*waveform,*/ volume;
28   int pos;
29   int size;
30//  int count;
31};
32
33
1534// ======================> gamate_sound_device
1635
1736class gamate_sound_device : public device_t,
r244679r244680
3049
3150public:
3251   DECLARE_WRITE8_MEMBER( device_w );
33   DECLARE_READ8_MEMBER( device_r );
3452
3553private:
3654
37   static const int DAConverter[];
38   static int Value2Volume(int volume) { return DAConverter[volume]*1; }
39
4055   sound_stream *m_mixer_channel;
41   struct Tone
42   {
43     Tone() :
44      envelope_on(false),
45      level(false),
46      tone(false), full_cycle(false),
47      volume(0),
48      pos(0),
49      size(0)
50     {
51     }
52
53     bool envelope_on, level;
54     bool tone/*else noise*/, full_cycle/* else square signal/pulse */;
55     int volume;
56     int pos, size;
57   };
58   enum { Right, Left, Both };
59   Tone m_channels[3];
60   struct Noise {
61     Noise(): state(1), level(false), step(0.0), pos(0.0) {}
62     int state;
63     bool level;
64     double step, pos;
65   } noise;
66   struct Envelope {
67     Envelope():control(0), index(0), first(false) {}
68     int control;
69     int index;
70     bool first;
71     double step, pos;
72   } envelope;
56   GAMATE_CHANNEL m_channels[3];
7357   UINT8 reg[14];
7458};
7559
trunk/src/osd/modules/osdwindow.h
r244679r244680
5555
5656#ifdef OSD_SDL
5757   virtual osd_dim blit_surface_size() = 0;
58   virtual sdl_monitor_info *monitor() const = 0;
58   virtual osd_monitor_info *monitor() const = 0;
5959#if (SDLMAME_SDL2)
6060   virtual SDL_Window *sdl_window() = 0;
6161#else
6262   virtual SDL_Surface *sdl_surface() = 0;
6363#endif
6464#else
65   virtual win_monitor_info *monitor() const = 0;
65   virtual osd_monitor_info *monitor() const = 0;
6666   virtual bool win_has_menu() = 0;
6767   // FIXME: cann we replace winwindow_video_window_monitor(NULL) with monitor() ?
68   virtual win_monitor_info *winwindow_video_window_monitor(const osd_rect *proposed) = 0;
68   virtual osd_monitor_info *winwindow_video_window_monitor(const osd_rect *proposed) = 0;
6969
7070   // window handle and info
7171   HWND                    m_hwnd;
trunk/src/osd/modules/render/drawd3d.c
r244679r244680
12661266      HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum);
12671267
12681268      // if we match the proposed monitor, this is it
1269      if (curmonitor == window().monitor()->handle())
1269      if (curmonitor == *((HMONITOR *)window().monitor()->oshandle()))
12701270      {
12711271         return adapternum;
12721272      }
trunk/src/osd/modules/render/drawdd.c
r244679r244680
9494
9595   // video modes
9696   int config_adapter_mode();
97   void get_adapter_for_monitor(win_monitor_info *monitor);
97   void get_adapter_for_monitor(osd_monitor_info *monitor);
9898   void pick_best_mode();
9999
100100   // various
r244679r244680
130130/* monitor_enum_info holds information during a monitor enumeration */
131131struct monitor_enum_info
132132{
133   win_monitor_info *      monitor;                    // pointer to monitor we want
133   osd_monitor_info *      monitor;                    // pointer to monitor we want
134134   GUID                    guid;                       // GUID of the one we found
135135   GUID *                  guid_ptr;                   // pointer to our GUID
136136   int                     foundit;                    // TRUE if we found what we wanted
r244679r244680
263263{
264264   // configure the adapter for the mode we want
265265   if (config_adapter_mode())
266   {
267      osd_printf_error("Unable to configure adapter.\n");
266268      goto error;
269   }
267270
268271   // create the ddraw object
269272   if (ddraw_create())
273   {
274      osd_printf_error("Unable to create ddraw object.\n");
270275      goto error;
276   }
271277
272278   return 0;
273279
r244679r244680
855861      // compute the appropriate visible area if we're trying to keepaspect
856862      if (video_config.keepaspect)
857863      {
858         win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
864         osd_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
859865         window().target()->compute_visible_area(target_width, target_height, monitor->aspect(), window().target()->orientation(), target_width, target_height);
860866         desired_aspect = (float)target_width / (float)target_height;
861867      }
r244679r244680
945951void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
946952{
947953   IDirectDrawSurface7 *target = (back != NULL) ? back : primary;
948   win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
954   osd_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
949955   DDBLTFX blitfx = { sizeof(DDBLTFX) };
950956   RECT clear, outer, dest, source;
951957   INT32 dstwidth, dstheight;
r244679r244680
11611167   monitor_enum_info *einfo = (monitor_enum_info *)context;
11621168
11631169   // do we match the desired monitor?
1164   if (hmonitor == einfo->monitor->handle() || (hmonitor == NULL && einfo->monitor->is_primary()))
1170   if (hmonitor == *((HMONITOR *)einfo->monitor->oshandle()) || (hmonitor == NULL && einfo->monitor->is_primary()))
11651171   {
11661172      einfo->guid_ptr = (guid != NULL) ? &einfo->guid : NULL;
11671173      if (guid != NULL)
r244679r244680
11771183//  get_adapter_for_monitor
11781184//============================================================
11791185
1180void renderer_dd::get_adapter_for_monitor(win_monitor_info *monitor)
1186void renderer_dd::get_adapter_for_monitor(osd_monitor_info *monitor)
11811187{
11821188   monitor_enum_info einfo;
11831189   HRESULT result;
trunk/src/osd/modules/render/drawsdl.c
r244679r244680
271271   UINT32 fmt;
272272
273273   // Determine preferred pixelformat and set up yuv if necessary
274   SDL_GetCurrentDisplayMode(window().monitor()->handle(), &mode);
274   SDL_GetCurrentDisplayMode(*((UINT64 *)window().monitor()->handle()), &mode);
275275
276276   if (m_yuv_bitmap)
277277   {
trunk/src/osd/sdl/video.c
r244679r244680
6363
6464osd_video_config video_config;
6565
66sdl_monitor_info *sdl_monitor_info::primary_monitor = NULL;
67sdl_monitor_info *sdl_monitor_info::list = NULL;
66osd_monitor_info *osd_monitor_info::list = NULL;
6867
6968//============================================================
7069//  LOCAL VARIABLES
r244679r244680
133132//============================================================
134133//  sdlvideo_monitor_refresh
135134//============================================================
136
135#if defined(SDLMAME_WIN32)  // Win32 version
136inline osd_rect RECT_to_osd_rect(const RECT &r)
137{
138   return osd_rect(r.left, r.top, r.right - r.left, r.bottom - r.top);
139}
140#endif
137141void sdl_monitor_info::refresh()
138142{
139143   #if (SDLMAME_SDL2)
r244679r244680
144148   #else
145149   SDL_GetCurrentDisplayMode(m_handle, &dmode);
146150   #endif
147   SDL_GetDisplayBounds(m_handle, &m_dimensions);
151   SDL_Rect dimensions;
152   SDL_GetDisplayBounds(m_handle, &dimensions);
148153
149   // FIXME: Use SDL_GetDisplayBounds(monitor->handle, &tt) to update monitor_x
150   // SDL_Rect tt;
154   m_pos_size = SDL_Rect_to_osd_rect(dimensions);
155   m_usuable_pos_size = SDL_Rect_to_osd_rect(dimensions);
156   m_is_primary = (m_handle == 0);
157
151158   #else
152159   #if defined(SDLMAME_WIN32)  // Win32 version
153160   MONITORINFOEX info;
154161   info.cbSize = sizeof(info);
155162   GetMonitorInfo((HMONITOR)m_handle, (LPMONITORINFO)&info);
156   m_dimensions.x = m_dimensions.y = 0;
157   m_dimensions.w = info.rcMonitor.right - info.rcMonitor.left;
158   m_dimensions.h = info.rcMonitor.bottom - info.rcMonitor.top;
163   m_pos_size = RECT_to_osd_rect(info.rcMonitor);
164   m_usuable_pos_size = RECT_to_osd_rect(info.rcWork);
165   m_is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) != 0);
159166   char *temp = utf8_from_wstring(info.szDevice);
160167   strncpy(m_name, temp, ARRAY_LENGTH(m_name) - 1);
161168   osd_free(temp);
r244679r244680
167174   primary = CGMainDisplayID();
168175   dbounds = CGDisplayBounds(primary);
169176
170   m_dimensions.x = m_dimensions.y = 0;
171   m_dimensions.w = dbounds.size.width - dbounds.origin.x;
172   m_dimensions.h = dbounds.size.height - dbounds.origin.y;
177   m_is_primary = (m_handle == 0);
178   m_pos_size = osd_rect(0, 0, dbounds.size.width - dbounds.origin.x, dbounds.size.height - dbounds.origin.y);
179   m_usuable_pos_size = m_pos_size;
173180   strncpy(m_name, "Mac OS X display", ARRAY_LENGTH(m_name) - 1);
174181   #elif defined(SDLMAME_X11) || defined(SDLMAME_NO_X11)       // X11 version
175182   {
r244679r244680
183190      {
184191         screen = DefaultScreen(info.info.x11.display);
185192         SDL_VideoDriverName(m_name, ARRAY_LENGTH(m_name) - 1);
186         m_dimensions.x = m_dimensions.y = 0;
187         m_dimensions.w = DisplayWidth(info.info.x11.display, screen);
188         m_dimensions.h = DisplayHeight(info.info.x11.display, screen);
193         m_pos_size = osd_rect(0, 0,
194               DisplayWidth(info.info.x11.display, screen),
195               DisplayHeight(info.info.x11.display, screen));
189196
190197         /* FIXME: If Xinerame is used we should compile a list of monitors
191198          * like we do for other targets and ignore SDL.
r244679r244680
197204
198205            xineinfo = XineramaQueryScreens(info.info.x11.display, &numscreens);
199206
200            m_dimensions.w = xineinfo[0].width;
201            m_dimensions.h = xineinfo[0].height;
207            m_pos_size = osd_rect(0, 0, xineinfo[0].width, xineinfo[0].height);
202208
203209            XFree(xineinfo);
204210         }
211         m_usuable_pos_size = m_pos_size;
212         m_is_primary = (m_handle == 0);
205213      }
206214      else
207215      #endif // defined(SDLMAME_X11)
r244679r244680
238246               }
239247            }
240248         }
241         m_dimensions.w = cw;
242         m_dimensions.h = ch;
249         m_pos_size = osd_rect(0, 0, cw, ch);
250         m_usuable_pos_size = m_pos_size;
251         m_is_primary = (m_handle == 0);
243252      }
244253   }
245254   #elif defined(SDLMAME_OS2)      // OS2 version
246   m_dimensions.x = m_dimensions.y = 0;
247   m_dimensions.w = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
248   m_dimensions.h = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
255   m_pos_size = osd_rect(0, 0,
256         WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ),
257         WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) );
258   m_usuable_pos_size = m_pos_size;
259   m_is_primary = (m_handle == 0);
249260   strncpy(m_name, "OS/2 display", ARRAY_LENGTH(m_name) - 1);
250261   #else
251262   #error Unknown SDLMAME_xx OS type!
r244679r244680
256267      if (!info_shown)
257268      {
258269         osd_printf_verbose("SDL Device Driver     : %s\n", m_name);
259         osd_printf_verbose("SDL Monitor Dimensions: %d x %d\n", m_dimensions.w, m_dimensions.h);
270         osd_printf_verbose("SDL Monitor Dimensions: %d x %d\n", m_pos_size.width(), m_pos_size.height());
260271         info_shown = 1;
261272      }
262273   }
r244679r244680
269280//  sdlvideo_monitor_get_aspect
270281//============================================================
271282
272float sdl_monitor_info::aspect()
283float osd_monitor_info::aspect()
273284{
274285   // refresh the monitor information and compute the aspect
275286   refresh();
276287   // FIXME: returning 0 looks odd, video_config is bad
277288   if (video_config.keepaspect)
278289   {
279      return m_aspect / ((float)m_dimensions.w / (float)m_dimensions.h);
290      return m_aspect / ((float)m_pos_size.width() / (float)m_pos_size.height());
280291   }
281292   return 0.0f;
282293}
r244679r244680
320331#if !defined(SDLMAME_WIN32) && !(SDLMAME_SDL2)
321332void sdl_monitor_info::add_primary_monitor(void *data)
322333{
323   sdl_monitor_info ***tailptr = (sdl_monitor_info ***)data;
324   sdl_monitor_info *monitor;
334   // make a list of monitors
335   osd_monitor_info::list = NULL;
336   osd_monitor_info **tailptr = &sdl_monitor_info::list;
325337
326338   // allocate a new monitor info
327   monitor = global_alloc_clear(sdl_monitor_info);
339   osd_monitor_info *monitor = global_alloc_clear(sdl_monitor_info(0, "", 1.0f));
328340
329   // copy in the data
330   monitor->m_handle = 1;
331
332   monitor->refresh();
333
341   //monitor->refresh();
334342   // guess the aspect ratio assuming square pixels
335   monitor->m_aspect = (float)(monitor->m_dimensions.w) / (float)(monitor->m_dimensions.h);
343   monitor->set_aspect((float)(monitor->position_size().width()) / (float)(monitor->position_size().height()));
336344
337   // save the primary monitor handle
338   primary_monitor = monitor;
339
340345   // hook us into the list
341   **tailptr = monitor;
342   *tailptr = &monitor->m_next;
346   *tailptr = monitor;
347   //tailptr = &monitor->m_next;
343348}
344349#endif
345350
r244679r244680
349354//============================================================
350355
351356#if defined(SDLMAME_WIN32) && !(SDLMAME_SDL2)
352static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
357BOOL CALLBACK sdl_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
353358{
354   sdl_monitor_info ***tailptr = (sdl_monitor_info ***)data;
355   sdl_monitor_info *monitor;
359   osd_monitor_info ***tailptr = (osd_monitor_info ***)data;
360   osd_monitor_info *monitor;
356361   MONITORINFOEX info;
357362   BOOL result;
358363
r244679r244680
371376   monitor = global_alloc(sdl_monitor_info((UINT64) handle, temp, aspect));
372377   osd_free(temp);
373378
374   // save the primary monitor handle
375   if (info.dwFlags & MONITORINFOF_PRIMARY)
376      sdl_monitor_info::primary_monitor = monitor;
377
378379   // hook us into the list
379380   **tailptr = monitor;
380381   *tailptr = &monitor->m_next;
r244679r244680
391392
392393void sdl_monitor_info::init()
393394{
394   sdl_monitor_info **tailptr;
395   osd_monitor_info **tailptr;
395396
396397   // make a list of monitors
397   sdl_monitor_info::list = NULL;
398   tailptr = &sdl_monitor_info::list;
398   osd_monitor_info::list = NULL;
399   tailptr = &osd_monitor_info::list;
399400
400401   #if (SDLMAME_SDL2)
401402   {
402      int i, monx = 0;
403      int i;
403404
404405      osd_printf_verbose("Enter init_monitors\n");
405406
406407      for (i = 0; i < SDL_GetNumVideoDisplays(); i++)
407408      {
408409         sdl_monitor_info *monitor;
409         SDL_DisplayMode dmode;
410410
411         char temp[64];
412         snprintf(temp, sizeof(temp)-1, "%s%d", OSDOPTION_SCREEN,i);
413
411414         // allocate a new monitor info
412         monitor = global_alloc_clear(sdl_monitor_info);
413         monitor->m_handle = i;
414415
415         snprintf(monitor->m_name, sizeof(monitor->m_name)-1, "%s%d", OSDOPTION_SCREEN,i);
416         monitor = global_alloc_clear(sdl_monitor_info(i, temp, 1.0f));
416417
417         SDL_GetDesktopDisplayMode(i, &dmode);
418         SDL_GetDisplayBounds(i, &monitor->m_dimensions);
418         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->devicename(),
419               monitor->position_size().width(), monitor->position_size().height());
419420
420421         // guess the aspect ratio assuming square pixels
421         monitor->m_aspect = (float)(dmode.w) / (float)(dmode.h);
422         monitor->set_aspect((float)(monitor->position_size().width()) / (float)(monitor->position_size().height()));
422423
423         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_name, dmode.w, dmode.h);
424
425         monx += dmode.w;
426
427         // save the primary monitor handle
428         if (i == 0)
429            primary_monitor = monitor;
430
431424         // hook us into the list
432425         *tailptr = monitor;
433426         tailptr = &monitor->m_next;
r244679r244680
446439   // free all of our monitor information
447440   while (sdl_monitor_info::list != NULL)
448441   {
449      sdl_monitor_info *temp = sdl_monitor_info::list;
442      osd_monitor_info *temp = sdl_monitor_info::list;
450443      sdl_monitor_info::list = temp->next();
451444      global_free(temp);
452445   }
r244679r244680
458451//============================================================
459452
460453#if (SDLMAME_SDL2) || defined(SDLMAME_WIN32)
461sdl_monitor_info *sdl_monitor_info::pick_monitor(sdl_options &options, int index)
454osd_monitor_info *osd_monitor_info::pick_monitor(sdl_options &options, int index)
462455{
463   sdl_monitor_info *monitor;
456   osd_monitor_info *monitor;
464457   const char *scrname, *scrname2;
465458   int moncount = 0;
466459   float aspect;
r244679r244680
494487         goto finishit;
495488
496489   // return the primary just in case all else fails
497   monitor = primary_monitor;
490   for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next())
491      if (monitor->is_primary())
492         goto finishit;
498493
494   // FIXME: FatalError?
499495finishit:
500496   if (aspect != 0)
501497   {
r244679r244680
504500   return monitor;
505501}
506502#else
507sdl_monitor_info *sdl_monitor_info::pick_monitor(sdl_options &options, int index)
503osd_monitor_info *osd_monitor_info::pick_monitor(sdl_options &options, int index)
508504{
509   sdl_monitor_info *monitor;
505   osd_monitor_info *monitor;
510506   float aspect;
511507
512508   // get the aspect ratio
513509   aspect = get_aspect(options.aspect(), options.aspect(index), TRUE);
514510
515511   // return the primary just in case all else fails
516   monitor = primary_monitor;
512   monitor = osd_monitor_info::list;
517513
518514   if (aspect != 0)
519515   {
trunk/src/osd/sdl/video.h
r244679r244680
7373class osd_rect
7474{
7575public:
76   osd_rect()
77   : m_x(0), m_y(0), m_d(0,0)
78   {
79   }
7680   osd_rect(const int x, const int y, const int &w, const int &h)
7781   : m_x(x), m_y(y), m_d(w,h)
7882   {
r244679r244680
105109   return osd_rect(r.x, r.y, r.w, r.h);
106110}
107111
108// FIXME: This is sort of ugly ... and should be a real interface only
109class sdl_monitor_info
112class osd_monitor_info
110113{
111114public:
112115
113   sdl_monitor_info()
114   : m_next(NULL), m_handle(0), m_aspect(0.0f)
115      {}
116   sdl_monitor_info(const UINT64 handle, const char *monitor_device, float aspect)
116#if 0
117   osd_monitor_info()
118   : m_next(NULL), m_handle(NULL), m_aspect(0.0f)
119      {
120         strcpy(m_name, "");
121      }
122#endif
123   osd_monitor_info(void *handle, const char *monitor_device, float aspect)
117124   : m_next(NULL), m_handle(handle), m_aspect(aspect)
118125   {
119126      strncpy(m_name, monitor_device, ARRAY_LENGTH(m_name) - 1);
120      refresh();
121127   }
122128
123   const UINT64 handle() { return m_handle; }
124   const osd_rect position_size() { refresh(); return SDL_Rect_to_osd_rect(m_dimensions); }
125   const osd_rect usuable_position_size() { refresh(); return SDL_Rect_to_osd_rect(m_dimensions); }
129   virtual ~osd_monitor_info() { }
126130
131   const void *handle() { return m_handle; }
132
133   const osd_rect &position_size() { refresh(); return m_pos_size; }
134   const osd_rect &usuable_position_size() { refresh(); return m_usuable_pos_size; }
135
127136   const char *devicename() { refresh(); return m_name[0] ? m_name : "UNKNOWN"; }
128137
129138   float aspect();
130139
131140   void set_aspect(const float a) { m_aspect = a; }
141   bool is_primary() { refresh(); return m_is_primary; }
132142
143   osd_monitor_info    * next() { return m_next; }   // pointer to next monitor in list
144
145   static osd_monitor_info *pick_monitor(sdl_options &options, int index);
146   static osd_monitor_info *list;
147
148   // FIXME: should be private!
149   osd_monitor_info    *m_next;                   // pointer to next monitor in list
150protected:
151   virtual void refresh() = 0;
152   osd_rect         m_pos_size;
153   osd_rect         m_usuable_pos_size;
154   bool            m_is_primary;
155   char                m_name[64];
156private:
157
158   void *              m_handle;                 // handle to the monitor
159   float               m_aspect;                 // computed/configured aspect ratio of the physical device
160};
161
162
163class sdl_monitor_info : public osd_monitor_info
164{
165public:
166#if 0
167   sdl_monitor_info()
168   : m_next(NULL), m_handle(0), m_aspect(0.0f)
169      {}
170#endif
171   sdl_monitor_info(const UINT64 handle, const char *monitor_device, float aspect)
172   : osd_monitor_info(&m_handle, monitor_device, aspect), m_handle(handle)
173   {
174      refresh();
175   }
176
133177   // STATIC
134178   static void init();
135179   static void exit();
136   static sdl_monitor_info *pick_monitor(sdl_options &options, int index);
137180#if !defined(SDLMAME_WIN32) && !(SDLMAME_SDL2)
138181   static void add_primary_monitor(void *data);
139182#endif
140
141   sdl_monitor_info    * next() { return m_next; }   // pointer to next monitor in list
142
143   // STATIC
144   static sdl_monitor_info *primary_monitor;
145   static sdl_monitor_info *list;
146
147   sdl_monitor_info    * m_next;                   // pointer to next monitor in list
183#if defined(SDLMAME_WIN32) && !(SDLMAME_SDL2)
184   static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
185#endif
148186private:
149   void refresh();
187   void virtual refresh();
150188
151189   UINT64              m_handle;                 // handle to the monitor
152   SDL_Rect            m_dimensions;
153   char                m_name[64];
154   float               m_aspect;                 // computed/configured aspect ratio of the physical device
155190};
156191
157192struct osd_video_config
trunk/src/osd/sdl/window.c
r244679r244680
865865      minimum_height -= 4;
866866   }
867867
868   num = SDL_GetNumDisplayModes(m_monitor->handle());
868   // FIXME: this should be provided by monitor !
869   num = SDL_GetNumDisplayModes(*((UINT64 *)m_monitor->handle()));
869870
870871   if (num == 0)
871872   {
r244679r244680
877878      for (i = 0; i < num; ++i)
878879      {
879880         SDL_DisplayMode mode;
880         SDL_GetDisplayMode(m_monitor->handle(), i, &mode);
881         SDL_GetDisplayMode(*((UINT64 *)m_monitor->handle()), i, &mode);
881882
882883         // compute initial score based on difference between target and current
883884         size_score = 1.0f / (1.0f + fabsf((INT32)mode.w - target_width) + fabsf((INT32)mode.h - target_height));
r244679r244680
13921393   INT32 viswidth, visheight;
13931394   INT32 adjwidth, adjheight;
13941395   float pixel_aspect;
1395   sdl_monitor_info *monitor = m_monitor;
1396   osd_monitor_info *monitor = m_monitor;
13961397
13971398   // get the pixel aspect ratio for the target monitor
13981399   pixel_aspect = monitor->aspect();
trunk/src/osd/sdl/window.h
r244679r244680
3535class sdl_window_info : public osd_window
3636{
3737public:
38   sdl_window_info(running_machine &a_machine, int index, sdl_monitor_info *a_monitor,
38   sdl_window_info(running_machine &a_machine, int index, osd_monitor_info *a_monitor,
3939         const osd_window_config *config)
4040   : osd_window(), m_next(NULL),
4141      // Following three are used by input code to defer resizes
r244679r244680
9494   int xy_to_render_target(int x, int y, int *xt, int *yt);
9595
9696   running_machine &machine() const { return m_machine; }
97   sdl_monitor_info *monitor() const { return m_monitor; }
97   osd_monitor_info *monitor() const { return m_monitor; }
9898   int fullscreen() const { return m_fullscreen; }
9999
100100   render_target *target() { return m_target; }
r244679r244680
164164   // Pointer to machine
165165   running_machine &   m_machine;
166166   // monitor info
167   sdl_monitor_info *  m_monitor;
167   osd_monitor_info *  m_monitor;
168168   int                 m_fullscreen;
169169   int                 m_index;
170170   osd_renderer *      m_renderer;
trunk/src/osd/windows/video.c
r244679r244680
4141//============================================================
4242
4343// monitor info
44win_monitor_info *win_monitor_list;
45static win_monitor_info *primary_monitor;
44osd_monitor_info *osd_monitor_info::list = NULL;
4645
47
48
4946//============================================================
5047//  PROTOTYPES
5148//============================================================
5249
5350static void init_monitors(void);
54static win_monitor_info *pick_monitor(windows_options &options, int index);
51static osd_monitor_info *pick_monitor(windows_options &options, int index);
5552
5653static void check_osd_inputs(running_machine &machine);
5754
r244679r244680
10097   window_exit();
10198
10299   // free all of our monitor information
103   while (win_monitor_list != NULL)
100   while (osd_monitor_info::list != NULL)
104101   {
105      win_monitor_info *temp = win_monitor_list;
106      win_monitor_list = temp->m_next;
102      osd_monitor_info *temp = osd_monitor_info::list;
103      osd_monitor_info::list = temp->m_next;
107104      global_free(temp);
108105   }
109106}
110107
111108
112109
113win_monitor_info::win_monitor_info()
114   : m_next(NULL),
115      m_handle(NULL),
116      m_aspect(0.0f),
117      m_name(NULL)
110win_monitor_info::win_monitor_info(const HMONITOR handle, const char *monitor_device, float aspect)
111   : osd_monitor_info(&m_handle, monitor_device, aspect), m_handle(handle)
118112{
119113}
120114
121115win_monitor_info::~win_monitor_info()
122116{
123   if (m_name != NULL)
124      osd_free(m_name);
125117}
126118
127119//============================================================
r244679r244680
136128   m_info.cbSize = sizeof(m_info);
137129   result = GetMonitorInfo(m_handle, (LPMONITORINFO)&m_info);
138130   assert(result);
139   if (m_name != NULL)
140      osd_free(m_name);
141   m_name = utf8_from_tstring(m_info.szDevice);
131   char *temp = utf8_from_tstring(m_info.szDevice);
132
133   strncpy(m_name, temp, sizeof(m_name));
134
135   m_pos_size = RECT_to_osd_rect(m_info.rcMonitor);
136   m_usuable_pos_size = RECT_to_osd_rect(m_info.rcWork);
137   m_is_primary = ((m_info.dwFlags & MONITORINFOF_PRIMARY) != 0);
142138   (void)result; // to silence gcc 4.6
143139}
144140
145141
146142
147143//============================================================
148//  winvideo_monitor_get_aspect
144//  sdlvideo_monitor_get_aspect
149145//============================================================
150146
151float win_monitor_info::aspect()
147float osd_monitor_info::aspect()
152148{
153149   // refresh the monitor information and compute the aspect
154150   refresh();
155151   // FIXME: returning 0 looks odd, video_config is bad
156152   if (video_config.keepaspect)
157153   {
158      int width, height;
159      refresh();
160      width = rect_width(&m_info.rcMonitor);
161      height = rect_height(&m_info.rcMonitor);
162      return m_aspect / ((float)width / (float)height);
154      return m_aspect / ((float)m_pos_size.width() / (float)m_pos_size.height());
163155   }
164156   return 0.0f;
165157}
166158
167
168
169159//============================================================
170160//  winvideo_monitor_from_handle
171161//============================================================
172162
173win_monitor_info *win_monitor_info::monitor_from_handle(HMONITOR hmonitor)
163osd_monitor_info *win_monitor_info::monitor_from_handle(HMONITOR hmonitor)
174164{
175   win_monitor_info *monitor;
165   osd_monitor_info *monitor;
176166
177167   // find the matching monitor
178   for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
179      if (monitor->handle() == hmonitor)
168   for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next)
169      if (*((HMONITOR *)monitor->oshandle()) == hmonitor)
180170         return monitor;
181171   return NULL;
182172}
r244679r244680
214204
215205static void init_monitors(void)
216206{
217   win_monitor_info **tailptr;
207   osd_monitor_info **tailptr;
218208
219209   // make a list of monitors
220   win_monitor_list = NULL;
221   tailptr = &win_monitor_list;
210   osd_monitor_info::list = NULL;
211   tailptr = &osd_monitor_info::list;
222212   EnumDisplayMonitors(NULL, NULL, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr);
223213
224214   // if we're verbose, print the list of monitors
225215   {
226      win_monitor_info *monitor;
227      for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
216      osd_monitor_info *monitor;
217      for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next)
228218      {
229         osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle(), monitor->devicename(), (monitor == primary_monitor) ? "(primary)" : "");
219         osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->oshandle(), monitor->devicename(), monitor->is_primary() ? "(primary)" : "");
230220      }
231221   }
232222}
r244679r244680
239229
240230BOOL CALLBACK win_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
241231{
242   win_monitor_info ***tailptr = (win_monitor_info ***)data;
243   win_monitor_info *monitor;
232   osd_monitor_info ***tailptr = (osd_monitor_info ***)data;
233   osd_monitor_info *monitor;
244234   MONITORINFOEX info;
245235   BOOL result;
246236
r244679r244680
251241   (void)result; // to silence gcc 4.6
252242
253243   // allocate a new monitor info
254   monitor = global_alloc(win_monitor_info);
255
244   monitor = global_alloc(win_monitor_info(handle, "", 1.0f));
256245   // copy in the data
257   monitor->m_handle = handle;
258   monitor->m_info = info;
246   //monitor->refresh();
259247
260248   // guess the aspect ratio assuming square pixels
261249   monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top));
262250
263   // save the primary monitor handle
264   if (monitor->m_info.dwFlags & MONITORINFOF_PRIMARY)
265      primary_monitor = monitor;
266
267251   // hook us into the list
268252   **tailptr = monitor;
269253   *tailptr = &monitor->m_next;
r244679r244680
278262//  pick_monitor
279263//============================================================
280264
281static win_monitor_info *pick_monitor(windows_options &options, int index)
265static osd_monitor_info *pick_monitor(windows_options &options, int index)
282266{
283267   const char *scrname, *scrname2;
284   win_monitor_info *monitor;
268   osd_monitor_info *monitor;
285269   int moncount = 0;
286270   float aspect;
287271
r244679r244680
299283   // look for a match in the name first
300284   if (scrname != NULL && (scrname[0] != 0))
301285   {
302      for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
286      for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next)
303287      {
304288         moncount++;
305289         if (strcmp(scrname, monitor->devicename()) == 0)
r244679r244680
309293
310294   // didn't find it; alternate monitors until we hit the jackpot
311295   index %= moncount;
312   for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
296   for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next)
313297      if (index-- == 0)
314298         goto finishit;
315299
316300   // return the primary just in case all else fails
317   monitor = primary_monitor;
301   for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next)
302      if (monitor->is_primary())
303         goto finishit;
318304
319305finishit:
320306   if (aspect != 0)
trunk/src/osd/windows/video.h
r244679r244680
5454class osd_rect
5555{
5656public:
57   osd_rect()
58   : m_x(0), m_y(0), m_d(0,0)
59   {
60   }
5761   osd_rect(const int x, const int y, const int &w, const int &h)
5862   : m_x(x), m_y(y), m_d(w,h)
5963   {
r244679r244680
8690   return osd_rect(r.left, r.top, r.right - r.left, r.bottom - r.top);
8791}
8892
89class win_monitor_info
93class osd_monitor_info
9094{
9195public:
92   win_monitor_info();
93   virtual ~win_monitor_info();
9496
95   void refresh();
97#if 0
98   osd_monitor_info()
99   : m_next(NULL), m_handle(NULL), m_aspect(0.0f)
100      {
101         strcpy(m_name, "");
102      }
103#endif
104   osd_monitor_info(void *handle, const char *monitor_device, float aspect)
105   : m_next(NULL), m_handle(handle), m_aspect(aspect)
106   {
107      strncpy(m_name, monitor_device, ARRAY_LENGTH(m_name) - 1);
108   }
96109
97   const HMONITOR handle() { return m_handle; }
98   // position_size is used only by draw_dd renderer
99   const osd_rect position_size() { refresh(); return RECT_to_osd_rect(m_info.rcMonitor); }
100   const osd_rect usuable_position_size() { refresh(); return RECT_to_osd_rect(m_info.rcWork); }
101   bool is_primary() { return (m_info.dwFlags & MONITORINFOF_PRIMARY) != 0; }
102   const char *devicename() { refresh(); return (m_name != NULL) ? m_name : "UNKNOWN"; }
110   virtual ~osd_monitor_info() { }
103111
112   const void *oshandle() { return m_handle; }
113
114   const osd_rect &position_size() { refresh(); return m_pos_size; }
115   const osd_rect &usuable_position_size() { refresh(); return m_usuable_pos_size; }
116
117   const char *devicename() { refresh(); return m_name[0] ? m_name : "UNKNOWN"; }
118
104119   float aspect();
105120
106121   void set_aspect(const float a) { m_aspect = a; }
122   bool is_primary() { refresh(); return m_is_primary; }
107123
108   win_monitor_info  * m_next;                   // pointer to next monitor in list
124   osd_monitor_info    * next() { return m_next; }   // pointer to next monitor in list
109125
126#ifdef OSD_SDL
127   static osd_monitor_info *pick_monitor(sdl_options &options, int index);
128#endif
129   static osd_monitor_info *list;
130
131   // FIXME: should be private!
132   osd_monitor_info    *m_next;                   // pointer to next monitor in list
133protected:
134   virtual void refresh() = 0;
135   osd_rect         m_pos_size;
136   osd_rect         m_usuable_pos_size;
137   bool            m_is_primary;
138   char                m_name[64];
139private:
140
141   void *              m_handle;                 // handle to the monitor
142   float               m_aspect;                 // computed/configured aspect ratio of the physical device
143};
144
145class win_monitor_info : public osd_monitor_info
146{
147public:
148   win_monitor_info(const HMONITOR handle, const char *monitor_device, float aspect);
149   virtual ~win_monitor_info();
150
151   virtual void refresh();
152
110153   // static
111154
112155   static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
113   static win_monitor_info *monitor_from_handle(HMONITOR monitor);
156   static osd_monitor_info *monitor_from_handle(HMONITOR monitor);
114157
158   HMONITOR handle() { return m_handle; }
159
115160private:
116161   HMONITOR            m_handle;                 // handle to the monitor
117162   MONITORINFOEX       m_info;                   // most recently retrieved info
118
119   float               m_aspect;               // computed/configured aspect ratio of the physical device
120   char *              m_name;
121163};
122164
123165struct osd_video_config
trunk/src/osd/windows/window.c
r244679r244680
646646//  (main thread)
647647//============================================================
648648
649void win_window_info::create(running_machine &machine, int index, win_monitor_info *monitor, const osd_window_config *config)
649void win_window_info::create(running_machine &machine, int index, osd_monitor_info *monitor, const osd_window_config *config)
650650{
651651   win_window_info *window, *win;
652652
r244679r244680
833833//  (window thread)
834834//============================================================
835835
836win_monitor_info *win_window_info::winwindow_video_window_monitor(const osd_rect *proposed)
836osd_monitor_info *win_window_info::winwindow_video_window_monitor(const osd_rect *proposed)
837837{
838   win_monitor_info *monitor;
838   osd_monitor_info *monitor;
839839
840840   // in window mode, find the nearest
841841   if (!m_fullscreen)
r244679r244680
858858      monitor = m_monitor;
859859
860860   // make sure we're up-to-date
861   monitor->refresh();
861   //monitor->refresh();
862862   return monitor;
863863}
864864
r244679r244680
15231523   INT32 viswidth, visheight;
15241524   INT32 adjwidth, adjheight;
15251525   float pixel_aspect;
1526   win_monitor_info *monitor = winwindow_video_window_monitor(&rect);
1526   osd_monitor_info *monitor = winwindow_video_window_monitor(&rect);
15271527
15281528   assert(GetCurrentThreadId() == window_threadid);
15291529
r244679r244680
16861686   //assert(GetCurrentThreadId() == window_threadid);
16871687
16881688   // compute the maximum client area
1689   m_monitor->refresh();
1689   //m_monitor->refresh();
16901690   osd_rect maximum = m_monitor->usuable_position_size();
16911691
16921692   // clamp to the window's max
r244679r244680
18231823   // in full screen, make sure it covers the primary display
18241824   else
18251825   {
1826      win_monitor_info *monitor = winwindow_video_window_monitor(NULL);
1826      osd_monitor_info *monitor = winwindow_video_window_monitor(NULL);
18271827      newrect = monitor->position_size();
18281828   }
18291829
trunk/src/osd/windows/window.h
r244679r244680
4646
4747   void update();
4848
49   win_monitor_info *winwindow_video_window_monitor(const osd_rect *proposed);
49   osd_monitor_info *winwindow_video_window_monitor(const osd_rect *proposed);
5050
5151   bool win_has_menu()
5252   {
r244679r244680
6060      return osd_dim(client.right - client.left, client.bottom - client.top);
6161   }
6262
63   win_monitor_info *monitor() const { return m_monitor; }
63   osd_monitor_info *monitor() const { return m_monitor; }
6464
6565   void destroy();
6666
6767   // static
6868
69   static void create(running_machine &machine, int index, win_monitor_info *monitor, const osd_window_config *config);
69   static void create(running_machine &machine, int index, osd_monitor_info *monitor, const osd_window_config *config);
7070
7171   // static callbacks
7272
r244679r244680
8686   int                 m_ismaximized;
8787
8888   // monitor info
89   win_monitor_info *  m_monitor;
89   osd_monitor_info *  m_monitor;
9090   int                 m_fullscreen;
9191   int                 m_fullscreen_safe;
9292   float               m_aspect;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team