trunk/src/mame/drivers/segas16b.c
| r243410 | r243411 | |
| 79 | 79 | Sega System 16B Hardware Overview |
| 80 | 80 | --------------------------------- |
| 81 | 81 | |
| 82 | | The games on this system include... (there may be more??) //todo |
| 82 | The games on this system include... |
| 83 | 83 | Ace Attacker (C) Sega/Jaleco, 1989 |
| 84 | 84 | Alien Syndrome (C) Sega, 1987 |
| 85 | 85 | Altered Beast / Jyuohki (C) Sega, 1988 |
| r243410 | r243411 | |
| 386 | 386 | -----------------|--------------------------------------------------------------------------------------------------| |
| 387 | 387 | Shinobi |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 388 | 388 | CPU - 317-0049 |--------------------------------------------------------------------------------------------------| |
| 389 | | 8751 - |EPR11280 EPR11281 - EPR11282 EPR11283 - EPR11287 EPR11288 EPR11289 - - | |
| 389 | 8751 - n/a |EPR11280 EPR11281 - EPR11282 EPR11283 - EPR11287 EPR11288 EPR11289 - - | |
| 390 | 390 | |--------------------------------------------------------------------------------------------------| |
| 391 | 391 | | | |
| 392 | 392 | J1 O O J2 O-O |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243410 | r243411 | |
| 430 | 430 | -----------------|--------------------------------------------------------------------------------------------------| |
| 431 | 431 | Sonic Boom |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 432 | 432 | CPU - 317-0053 |--------------------------------------------------------------------------------------------------| |
| 433 | | 8751 - |EPR11340 EPR11341 - EPR11342 EPR11343 - EPR11347 EPR11348 EPR11349 - - | |
| 433 | 8751 - n/a |EPR11340 EPR11341 - EPR11342 EPR11343 - EPR11347 EPR11348 EPR11349 - - | |
| 434 | 434 | |--------------------------------------------------------------------------------------------------| |
| 435 | 435 | | | |
| 436 | 436 | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243410 | r243411 | |
| 441 | 441 | -----------------|--------------------------------------------------------------------------------------------------| |
| 442 | 442 | Passing Shot |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 443 | 443 | CPU - 317-0080 |--------------------------------------------------------------------------------------------------| |
| 444 | | 8751 - |EPR11870 - - EPR11871 - - EPR11857 EPR11858 EPR11859 EPR11860 EPR11861| |
| 444 | 8751 - n/a |EPR11870 - - EPR11871 - - EPR11857 EPR11858 EPR11859 EPR11860 EPR11861| |
| 445 | 445 | |--------------------------------------------------------------------------------------------------| |
| 446 | 446 | | | |
| 447 | 447 | J1 O O J2 O-O |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243410 | r243411 | |
| 452 | 452 | -----------------|--------------------------------------------------------------------------------------------------| |
| 453 | 453 | Bullet |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 454 | 454 | CPU - 317-0041 |--------------------------------------------------------------------------------------------------| |
| 455 | | 8751 - |EPR11007 EPR11008 EPR11009 EPR11010 EPR11011 EPR11012 EPR10997 EPR10998 - - - | |
| 455 | 8751 - n/a |EPR11007 EPR11008 EPR11009 EPR11010 EPR11011 EPR11012 EPR10997 EPR10998 - - - | |
| 456 | 456 | |--------------------------------------------------------------------------------------------------| |
| 457 | 457 | | | |
| 458 | 458 | J1 O O J2 O-O |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243410 | r243411 | |
| 463 | 463 | -----------------|--------------------------------------------------------------------------------------------------| |
| 464 | 464 | Tetris |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 465 | 465 | CPU - 317-0091 |--------------------------------------------------------------------------------------------------| |
| 466 | | 8751 - |EPR12163 - - EPR12164 - - EPR12168 - - - - | |
| 466 | 8751 - n/a |EPR12163 - - EPR12164 - - EPR12168 - - - - | |
| 467 | 467 | |--------------------------------------------------------------------------------------------------| |
| 468 | 468 | | | |
| 469 | 469 | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243410 | r243411 | |
| 474 | 474 | -----------------|--------------------------------------------------------------------------------------------------| |
| 475 | 475 | Wonder Boy III |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 476 | 476 | CPU - 317-0085 |--------------------------------------------------------------------------------------------------| |
| 477 | | 8751 - |EPR12198 EPR12199 - EPR12100 EPR12101 - EPR12127 - - - - | |
| 477 | 8751 - n/a |EPR12198 EPR12199 - EPR12100 EPR12101 - EPR12127 - - - - | |
| 478 | 478 | |--------------------------------------------------------------------------------------------------| |
| 479 | 479 | | | |
| 480 | | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| 481 | | |--------------------------------------------------------------------------------------------------| |
| 482 | | |EPR12190 EPR12191 EPR12192 EPR12193 EPR12194 EPR12195 EPR12196 EPR12197 EPR12124 EPR12125 EPR12126| |
| 480 | J1 O O J2 O-O |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| 481 | J3 512 J4 256 |--------------------------------------------------------------------------------------------------| |
| 482 | J5 512 J6 512 |EPR12190 EPR12191 EPR12192 EPR12193 EPR12194 EPR12195 EPR12196 EPR12197 EPR12124 EPR12125 EPR12126| |
| 483 | 483 | -----------------|--------------------------------------------------------------------------------------------------| |
| 484 | 484 | |
| 485 | 485 | -----------------|--------------------------------------------------------------------------------------------------| |
| 486 | 486 | Excite League |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 487 | | CPU - 317-0079? |--------------------------------------------------------------------------------------------------| |
| 487 | CPU - 317-0079 |--------------------------------------------------------------------------------------------------| |
| 488 | 488 | 8751 - |EPR11936 EPR11937 EPR11938 EPR11939 EPR11940 EPR11941 EPR11945 EPR11140 EPR11141 EPR11142 EPR11143| |
| 489 | 489 | |--------------------------------------------------------------------------------------------------| |
| 490 | 490 | | | |
| 491 | | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| 492 | | |--------------------------------------------------------------------------------------------------| |
| 493 | | |EPR11950 EPR11951 EPR11952 EPR11953 EPR11954 EPR11955 EPR11956 EPR11957 EPR11942 EPR11943 EPR11944| |
| 491 | J1 O O J2 O-O |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| 492 | J3 512 J4 256 |--------------------------------------------------------------------------------------------------| |
| 493 | J5 512 J6 256/512|EPR11950 EPR11951 EPR11952 EPR11953 EPR11954 EPR11955 EPR11956 EPR11957 EPR11942 EPR11943 EPR11944| |
| 494 | 494 | -----------------|--------------------------------------------------------------------------------------------------| |
| 495 | | |
| 495 | J6 jumper tied from lower left side of 256 jumper to upper right side of 512 jumper like this: / |
| 496 | 496 | -----------------|--------------------------------------------------------------------------------------------------| |
| 497 | 497 | Super League |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 498 | | CPU - 317-0045? |--------------------------------------------------------------------------------------------------| |
| 498 | CPU - 317-0045 |--------------------------------------------------------------------------------------------------| |
| 499 | 499 | 8751 - |EPR11130 EPR11131 EPR11132 EPR11133 EPR11134 EPR11135 EPR11139 EPR11140 EPR11141 EPR11142 EPR11143| |
| 500 | 500 | |--------------------------------------------------------------------------------------------------| |
| 501 | 501 | | | |
| 502 | | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| 503 | | |--------------------------------------------------------------------------------------------------| |
| 504 | | |EPR11144 EPR11145 EPR11146 EPR11147 EPR11148 EPR11149 EPR11150 EPR11151 EPR11136 EPR11137 EPR11138| |
| 502 | J1 O O J2 O-O |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| 503 | J3 512 J4 256 |--------------------------------------------------------------------------------------------------| |
| 504 | J5 512 J6 512 |EPR11144 EPR11145 EPR11146 EPR11147 EPR11148 EPR11149 EPR11150 EPR11151 EPR11136 EPR11137 EPR11138| |
| 505 | 505 | -----------------|--------------------------------------------------------------------------------------------------| |
| 506 | 506 | |
| 507 | 507 | -----------------|--------------------------------------------------------------------------------------------------| |
| r243410 | r243411 | |
| 592 | 592 | 315-5298 - Signetics PLS153F Field Programmable Logic Array stamped '315-5298' (DIP20) |
| 593 | 593 | 315-5248 - Custom Sega IC (QFP100) |
| 594 | 594 | 315-5250 - Custom Sega IC (QFP120) |
| 595 | | S1-S16 - Jumpers to configure ROM sizes //usage TODO |
| 595 | S1-S16 - Jumpers to configure ROM sizes |
| 596 | 596 | Jumpers are either shorted or not shorted. |
| 597 | 597 | In the tables below, the listed jumpers per game are the shorted ones, the unlisted ones are not shorted. |
| 598 | 598 | |
| r243410 | r243411 | |
| 714 | 714 | Notes: |
| 715 | 715 | * - Empty position, no socket |
| 716 | 716 | 315-5298 - Signetics PLS153F Field Programmable Logic Array stamped '315-5298' (DIP20) |
| 717 | | S1-S18 - Jumpers to configure ROM sizes //usage TODO |
| 717 | S1-S18 - Jumpers to configure ROM sizes |
| 718 | 718 | Jumpers are either shorted or not shorted. |
| 719 | 719 | In the tables below, the listed jumpers per game are the shorted ones, the unlisted ones are not shorted. |
| 720 | 720 | S1/S2 - Jumpers to configure 68k program ROM size |
| r243410 | r243411 | |
| 737 | 737 | -----------------|--------------------------------------------------------------------------------------------------------------------------------------| |
| 738 | 738 | Golden Axe |A1 A2 A3 A4 A5 A6 A7 A8 A10 A11 A12 A14 A15 A16 | |
| 739 | 739 | CPU - 317-0121 |--------------------------------------------------------------------------------------------------------------------------------------| |
| 740 | | 8751 - |- - - - EPR12539 EPR12519 EPR12540 EPR12521 EPR12390 MPR12384 - EPR12385 EPR12386 EPR12387| |
| 740 | 8751 - n/a |- - - - EPR12539 EPR12519 EPR12540 EPR12521 EPR12390 MPR12384 - EPR12385 EPR12386 EPR12387| |
| 741 | 741 | |--------------------------------------------------------------------------------------------------------------------------------------| |
| 742 | 742 | | | |
| 743 | 743 | |B1 B2 B3 B4 B5 B6 B7 B8 B10 B11 B12 B13 B14 B15 B16 | |
| r243410 | r243411 | |
| 814 | 814 | -----------------|--------------------------------------------------------------------------------------------------------------------------------------| |
| 815 | 815 | Altered Beast |A1 A2 A3 A4 A5 A6 A7 A8 A10 A11 A12 A14 A15 A16 | |
| 816 | 816 | CPU - 68000 |--------------------------------------------------------------------------------------------------------------------------------------| |
| 817 | | 8751 - 317-0078? |EPR11717 EPR11718 EPR11719 - EPR11884 - EPR11885 - EPR11671 EPR11672 EPR11673 EPR11722 EPR11723 EPR11724| |
| 817 | 8751 - 317-0078 |EPR11717 EPR11718 EPR11719 - EPR11884 - EPR11885 - EPR11671 EPR11672 EPR11673 EPR11722 EPR11723 EPR11724| |
| 818 | 818 | |--------------------------------------------------------------------------------------------------------------------------------------| |
| 819 | 819 | | | |
| 820 | 820 | |B1 B2 B3 B4 B5 B6 B7 B8 B10 B11 B12 B13 B14 B15 B16 | |
| r243410 | r243411 | |
| 858 | 858 | -----------------|--------------------------------------------------------------------------------------------------------------------------------------| |
| 859 | 859 | Tetris |A1 A2 A3 A4 A5 A6 A7 A8 A10 A11 A12 A14 A15 A16 | |
| 860 | 860 | CPU - 317-0092 |--------------------------------------------------------------------------------------------------------------------------------------| |
| 861 | | 8751 - |- - - - EPR12192 - EPR12193 - EPR12168 - - EPR12165 EPR12166 EPR12167| |
| 861 | 8751 - n/a |- - - - EPR12192 - EPR12193 - EPR12168 - - EPR12165 EPR12166 EPR12167| |
| 862 | 862 | |--------------------------------------------------------------------------------------------------------------------------------------| |
| 863 | 863 | | | |
| 864 | 864 | |B1 B2 B3 B4 B5 B6 B7 B8 B10 B11 B12 B13 B14 B15 B16 | |
| 865 | | |--------------------------------------------------------------------------------------------------------------------------------------| |
| 866 | | |EPR - - - EPR - - - - - - - - - - | |
| 865 | S2 S3 S6 S7 S9 |--------------------------------------------------------------------------------------------------------------------------------------| |
| 866 | S11 S13 S15 S17 |EPR12194 - - - EPR12195 - - - - - - - - - - | |
| 867 | 867 | -----------------|--------------------------------------------------------------------------------------------------------------------------------------| |
| 868 | | Sega part number for B1 & B5 unknown |
| 869 | 868 | |
| 870 | 869 | ***************************************************************************/ |
| 871 | 870 | |
| r243410 | r243411 | |
| 3646 | 3645 | ROM_LOAD( "opr-11673.a12", 0x30000, 0x20000, CRC(400c4a36) SHA1(de4bdfa91734410e0a7f6a16bf8336db172f458a) ) |
| 3647 | 3646 | |
| 3648 | 3647 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 3649 | | ROM_LOAD( "317-0078.mcu", 0x00000, 0x1000, NO_DUMP ) |
| 3648 | ROM_LOAD( "317-0078.c2", 0x00000, 0x1000, NO_DUMP ) |
| 3650 | 3649 | ROM_END |
| 3651 | 3650 | |
| 3652 | 3651 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 3689 | 3688 | ROM_LOAD( "opr-11673.a12", 0x30000, 0x20000, CRC(400c4a36) SHA1(de4bdfa91734410e0a7f6a16bf8336db172f458a) ) |
| 3690 | 3689 | |
| 3691 | 3690 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 3692 | | ROM_LOAD( "317-0077.mcu", 0x00000, 0x1000, NO_DUMP ) |
| 3691 | ROM_LOAD( "317-0077.c2", 0x00000, 0x1000, NO_DUMP ) |
| 3693 | 3692 | ROM_END |
| 3694 | 3693 | |
| 3695 | 3694 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 3732 | 3731 | ROM_LOAD( "opr-11673.a12", 0x30000, 0x20000, CRC(400c4a36) SHA1(de4bdfa91734410e0a7f6a16bf8336db172f458a) ) |
| 3733 | 3732 | |
| 3734 | 3733 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 3735 | | ROM_LOAD( "317-0076.mcu", 0x00000, 0x1000, NO_DUMP ) |
| 3734 | ROM_LOAD( "317-0076.c2", 0x00000, 0x1000, NO_DUMP ) |
| 3736 | 3735 | ROM_END |
| 3737 | 3736 | |
| 3738 | 3737 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 4695 | 4694 | ROM_REGION( 0x10000, "soundcpu", 0 ) // sound CPU |
| 4696 | 4695 | ROM_LOAD( "epr-11916.a10", 0x0000, 0x8000, CRC(7ab541cf) SHA1(feb88022ca1796d020e53e95ad345159bd415530) ) |
| 4697 | 4696 | |
| 4698 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 4699 | | ROM_LOAD( "317-0095.bin", 0x00000, 0x1000, NO_DUMP ) |
| 4697 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 4698 | ROM_LOAD( "317-0095.c2", 0x00000, 0x1000, NO_DUMP ) |
| 4700 | 4699 | ROM_END |
| 4701 | 4700 | |
| 4702 | 4701 | |
| r243410 | r243411 | |
| 4854 | 4853 | ROM_LOAD16_BYTE( "epr-12680.a3", 0x180001, 0x20000, CRC(f321452c) SHA1(cdccd8facc2941745f05fba25ad7d76b445eb873) ) |
| 4855 | 4854 | ROM_LOAD16_BYTE( "epr-12699.b12",0x180000, 0x20000, CRC(ac329586) SHA1(98994f41ee2f0fa5cd800f565b277ba21f2bb0c3) ) |
| 4856 | 4855 | |
| 4857 | | |
| 4858 | 4856 | ROM_REGION( 0x90000, "soundcpu", 0 ) // sound CPU |
| 4859 | 4857 | ROM_LOAD( "epr-12685.a10", 0x00000, 0x08000, CRC(5d0c16d7) SHA1(7ab13376c2a1da0566689ccbc258f94d1f4de487) ) |
| 4860 | 4858 | ROM_LOAD( "mpr-12686.a11", 0x10000, 0x20000, CRC(f451705e) SHA1(2b3d1b3ffbc6ba2285c4141e6fd3447252a31c8b) ) |
| r243410 | r243411 | |
| 4871 | 4869 | // |
| 4872 | 4870 | ROM_START( exctleag ) |
| 4873 | 4871 | ROM_REGION( 0x60000, "maincpu", 0 ) // 68000 code |
| 4874 | | ROM_LOAD16_BYTE( "epr-11939.a04", 0x00000, 0x10000, CRC(117dd98f) SHA1(0234c2cf3421849854bec3711ab64f50f12cc5dd) ) |
| 4875 | | ROM_LOAD16_BYTE( "epr-11936.a01", 0x00001, 0x10000, CRC(0863de60) SHA1(540a5cae2623bce296c07603239f737a782e3b0b) ) |
| 4876 | | ROM_LOAD16_BYTE( "epr-11940.a05", 0x20000, 0x10000, CRC(dec83274) SHA1(85919bcd372fbfb9f06c34897b4d28d08ef3c9d1) ) |
| 4877 | | ROM_LOAD16_BYTE( "epr-11937.a02", 0x20001, 0x10000, CRC(4ebda367) SHA1(ab4db50eb0d2e10a3b4b7fc0f4bdc82412379809) ) |
| 4878 | | ROM_LOAD16_BYTE( "epr-11941.a06", 0x40000, 0x10000, CRC(4df2d451) SHA1(644541b20e034a0149117874021c158bd3759e35) ) |
| 4879 | | ROM_LOAD16_BYTE( "epr-11938.a03", 0x40001, 0x10000, CRC(07c08d47) SHA1(47d3445cfa2514918206cd29a203837a9f434b42) ) |
| 4872 | ROM_LOAD16_BYTE( "epr-11939.a4", 0x00000, 0x10000, CRC(117dd98f) SHA1(0234c2cf3421849854bec3711ab64f50f12cc5dd) ) |
| 4873 | ROM_LOAD16_BYTE( "epr-11936.a1", 0x00001, 0x10000, CRC(0863de60) SHA1(540a5cae2623bce296c07603239f737a782e3b0b) ) |
| 4874 | ROM_LOAD16_BYTE( "epr-11940.a5", 0x20000, 0x10000, CRC(dec83274) SHA1(85919bcd372fbfb9f06c34897b4d28d08ef3c9d1) ) |
| 4875 | ROM_LOAD16_BYTE( "epr-11937.a2", 0x20001, 0x10000, CRC(4ebda367) SHA1(ab4db50eb0d2e10a3b4b7fc0f4bdc82412379809) ) |
| 4876 | ROM_LOAD16_BYTE( "epr-11941.a6", 0x40000, 0x10000, CRC(4df2d451) SHA1(644541b20e034a0149117874021c158bd3759e35) ) |
| 4877 | ROM_LOAD16_BYTE( "epr-11938.a3", 0x40001, 0x10000, CRC(07c08d47) SHA1(47d3445cfa2514918206cd29a203837a9f434b42) ) |
| 4880 | 4878 | |
| 4881 | 4879 | ROM_REGION( 0x2000, "maincpu:key", 0 ) // decryption key |
| 4882 | 4880 | ROM_LOAD( "317-0079.key", 0x0000, 0x2000, CRC(effefa1c) SHA1(f42e87f60c9589862ea2c05a29b1b15dc7194051) ) |
| r243410 | r243411 | |
| 4887 | 4885 | ROM_LOAD( "epr-11944.b11", 0x20000, 0x10000, CRC(a75cae80) SHA1(17c148a33b09b5403e68f5d96e506545c2ced206) ) |
| 4888 | 4886 | |
| 4889 | 4887 | ROM_REGION16_BE( 0x80000, "sprites", 0 ) // sprites |
| 4890 | | ROM_LOAD16_BYTE( "epr-11950.b01", 0x00001, 0x10000, CRC(af497849) SHA1(c5fdca8d3b1d83e3d377a49ecdc0fc53714afc09) ) |
| 4891 | | ROM_LOAD16_BYTE( "epr-11954.b05", 0x00000, 0x10000, CRC(5fa2106c) SHA1(2f2620fa52d07667dff4720fea32a6615d99e522) ) |
| 4892 | | ROM_LOAD16_BYTE( "epr-11951.b02", 0x20001, 0x10000, CRC(c04fa974) SHA1(b1a4fb8522126113d7857d559f169f09c5f51a13) ) |
| 4893 | | ROM_LOAD16_BYTE( "epr-11955.b06", 0x20000, 0x10000, CRC(86a0c368) SHA1(ab8d6ab5c571121bf9c5d40727b1ef385a033845) ) |
| 4894 | | ROM_LOAD16_BYTE( "epr-11952.b03", 0x40001, 0x10000, CRC(e64a9761) SHA1(e16b3a30165710abc11ab0f358cb7ef875cc672c) ) |
| 4895 | | ROM_LOAD16_BYTE( "epr-11956.b07", 0x40000, 0x10000, CRC(aff5c2fa) SHA1(1ec76193f2abf3547fa610761147436548beccbc) ) |
| 4896 | | ROM_LOAD16_BYTE( "epr-11953.b04", 0x60001, 0x10000, CRC(4cae3999) SHA1(22089e43a5e2e4fe672015366154e24ad38d3c19) ) |
| 4897 | | ROM_LOAD16_BYTE( "epr-11957.b08", 0x60000, 0x10000, CRC(218f835b) SHA1(bfef3ec45665a5921c095da34701528d4d4e0e3a) ) |
| 4888 | ROM_LOAD16_BYTE( "epr-11950.b1", 0x00001, 0x10000, CRC(af497849) SHA1(c5fdca8d3b1d83e3d377a49ecdc0fc53714afc09) ) |
| 4889 | ROM_LOAD16_BYTE( "epr-11954.b5", 0x00000, 0x10000, CRC(5fa2106c) SHA1(2f2620fa52d07667dff4720fea32a6615d99e522) ) |
| 4890 | ROM_LOAD16_BYTE( "epr-11951.b2", 0x20001, 0x10000, CRC(c04fa974) SHA1(b1a4fb8522126113d7857d559f169f09c5f51a13) ) |
| 4891 | ROM_LOAD16_BYTE( "epr-11955.b6", 0x20000, 0x10000, CRC(86a0c368) SHA1(ab8d6ab5c571121bf9c5d40727b1ef385a033845) ) |
| 4892 | ROM_LOAD16_BYTE( "epr-11952.b3", 0x40001, 0x10000, CRC(e64a9761) SHA1(e16b3a30165710abc11ab0f358cb7ef875cc672c) ) |
| 4893 | ROM_LOAD16_BYTE( "epr-11956.b7", 0x40000, 0x10000, CRC(aff5c2fa) SHA1(1ec76193f2abf3547fa610761147436548beccbc) ) |
| 4894 | ROM_LOAD16_BYTE( "epr-11953.b4", 0x60001, 0x10000, CRC(4cae3999) SHA1(22089e43a5e2e4fe672015366154e24ad38d3c19) ) |
| 4895 | ROM_LOAD16_BYTE( "epr-11957.b8", 0x60000, 0x10000, CRC(218f835b) SHA1(bfef3ec45665a5921c095da34701528d4d4e0e3a) ) |
| 4898 | 4896 | |
| 4899 | 4897 | ROM_REGION( 0x50000, "soundcpu", 0 ) // sound CPU |
| 4900 | | ROM_LOAD( "epr-11945.a07", 0x00000, 0x8000, CRC(c2a83012) SHA1(b3de8af803497438aa3e110a9c608ac290f7d1e8) ) |
| 4901 | | ROM_LOAD( "epr-11140.a08", 0x10000, 0x8000, CRC(b297371b) SHA1(4e787aa9ee2aeab4da30237644421df407b684a5) ) |
| 4902 | | ROM_LOAD( "epr-11141.a09", 0x20000, 0x8000, CRC(19756aa6) SHA1(81597e17b848f6a41f5fb117296e7508297815e4) ) |
| 4898 | ROM_LOAD( "epr-11945.a7", 0x00000, 0x8000, CRC(c2a83012) SHA1(b3de8af803497438aa3e110a9c608ac290f7d1e8) ) |
| 4899 | ROM_LOAD( "epr-11140.a8", 0x10000, 0x8000, CRC(b297371b) SHA1(4e787aa9ee2aeab4da30237644421df407b684a5) ) |
| 4900 | ROM_LOAD( "epr-11141.a9", 0x20000, 0x8000, CRC(19756aa6) SHA1(81597e17b848f6a41f5fb117296e7508297815e4) ) |
| 4903 | 4901 | ROM_LOAD( "epr-11142.a10", 0x30000, 0x8000, CRC(25d26c66) SHA1(2485afb859f84a9cc90b2091e9ae4eef263f42b3) ) |
| 4904 | 4902 | ROM_LOAD( "epr-11143.a11", 0x40000, 0x8000, CRC(848b7b77) SHA1(8903a39f8f0ffb4ce32117d33282876196516c30) ) |
| 4905 | 4903 | ROM_END |
| r243410 | r243411 | |
| 5041 | 5039 | ROM_LOAD( "epr-12390.ic8", 0x00000, 0x08000, CRC(399fc5f5) SHA1(6f290b36dc71ff4759598e2a9c185a8945a3c9e7) ) |
| 5042 | 5040 | ROM_LOAD( "mpr-12384.ic6", 0x10000, 0x20000, CRC(6218d8e7) SHA1(5a745c750efb4a61716f99befb7ed14cc84e9973) ) |
| 5043 | 5041 | |
| 5044 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 5045 | | ROM_LOAD( "317-0123a.bin", 0x00000, 0x1000, NO_DUMP ) |
| 5042 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 5043 | ROM_LOAD( "317-0123a.c2", 0x00000, 0x1000, NO_DUMP ) |
| 5046 | 5044 | ROM_END |
| 5047 | 5045 | |
| 5048 | 5046 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 5201 | 5199 | ROM_LOAD( "epr-12390.a10", 0x00000, 0x08000, CRC(399fc5f5) SHA1(6f290b36dc71ff4759598e2a9c185a8945a3c9e7) ) |
| 5202 | 5200 | ROM_LOAD( "mpr-12384.a11", 0x10000, 0x20000, CRC(6218d8e7) SHA1(5a745c750efb4a61716f99befb7ed14cc84e9973) ) |
| 5203 | 5201 | |
| 5204 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 5205 | | ROM_LOAD( "317-0112.bin", 0x00000, 0x1000, NO_DUMP ) |
| 5202 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 5203 | ROM_LOAD( "317-0112.c2", 0x00000, 0x1000, NO_DUMP ) |
| 5206 | 5204 | ROM_END |
| 5207 | 5205 | |
| 5208 | 5206 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 6016 | 6014 | // |
| 6017 | 6015 | ROM_START( suprleag ) |
| 6018 | 6016 | ROM_REGION( 0x60000, "maincpu", 0 ) // 68000 code |
| 6019 | | ROM_LOAD16_BYTE( "epr-11133.a04", 0x00000, 0x10000, CRC(eed72f37) SHA1(80b68abdb90a63b30754dd031e85b1020dcc0cc4) ) |
| 6020 | | ROM_LOAD16_BYTE( "epr-11130.a01", 0x00001, 0x10000, CRC(e2451676) SHA1(d2f71d9fca933e63e2bd5ee48217801ab0cb049c) ) |
| 6021 | | ROM_LOAD16_BYTE( "epr-11134.a05", 0x20000, 0x10000, CRC(ccd857f5) SHA1(2566bb458bdd365db403e8229ecdad79e23076a1) ) |
| 6022 | | ROM_LOAD16_BYTE( "epr-11131.a02", 0x20001, 0x10000, CRC(9b78c2cc) SHA1(9a453dd999120590c52b17f8ff2b49fd2fde0b35) ) |
| 6023 | | ROM_LOAD16_BYTE( "epr-11135.a06", 0x40000, 0x10000, CRC(3735e0e1) SHA1(ae2910099909245993ee29e5a03a5591f20962c7) ) |
| 6024 | | ROM_LOAD16_BYTE( "epr-11132.a03", 0x40001, 0x10000, CRC(ff199325) SHA1(2ece15b6b79ec3f948f7bec623e1df281cf89382) ) |
| 6017 | ROM_LOAD16_BYTE( "epr-11133.a4", 0x00000, 0x10000, CRC(eed72f37) SHA1(80b68abdb90a63b30754dd031e85b1020dcc0cc4) ) |
| 6018 | ROM_LOAD16_BYTE( "epr-11130.a1", 0x00001, 0x10000, CRC(e2451676) SHA1(d2f71d9fca933e63e2bd5ee48217801ab0cb049c) ) |
| 6019 | ROM_LOAD16_BYTE( "epr-11134.a5", 0x20000, 0x10000, CRC(ccd857f5) SHA1(2566bb458bdd365db403e8229ecdad79e23076a1) ) |
| 6020 | ROM_LOAD16_BYTE( "epr-11131.a2", 0x20001, 0x10000, CRC(9b78c2cc) SHA1(9a453dd999120590c52b17f8ff2b49fd2fde0b35) ) |
| 6021 | ROM_LOAD16_BYTE( "epr-11135.a6", 0x40000, 0x10000, CRC(3735e0e1) SHA1(ae2910099909245993ee29e5a03a5591f20962c7) ) |
| 6022 | ROM_LOAD16_BYTE( "epr-11132.a3", 0x40001, 0x10000, CRC(ff199325) SHA1(2ece15b6b79ec3f948f7bec623e1df281cf89382) ) |
| 6025 | 6023 | |
| 6026 | 6024 | ROM_REGION( 0x2000, "maincpu:key", 0 ) // decryption key |
| 6027 | 6025 | ROM_LOAD( "317-0045.key", 0x0000, 0x2000, CRC(0594cc2e) SHA1(8aec3fffd00cbfd50d7cfb92e4748e2653fbb504) ) |
| 6028 | 6026 | |
| 6029 | 6027 | ROM_REGION( 0x30000, "gfx1", 0 ) // tiles |
| 6030 | | ROM_LOAD( "epr-11136.b09", 0x00000, 0x10000, CRC(c3860ce4) SHA1(af7618f3b5a0e8d6374877c7815ba69fff218a45) ) |
| 6028 | ROM_LOAD( "epr-11136.b9", 0x00000, 0x10000, CRC(c3860ce4) SHA1(af7618f3b5a0e8d6374877c7815ba69fff218a45) ) |
| 6031 | 6029 | ROM_LOAD( "epr-11137.b10", 0x10000, 0x10000, CRC(92d96187) SHA1(45138795992b9842d5b0c86a96b300445bf12060) ) |
| 6032 | 6030 | ROM_LOAD( "epr-11138.b11", 0x20000, 0x10000, CRC(c01dc773) SHA1(b27da906186e1272cdd6f8d5e5a979f6623255ac) ) |
| 6033 | 6031 | |
| 6034 | 6032 | ROM_REGION16_BE( 0x80000, "sprites", 0 ) // sprites |
| 6035 | | ROM_LOAD16_BYTE( "epr-11144.b01", 0x00001, 0x10000, CRC(b31de51c) SHA1(011a79a37d32ab4545187e28e61f27aa0601f686) ) |
| 6036 | | ROM_LOAD16_BYTE( "epr-11148.b05", 0x00000, 0x10000, CRC(126e1309) SHA1(7386ac5ac57325d8f661caf8cab0b19a42c0309d) ) |
| 6037 | | ROM_LOAD16_BYTE( "epr-11145.b02", 0x20001, 0x10000, CRC(4223d2c3) SHA1(310d5c411eeaf69fe0dc9350e6bfe6dfe950b373) ) |
| 6038 | | ROM_LOAD16_BYTE( "epr-11149.b06", 0x20000, 0x10000, CRC(694d3765) SHA1(4aa8590648d5b8eb5db489edefb1326ecd01ea2c) ) |
| 6039 | | ROM_LOAD16_BYTE( "epr-11146.b03", 0x40001, 0x10000, CRC(bf0359b6) SHA1(6cd5e6b685e53f062d5b04888f225c808aab3c4c) ) |
| 6040 | | ROM_LOAD16_BYTE( "epr-11150.b07", 0x40000, 0x10000, CRC(9fc0aded) SHA1(7ad9e8fe79a0a07c748b0c20ad46c0e00de8a23a) ) |
| 6041 | | ROM_LOAD16_BYTE( "epr-11147.b04", 0x60001, 0x10000, CRC(3e592772) SHA1(b0fe2c680871dcdbe655c0b1b98bcf8118fb3a50) ) |
| 6042 | | ROM_LOAD16_BYTE( "epr-11151.b08", 0x60000, 0x10000, CRC(9de95169) SHA1(1a2801ecd9dece3dae7ceab3b793d5005caa4614) ) |
| 6033 | ROM_LOAD16_BYTE( "epr-11144.b1", 0x00001, 0x10000, CRC(b31de51c) SHA1(011a79a37d32ab4545187e28e61f27aa0601f686) ) |
| 6034 | ROM_LOAD16_BYTE( "epr-11148.b5", 0x00000, 0x10000, CRC(126e1309) SHA1(7386ac5ac57325d8f661caf8cab0b19a42c0309d) ) |
| 6035 | ROM_LOAD16_BYTE( "epr-11145.b2", 0x20001, 0x10000, CRC(4223d2c3) SHA1(310d5c411eeaf69fe0dc9350e6bfe6dfe950b373) ) |
| 6036 | ROM_LOAD16_BYTE( "epr-11149.b6", 0x20000, 0x10000, CRC(694d3765) SHA1(4aa8590648d5b8eb5db489edefb1326ecd01ea2c) ) |
| 6037 | ROM_LOAD16_BYTE( "epr-11146.b3", 0x40001, 0x10000, CRC(bf0359b6) SHA1(6cd5e6b685e53f062d5b04888f225c808aab3c4c) ) |
| 6038 | ROM_LOAD16_BYTE( "epr-11150.b7", 0x40000, 0x10000, CRC(9fc0aded) SHA1(7ad9e8fe79a0a07c748b0c20ad46c0e00de8a23a) ) |
| 6039 | ROM_LOAD16_BYTE( "epr-11147.b4", 0x60001, 0x10000, CRC(3e592772) SHA1(b0fe2c680871dcdbe655c0b1b98bcf8118fb3a50) ) |
| 6040 | ROM_LOAD16_BYTE( "epr-11151.b8", 0x60000, 0x10000, CRC(9de95169) SHA1(1a2801ecd9dece3dae7ceab3b793d5005caa4614) ) |
| 6043 | 6041 | |
| 6044 | 6042 | ROM_REGION( 0x50000, "soundcpu", 0 ) // sound CPU |
| 6045 | | ROM_LOAD( "epr-11139.a07", 0x00000, 0x08000, CRC(9cbd99da) SHA1(55960b68b23a4f89ec810e1d31f22ba60cda0cfe) ) |
| 6046 | | ROM_LOAD( "epr-11140.a08", 0x10000, 0x08000, CRC(b297371b) SHA1(4e787aa9ee2aeab4da30237644421df407b684a5) ) |
| 6047 | | ROM_LOAD( "epr-11141.a09", 0x20000, 0x08000, CRC(19756aa6) SHA1(81597e17b848f6a41f5fb117296e7508297815e4) ) |
| 6043 | ROM_LOAD( "epr-11139.a7", 0x00000, 0x08000, CRC(9cbd99da) SHA1(55960b68b23a4f89ec810e1d31f22ba60cda0cfe) ) |
| 6044 | ROM_LOAD( "epr-11140.a8", 0x10000, 0x08000, CRC(b297371b) SHA1(4e787aa9ee2aeab4da30237644421df407b684a5) ) |
| 6045 | ROM_LOAD( "epr-11141.a9", 0x20000, 0x08000, CRC(19756aa6) SHA1(81597e17b848f6a41f5fb117296e7508297815e4) ) |
| 6048 | 6046 | ROM_LOAD( "epr-11142.a10", 0x30000, 0x08000, CRC(25d26c66) SHA1(2485afb859f84a9cc90b2091e9ae4eef263f42b3) ) |
| 6049 | 6047 | ROM_LOAD( "epr-11143.a11", 0x40000, 0x08000, CRC(848b7b77) SHA1(8903a39f8f0ffb4ce32117d33282876196516c30) ) |
| 6050 | 6048 | ROM_END |
| r243410 | r243411 | |
| 6222 | 6220 | ROM_LOAD( "opr-12329.a11", 0x10000, 0x10000, CRC(ed9a686d) SHA1(da433033d501ee871429ee676b3972b14179df9f) ) // speech |
| 6223 | 6221 | ROM_LOAD( "opr-12330.a12", 0x20000, 0x10000, CRC(fb762bca) SHA1(ff9191c5ec38c711ebb7c2ad043f62b6d7e2203c) ) |
| 6224 | 6222 | |
| 6225 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6226 | | ROM_LOAD( "317-0104.bin", 0x00000, 0x1000, NO_DUMP ) |
| 6223 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6224 | ROM_LOAD( "317-0104.c2", 0x00000, 0x1000, NO_DUMP ) |
| 6227 | 6225 | ROM_END |
| 6228 | 6226 | |
| 6229 | 6227 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 6234 | 6232 | // |
| 6235 | 6233 | ROM_START( tturfu ) |
| 6236 | 6234 | ROM_REGION( 0x40000, "maincpu", 0 ) // 68000 code |
| 6237 | | ROM_LOAD16_BYTE( "epr-12266.bin", 0x00000, 0x10000, CRC(f549def8) SHA1(9e913509d46274bd192455321904ec9884b5f629) ) |
| 6238 | | ROM_LOAD16_BYTE( "epr-12264.bin", 0x00001, 0x10000, CRC(f7cdb289) SHA1(9c386cf33a96a977c623c2f243db38fda2c41ba4) ) |
| 6239 | | ROM_LOAD16_BYTE( "epr-12267.bin", 0x20000, 0x10000, CRC(3c3ce191) SHA1(036ece2be585a85e05c047fe4a1ab3b6814c3490) ) |
| 6240 | | ROM_LOAD16_BYTE( "epr-12265.bin", 0x20001, 0x10000, CRC(8cdadd9a) SHA1(a17852f0eb8f63a82ff44cbeb100da72fe5890e0) ) |
| 6235 | ROM_LOAD16_BYTE( "epr-12266.a1", 0x00000, 0x10000, CRC(f549def8) SHA1(9e913509d46274bd192455321904ec9884b5f629) ) |
| 6236 | ROM_LOAD16_BYTE( "epr-12264.a4", 0x00001, 0x10000, CRC(f7cdb289) SHA1(9c386cf33a96a977c623c2f243db38fda2c41ba4) ) |
| 6237 | ROM_LOAD16_BYTE( "epr-12267.a2", 0x20000, 0x10000, CRC(3c3ce191) SHA1(036ece2be585a85e05c047fe4a1ab3b6814c3490) ) |
| 6238 | ROM_LOAD16_BYTE( "epr-12265.a5", 0x20001, 0x10000, CRC(8cdadd9a) SHA1(a17852f0eb8f63a82ff44cbeb100da72fe5890e0) ) |
| 6241 | 6239 | |
| 6242 | 6240 | ROM_REGION( 0x30000, "gfx1", 0 ) // tiles |
| 6243 | 6241 | ROM_LOAD( "epr-12268.a14", 0x00000, 0x10000, CRC(e0dac07f) SHA1(c7f6de42eb93a8f34afdc300628735b5f40a34c2) ) |
| r243410 | r243411 | |
| 6261 | 6259 | ROM_LOAD( "epr-12274.a10", 0x30000, 0x8000, CRC(8207f0c4) SHA1(169914861a52fa731a305e1ee2d230aa0d0d97fe) ) |
| 6262 | 6260 | ROM_LOAD( "epr-12275.a11", 0x40000, 0x8000, CRC(182f3c3d) SHA1(1482fe08a05a721e315b1a3aa5bef4dddc72e26e) ) |
| 6263 | 6261 | |
| 6264 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6265 | | ROM_LOAD( "317-0099.bin", 0x00000, 0x1000, CRC(f676e3e4) SHA1(b71bad46c8b5f7328fd8d48f18624a620f0d34ce) ) |
| 6262 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6263 | ROM_LOAD( "317-0099.c2", 0x00000, 0x1000, CRC(f676e3e4) SHA1(b71bad46c8b5f7328fd8d48f18624a620f0d34ce) ) |
| 6266 | 6264 | ROM_END |
| 6267 | 6265 | |
| 6268 | 6266 | |
| r243410 | r243411 | |
| 6296 | 6294 | ROM_REGION( 0x10000, "soundcpu", 0 ) // sound CPU |
| 6297 | 6295 | ROM_LOAD( "epr-12127.a10", 0x0000, 0x8000, CRC(0bb901bb) SHA1(c81b198df8e3b0ec568032c76addf0d1a1711194) ) |
| 6298 | 6296 | |
| 6299 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6300 | | ROM_LOAD( "317-0098.bin", 0x00000, 0x1000, NO_DUMP ) |
| 6297 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6298 | ROM_LOAD( "317-0098.c2", 0x00000, 0x1000, NO_DUMP ) |
| 6301 | 6299 | ROM_END |
| 6302 | 6300 | |
| 6303 | 6301 | |
| r243410 | r243411 | |
| 6386 | 6384 | ROM_START( wb32 ) |
| 6387 | 6385 | ROM_REGION( 0x40000, "maincpu", 0 ) // 68000 code |
| 6388 | 6386 | ROM_LOAD16_BYTE( "epr-12098.a1", 0x000001, 0x10000, CRC(d998e5e5) SHA1(a7398b7338a33451a650c2f1d382dad2e5130528) ) |
| 6389 | | ROM_LOAD16_BYTE( "epr-12100.a6", 0x000000, 0x10000, CRC(f5ca4abc) SHA1(1331db10cf99905fb13c1606a3f4d8bbf3d681b6) ) |
| 6387 | ROM_LOAD16_BYTE( "epr-12100.a4", 0x000000, 0x10000, CRC(f5ca4abc) SHA1(1331db10cf99905fb13c1606a3f4d8bbf3d681b6) ) |
| 6390 | 6388 | ROM_LOAD16_BYTE( "epr-12099.a2", 0x020001, 0x10000, CRC(3e243b45) SHA1(2a079553d1b61aaf18025847570003b79c8d6edf) ) |
| 6391 | 6389 | ROM_LOAD16_BYTE( "epr-12101.a5", 0x020000, 0x10000, CRC(6146492b) SHA1(93515578a6ccf770944fea86d2f3200fa08f5075) ) |
| 6392 | 6390 | |
| r243410 | r243411 | |
| 6470 | 6468 | ROM_LOAD( "mpr-12148.a11", 0x10000, 0x20000, CRC(fb9a7f29) SHA1(7ba79c18ab4e586be2deccd78e4479d55eb75a7e) ) |
| 6471 | 6469 | ROM_LOAD( "mpr-12149.a12", 0x30000, 0x20000, CRC(d6617b19) SHA1(aa36d257eaa52c8c871a39aaa2f29c203525dbaf) ) |
| 6472 | 6470 | |
| 6473 | | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6474 | | ROM_LOAD( "317-0103.bin", 0x00000, 0x1000, CRC(aa0710f5) SHA1(61ba8d23d045806b0a7b75184766be00f872cc72) ) |
| 6471 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6472 | ROM_LOAD( "317-0103.c2", 0x00000, 0x1000, CRC(aa0710f5) SHA1(61ba8d23d045806b0a7b75184766be00f872cc72) ) |
| 6475 | 6473 | ROM_END |
| 6476 | 6474 | |
| 6477 | 6475 | //************************************************************************************************************************* |
| r243410 | r243411 | |
| 6565 | 6563 | // Sega operated this game on actual System 16 PCBs for various events, |
| 6566 | 6564 | // it was also included in the PS2 Sega Ages collection Vol 33. |
| 6567 | 6565 | // Various bootlegs were sourced from this version. The dump will have to |
| 6568 | | // be verified if the official PCB ever gets into MAME friendly hands. |
| 6566 | // be verified if the official PCB ever gets into MAME-friendly hands. |
| 6569 | 6567 | // |
| 6570 | 6568 | // There is also a demo version of the game available on the PC, but |
| 6571 | 6569 | // attempting to use those ROMs on a real PCB / emulator will result |
trunk/src/mame/drivers/sidearms.c
| r243410 | r243411 | |
| 768 | 768 | ROM_LOAD( "63s081.3j", 0x0300, 0x0020, CRC(c5817816) SHA1(cc642daafa0bcb160ee04e74e2d168fd44087608) ) // unknown |
| 769 | 769 | ROM_END |
| 770 | 770 | |
| 771 | | ROM_START( sidearmsr ) |
| 771 | ROM_START( sidearmsu ) |
| 772 | 772 | ROM_REGION( 0x20000, "maincpu", 0 ) /* 64k for code + banked ROMs images */ |
| 773 | ROM_LOAD( "SAA_03.15E", 0x00000, 0x08000, CRC(32ef2739) SHA1(15e0535a6e3508c0d1ed73157a052c3716571000) ) /* CODE */ |
| 774 | ROM_LOAD( "a_14e.rom", 0x10000, 0x08000, CRC(4925ed03) SHA1(b11dbd9889db89cff008ca21beb6b1b70d983e16) ) /* 0+1 */ |
| 775 | ROM_LOAD( "a_12e.rom", 0x18000, 0x08000, CRC(81d0ece7) SHA1(5c1d154f9c1de6b5f5d7abf5d413e9c493461e6f) ) /* 2+3 */ |
| 776 | |
| 777 | ROM_REGION( 0x10000, "audiocpu", 0 ) |
| 778 | ROM_LOAD( "a_04k.rom", 0x0000, 0x8000, CRC(34efe2d2) SHA1(e1d8895c113e4dee1a132e2471d75dfa6c36b620) ) |
| 779 | |
| 780 | ROM_REGION( 0x08000, "user1", 0 ) /* starfield data */ |
| 781 | ROM_LOAD( "b_11j.rom", 0x0000, 0x8000, CRC(134dc35b) SHA1(6360c1efa7c4e1d6d817a97ca43dd4af8ed6afe5) ) |
| 782 | |
| 783 | ROM_REGION( 0x04000, "gfx1", 0 ) |
| 784 | ROM_LOAD( "a_10j.rom", 0x00000, 0x4000, CRC(651fef75) SHA1(9c821a2ee30c222987f0d4192133776490d6a4e0) ) /* characters */ |
| 785 | |
| 786 | ROM_REGION( 0x40000, "gfx2", 0 ) |
| 787 | ROM_LOAD( "b_13d.rom", 0x00000, 0x8000, CRC(3c59afe1) SHA1(5459a5795cf13012674993aa55bbd39e9a5c2f1b) ) /* tiles */ |
| 788 | ROM_LOAD( "b_13e.rom", 0x08000, 0x8000, CRC(64bc3b77) SHA1(54fe6f258fda509a92eb0f5aa238102efce729e0) ) |
| 789 | ROM_LOAD( "b_13f.rom", 0x10000, 0x8000, CRC(e6bcea6f) SHA1(19477e284967beafc4e7cd0d0da3534eb6dec388) ) |
| 790 | ROM_LOAD( "b_13g.rom", 0x18000, 0x8000, CRC(c71a3053) SHA1(963e105aa0b0174e8aa5e1f7676c5c604ca72d1c) ) |
| 791 | ROM_LOAD( "b_14d.rom", 0x20000, 0x8000, CRC(826e8a97) SHA1(ad5ed9a81805dde54fb2703345b2ab7b56853ec6) ) |
| 792 | ROM_LOAD( "b_14e.rom", 0x28000, 0x8000, CRC(6cfc02a4) SHA1(491e880e85d5256fa2eea6d0fb402f0a1176b675) ) |
| 793 | ROM_LOAD( "b_14f.rom", 0x30000, 0x8000, CRC(9b9f6730) SHA1(0f8fe5dc32ee50ebb2051c0c0c4d635582416317) ) |
| 794 | ROM_LOAD( "b_14g.rom", 0x38000, 0x8000, CRC(ef6af630) SHA1(499b17eeb5e7256ede477510b0547df520316996) ) |
| 795 | |
| 796 | ROM_REGION( 0x40000, "gfx3", 0 ) |
| 797 | ROM_LOAD( "b_11b.rom", 0x00000, 0x8000, CRC(eb6f278c) SHA1(15e250aa98ee69ac3983d4511976c35833b37cab) ) /* sprites */ |
| 798 | ROM_LOAD( "b_13b.rom", 0x08000, 0x8000, CRC(e91b4014) SHA1(6557344ce8bc05309ab8ebe846871ed554b256b8) ) |
| 799 | ROM_LOAD( "b_11a.rom", 0x10000, 0x8000, CRC(2822c522) SHA1(00b3cab899e5ac1af6300f2ec2a54303df9ab014) ) |
| 800 | ROM_LOAD( "b_13a.rom", 0x18000, 0x8000, CRC(3e8a9f75) SHA1(b1bfb7604791950aa0454b68b24f6ad3b9131be8) ) |
| 801 | ROM_LOAD( "b_12b.rom", 0x20000, 0x8000, CRC(86e43eda) SHA1(c33b0ab6f7f0f886410a3943988b737d175635be) ) |
| 802 | ROM_LOAD( "b_14b.rom", 0x28000, 0x8000, CRC(076e92d1) SHA1(27144834b5b2849be8c46e97aaaeaa8b304ea810) ) |
| 803 | ROM_LOAD( "b_12a.rom", 0x30000, 0x8000, CRC(ce107f3c) SHA1(2235281449247cb2446b008b36077788c5b15026) ) |
| 804 | ROM_LOAD( "b_14a.rom", 0x38000, 0x8000, CRC(dba06076) SHA1(87b3b3437bc4bd727ce7e34dd914e6fe23bcac3d) ) |
| 805 | |
| 806 | ROM_REGION( 0x08000, "gfx4", 0 ) /* background tilemaps */ |
| 807 | ROM_LOAD( "b_03d.rom", 0x0000, 0x8000, CRC(6f348008) SHA1(b500bc32ba47e9cc9dcf2254b9455ac4d61992db) ) |
| 808 | |
| 809 | ROM_REGION( 0x0320, "proms", 0 ) |
| 810 | ROM_LOAD( "63s141.16h", 0x0000, 0x0100, CRC(75af3553) SHA1(14da009592877a6097b34ea844fa897ceda7465e) ) // timing |
| 811 | ROM_LOAD( "63s141.11h", 0x0100, 0x0100, CRC(a6e4d68f) SHA1(b9367e0c959cdf0397d33a49d778a66a407572b7) ) // color mixing |
| 812 | ROM_LOAD( "63s141.15h", 0x0200, 0x0100, CRC(c47c182a) SHA1(47d6139256e6838f633a04084bd0a7a84912f7fb) ) // timing |
| 813 | ROM_LOAD( "63s081.3j", 0x0300, 0x0020, CRC(c5817816) SHA1(cc642daafa0bcb160ee04e74e2d168fd44087608) ) // unknown |
| 814 | ROM_END |
| 815 | |
| 816 | ROM_START( sidearmsur1 ) |
| 817 | ROM_REGION( 0x20000, "maincpu", 0 ) /* 64k for code + banked ROMs images */ |
| 773 | 818 | ROM_LOAD( "03", 0x00000, 0x08000, CRC(9a799c45) SHA1(cf6836108506929ee2449546a4867a7cbf00bcc8) ) /* CODE */ |
| 774 | 819 | ROM_LOAD( "a_14e.rom", 0x10000, 0x08000, CRC(4925ed03) SHA1(b11dbd9889db89cff008ca21beb6b1b70d983e16) ) /* 0+1 */ |
| 775 | 820 | ROM_LOAD( "a_12e.rom", 0x18000, 0x08000, CRC(81d0ece7) SHA1(5c1d154f9c1de6b5f5d7abf5d413e9c493461e6f) ) /* 2+3 */ |
| r243410 | r243411 | |
| 1106 | 1151 | m_gameid = 3; |
| 1107 | 1152 | } |
| 1108 | 1153 | |
| 1109 | | GAME( 1986, sidearms, 0, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom", "Side Arms - Hyper Dyne (World)", GAME_IMPERFECT_GRAPHICS ) |
| 1110 | | GAME( 1986, sidearmsr,sidearms, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom (Romstar license)", "Side Arms - Hyper Dyne (US)", GAME_IMPERFECT_GRAPHICS ) |
| 1111 | | GAME( 1986, sidearmsj,sidearms, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom", "Side Arms - Hyper Dyne (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 1112 | | GAME( 1988, turtship, 0, turtship, turtship, sidearms_state, turtship, ROT0, "Philko (Sharp Image license)", "Turtle Ship (North America)", 0 ) |
| 1154 | // date string is at 0xaa2 in 'rom 03' it does not appear to be displayed |
| 1155 | |
| 1156 | GAME( 1986, sidearms, 0, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom", "Side Arms - Hyper Dyne (World, 861129)", GAME_IMPERFECT_GRAPHICS ) |
| 1157 | GAME( 1986, sidearmsu, sidearms, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom (Romstar license)", "Side Arms - Hyper Dyne (US, 861202)", GAME_IMPERFECT_GRAPHICS ) |
| 1158 | GAME( 1986, sidearmsur1,sidearms, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom (Romstar license)", "Side Arms - Hyper Dyne (US, 861128)", GAME_IMPERFECT_GRAPHICS ) |
| 1159 | GAME( 1986, sidearmsj, sidearms, sidearms, sidearms, sidearms_state, sidearms, ROT0, "Capcom", "Side Arms - Hyper Dyne (Japan, 861128)", GAME_IMPERFECT_GRAPHICS ) |
| 1160 | |
| 1161 | GAME( 1988, turtship, 0, turtship, turtship, sidearms_state, turtship, ROT0, "Philko (Sharp Image license)", "Turtle Ship (North America)", 0 ) |
| 1113 | 1162 | GAME( 1988, turtshipj,turtship, turtship, turtship, sidearms_state, turtship, ROT0, "Philko (Pacific Games license)", "Turtle Ship (Japan)", 0 ) |
| 1114 | | GAME( 1988, turtshipk,turtship, turtship, turtship, sidearms_state, turtship, ROT0, "Philko", "Turtle Ship (Korea)", 0 ) |
| 1163 | GAME( 1988, turtshipk,turtship, turtship, turtship, sidearms_state, turtship, ROT0, "Philko", "Turtle Ship (Korea)", 0 ) |
| 1164 | |
| 1115 | 1165 | GAME( 1989, dyger, 0, turtship, dyger, sidearms_state, dyger, ROT270, "Philko", "Dyger (Korea set 1)", 0 ) |
| 1116 | 1166 | GAME( 1989, dygera, dyger, turtship, dyger, sidearms_state, dyger, ROT270, "Philko", "Dyger (Korea set 2)", 0 ) |
| 1167 | |
| 1117 | 1168 | GAME( 1989, twinfalc, 0, whizz, whizz, sidearms_state, whizz, ROT0, "Philko (Poara Enterprises license)", "Twin Falcons", 0 ) |
| 1118 | | GAME( 1989, whizz, twinfalc, whizz, whizz, sidearms_state, whizz, ROT0, "Philko", "Whizz", 0 ) |
| 1169 | GAME( 1989, whizz, twinfalc, whizz, whizz, sidearms_state, whizz, ROT0, "Philko", "Whizz", 0 ) |
trunk/src/mess/drivers/ti74.c
| r243410 | r243411 | |
| 301 | 301 | PORT_START("IN.0") |
| 302 | 302 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') PORT_NAME("m M Frac") |
| 303 | 303 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') PORT_NAME("k K Frq") |
| 304 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') PORT_NAME("i I "UTF8_SQUAREROOT"x") |
| 305 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_NAME(UTF8_LEFT" "UTF8_LEFT) |
| 304 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') PORT_NAME("i I " UTF8_SQUAREROOT"x") |
| 305 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_NAME(UTF8_LEFT" " UTF8_LEFT) |
| 306 | 306 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 307 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') PORT_NAME("u U x"UTF8_POW_2) |
| 307 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') PORT_NAME("u U x" UTF8_POW_2) |
| 308 | 308 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') PORT_NAME("j J nCr") |
| 309 | 309 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') PORT_NAME("n N Intg") |
| 310 | 310 | |
| r243410 | r243411 | |
| 319 | 319 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') PORT_NAME("b B EXC") |
| 320 | 320 | |
| 321 | 321 | PORT_START("IN.2") |
| 322 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') PORT_CHAR('\'') PORT_NAME("SPACE ' "UTF8_CAPITAL_DELTA"%") |
| 323 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') PORT_NAME("; : "UTF8_CAPITAL_SIGMA"+") |
| 324 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') PORT_NAME("p P y"UTF8_POW_X) |
| 322 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') PORT_CHAR('\'') PORT_NAME("SPACE ' " UTF8_CAPITAL_DELTA"%") |
| 323 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') PORT_NAME("; : " UTF8_CAPITAL_SIGMA"+") |
| 324 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') PORT_NAME("p P y" UTF8_POW_X) |
| 325 | 325 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_CHAR('(') PORT_NAME(UTF8_UP" (") |
| 326 | 326 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 327 | 327 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') PORT_NAME("t T ln(x)") |
| r243410 | r243411 | |
| 334 | 334 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(END)) PORT_NAME("CLR UCL CE/C") |
| 335 | 335 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(')') PORT_NAME(UTF8_DOWN" )") |
| 336 | 336 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_NAME("RUN x<>y") |
| 337 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') PORT_NAME("r R "UTF8_SMALL_PI) |
| 337 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') PORT_NAME("r R " UTF8_SMALL_PI) |
| 338 | 338 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') PORT_NAME("f F P>R") |
| 339 | 339 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') PORT_NAME("c C RCL") |
| 340 | 340 | |
| 341 | 341 | PORT_START("IN.4") |
| 342 | 342 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('~') PORT_CHAR('?') PORT_NAME("+/- ? CSR") |
| 343 | 343 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') PORT_NAME("1 ! r") |
| 344 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') PORT_NAME("4 $ "UTF8_CAPITAL_SIGMA"x") |
| 345 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_NAME("7 DEL "UTF8_CAPITAL_SIGMA"x"UTF8_POW_2) |
| 344 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') PORT_NAME("4 $ " UTF8_CAPITAL_SIGMA"x") |
| 345 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_NAME("7 DEL " UTF8_CAPITAL_SIGMA"x" UTF8_POW_2) |
| 346 | 346 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(PAUSE)) PORT_NAME("BREAK") |
| 347 | 347 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') PORT_NAME("e E tan") |
| 348 | 348 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') PORT_NAME("d D DRG>") |
| 349 | 349 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') PORT_NAME("x X STO") |
| 350 | 350 | |
| 351 | 351 | PORT_START("IN.5") |
| 352 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('<') PORT_NAME("0 < x"UTF8_PRIME) |
| 352 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('<') PORT_NAME("0 < x" UTF8_PRIME) |
| 353 | 353 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') PORT_NAME("2 \" a") |
| 354 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('&') PORT_NAME("5 & "UTF8_CAPITAL_SIGMA"y") |
| 355 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR(UCHAR_MAMEKEY(INSERT)) PORT_NAME("8 INS "UTF8_CAPITAL_SIGMA"y"UTF8_POW_2) |
| 354 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('&') PORT_NAME("5 & " UTF8_CAPITAL_SIGMA"y") |
| 355 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR(UCHAR_MAMEKEY(INSERT)) PORT_NAME("8 INS " UTF8_CAPITAL_SIGMA"y" UTF8_POW_2) |
| 356 | 356 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PGUP) PORT_CHAR(UCHAR_MAMEKEY(PGUP)) PORT_NAME("MODE") |
| 357 | 357 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') PORT_NAME("w W cos") |
| 358 | 358 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') PORT_NAME("s S DRG") |
| 359 | 359 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') PORT_NAME("z Z PRINT") |
| 360 | 360 | |
| 361 | 361 | PORT_START("IN.6") |
| 362 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR('.') PORT_CHAR('>') PORT_NAME(". > y"UTF8_PRIME) // 2 on the keyboard, same scancode |
| 362 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR('.') PORT_CHAR('>') PORT_NAME(". > y" UTF8_PRIME) // 2 on the keyboard, same scancode |
| 363 | 363 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') PORT_NAME("3 # b") |
| 364 | 364 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') PORT_NAME("6 ^ n") |
| 365 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_NAME("9 PB "UTF8_CAPITAL_SIGMA"xy") |
| 365 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_NAME("9 PB " UTF8_CAPITAL_SIGMA"xy") |
| 366 | 366 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PGDN) PORT_CHAR(UCHAR_MAMEKEY(PGDN)) PORT_NAME("OFF") |
| 367 | 367 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') PORT_NAME("q Q sin") |
| 368 | 368 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') PORT_NAME("a A DMS>DD") |
| r243410 | r243411 | |
| 371 | 371 | PORT_START("IN.7") |
| 372 | 372 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) PORT_NAME("+ s(y)") |
| 373 | 373 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_NAME("- s(x)") |
| 374 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) PORT_NAME("* y"UTF8_NONSPACE_MACRON) |
| 375 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH_PAD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) PORT_NAME("/ x"UTF8_NONSPACE_MACRON) |
| 374 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) PORT_NAME("* y" UTF8_NONSPACE_MACRON) |
| 375 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH_PAD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) PORT_NAME("/ x" UTF8_NONSPACE_MACRON) |
| 376 | 376 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 377 | 377 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(F1)) PORT_NAME("FN hyp") |
| 378 | 378 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2) PORT_NAME("CTL STAT") |
| r243410 | r243411 | |
| 425 | 425 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_NAME("CONV V") |
| 426 | 426 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_NAME("OLD NOP") |
| 427 | 427 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_NAME("9 > x!") |
| 428 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) PORT_NAME(UTF8_MULTIPLY" ^ "UTF8_SMALL_PI) |
| 428 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) PORT_NAME(UTF8_MULTIPLY" ^ " UTF8_SMALL_PI) |
| 429 | 429 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_NAME("8 < nCr") |
| 430 | 430 | |
| 431 | 431 | PORT_START("IN.4") |
| r243410 | r243411 | |
| 441 | 441 | PORT_START("IN.5") |
| 442 | 442 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_NAME("F4") |
| 443 | 443 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_NAME("INCR Y CH") |
| 444 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_NAME("x"UTF8_POW_2" H") |
| 444 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_NAME("x" UTF8_POW_2" H") |
| 445 | 445 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_NAME("FLAGS N") |
| 446 | 446 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_NAME(UTF8_LEFT" DEL") |
| 447 | 447 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_NAME("RCL O FH") |
| r243410 | r243411 | |
| 454 | 454 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_NAME(UTF8_SQUAREROOT"x J") |
| 455 | 455 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_NAME("TESTS M") |
| 456 | 456 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_NAME(UTF8_RIGHT" INS") |
| 457 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_NAME("y"UTF8_POW_X" L") |
| 457 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_NAME("y" UTF8_POW_X" L") |
| 458 | 458 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_NAME("2nd") |
| 459 | 459 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_4) PORT_CHAR('4' )PORT_NAME("4 IND") |
| 460 | 460 | |
trunk/src/osd/sdl/draw13.c
| r243410 | r243411 | |
| 118 | 118 | |
| 119 | 119 | private: |
| 120 | 120 | Uint32 m_sdl_access; |
| 121 | | SDL_Renderer * m_renderer; |
| 121 | SDL_Renderer * m_sdl_renderer; |
| 122 | 122 | render_texinfo m_texinfo; // copy of the texture info |
| 123 | 123 | HashT m_hash; // hash value for the texture (must be >= pointer size) |
| 124 | 124 | UINT32 m_flags; // rendering flags |
| r243410 | r243411 | |
| 143 | 143 | { |
| 144 | 144 | public: |
| 145 | 145 | sdl_info13(sdl_window_info *w) |
| 146 | | : osd_renderer(w), m_blittimer(0), m_renderer(NULL), |
| 146 | : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL), |
| 147 | 147 | m_last_hofs(0), m_last_vofs(0), |
| 148 | | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 148 | m_last_width(0), m_last_height(0), |
| 149 | 149 | m_last_blit_time(0), m_last_blit_pixels(0) |
| 150 | 150 | {} |
| 151 | 151 | |
| 152 | | /* virtual */ int create(int width, int height); |
| 153 | | /* virtual */ void resize(int width, int height); |
| 154 | | /* virtual */ int draw(UINT32 dc, int update); |
| 155 | | /* virtual */ void set_target_bounds(); |
| 156 | | /* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt); |
| 152 | /* virtual */ int create(); |
| 153 | /* virtual */ int draw(const UINT32 dc, const int update); |
| 154 | /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); |
| 157 | 155 | /* virtual */ void destroy_all_textures(); |
| 158 | 156 | /* virtual */ void destroy(); |
| 159 | 157 | /* virtual */ void clear(); |
| r243410 | r243411 | |
| 164 | 162 | texture_info *texture_update(const render_primitive &prim); |
| 165 | 163 | |
| 166 | 164 | INT32 m_blittimer; |
| 167 | | UINT32 m_extra_flags; |
| 168 | 165 | |
| 169 | | SDL_Renderer * m_renderer; |
| 166 | #if (SDLMAME_SDL2) |
| 167 | SDL_GLContext m_gl_context_id; |
| 168 | #else |
| 169 | // SDL surface |
| 170 | SDL_Surface *m_sdlsurf; |
| 171 | #endif |
| 172 | |
| 173 | SDL_Renderer * m_sdl_renderer; |
| 170 | 174 | simple_list<texture_info> m_texlist; // list of active textures |
| 171 | 175 | |
| 172 | 176 | float m_last_hofs; |
| 173 | 177 | float m_last_vofs; |
| 174 | 178 | |
| 175 | | // resize information |
| 179 | int m_last_width; |
| 180 | int m_last_height; |
| 176 | 181 | |
| 177 | | UINT8 m_resize_pending; |
| 178 | | UINT32 m_resize_width; |
| 179 | | UINT32 m_resize_height; |
| 180 | | |
| 181 | 182 | // Stats |
| 182 | 183 | INT64 m_last_blit_time; |
| 183 | 184 | INT64 m_last_blit_pixels; |
| 184 | | |
| 185 | | // Original display_mode |
| 186 | | SDL_DisplayMode m_original_mode; |
| 187 | 185 | }; |
| 188 | 186 | |
| 189 | 187 | struct copy_info_t { |
| r243410 | r243411 | |
| 202 | 200 | copy_info_t *next; |
| 203 | 201 | }; |
| 204 | 202 | |
| 203 | |
| 205 | 204 | //============================================================ |
| 206 | 205 | // PROTOTYPES |
| 207 | 206 | //============================================================ |
| r243410 | r243411 | |
| 386 | 385 | |
| 387 | 386 | SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); |
| 388 | 387 | set_coloralphamode(m_texture_id, &prim->color); |
| 389 | | SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); |
| 388 | SDL_RenderCopy(m_sdl_renderer, m_texture_id, NULL, &target_rect); |
| 390 | 389 | } |
| 391 | 390 | |
| 392 | 391 | void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) |
| r243410 | r243411 | |
| 420 | 419 | UINT32 sb = (UINT32)(255.0f * prim->color.b); |
| 421 | 420 | UINT32 sa = (UINT32)(255.0f * prim->color.a); |
| 422 | 421 | |
| 423 | | SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 424 | | SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); |
| 425 | | SDL_RenderFillRect(m_renderer, &target_rect); |
| 422 | SDL_SetRenderDrawBlendMode(m_sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 423 | SDL_SetRenderDrawColor(m_sdl_renderer, sr, sg, sb, sa); |
| 424 | SDL_RenderFillRect(m_sdl_renderer, &target_rect); |
| 426 | 425 | } |
| 427 | 426 | } |
| 428 | 427 | |
| r243410 | r243411 | |
| 454 | 453 | } |
| 455 | 454 | |
| 456 | 455 | //============================================================ |
| 457 | | // drawsdl2_init |
| 456 | // drawsdl_init |
| 458 | 457 | //============================================================ |
| 459 | 458 | |
| 460 | 459 | static void add_list(copy_info_t **head, copy_info_t *element, Uint32 bm) |
| r243410 | r243411 | |
| 518 | 517 | else |
| 519 | 518 | osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); |
| 520 | 519 | |
| 521 | | /* Enable bilinear filtering in case it is supported. |
| 522 | | * This applies to all texture operations. However, artwort is pre-scaled |
| 523 | | * and thus shouldn't be affected. |
| 524 | | */ |
| 525 | | if (video_config.filter) |
| 526 | | { |
| 527 | | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); |
| 528 | | } |
| 529 | | else |
| 530 | | { |
| 531 | | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); |
| 532 | | } |
| 533 | | |
| 534 | 520 | return 0; |
| 535 | 521 | } |
| 536 | 522 | |
| 537 | 523 | |
| 538 | 524 | //============================================================ |
| 539 | | // drawsdl2_exit |
| 525 | // drawsdl_exit |
| 540 | 526 | //============================================================ |
| 541 | 527 | |
| 542 | 528 | static void drawsdl2_exit(void) |
| r243410 | r243411 | |
| 586 | 572 | // a |
| 587 | 573 | //============================================================ |
| 588 | 574 | |
| 589 | | int sdl_info13::create(int width, int height) |
| 575 | int sdl_info13::create() |
| 590 | 576 | { |
| 591 | | /* FIXME: On Ubuntu and potentially other Linux OS you should use |
| 592 | | * to disable panning. This has to be done before every invocation of mame. |
| 593 | | * |
| 594 | | * xrandr --output HDMI-0 --panning 0x0+0+0 --fb 0x0 |
| 595 | | * |
| 596 | | */ |
| 577 | #if (SDLMAME_SDL2) |
| 578 | // create renderer |
| 597 | 579 | |
| 598 | | osd_printf_verbose("Enter sdl_info13::create\n"); |
| 599 | | |
| 600 | | // create the SDL window |
| 601 | | m_extra_flags = (window().fullscreen() ? |
| 602 | | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); |
| 603 | | |
| 604 | | #if defined(SDLMAME_WIN32) |
| 605 | | SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); |
| 606 | | #endif |
| 607 | | // create the SDL window |
| 608 | | window().m_sdl_window = SDL_CreateWindow(window().m_title, |
| 609 | | window().monitor()->position_size().x, window().monitor()->position_size().y, |
| 610 | | width, height, m_extra_flags); |
| 611 | | |
| 612 | | if (!window().m_sdl_window ) |
| 580 | /* Enable bilinear filtering in case it is supported. |
| 581 | * This applies to all texture operations. However, artwort is pre-scaled |
| 582 | * and thus shouldn't be affected. |
| 583 | */ |
| 584 | if (video_config.filter) |
| 613 | 585 | { |
| 614 | | osd_printf_error("Window creation failed: %s\n", SDL_GetError()); |
| 615 | | return 1; |
| 586 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); |
| 616 | 587 | } |
| 617 | | |
| 618 | | if (window().fullscreen() && video_config.switchres) |
| 619 | | { |
| 620 | | SDL_DisplayMode mode; |
| 621 | | //SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode); |
| 622 | | SDL_GetWindowDisplayMode(window().m_sdl_window, &mode); |
| 623 | | m_original_mode = mode; |
| 624 | | mode.w = width; |
| 625 | | mode.h = height; |
| 626 | | if (window().m_refresh) |
| 627 | | mode.refresh_rate = window().m_refresh; |
| 628 | | |
| 629 | | SDL_SetWindowDisplayMode(window().m_sdl_window, &mode); // Try to set mode |
| 630 | | #ifndef SDLMAME_WIN32 |
| 631 | | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| 632 | | * is in place after the mode switch - which will most likely be the case |
| 633 | | * This is a hack to work around a deficiency in SDL2 |
| 634 | | */ |
| 635 | | SDL_WarpMouseInWindow(window().m_sdl_window, 1, 1); |
| 636 | | #endif |
| 637 | | } |
| 638 | 588 | else |
| 639 | 589 | { |
| 640 | | //SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop |
| 590 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); |
| 641 | 591 | } |
| 642 | | // create renderer |
| 643 | 592 | |
| 644 | 593 | if (video_config.waitvsync) |
| 645 | | m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 594 | m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 646 | 595 | else |
| 647 | | m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED); |
| 596 | m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_ACCELERATED); |
| 648 | 597 | |
| 649 | | if (!m_renderer) |
| 598 | if (!m_sdl_renderer) |
| 650 | 599 | { |
| 651 | 600 | fatalerror("Error on creating renderer: %s\n", SDL_GetError()); |
| 652 | 601 | } |
| 653 | 602 | |
| 654 | 603 | //SDL_SelectRenderer(window().sdl_window); |
| 655 | 604 | |
| 656 | | // show window |
| 657 | | |
| 658 | | SDL_ShowWindow(window().m_sdl_window); |
| 659 | | //SDL_SetWindowFullscreen(window().sdl_window, window().fullscreen); |
| 660 | | SDL_RaiseWindow(window().m_sdl_window); |
| 661 | | |
| 662 | | SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height); |
| 663 | | |
| 664 | 605 | m_blittimer = 3; |
| 665 | 606 | |
| 666 | | SDL_RenderPresent(m_renderer); |
| 607 | SDL_RenderPresent(m_sdl_renderer); |
| 667 | 608 | osd_printf_verbose("Leave sdl_info13::create\n"); |
| 609 | |
| 610 | #else |
| 611 | |
| 612 | #endif |
| 668 | 613 | return 0; |
| 669 | 614 | } |
| 670 | 615 | |
| 616 | |
| 671 | 617 | //============================================================ |
| 672 | | // sdl_info::resize |
| 618 | // sdl_info::destroy |
| 673 | 619 | //============================================================ |
| 674 | 620 | |
| 675 | | void sdl_info13::resize(int width, int height) |
| 621 | void sdl_info13::destroy() |
| 676 | 622 | { |
| 677 | | m_resize_pending = 1; |
| 678 | | m_resize_height = height; |
| 679 | | m_resize_width = width; |
| 623 | destroy_all_textures(); |
| 624 | } |
| 680 | 625 | |
| 681 | | window().m_width = width; |
| 682 | | window().m_height = height; |
| 626 | //============================================================ |
| 627 | // sdl_info::clear |
| 628 | //============================================================ |
| 683 | 629 | |
| 684 | | m_blittimer = 3; |
| 685 | | |
| 630 | void sdl_info13::clear() |
| 631 | { |
| 632 | m_blittimer = 2; |
| 686 | 633 | } |
| 687 | 634 | |
| 635 | |
| 688 | 636 | //============================================================ |
| 689 | 637 | // drawsdl_xy_to_render_target |
| 690 | 638 | //============================================================ |
| r243410 | r243411 | |
| 694 | 642 | |
| 695 | 643 | *xt = x - m_last_hofs; |
| 696 | 644 | *yt = y - m_last_vofs; |
| 697 | | if (*xt<0 || *xt >= window().m_blitwidth) |
| 645 | if (*xt<0 || *xt >= window().blitwidth()) |
| 698 | 646 | return 0; |
| 699 | | if (*yt<0 || *yt >= window().m_blitheight) |
| 647 | if (*yt<0 || *yt >= window().blitheight()) |
| 700 | 648 | return 0; |
| 701 | 649 | return 1; |
| 702 | 650 | } |
| 703 | 651 | |
| 704 | 652 | //============================================================ |
| 705 | | // sdl_info::get_primitives |
| 653 | // drawsdl_destroy_all_textures |
| 706 | 654 | //============================================================ |
| 707 | 655 | |
| 708 | | void sdl_info13::set_target_bounds() |
| 656 | void sdl_info13::destroy_all_textures() |
| 709 | 657 | { |
| 710 | | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 658 | if(window().m_primlist) |
| 659 | { |
| 660 | window().m_primlist->acquire_lock(); |
| 661 | m_texlist.reset(); |
| 662 | window().m_primlist->release_lock(); |
| 663 | } |
| 664 | else |
| 665 | m_texlist.reset(); |
| 711 | 666 | } |
| 712 | 667 | |
| 713 | 668 | //============================================================ |
| r243410 | r243411 | |
| 726 | 681 | return 0; |
| 727 | 682 | } |
| 728 | 683 | |
| 729 | | if (m_resize_pending) |
| 684 | if ((window().width() != m_last_width) || (window().height() != m_last_height)) |
| 730 | 685 | { |
| 731 | | SDL_SetWindowSize(window().m_sdl_window, m_resize_width, m_resize_height); |
| 732 | | SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height); |
| 733 | | m_resize_pending = 0; |
| 734 | | SDL_RenderSetViewport(m_renderer, NULL); |
| 735 | | //sdlvideo_monitor_refresh(window().monitor()); |
| 736 | | |
| 686 | m_last_width = window().width(); |
| 687 | m_last_height = window().height(); |
| 688 | SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 689 | m_blittimer = 3; |
| 737 | 690 | } |
| 738 | | |
| 739 | 691 | //SDL_SelectRenderer(window().sdl_window); |
| 740 | 692 | |
| 741 | 693 | if (m_blittimer > 0) |
| 742 | 694 | { |
| 743 | 695 | /* SDL Underlays need alpha = 0 ! */ |
| 744 | | SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE); |
| 696 | SDL_SetRenderDrawBlendMode(m_sdl_renderer, SDL_BLENDMODE_NONE); |
| 745 | 697 | //SDL_SetRenderDrawColor(0,0,0,255); |
| 746 | | SDL_SetRenderDrawColor(m_renderer, 0,0,0,0); |
| 747 | | SDL_RenderFillRect(m_renderer, NULL); |
| 698 | SDL_SetRenderDrawColor(m_sdl_renderer, 0,0,0,0); |
| 699 | SDL_RenderFillRect(m_sdl_renderer, NULL); |
| 748 | 700 | m_blittimer--; |
| 749 | 701 | } |
| 750 | 702 | |
| r243410 | r243411 | |
| 762 | 714 | } |
| 763 | 715 | else |
| 764 | 716 | { |
| 765 | | ch = window().m_height; |
| 766 | | cw = window().m_width; |
| 717 | ch = window().height(); |
| 718 | cw = window().width(); |
| 767 | 719 | } |
| 768 | 720 | |
| 769 | 721 | if (video_config.centerv) |
| 770 | 722 | { |
| 771 | | vofs = (ch - window().m_blitheight) / 2.0f; |
| 723 | vofs = (ch - window().blitheight()) / 2.0f; |
| 772 | 724 | } |
| 773 | 725 | if (video_config.centerh) |
| 774 | 726 | { |
| 775 | | hofs = (cw - window().m_blitwidth) / 2.0f; |
| 727 | hofs = (cw - window().blitwidth()) / 2.0f; |
| 776 | 728 | } |
| 777 | 729 | } |
| 778 | 730 | |
| r243410 | r243411 | |
| 794 | 746 | sb = (int)(255.0f * prim->color.b); |
| 795 | 747 | sa = (int)(255.0f * prim->color.a); |
| 796 | 748 | |
| 797 | | SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 798 | | SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); |
| 799 | | SDL_RenderDrawLine(m_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs, |
| 749 | SDL_SetRenderDrawBlendMode(m_sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 750 | SDL_SetRenderDrawColor(m_sdl_renderer, sr, sg, sb, sa); |
| 751 | SDL_RenderDrawLine(m_sdl_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs, |
| 800 | 752 | prim->bounds.x1 + hofs, prim->bounds.y1 + vofs); |
| 801 | 753 | break; |
| 802 | 754 | case render_primitive::QUAD: |
| r243410 | r243411 | |
| 816 | 768 | |
| 817 | 769 | m_last_blit_pixels = blit_pixels; |
| 818 | 770 | m_last_blit_time = -osd_ticks(); |
| 819 | | SDL_RenderPresent(m_renderer); |
| 771 | SDL_RenderPresent(m_sdl_renderer); |
| 820 | 772 | m_last_blit_time += osd_ticks(); |
| 821 | 773 | |
| 822 | 774 | return 0; |
| r243410 | r243411 | |
| 824 | 776 | |
| 825 | 777 | |
| 826 | 778 | //============================================================ |
| 827 | | // sdl_info13::clear |
| 828 | | //============================================================ |
| 829 | | |
| 830 | | void sdl_info13::clear() |
| 831 | | { |
| 832 | | m_blittimer = 2; |
| 833 | | } |
| 834 | | |
| 835 | | |
| 836 | | //============================================================ |
| 837 | | // sdl_info13::destroy |
| 838 | | //============================================================ |
| 839 | | |
| 840 | | void sdl_info13::destroy() |
| 841 | | { |
| 842 | | // free the memory in the window |
| 843 | | |
| 844 | | destroy_all_textures(); |
| 845 | | |
| 846 | | if (window().fullscreen() && video_config.switchres) |
| 847 | | { |
| 848 | | SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode |
| 849 | | SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode |
| 850 | | SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 851 | | } |
| 852 | | |
| 853 | | SDL_DestroyWindow(window().m_sdl_window); |
| 854 | | |
| 855 | | } |
| 856 | | |
| 857 | | //============================================================ |
| 858 | 779 | // texture handling |
| 859 | 780 | //============================================================ |
| 860 | 781 | |
| r243410 | r243411 | |
| 873 | 794 | if ((m_is_rotated == bi->blitter->m_is_rot) |
| 874 | 795 | && (m_sdl_blendmode == bi->bm_mask)) |
| 875 | 796 | { |
| 876 | | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 797 | if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 877 | 798 | { |
| 878 | 799 | int perf = bi->perf; |
| 879 | 800 | if (perf == 0) |
| r243410 | r243411 | |
| 893 | 814 | { |
| 894 | 815 | if ((m_is_rotated == bi->blitter->m_is_rot) |
| 895 | 816 | && (m_sdl_blendmode == bi->bm_mask)) |
| 896 | | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 817 | if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 897 | 818 | return bi; |
| 898 | 819 | } |
| 899 | 820 | //FIXME: crash implement a -do nothing handler */ |
| r243410 | r243411 | |
| 931 | 852 | texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags) |
| 932 | 853 | { |
| 933 | 854 | // fill in the core data |
| 934 | | m_renderer = renderer; |
| 855 | m_sdl_renderer = renderer; |
| 935 | 856 | m_hash = texture_compute_hash(texsource, flags); |
| 936 | 857 | m_flags = flags; |
| 937 | 858 | m_texinfo = texsource; |
| r243410 | r243411 | |
| 980 | 901 | |
| 981 | 902 | m_copyinfo = compute_size_type(); |
| 982 | 903 | |
| 983 | | m_texture_id = SDL_CreateTexture(m_renderer, m_copyinfo->dst_fmt, m_sdl_access, |
| 904 | m_texture_id = SDL_CreateTexture(m_sdl_renderer, m_copyinfo->dst_fmt, m_sdl_access, |
| 984 | 905 | m_setup.rotwidth, m_setup.rotheight); |
| 985 | 906 | |
| 986 | 907 | if (!m_texture_id) |
| r243410 | r243411 | |
| 1153 | 1074 | // if we didn't find one, create a new texture |
| 1154 | 1075 | if (texture == NULL && prim.texture.base != NULL) |
| 1155 | 1076 | { |
| 1156 | | texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags)); |
| 1077 | texture = global_alloc(texture_info(m_sdl_renderer, prim.texture, setup, prim.flags)); |
| 1157 | 1078 | /* add us to the texture list */ |
| 1158 | 1079 | m_texlist.prepend(*texture); |
| 1159 | 1080 | |
| r243410 | r243411 | |
| 1172 | 1093 | return texture; |
| 1173 | 1094 | } |
| 1174 | 1095 | |
| 1175 | | |
| 1176 | | void sdl_info13::destroy_all_textures() |
| 1177 | | { |
| 1178 | | if(window().m_primlist) |
| 1179 | | { |
| 1180 | | window().m_primlist->acquire_lock(); |
| 1181 | | m_texlist.reset(); |
| 1182 | | window().m_primlist->release_lock(); |
| 1183 | | } |
| 1184 | | else |
| 1185 | | m_texlist.reset(); |
| 1186 | | } |
trunk/src/osd/sdl/drawogl.c
| r243410 | r243411 | |
| 58 | 58 | typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum m_target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); |
| 59 | 59 | typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); |
| 60 | 60 | typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum m_target, GLuint renderbuffer); |
| 61 | | typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum m_target, GLenum internalformat, GLsizei m_width, GLsizei m_height); |
| 61 | typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum m_target, GLenum internalformat, GLsizei width, GLsizei height); |
| 62 | 62 | typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum m_target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); |
| 63 | 63 | typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); |
| 64 | 64 | #endif |
| r243410 | r243411 | |
| 156 | 156 | // TYPES |
| 157 | 157 | //============================================================ |
| 158 | 158 | |
| 159 | | struct texture_info; |
| 159 | //============================================================ |
| 160 | // Textures |
| 161 | //============================================================ |
| 160 | 162 | |
| 161 | 163 | /* texture_info holds information about a texture */ |
| 162 | | struct texture_info |
| 164 | class texture_info |
| 163 | 165 | { |
| 166 | public: |
| 164 | 167 | texture_info() |
| 165 | | : hash(0), flags(0), rawwidth(0), rawheight(0), |
| 168 | : hash(0), flags(0), rawwidth(0), rawheight(0), |
| 166 | 169 | rawwidth_create(0), rawheight_create(0), |
| 167 | 170 | type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0), |
| 168 | 171 | texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL), |
| r243410 | r243411 | |
| 219 | 222 | { |
| 220 | 223 | public: |
| 221 | 224 | sdl_info_ogl(sdl_window_info *window) |
| 222 | | : osd_renderer(window), m_blittimer(0), m_extra_flags(0), |
| 225 | : osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0), |
| 226 | m_screen_width(0), m_screen_height(0), |
| 227 | m_last_width(0), m_last_height(0), |
| 223 | 228 | #if (SDLMAME_SDL2) |
| 224 | 229 | m_gl_context_id(0), |
| 225 | 230 | #else |
| 226 | | m_sdlsurf(NULL), |
| 227 | 231 | #endif |
| 228 | 232 | m_initialized(0), |
| 229 | 233 | m_last_blendmode(0), |
| r243410 | r243411 | |
| 248 | 252 | m_texVerticex[i] = 0.0f; |
| 249 | 253 | } |
| 250 | 254 | |
| 251 | | /* virtual */ int create(int width, int height); |
| 252 | | /* virtual */ void resize(int width, int height); |
| 253 | | /* virtual */ int draw(UINT32 dc, int update); |
| 254 | | /* virtual */ void set_target_bounds(); |
| 255 | | /* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt); |
| 255 | /* virtual */ int create(); |
| 256 | /* virtual */ int draw(const UINT32 dc, const int update); |
| 257 | /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); |
| 256 | 258 | /* virtual */ void destroy_all_textures(); |
| 257 | 259 | /* virtual */ void destroy(); |
| 258 | 260 | /* virtual */ void clear(); |
| r243410 | r243411 | |
| 276 | 278 | void texture_all_disable(); |
| 277 | 279 | |
| 278 | 280 | INT32 m_blittimer; |
| 279 | | UINT32 m_extra_flags; |
| 281 | int m_screen_width; |
| 282 | int m_screen_height; |
| 283 | int m_last_width; |
| 284 | int m_last_height; |
| 280 | 285 | |
| 281 | | |
| 282 | 286 | #if (SDLMAME_SDL2) |
| 283 | | // Original display_mode |
| 284 | | SDL_DisplayMode m_original_mode; |
| 285 | | |
| 286 | 287 | SDL_GLContext m_gl_context_id; |
| 287 | 288 | #else |
| 288 | | // SDL surface |
| 289 | | SDL_Surface *m_sdlsurf; |
| 290 | 289 | #endif |
| 291 | 290 | |
| 292 | 291 | int m_initialized; // is everything well initialized, i.e. all GL stuff etc. |
| r243410 | r243411 | |
| 393 | 392 | |
| 394 | 393 | // core functions |
| 395 | 394 | |
| 395 | //============================================================ |
| 396 | // STATIC VARIABLES |
| 397 | //============================================================ |
| 398 | |
| 396 | 399 | static void drawogl_exit(void); |
| 397 | 400 | static void load_gl_lib(running_machine &machine); |
| 398 | 401 | |
| r243410 | r243411 | |
| 440 | 443 | static int dll_loaded = 0; |
| 441 | 444 | |
| 442 | 445 | //============================================================ |
| 443 | | // drawogl_init |
| 446 | // drawsdl_init |
| 444 | 447 | //============================================================ |
| 445 | 448 | |
| 446 | 449 | static osd_renderer *drawogl_create(sdl_window_info *window) |
| r243410 | r243411 | |
| 456 | 459 | |
| 457 | 460 | dll_loaded = 0; |
| 458 | 461 | |
| 462 | load_gl_lib(machine); |
| 459 | 463 | if (SDLMAME_SDL2) |
| 460 | 464 | { |
| 461 | 465 | osd_printf_verbose("Using SDL multi-window OpenGL driver (SDL 2.0+)\n"); |
| 462 | | load_gl_lib(machine); |
| 463 | 466 | } |
| 464 | 467 | else |
| 465 | 468 | osd_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n"); |
| r243410 | r243411 | |
| 708 | 711 | // a |
| 709 | 712 | //============================================================ |
| 710 | 713 | |
| 711 | | int sdl_info_ogl::create(int width, int height) |
| 714 | int sdl_info_ogl::create() |
| 712 | 715 | { |
| 713 | | #if (SDLMAME_SDL2) |
| 714 | 716 | |
| 715 | | SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); |
| 716 | | |
| 717 | | /* FIXME: A reminder that gamma is wrong throughout MAME. Currently, SDL2.0 doesn't seem to |
| 718 | | * support the following attribute although my hardware lists GL_ARB_framebuffer_sRGB as an extension. |
| 719 | | * |
| 720 | | * SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 ); |
| 721 | | * |
| 722 | | */ |
| 723 | | |
| 724 | | osd_printf_verbose("Enter sdl_info_ogl::create\n"); |
| 725 | | |
| 726 | | // create the SDL window |
| 727 | | // soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS |
| 728 | | m_extra_flags = (window().fullscreen() ? |
| 729 | | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); |
| 730 | | |
| 731 | | m_extra_flags |= SDL_WINDOW_OPENGL; |
| 732 | | |
| 733 | | |
| 734 | | #if defined(SDLMAME_WIN32) |
| 735 | | SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); |
| 736 | | #endif |
| 737 | | // create the SDL window |
| 738 | | window().m_sdl_window = SDL_CreateWindow(window().m_title, |
| 739 | | window().monitor()->position_size().x, window().monitor()->position_size().y, |
| 740 | | width, height, m_extra_flags); |
| 741 | | //window().m_sdl_window = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
| 742 | | // width, height, m_extra_flags); |
| 743 | | |
| 744 | | if (!window().m_sdl_window ) |
| 745 | | { |
| 746 | | osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); |
| 747 | | return 1; |
| 748 | | } |
| 749 | | |
| 750 | | if (window().fullscreen() && video_config.switchres) |
| 751 | | { |
| 752 | | SDL_DisplayMode mode; |
| 753 | | //SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode); |
| 754 | | SDL_GetWindowDisplayMode(window().m_sdl_window, &mode); |
| 755 | | m_original_mode = mode; |
| 756 | | mode.w = width; |
| 757 | | mode.h = height; |
| 758 | | if (window().m_refresh) |
| 759 | | mode.refresh_rate = window().m_refresh; |
| 760 | | |
| 761 | | SDL_SetWindowDisplayMode(window().m_sdl_window, &mode); // Try to set mode |
| 762 | | #ifndef SDLMAME_WIN32 |
| 763 | | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| 764 | | * is in place after the mode switch - which will most likely be the case |
| 765 | | * This is a hack to work around a deficiency in SDL2 |
| 766 | | */ |
| 767 | | SDL_WarpMouseInWindow(window().m_sdl_window, 1, 1); |
| 768 | | #endif |
| 769 | | } |
| 770 | | else |
| 771 | | { |
| 772 | | //SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop |
| 773 | | } |
| 717 | #if (SDLMAME_SDL2) |
| 774 | 718 | // create renderer |
| 775 | 719 | |
| 776 | | //SDL_SelectRenderer(window().sdl_window); |
| 777 | | |
| 778 | | // show window |
| 779 | | |
| 780 | | SDL_ShowWindow(window().m_sdl_window); |
| 781 | | //SDL_SetWindowFullscreen(window().m_sdl_window, window().fullscreen); |
| 782 | | SDL_RaiseWindow(window().m_sdl_window); |
| 783 | | |
| 784 | | SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height); |
| 785 | | |
| 786 | | |
| 787 | | m_gl_context_id = SDL_GL_CreateContext(window().m_sdl_window); |
| 720 | m_gl_context_id = SDL_GL_CreateContext(window().sdl_window()); |
| 788 | 721 | if (!m_gl_context_id) |
| 789 | 722 | { |
| 790 | 723 | osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); |
| r243410 | r243411 | |
| 794 | 727 | SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0); |
| 795 | 728 | |
| 796 | 729 | #else |
| 797 | | m_extra_flags = (window().fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE); |
| 798 | | m_extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF; |
| 799 | | |
| 800 | | SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); |
| 801 | | #if (SDL_VERSION_ATLEAST(1,2,10)) && (!defined(SDLMAME_EMSCRIPTEN)) |
| 802 | | SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0); |
| 803 | | #endif |
| 804 | | |
| 805 | | load_gl_lib(window().machine()); |
| 806 | | |
| 807 | | // create the SDL surface (which creates the window in windowed mode) |
| 808 | | m_sdlsurf = SDL_SetVideoMode(width, height, |
| 809 | | 0, SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags); |
| 810 | | |
| 811 | | if (!m_sdlsurf) |
| 812 | | return 1; |
| 813 | | |
| 814 | | window().m_width = m_sdlsurf->w; |
| 815 | | window().m_height = m_sdlsurf->h; |
| 816 | | |
| 817 | | window().m_screen_width = 0; |
| 818 | | window().m_screen_height = 0; |
| 819 | | |
| 820 | | if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(m_sdlsurf->flags & SDL_OPENGL) ) |
| 821 | | { |
| 822 | | osd_printf_error("OpenGL not supported on this driver!\n"); |
| 823 | | return 1; |
| 824 | | } |
| 825 | | |
| 826 | | // set the window title |
| 827 | | SDL_WM_SetCaption(window().m_title, "SDLMAME"); |
| 828 | | |
| 829 | 730 | #endif |
| 830 | 731 | |
| 732 | m_screen_width = 0; |
| 733 | m_screen_height = 0; |
| 734 | |
| 831 | 735 | m_blittimer = 0; |
| 832 | 736 | m_surf_w = 0; |
| 833 | 737 | m_surf_h = 0; |
| r243410 | r243411 | |
| 852 | 756 | return 0; |
| 853 | 757 | } |
| 854 | 758 | |
| 759 | |
| 855 | 760 | //============================================================ |
| 856 | | // sdl_info::resize |
| 761 | // sdl_info::destroy |
| 857 | 762 | //============================================================ |
| 858 | 763 | |
| 859 | | void sdl_info_ogl::resize(int width, int height) |
| 764 | void sdl_info_ogl::destroy() |
| 860 | 765 | { |
| 861 | | #if (SDLMAME_SDL2) |
| 862 | | //SDL_GL_MakeCurrent(window().sdl_window, gl_context_id); |
| 863 | | SDL_SetWindowSize(window().m_sdl_window, width, height); |
| 864 | | SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height); |
| 865 | | m_blittimer = 3; |
| 866 | | #else |
| 867 | | SDL_FreeSurface(m_sdlsurf); |
| 868 | 766 | |
| 869 | | m_sdlsurf = SDL_SetVideoMode(width, height, 0, |
| 870 | | SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags); |
| 767 | // free the memory in the window |
| 871 | 768 | |
| 872 | | window().m_width = m_sdlsurf->w; |
| 873 | | window().m_height = m_sdlsurf->h; |
| 769 | destroy_all_textures(); |
| 770 | |
| 771 | #if (SDLMAME_SDL2) |
| 772 | SDL_GL_DeleteContext(m_gl_context_id); |
| 874 | 773 | #endif |
| 875 | | m_init_context = 1; |
| 876 | 774 | |
| 877 | 775 | } |
| 878 | 776 | |
| 879 | 777 | //============================================================ |
| 778 | // sdl_info::clear |
| 779 | //============================================================ |
| 780 | |
| 781 | void sdl_info_ogl::clear() |
| 782 | { |
| 783 | //FIXME: Handled in sdl_info::draw as well |
| 784 | m_blittimer = 3; |
| 785 | } |
| 786 | |
| 787 | //============================================================ |
| 880 | 788 | // drawsdl_xy_to_render_target |
| 881 | 789 | //============================================================ |
| 882 | 790 | |
| 883 | 791 | int sdl_info_ogl::xy_to_render_target(int x, int y, int *xt, int *yt) |
| 884 | 792 | { |
| 793 | |
| 885 | 794 | *xt = x - m_last_hofs; |
| 886 | 795 | *yt = y - m_last_vofs; |
| 887 | | if (*xt<0 || *xt >= window().m_blitwidth) |
| 796 | if (*xt<0 || *xt >= window().blitwidth()) |
| 888 | 797 | return 0; |
| 889 | | if (*yt<0 || *yt >= window().m_blitheight) |
| 798 | if (*yt<0 || *yt >= window().blitheight()) |
| 890 | 799 | return 0; |
| 891 | 800 | return 1; |
| 892 | 801 | } |
| 893 | 802 | |
| 894 | 803 | //============================================================ |
| 895 | | // sdl_info::get_primitives |
| 804 | // drawsdl_destroy_all_textures |
| 896 | 805 | //============================================================ |
| 897 | 806 | |
| 898 | | void sdl_info_ogl::set_target_bounds() |
| 807 | void sdl_info_ogl::destroy_all_textures() |
| 899 | 808 | { |
| 900 | | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 901 | | } |
| 809 | texture_info *texture = NULL; |
| 810 | int lock=FALSE; |
| 811 | int i; |
| 902 | 812 | |
| 813 | if ( !m_initialized ) |
| 814 | return; |
| 815 | |
| 816 | #if (SDLMAME_SDL2) |
| 817 | SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id); |
| 818 | #endif |
| 819 | |
| 820 | if(window().m_primlist) |
| 821 | { |
| 822 | lock=TRUE; |
| 823 | window().m_primlist->acquire_lock(); |
| 824 | } |
| 825 | |
| 826 | glFinish(); |
| 827 | |
| 828 | texture_all_disable(); |
| 829 | glFinish(); |
| 830 | glDisableClientState(GL_VERTEX_ARRAY); |
| 831 | |
| 832 | i=0; |
| 833 | while (i<HASH_SIZE+OVERFLOW_SIZE) |
| 834 | { |
| 835 | texture = m_texhash[i]; |
| 836 | m_texhash[i] = NULL; |
| 837 | if (texture != NULL) |
| 838 | { |
| 839 | if(m_usevbo) |
| 840 | { |
| 841 | pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) ); |
| 842 | texture->texCoordBufferName=0; |
| 843 | } |
| 844 | |
| 845 | if(m_usepbo && texture->pbo) |
| 846 | { |
| 847 | pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) ); |
| 848 | texture->pbo=0; |
| 849 | } |
| 850 | |
| 851 | if( m_glsl_program_num > 1 ) |
| 852 | { |
| 853 | assert(m_usefbo); |
| 854 | pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]); |
| 855 | glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]); |
| 856 | } |
| 857 | |
| 858 | if ( m_glsl_program_mb2sc < m_glsl_program_num - 1 ) |
| 859 | { |
| 860 | assert(m_usefbo); |
| 861 | pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]); |
| 862 | glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]); |
| 863 | } |
| 864 | |
| 865 | glDeleteTextures(1, (GLuint *)&texture->texture); |
| 866 | if ( texture->data_own ) |
| 867 | { |
| 868 | free(texture->data); |
| 869 | texture->data=NULL; |
| 870 | texture->data_own=FALSE; |
| 871 | } |
| 872 | global_free(texture); |
| 873 | } |
| 874 | i++; |
| 875 | } |
| 876 | if ( m_useglsl ) |
| 877 | { |
| 878 | glsl_shader_free(m_glsl); |
| 879 | m_glsl = NULL; |
| 880 | } |
| 881 | |
| 882 | m_initialized = 0; |
| 883 | |
| 884 | if (lock) |
| 885 | window().m_primlist->release_lock(); |
| 886 | } |
| 903 | 887 | //============================================================ |
| 904 | 888 | // loadGLExtensions |
| 905 | 889 | //============================================================ |
| r243410 | r243411 | |
| 1118 | 1102 | |
| 1119 | 1103 | if ( m_useglsl ) |
| 1120 | 1104 | { |
| 1121 | | if ( window().m_prescale != 1 ) |
| 1105 | if ( window().prescale() != 1 ) |
| 1122 | 1106 | { |
| 1123 | 1107 | m_useglsl = 0; |
| 1124 | 1108 | if (_once) |
| r243410 | r243411 | |
| 1211 | 1195 | } |
| 1212 | 1196 | |
| 1213 | 1197 | //============================================================ |
| 1214 | | // sdl_info::destroy |
| 1215 | | //============================================================ |
| 1216 | | |
| 1217 | | void sdl_info_ogl::destroy() |
| 1218 | | { |
| 1219 | | |
| 1220 | | // free the memory in the window |
| 1221 | | |
| 1222 | | destroy_all_textures(); |
| 1223 | | |
| 1224 | | #if (SDLMAME_SDL2) |
| 1225 | | SDL_GL_DeleteContext(m_gl_context_id); |
| 1226 | | if (window().fullscreen() && video_config.switchres) |
| 1227 | | { |
| 1228 | | SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode |
| 1229 | | SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode |
| 1230 | | SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 1231 | | } |
| 1232 | | |
| 1233 | | SDL_DestroyWindow(window().m_sdl_window); |
| 1234 | | #else |
| 1235 | | if (m_sdlsurf) |
| 1236 | | { |
| 1237 | | SDL_FreeSurface(m_sdlsurf); |
| 1238 | | m_sdlsurf = NULL; |
| 1239 | | } |
| 1240 | | #endif |
| 1241 | | } |
| 1242 | | |
| 1243 | | //============================================================ |
| 1244 | 1198 | // sdl_info::draw |
| 1245 | 1199 | //============================================================ |
| 1246 | 1200 | |
| r243410 | r243411 | |
| 1257 | 1211 | return 0; |
| 1258 | 1212 | } |
| 1259 | 1213 | |
| 1214 | if ((window().width() != m_last_width) || (window().height() != m_last_height)) |
| 1215 | { |
| 1216 | m_last_width = window().width(); |
| 1217 | m_last_height = window().height(); |
| 1260 | 1218 | #if (SDLMAME_SDL2) |
| 1261 | | SDL_GL_MakeCurrent(window().m_sdl_window, m_gl_context_id); |
| 1219 | m_blittimer = 3; |
| 1220 | #endif |
| 1221 | m_init_context = 1; |
| 1222 | } |
| 1223 | |
| 1224 | #if (SDLMAME_SDL2) |
| 1225 | SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id); |
| 1262 | 1226 | #else |
| 1263 | 1227 | if (!m_init_context) |
| 1264 | 1228 | { |
| r243410 | r243411 | |
| 1267 | 1231 | { |
| 1268 | 1232 | if (window().index() == 0) |
| 1269 | 1233 | { |
| 1270 | | if ((screen->width() != window().m_screen_width) || (screen->height() != window().m_screen_height)) |
| 1234 | if ((screen->width() != m_screen_width) || (screen->height() != m_screen_height)) |
| 1271 | 1235 | { |
| 1272 | | window().m_screen_width = screen->width(); |
| 1273 | | window().m_screen_height = screen->height(); |
| 1236 | m_screen_width = screen->width(); |
| 1237 | m_screen_height = screen->height(); |
| 1274 | 1238 | |
| 1275 | 1239 | // force all textures to be regenerated |
| 1276 | 1240 | destroy_all_textures(); |
| r243410 | r243411 | |
| 1321 | 1285 | } |
| 1322 | 1286 | |
| 1323 | 1287 | if ( !m_initialized || |
| 1324 | | window().m_width!= m_surf_w || window().m_height!= m_surf_h ) |
| 1288 | window().width()!= m_surf_w || window().height()!= m_surf_h ) |
| 1325 | 1289 | { |
| 1326 | 1290 | if ( !m_initialized ) |
| 1327 | 1291 | { |
| 1328 | 1292 | loadGLExtensions(); |
| 1329 | 1293 | } |
| 1330 | 1294 | |
| 1331 | | m_surf_w=window().m_width; |
| 1332 | | m_surf_h=window().m_height; |
| 1295 | m_surf_w=window().width(); |
| 1296 | m_surf_h=window().height(); |
| 1333 | 1297 | |
| 1334 | 1298 | // we're doing nothing 3d, so the Z-buffer is currently not interesting |
| 1335 | 1299 | glDisable(GL_DEPTH_TEST); |
| r243410 | r243411 | |
| 1370 | 1334 | // |_________| |
| 1371 | 1335 | // (0,h) (w,h) |
| 1372 | 1336 | |
| 1373 | | glViewport(0.0, 0.0, (GLsizei)window().m_width, (GLsizei)window().m_height); |
| 1337 | glViewport(0.0, 0.0, (GLsizei)window().width(), (GLsizei)window().height()); |
| 1374 | 1338 | glMatrixMode(GL_PROJECTION); |
| 1375 | 1339 | glLoadIdentity(); |
| 1376 | | glOrtho(0.0, (GLdouble)window().m_width, (GLdouble)window().m_height, 0.0, 0.0, -1.0); |
| 1340 | glOrtho(0.0, (GLdouble)window().width(), (GLdouble)window().height(), 0.0, 0.0, -1.0); |
| 1377 | 1341 | glMatrixMode(GL_MODELVIEW); |
| 1378 | 1342 | glLoadIdentity(); |
| 1379 | 1343 | |
| r243410 | r243411 | |
| 1400 | 1364 | } |
| 1401 | 1365 | else |
| 1402 | 1366 | { |
| 1403 | | ch = window().m_height; |
| 1404 | | cw = window().m_width; |
| 1367 | ch = window().height(); |
| 1368 | cw = window().width(); |
| 1405 | 1369 | } |
| 1406 | 1370 | |
| 1407 | 1371 | if (video_config.centerv) |
| 1408 | 1372 | { |
| 1409 | | vofs = (ch - window().m_blitheight) / 2.0f; |
| 1373 | vofs = (ch - window().blitheight()) / 2.0f; |
| 1410 | 1374 | } |
| 1411 | 1375 | if (video_config.centerh) |
| 1412 | 1376 | { |
| 1413 | | hofs = (cw - window().m_blitwidth) / 2.0f; |
| 1377 | hofs = (cw - window().blitwidth()) / 2.0f; |
| 1414 | 1378 | } |
| 1415 | 1379 | } |
| 1416 | 1380 | |
| r243410 | r243411 | |
| 1486 | 1450 | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1487 | 1451 | |
| 1488 | 1452 | // compute the effective width based on the direction of the line |
| 1489 | | effwidth = prim->m_width; |
| 1453 | effwidth = prim->width(); |
| 1490 | 1454 | if (effwidth < 0.5f) |
| 1491 | 1455 | effwidth = 0.5f; |
| 1492 | 1456 | |
| r243410 | r243411 | |
| 1591 | 1555 | // 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1) on texture dimensions |
| 1592 | 1556 | m_texVerticex[0]=(GLfloat)0.0; |
| 1593 | 1557 | m_texVerticex[1]=(GLfloat)0.0; |
| 1594 | | m_texVerticex[2]=(GLfloat)window().m_width; |
| 1558 | m_texVerticex[2]=(GLfloat)window().width(); |
| 1595 | 1559 | m_texVerticex[3]=(GLfloat)0.0; |
| 1596 | | m_texVerticex[4]=(GLfloat)window().m_width; |
| 1597 | | m_texVerticex[5]=(GLfloat)window().m_height; |
| 1560 | m_texVerticex[4]=(GLfloat)window().width(); |
| 1561 | m_texVerticex[5]=(GLfloat)window().height(); |
| 1598 | 1562 | m_texVerticex[6]=(GLfloat)0.0; |
| 1599 | | m_texVerticex[7]=(GLfloat)window().m_height; |
| 1563 | m_texVerticex[7]=(GLfloat)window().height(); |
| 1600 | 1564 | } |
| 1601 | 1565 | |
| 1602 | 1566 | if(i>0) // first fetch already done |
| r243410 | r243411 | |
| 1642 | 1606 | #if (!SDLMAME_SDL2) |
| 1643 | 1607 | SDL_GL_SwapBuffers(); |
| 1644 | 1608 | #else |
| 1645 | | SDL_GL_SwapWindow(window().m_sdl_window); |
| 1609 | SDL_GL_SwapWindow(window().sdl_window()); |
| 1646 | 1610 | #endif |
| 1647 | 1611 | return 0; |
| 1648 | 1612 | } |
| r243410 | r243411 | |
| 1800 | 1764 | texture->xprescale--; |
| 1801 | 1765 | while (texture->yprescale > 1 && height_create * texture->yprescale > m_texture_max_height) |
| 1802 | 1766 | texture->yprescale--; |
| 1803 | | if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != window().m_prescale || texture->yprescale != window().m_prescale)) |
| 1804 | | osd_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", window().m_prescale, window().m_prescale, texture->xprescale, texture->yprescale); |
| 1767 | if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != window().prescale() || texture->yprescale != window().prescale())) |
| 1768 | osd_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", window().prescale(), window().prescale(), texture->xprescale, texture->yprescale); |
| 1805 | 1769 | |
| 1806 | 1770 | width *= texture->xprescale; |
| 1807 | 1771 | height *= texture->yprescale; |
| r243410 | r243411 | |
| 1980 | 1944 | { |
| 1981 | 1945 | int uniform_location; |
| 1982 | 1946 | int i; |
| 1983 | | int surf_w_pow2 = get_valid_pow2_value (window().m_blitwidth, texture->texpow2); |
| 1984 | | int surf_h_pow2 = get_valid_pow2_value (window().m_blitheight, texture->texpow2); |
| 1947 | int surf_w_pow2 = get_valid_pow2_value (window().blitwidth(), texture->texpow2); |
| 1948 | int surf_h_pow2 = get_valid_pow2_value (window().blitheight(), texture->texpow2); |
| 1985 | 1949 | |
| 1986 | 1950 | assert ( texture->type==TEXTURE_TYPE_SHADER ); |
| 1987 | 1951 | |
| r243410 | r243411 | |
| 2028 | 1992 | pfn_glUniform2fvARB(uniform_location, 1, &(color_texture_pow2_sz[0])); |
| 2029 | 1993 | GL_CHECK_ERROR_NORMAL(); |
| 2030 | 1994 | |
| 2031 | | GLfloat screen_texture_sz[2] = { (GLfloat)window().m_blitwidth, (GLfloat)window().m_blitheight }; |
| 1995 | GLfloat screen_texture_sz[2] = { (GLfloat)window().blitwidth(), (GLfloat)window().blitheight() }; |
| 2032 | 1996 | uniform_location = pfn_glGetUniformLocationARB(m_glsl_program[i], "screen_texture_sz"); |
| 2033 | 1997 | pfn_glUniform2fvARB(uniform_location, 1, &(screen_texture_sz[0])); |
| 2034 | 1998 | GL_CHECK_ERROR_NORMAL(); |
| r243410 | r243411 | |
| 2084 | 2048 | } |
| 2085 | 2049 | |
| 2086 | 2050 | osd_printf_verbose("GL texture: mpass screen-bmp 2x %dx%d (pow2 %dx%d)\n", |
| 2087 | | window().m_width, window().m_height, surf_w_pow2, surf_h_pow2); |
| 2051 | window().width(), window().height(), surf_w_pow2, surf_h_pow2); |
| 2088 | 2052 | } |
| 2089 | 2053 | |
| 2090 | 2054 | // GL_TEXTURE0 |
| r243410 | r243411 | |
| 2163 | 2127 | texture->texinfo.seqid = -1; // force set data |
| 2164 | 2128 | if (PRIMFLAG_GET_SCREENTEX(flags)) |
| 2165 | 2129 | { |
| 2166 | | texture->xprescale = window().m_prescale; |
| 2167 | | texture->yprescale = window().m_prescale; |
| 2130 | texture->xprescale = window().prescale(); |
| 2131 | texture->yprescale = window().prescale(); |
| 2168 | 2132 | } |
| 2169 | 2133 | else |
| 2170 | 2134 | { |
| r243410 | r243411 | |
| 2794 | 2758 | } |
| 2795 | 2759 | else if ( texture->type == TEXTURE_TYPE_SHADER && shaderIdx>m_glsl_program_mb2sc ) |
| 2796 | 2760 | { |
| 2797 | | int surf_w_pow2 = get_valid_pow2_value (window().m_width, texture->texpow2); |
| 2798 | | int surf_h_pow2 = get_valid_pow2_value (window().m_height, texture->texpow2); |
| 2761 | int surf_w_pow2 = get_valid_pow2_value (window().width(), texture->texpow2); |
| 2762 | int surf_h_pow2 = get_valid_pow2_value (window().height(), texture->texpow2); |
| 2799 | 2763 | |
| 2800 | | ustop = (float)(window().m_width) / (float)surf_w_pow2; |
| 2801 | | vstop = (float)(window().m_height) / (float)surf_h_pow2; |
| 2764 | ustop = (float)(window().width()) / (float)surf_w_pow2; |
| 2765 | vstop = (float)(window().height()) / (float)surf_h_pow2; |
| 2802 | 2766 | } |
| 2803 | 2767 | else |
| 2804 | 2768 | { |
| r243410 | r243411 | |
| 3086 | 3050 | } |
| 3087 | 3051 | } |
| 3088 | 3052 | |
| 3089 | | void sdl_info_ogl::destroy_all_textures() |
| 3090 | | { |
| 3091 | | texture_info *texture = NULL; |
| 3092 | | int lock=FALSE; |
| 3093 | | int i; |
| 3094 | 3053 | |
| 3095 | | if ( !m_initialized ) |
| 3096 | | return; |
| 3097 | 3054 | |
| 3098 | | #if (SDLMAME_SDL2) |
| 3099 | | SDL_GL_MakeCurrent(window().m_sdl_window, m_gl_context_id); |
| 3100 | | #endif |
| 3101 | | |
| 3102 | | if(window().m_primlist) |
| 3103 | | { |
| 3104 | | lock=TRUE; |
| 3105 | | window().m_primlist->acquire_lock(); |
| 3106 | | } |
| 3107 | | |
| 3108 | | glFinish(); |
| 3109 | | |
| 3110 | | texture_all_disable(); |
| 3111 | | glFinish(); |
| 3112 | | glDisableClientState(GL_VERTEX_ARRAY); |
| 3113 | | |
| 3114 | | i=0; |
| 3115 | | while (i<HASH_SIZE+OVERFLOW_SIZE) |
| 3116 | | { |
| 3117 | | texture = m_texhash[i]; |
| 3118 | | m_texhash[i] = NULL; |
| 3119 | | if (texture != NULL) |
| 3120 | | { |
| 3121 | | if(m_usevbo) |
| 3122 | | { |
| 3123 | | pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) ); |
| 3124 | | texture->texCoordBufferName=0; |
| 3125 | | } |
| 3126 | | |
| 3127 | | if(m_usepbo && texture->pbo) |
| 3128 | | { |
| 3129 | | pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) ); |
| 3130 | | texture->pbo=0; |
| 3131 | | } |
| 3132 | | |
| 3133 | | if( m_glsl_program_num > 1 ) |
| 3134 | | { |
| 3135 | | assert(m_usefbo); |
| 3136 | | pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]); |
| 3137 | | glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]); |
| 3138 | | } |
| 3139 | | |
| 3140 | | if ( m_glsl_program_mb2sc < m_glsl_program_num - 1 ) |
| 3141 | | { |
| 3142 | | assert(m_usefbo); |
| 3143 | | pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]); |
| 3144 | | glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]); |
| 3145 | | } |
| 3146 | | |
| 3147 | | glDeleteTextures(1, (GLuint *)&texture->texture); |
| 3148 | | if ( texture->data_own ) |
| 3149 | | { |
| 3150 | | free(texture->data); |
| 3151 | | texture->data=NULL; |
| 3152 | | texture->data_own=FALSE; |
| 3153 | | } |
| 3154 | | global_free(texture); |
| 3155 | | } |
| 3156 | | i++; |
| 3157 | | } |
| 3158 | | if ( m_useglsl ) |
| 3159 | | { |
| 3160 | | glsl_shader_free(m_glsl); |
| 3161 | | m_glsl = NULL; |
| 3162 | | } |
| 3163 | | |
| 3164 | | m_initialized = 0; |
| 3165 | | |
| 3166 | | if (lock) |
| 3167 | | window().m_primlist->release_lock(); |
| 3168 | | } |
| 3169 | | |
| 3170 | | //============================================================ |
| 3171 | | // TEXCOPY FUNCS |
| 3172 | | //============================================================ |
| 3173 | | |
| 3174 | | void sdl_info_ogl::clear() |
| 3175 | | { |
| 3176 | | //FIXME: Handled in sdl_info::draw as well |
| 3177 | | m_blittimer = 3; |
| 3178 | | } |
trunk/src/osd/sdl/drawsdl.c
| r243410 | r243411 | |
| 50 | 50 | { |
| 51 | 51 | public: |
| 52 | 52 | |
| 53 | | sdl_info(sdl_window_info *w) |
| 54 | | : osd_renderer(w), |
| 55 | | m_blittimer(0), |
| 56 | | m_extra_flags(0), |
| 57 | | |
| 53 | sdl_info(sdl_window_info *w, int extra_flags) |
| 54 | : osd_renderer(w, extra_flags), |
| 58 | 55 | #if (SDLMAME_SDL2) |
| 59 | 56 | m_sdl_renderer(NULL), |
| 60 | 57 | m_texture_id(NULL), |
| 61 | 58 | #else |
| 62 | | m_sdlsurf(NULL), |
| 63 | 59 | m_yuvsurf(NULL), |
| 64 | 60 | #endif |
| 65 | 61 | m_yuv_lookup(NULL), |
| r243410 | r243411 | |
| 69 | 65 | m_last_hofs(0), |
| 70 | 66 | m_last_vofs(0), |
| 71 | 67 | m_old_blitwidth(0), |
| 72 | | m_old_blitheight(0) |
| 68 | m_old_blitheight(0), |
| 69 | m_last_width(0), |
| 70 | m_last_height(0) |
| 73 | 71 | { } |
| 74 | 72 | |
| 75 | | /* virtual */ int create(int width, int height); |
| 76 | | /* virtual */ void resize(int width, int height); |
| 77 | | /* virtual */ int draw(UINT32 dc, int update); |
| 78 | | /* virtual */ void set_target_bounds(); |
| 79 | | /* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt); |
| 73 | /* virtual */ int create(); |
| 74 | /* virtual */ int draw(const UINT32 dc, const int update); |
| 75 | /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); |
| 80 | 76 | /* virtual */ void destroy_all_textures(); |
| 81 | 77 | /* virtual */ void destroy(); |
| 82 | 78 | /* virtual */ void clear(); |
| r243410 | r243411 | |
| 93 | 89 | #endif |
| 94 | 90 | |
| 95 | 91 | INT32 m_blittimer; |
| 96 | | UINT32 m_extra_flags; |
| 97 | 92 | |
| 98 | 93 | #if (SDLMAME_SDL2) |
| 99 | | // Original display_mode |
| 100 | | SDL_DisplayMode m_original_mode; |
| 101 | | |
| 102 | 94 | SDL_Renderer *m_sdl_renderer; |
| 103 | 95 | SDL_Texture *m_texture_id; |
| 104 | 96 | #else |
| 105 | | // SDL surface |
| 106 | | SDL_Surface *m_sdlsurf; |
| 107 | 97 | SDL_Overlay *m_yuvsurf; |
| 108 | 98 | #endif |
| 109 | 99 | |
| r243410 | r243411 | |
| 118 | 108 | int m_last_vofs; |
| 119 | 109 | int m_old_blitwidth; |
| 120 | 110 | int m_old_blitheight; |
| 111 | int m_last_width; |
| 112 | int m_last_height; |
| 121 | 113 | }; |
| 122 | 114 | |
| 123 | 115 | struct sdl_scale_mode |
| r243410 | r243411 | |
| 165 | 157 | |
| 166 | 158 | static const sdl_scale_mode scale_modes[] = |
| 167 | 159 | { |
| 168 | | { "none", 0, 0, 1, 1, SDL_DOUBLEBUF, 0, 0 }, |
| 169 | | { "async", 0, 0, 1, 1, SDL_DOUBLEBUF | SDL_ASYNCBLIT, 0, 0 }, |
| 160 | { "none", 0, 0, 1, 1, osd_renderer::FLAG_NEEDS_DOUBLEBUF, 0, 0 }, |
| 161 | { "async", 0, 0, 1, 1, osd_renderer::FLAG_NEEDS_DOUBLEBUF | osd_renderer::FLAG_NEEDS_ASYNCBLIT, 0, 0 }, |
| 170 | 162 | { "yv12", 1, 1, 1, 1, 0, SDL_YV12_OVERLAY, yuv_RGB_to_YV12 }, |
| 171 | 163 | { "yv12x2", 1, 1, 2, 2, 0, SDL_YV12_OVERLAY, yuv_RGB_to_YV12X2 }, |
| 172 | 164 | { "yuy2", 1, 1, 1, 1, 0, SDL_YUY2_OVERLAY, yuv_RGB_to_YUY2 }, |
| r243410 | r243411 | |
| 179 | 171 | { "none", 0, 0, 1, 1, DRAW2_SCALEMODE_NEAREST, 0, 0 }, |
| 180 | 172 | { "hwblit", 1, 0, 1, 1, DRAW2_SCALEMODE_LINEAR, 0, 0 }, |
| 181 | 173 | { "hwbest", 1, 0, 1, 1, DRAW2_SCALEMODE_BEST, 0, 0 }, |
| 182 | | { "yv12", 1, 1, 1, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12 }, |
| 183 | | { "yv12x2", 1, 1, 2, 2, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12X2 }, |
| 184 | | { "yuy2", 1, 1, 1, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2 }, |
| 185 | | { "yuy2x2", 1, 1, 2, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2X2 }, |
| 174 | /* SDL1.2 uses interpolation as well */ |
| 175 | { "yv12", 1, 1, 1, 1, DRAW2_SCALEMODE_BEST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12 }, |
| 176 | { "yv12x2", 1, 1, 2, 2, DRAW2_SCALEMODE_BEST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12X2 }, |
| 177 | { "yuy2", 1, 1, 1, 1, DRAW2_SCALEMODE_BEST, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2 }, |
| 178 | { "yuy2x2", 1, 1, 2, 1, DRAW2_SCALEMODE_BEST, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2X2 }, |
| 186 | 179 | { NULL } |
| 187 | 180 | }; |
| 188 | 181 | #endif |
| r243410 | r243411 | |
| 221 | 214 | return -1; |
| 222 | 215 | } |
| 223 | 216 | |
| 224 | | //============================================================ |
| 225 | | // drawsdl_init |
| 226 | | //============================================================ |
| 227 | 217 | |
| 228 | 218 | static osd_renderer *drawsdl_create(sdl_window_info *window) |
| 229 | 219 | { |
| 230 | | return global_alloc(sdl_info(window)); |
| 220 | // FIXME: QUALITY HINTS |
| 221 | #if (SDLMAME_SDL2) |
| 222 | return global_alloc(sdl_info(window, osd_renderer::FLAG_NONE)); |
| 223 | #else |
| 224 | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 225 | return global_alloc(sdl_info(window, sm->m_extra_flags)); |
| 226 | #endif |
| 231 | 227 | } |
| 232 | 228 | |
| 229 | //============================================================ |
| 230 | // drawsdl_init |
| 231 | //============================================================ |
| 233 | 232 | |
| 234 | 233 | int drawsdl_init(sdl_draw_info *callbacks) |
| 235 | 234 | { |
| r243410 | r243411 | |
| 254 | 253 | } |
| 255 | 254 | |
| 256 | 255 | //============================================================ |
| 257 | | // drawsdl_destroy_all_textures |
| 258 | | //============================================================ |
| 259 | | |
| 260 | | void sdl_info::destroy_all_textures() |
| 261 | | { |
| 262 | | /* nothing to be done in soft mode */ |
| 263 | | } |
| 264 | | |
| 265 | | //============================================================ |
| 266 | 256 | // setup_texture for window |
| 267 | 257 | //============================================================ |
| 268 | 258 | |
| r243410 | r243411 | |
| 289 | 279 | int m_hw_scale_width =0; |
| 290 | 280 | int m_hw_scale_height = 0; |
| 291 | 281 | |
| 292 | | window().m_target->compute_minimum_size(m_hw_scale_width, m_hw_scale_height); |
| 282 | window().target()->compute_minimum_size(m_hw_scale_width, m_hw_scale_height); |
| 293 | 283 | if (video_config.prescale) |
| 294 | 284 | { |
| 295 | 285 | m_hw_scale_width *= video_config.prescale; |
| r243410 | r243411 | |
| 325 | 315 | const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; |
| 326 | 316 | int minimum_width, minimum_height; |
| 327 | 317 | |
| 328 | | window().m_target->compute_minimum_size(minimum_width, minimum_height); |
| 318 | window().target()->compute_minimum_size(minimum_width, minimum_height); |
| 329 | 319 | |
| 330 | 320 | if (video_config.prescale) |
| 331 | 321 | { |
| r243410 | r243411 | |
| 349 | 339 | m_yuv_bitmap = global_alloc_array(UINT16, minimum_width*minimum_height); |
| 350 | 340 | |
| 351 | 341 | m_yuvsurf = SDL_CreateYUVOverlay(minimum_width * sdl_sm->mult_w, minimum_height * sdl_sm->mult_h, |
| 352 | | sdl_sm->pixel_format, m_sdlsurf); |
| 342 | sdl_sm->pixel_format, window().sdl_surface()); |
| 353 | 343 | |
| 354 | 344 | if ( m_yuvsurf == NULL ) { |
| 355 | 345 | osd_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError()); |
| r243410 | r243411 | |
| 429 | 419 | // a |
| 430 | 420 | //============================================================ |
| 431 | 421 | |
| 432 | | int sdl_info::create(int width, int height) |
| 422 | int sdl_info::create() |
| 433 | 423 | { |
| 434 | | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 435 | 424 | |
| 436 | 425 | #if (SDLMAME_SDL2) |
| 426 | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 437 | 427 | |
| 438 | | osd_printf_verbose("Enter sdl_info::create\n"); |
| 428 | // create renderer |
| 439 | 429 | |
| 440 | 430 | /* set hints ... */ |
| 441 | 431 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode); |
| 442 | 432 | |
| 443 | | // create the SDL window |
| 444 | | // soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS |
| 445 | | m_extra_flags = (window().fullscreen() ? |
| 446 | | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); |
| 447 | 433 | |
| 448 | | #if defined(SDLMAME_WIN32) |
| 449 | | SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); |
| 450 | | #endif |
| 451 | | window().m_sdl_window = SDL_CreateWindow(window().m_title, |
| 452 | | window().monitor()->position_size().x, window().monitor()->position_size().y, |
| 453 | | width, height, m_extra_flags); |
| 454 | | //window().m_sdl_window = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
| 455 | | // width, height, m_extra_flags); |
| 434 | if (video_config.waitvsync) |
| 435 | m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 436 | else |
| 437 | m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_ACCELERATED); |
| 456 | 438 | |
| 457 | | if (!window().m_sdl_window ) |
| 439 | if (!m_sdl_renderer) |
| 458 | 440 | { |
| 459 | | osd_printf_error("Unable to create window: %s\n", SDL_GetError()); |
| 460 | | return 1; |
| 441 | fatalerror("Error on creating renderer: %s\n", SDL_GetError()); |
| 461 | 442 | } |
| 462 | 443 | |
| 463 | | if (window().fullscreen() && video_config.switchres) |
| 464 | 444 | { |
| 465 | | SDL_DisplayMode mode; |
| 466 | | //SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode); |
| 467 | | SDL_GetWindowDisplayMode(window().m_sdl_window, &mode); |
| 468 | | m_original_mode = mode; |
| 469 | | mode.w = width; |
| 470 | | mode.h = height; |
| 471 | | if (window().m_refresh) |
| 472 | | mode.refresh_rate = window().m_refresh; |
| 473 | | |
| 474 | | SDL_SetWindowDisplayMode(window().m_sdl_window, &mode); // Try to set mode |
| 475 | | #ifndef SDLMAME_WIN32 |
| 476 | | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| 477 | | * is in place after the mode switch - which will most likely be the case |
| 478 | | * This is a hack to work around a deficiency in SDL2 |
| 479 | | */ |
| 480 | | SDL_WarpMouseInWindow(window().m_sdl_window, 1, 1); |
| 481 | | #endif |
| 482 | | } |
| 483 | | else |
| 484 | | { |
| 485 | | //SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop |
| 486 | | } |
| 487 | | // create renderer |
| 488 | | |
| 489 | | //SDL_SelectRenderer(window().sdl_window); |
| 490 | | |
| 491 | | // show window |
| 492 | | |
| 493 | | SDL_ShowWindow(window().m_sdl_window); |
| 494 | | //SDL_SetWindowFullscreen(window().m_sdl_window, window().fullscreen); |
| 495 | | SDL_RaiseWindow(window().m_sdl_window); |
| 496 | | |
| 497 | | SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height); |
| 498 | | |
| 499 | | /* FIXME: Bug in SDL 1.3 */ |
| 500 | | if (window().fullscreen()) |
| 501 | | SDL_SetWindowGrab(window().m_sdl_window, SDL_TRUE); |
| 502 | | |
| 503 | | // create a texture |
| 504 | | |
| 505 | | if (video_config.waitvsync) |
| 506 | | m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC); |
| 507 | | else |
| 508 | | m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0); |
| 509 | | |
| 510 | | //SDL_SelectRenderer(window().sdl_window); |
| 511 | | |
| 512 | | { |
| 513 | 445 | struct SDL_RendererInfo render_info; |
| 514 | 446 | |
| 515 | 447 | SDL_GetRendererInfo(m_sdl_renderer, &render_info); |
| r243410 | r243411 | |
| 533 | 465 | } |
| 534 | 466 | } |
| 535 | 467 | |
| 536 | | setup_texture(width, height); |
| 468 | setup_texture(window().width(), window().height()); |
| 537 | 469 | #else |
| 538 | | m_extra_flags = (window().fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE); |
| 539 | | |
| 540 | | m_extra_flags |= sm->m_extra_flags; |
| 541 | | |
| 542 | | m_sdlsurf = SDL_SetVideoMode(width, height, |
| 543 | | 0, SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags); |
| 544 | | |
| 545 | | if (!m_sdlsurf) |
| 546 | | return 1; |
| 547 | | window().m_width = m_sdlsurf->w; |
| 548 | | window().m_height = m_sdlsurf->h; |
| 549 | | if (sm->is_yuv) |
| 550 | | yuv_overlay_init(); |
| 551 | | |
| 552 | | // set the window title |
| 553 | | SDL_WM_SetCaption(window().m_title, "SDLMAME"); |
| 554 | | |
| 555 | 470 | #endif |
| 556 | 471 | |
| 557 | 472 | m_yuv_lookup = NULL; |
| r243410 | r243411 | |
| 563 | 478 | } |
| 564 | 479 | |
| 565 | 480 | //============================================================ |
| 566 | | // sdl_info::resize |
| 567 | | //============================================================ |
| 568 | | |
| 569 | | void sdl_info::resize(int width, int height) |
| 570 | | { |
| 571 | | #if (!SDLMAME_SDL2) |
| 572 | | const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; |
| 573 | | #endif |
| 574 | | #if (SDLMAME_SDL2) |
| 575 | | SDL_SetWindowSize(window().m_sdl_window, width, height); |
| 576 | | SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height); |
| 577 | | |
| 578 | | #else |
| 579 | | if (m_yuvsurf != NULL) |
| 580 | | { |
| 581 | | SDL_FreeYUVOverlay(m_yuvsurf); |
| 582 | | m_yuvsurf = NULL; |
| 583 | | } |
| 584 | | SDL_FreeSurface(m_sdlsurf); |
| 585 | | |
| 586 | | m_sdlsurf = SDL_SetVideoMode(width, height, 0, |
| 587 | | SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags); |
| 588 | | |
| 589 | | window().m_width = m_sdlsurf->w; |
| 590 | | window().m_height = m_sdlsurf->h; |
| 591 | | |
| 592 | | if (sdl_sm->is_yuv) |
| 593 | | { |
| 594 | | yuv_overlay_init(); |
| 595 | | } |
| 596 | | |
| 597 | | #endif |
| 598 | | } |
| 599 | | |
| 600 | | |
| 601 | | //============================================================ |
| 602 | 481 | // sdl_info::destroy |
| 603 | 482 | //============================================================ |
| 604 | 483 | |
| 605 | 484 | void sdl_info::destroy() |
| 606 | 485 | { |
| 607 | 486 | |
| 608 | | #if (SDLMAME_SDL2) |
| 609 | | //SDL_SelectRenderer(window().sdl_window); |
| 610 | | SDL_DestroyTexture(m_texture_id); |
| 611 | | //SDL_DestroyRenderer(window().sdl_window); |
| 612 | | if (window().fullscreen() && video_config.switchres) |
| 613 | | { |
| 614 | | SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode |
| 615 | | SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode |
| 616 | | SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 617 | | } |
| 618 | | |
| 619 | | SDL_DestroyWindow(window().m_sdl_window); |
| 620 | | #else |
| 621 | | if (m_yuvsurf != NULL) |
| 622 | | { |
| 623 | | SDL_FreeYUVOverlay(m_yuvsurf); |
| 624 | | m_yuvsurf = NULL; |
| 625 | | } |
| 626 | | |
| 627 | | if (m_sdlsurf) |
| 628 | | { |
| 629 | | SDL_FreeSurface(m_sdlsurf); |
| 630 | | m_sdlsurf = NULL; |
| 631 | | } |
| 632 | | #endif |
| 633 | 487 | // free the memory in the window |
| 634 | 488 | |
| 489 | destroy_all_textures(); |
| 490 | |
| 635 | 491 | if (m_yuv_lookup != NULL) |
| 636 | 492 | { |
| 637 | 493 | global_free_array(m_yuv_lookup); |
| r243410 | r243411 | |
| 645 | 501 | } |
| 646 | 502 | |
| 647 | 503 | //============================================================ |
| 648 | | // sdl_info::draw |
| 504 | // sdl_info::clear |
| 649 | 505 | //============================================================ |
| 650 | 506 | |
| 651 | 507 | void sdl_info::clear() |
| 652 | 508 | { |
| 509 | //FIXME: Handled in sdl_info::draw as well |
| 653 | 510 | m_blittimer = 3; |
| 654 | 511 | } |
| 655 | 512 | |
| r243410 | r243411 | |
| 659 | 516 | |
| 660 | 517 | int sdl_info::xy_to_render_target(int x, int y, int *xt, int *yt) |
| 661 | 518 | { |
| 662 | | // const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 663 | | |
| 664 | 519 | *xt = x - m_last_hofs; |
| 665 | 520 | *yt = y - m_last_vofs; |
| 666 | | if (*xt<0 || *xt >= window().m_blitwidth) |
| 521 | if (*xt<0 || *xt >= window().blitwidth()) |
| 667 | 522 | return 0; |
| 668 | | if (*yt<0 || *xt >= window().m_blitheight) |
| 523 | if (*yt<0 || *yt >= window().blitheight()) |
| 669 | 524 | return 0; |
| 670 | 525 | return 1; |
| 671 | 526 | } |
| 672 | 527 | |
| 673 | 528 | //============================================================ |
| 674 | | // drawsdl_window_get_primitives |
| 529 | // drawsdl_destroy_all_textures |
| 675 | 530 | //============================================================ |
| 676 | 531 | |
| 677 | | void sdl_info::set_target_bounds() |
| 532 | void sdl_info::destroy_all_textures() |
| 678 | 533 | { |
| 679 | | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 534 | #if (SDLMAME_SDL2) |
| 535 | SDL_DestroyTexture(m_texture_id); |
| 536 | m_texture_id = NULL; |
| 537 | #else |
| 538 | if (m_yuvsurf != NULL) |
| 539 | { |
| 540 | SDL_FreeYUVOverlay(m_yuvsurf); |
| 541 | m_yuvsurf = NULL; |
| 542 | } |
| 543 | #endif |
| 680 | 544 | } |
| 681 | 545 | |
| 546 | |
| 682 | 547 | //============================================================ |
| 683 | | // drawsdl_window_draw |
| 548 | // sdl_info::draw |
| 684 | 549 | //============================================================ |
| 685 | 550 | |
| 686 | 551 | int sdl_info::draw(UINT32 dc, int update) |
| r243410 | r243411 | |
| 700 | 565 | return 0; |
| 701 | 566 | } |
| 702 | 567 | |
| 568 | if ((window().width() != m_last_width) || (window().height() != m_last_height)) |
| 569 | { |
| 570 | m_last_width = window().width(); |
| 571 | m_last_height = window().height(); |
| 572 | #if (SDLMAME_SDL2) |
| 573 | SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 574 | #else |
| 575 | const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; |
| 576 | if (sdl_sm->is_yuv) |
| 577 | { |
| 578 | yuv_overlay_init(); |
| 579 | } |
| 580 | #endif |
| 581 | } |
| 582 | |
| 703 | 583 | // lock it if we need it |
| 704 | 584 | #if (!SDLMAME_SDL2) |
| 705 | 585 | |
| 706 | | pitch = m_sdlsurf->pitch; |
| 707 | | bpp = m_sdlsurf->format->BytesPerPixel; |
| 708 | | rmask = m_sdlsurf->format->Rmask; |
| 709 | | gmask = m_sdlsurf->format->Gmask; |
| 710 | | bmask = m_sdlsurf->format->Bmask; |
| 586 | pitch = window().sdl_surface()->pitch; |
| 587 | bpp = window().sdl_surface()->format->BytesPerPixel; |
| 588 | rmask = window().sdl_surface()->format->Rmask; |
| 589 | gmask = window().sdl_surface()->format->Gmask; |
| 590 | bmask = window().sdl_surface()->format->Bmask; |
| 711 | 591 | // amask = sdlsurf->format->Amask; |
| 712 | 592 | |
| 713 | | if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight) |
| 593 | if (window().blitwidth() != m_old_blitwidth || window().blitheight() != m_old_blitheight) |
| 714 | 594 | { |
| 715 | 595 | if (sm->is_yuv) |
| 716 | 596 | yuv_overlay_init(); |
| 717 | | m_old_blitwidth = window().m_blitwidth; |
| 718 | | m_old_blitheight = window().m_blitheight; |
| 597 | m_old_blitwidth = window().blitwidth(); |
| 598 | m_old_blitheight = window().blitheight(); |
| 719 | 599 | m_blittimer = 3; |
| 720 | 600 | } |
| 721 | 601 | |
| 722 | | if (SDL_MUSTLOCK(m_sdlsurf)) |
| 723 | | SDL_LockSurface(m_sdlsurf); |
| 602 | if (SDL_MUSTLOCK(window().sdl_surface())) |
| 603 | SDL_LockSurface(window().sdl_surface()); |
| 724 | 604 | |
| 725 | 605 | // Clear if necessary |
| 726 | 606 | if (m_blittimer > 0) |
| 727 | 607 | { |
| 728 | | memset(m_sdlsurf->pixels, 0, window().m_height * m_sdlsurf->pitch); |
| 608 | memset(window().sdl_surface()->pixels, 0, window().height() * window().sdl_surface()->pitch); |
| 729 | 609 | m_blittimer--; |
| 730 | 610 | } |
| 731 | 611 | |
| r243410 | r243411 | |
| 743 | 623 | #endif |
| 744 | 624 | } |
| 745 | 625 | else |
| 746 | | surfptr = (UINT8 *)m_sdlsurf->pixels; |
| 626 | surfptr = (UINT8 *)window().sdl_surface()->pixels; |
| 747 | 627 | #else |
| 748 | 628 | //SDL_SelectRenderer(window().sdl_window); |
| 749 | 629 | |
| 750 | | if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight) |
| 630 | if (window().blitwidth() != m_old_blitwidth || window().blitheight() != m_old_blitheight) |
| 751 | 631 | { |
| 752 | | SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 632 | //SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 753 | 633 | |
| 754 | | SDL_DestroyTexture(m_texture_id); |
| 755 | | setup_texture(window().m_blitwidth, window().m_blitheight); |
| 756 | | m_old_blitwidth = window().m_blitwidth; |
| 757 | | m_old_blitheight = window().m_blitheight; |
| 634 | if (m_texture_id != NULL) |
| 635 | SDL_DestroyTexture(m_texture_id); |
| 636 | setup_texture(window().blitwidth(), window().blitheight()); |
| 637 | m_old_blitwidth = window().blitwidth(); |
| 638 | m_old_blitheight = window().blitheight(); |
| 758 | 639 | m_blittimer = 3; |
| 759 | 640 | } |
| 760 | 641 | |
| r243410 | r243411 | |
| 782 | 663 | #endif |
| 783 | 664 | // get ready to center the image |
| 784 | 665 | vofs = hofs = 0; |
| 785 | | blitwidth = window().m_blitwidth; |
| 786 | | blitheight = window().m_blitheight; |
| 666 | blitwidth = window().blitwidth(); |
| 667 | blitheight = window().blitheight(); |
| 787 | 668 | |
| 788 | 669 | // figure out what coordinate system to use for centering - in window mode it's always the |
| 789 | 670 | // SDL surface size. in fullscreen the surface covers all monitors, so center according to |
| r243410 | r243411 | |
| 795 | 676 | } |
| 796 | 677 | else |
| 797 | 678 | { |
| 798 | | ch = window().m_height; |
| 799 | | cw = window().m_width; |
| 679 | ch = window().height(); |
| 680 | cw = window().width(); |
| 800 | 681 | } |
| 801 | 682 | |
| 802 | 683 | // do not crash if the window's smaller than the blit area |
| r243410 | r243411 | |
| 806 | 687 | } |
| 807 | 688 | else if (video_config.centerv) |
| 808 | 689 | { |
| 809 | | vofs = (ch - window().m_blitheight) / 2; |
| 690 | vofs = (ch - window().blitheight()) / 2; |
| 810 | 691 | } |
| 811 | 692 | |
| 812 | 693 | if (blitwidth > cw) |
| r243410 | r243411 | |
| 815 | 696 | } |
| 816 | 697 | else if (video_config.centerh) |
| 817 | 698 | { |
| 818 | | hofs = (cw - window().m_blitwidth) / 2; |
| 699 | hofs = (cw - window().blitwidth()) / 2; |
| 819 | 700 | } |
| 820 | 701 | |
| 821 | 702 | m_last_hofs = hofs; |
| r243410 | r243411 | |
| 829 | 710 | if (!sm->is_yuv) |
| 830 | 711 | { |
| 831 | 712 | surfptr += ((vofs * pitch) + (hofs * bpp)); |
| 832 | | mamewidth = blitwidth; //m_sdlsurf->w; |
| 833 | | mameheight = blitheight; //m_sdlsurf->h; |
| 713 | mamewidth = blitwidth; //sdl_surface()->w; |
| 714 | mameheight = blitheight; //sdl_surface()->h; |
| 834 | 715 | } |
| 835 | 716 | else |
| 836 | 717 | { |
| r243410 | r243411 | |
| 855 | 736 | |
| 856 | 737 | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 857 | 738 | { |
| 858 | | prim->bounds.x0 *= fw; |
| 859 | | prim->bounds.x1 *= fw; |
| 860 | | prim->bounds.y0 *= fh; |
| 861 | | prim->bounds.y1 *= fh; |
| 739 | prim->bounds.x0 = floor(fw * prim->bounds.x0 + 0.5f); |
| 740 | prim->bounds.x1 = floor(fw * prim->bounds.x1 + 0.5f); |
| 741 | prim->bounds.y0 = floor(fh * prim->bounds.y0 + 0.5f); |
| 742 | prim->bounds.y1 = floor(fh * prim->bounds.y1 + 0.5f); |
| 862 | 743 | } |
| 863 | 744 | |
| 864 | 745 | // render to it |
| r243410 | r243411 | |
| 903 | 784 | |
| 904 | 785 | // unlock and flip |
| 905 | 786 | #if (!SDLMAME_SDL2) |
| 906 | | if (SDL_MUSTLOCK(m_sdlsurf)) SDL_UnlockSurface(m_sdlsurf); |
| 787 | if (SDL_MUSTLOCK(window().sdl_surface())) SDL_UnlockSurface(window().sdl_surface()); |
| 907 | 788 | if (!sm->is_yuv) |
| 908 | 789 | { |
| 909 | | SDL_Flip(m_sdlsurf); |
| 790 | SDL_Flip(window().sdl_surface()); |
| 910 | 791 | } |
| 911 | 792 | else |
| 912 | 793 | { |
trunk/src/osd/sdl/window.c
| r243410 | r243411 | |
| 100 | 100 | |
| 101 | 101 | struct worker_param { |
| 102 | 102 | worker_param() |
| 103 | | : m_window(NULL), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 103 | : m_window(NULL), m_list(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 104 | 104 | { |
| 105 | 105 | } |
| 106 | | worker_param(running_machine &amachine, sdl_window_info *awindow) |
| 107 | | : m_window(awindow), m_list(NULL), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0) |
| 106 | worker_param(sdl_window_info *awindow, render_primitive_list &alist) |
| 107 | : m_window(awindow), m_list(&alist), m_resize_new_width(0), m_resize_new_height(0) |
| 108 | 108 | { |
| 109 | 109 | } |
| 110 | | worker_param(running_machine &amachine, sdl_window_info *awindow, render_primitive_list &alist) |
| 111 | | : m_window(awindow), m_list(&alist), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0) |
| 112 | | { |
| 113 | | } |
| 114 | 110 | worker_param(sdl_window_info *awindow, int anew_width, int anew_height) |
| 115 | | : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height) |
| 111 | : m_window(awindow), m_list(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height) |
| 116 | 112 | { |
| 117 | 113 | } |
| 118 | 114 | worker_param(sdl_window_info *awindow) |
| 119 | | : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 115 | : m_window(awindow), m_list(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 120 | 116 | { |
| 121 | 117 | } |
| 122 | | running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } |
| 123 | 118 | sdl_window_info *window() const { assert(m_window != NULL); return m_window; } |
| 124 | 119 | render_primitive_list *list() const { return m_list; } |
| 125 | 120 | int new_width() const { return m_resize_new_width; } |
| r243410 | r243411 | |
| 129 | 124 | private: |
| 130 | 125 | sdl_window_info *m_window; |
| 131 | 126 | render_primitive_list *m_list; |
| 132 | | running_machine *m_machine; |
| 133 | 127 | int m_resize_new_width; |
| 134 | 128 | int m_resize_new_height; |
| 135 | 129 | }; |
| r243410 | r243411 | |
| 139 | 133 | // PROTOTYPES |
| 140 | 134 | //============================================================ |
| 141 | 135 | |
| 142 | | static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window); |
| 143 | 136 | static void sdlwindow_sync(void); |
| 144 | 137 | |
| 145 | | static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view); |
| 146 | | |
| 147 | 138 | //============================================================ |
| 148 | 139 | // execute_async |
| 149 | 140 | //============================================================ |
| r243410 | r243411 | |
| 275 | 266 | SDL_HINT_RENDER_VSYNC, |
| 276 | 267 | SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XINERAMA, |
| 277 | 268 | SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_GRAB_KEYBOARD, |
| 278 | | SDL_HINT_MOUSE_RELATIVE_MODE_WARP, |
| 279 | 269 | SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_IDLE_TIMER_DISABLED, |
| 280 | 270 | SDL_HINT_ORIENTATIONS, |
| 281 | 271 | SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG, |
| r243410 | r243411 | |
| 285 | 275 | SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER, |
| 286 | 276 | SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, |
| 287 | 277 | SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, |
| 288 | | SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, |
| 278 | SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_HINT_MOUSE_RELATIVE_MODE_WARP, |
| 289 | 279 | #endif |
| 290 | 280 | #if SDL_VERSION_ATLEAST(2, 0, 3) |
| 291 | 281 | SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED, |
| r243410 | r243411 | |
| 355 | 345 | { |
| 356 | 346 | sdl_window_info *temp = sdl_window_list; |
| 357 | 347 | sdl_window_list = temp->m_next; |
| 358 | | temp->video_window_destroy(machine()); |
| 348 | temp->destroy(); |
| 359 | 349 | // free the window itself |
| 360 | 350 | global_free(temp); |
| 361 | 351 | } |
| r243410 | r243411 | |
| 464 | 454 | newwidth = window_width; |
| 465 | 455 | |
| 466 | 456 | if ((m_blitwidth != newwidth) || (m_blitheight != newheight)) |
| 467 | | window_clear(); |
| 457 | clear(); |
| 468 | 458 | |
| 469 | 459 | m_blitwidth = newwidth; |
| 470 | 460 | m_blitheight = newheight; |
| r243410 | r243411 | |
| 480 | 470 | { |
| 481 | 471 | worker_param * wp = (worker_param *) param; |
| 482 | 472 | sdl_window_info * window = wp->window(); |
| 473 | int width = wp->new_width(); |
| 474 | int height = wp->new_height(); |
| 483 | 475 | |
| 484 | 476 | ASSERT_WINDOW_THREAD(); |
| 485 | 477 | |
| 486 | 478 | window->renderer().destroy_all_textures(); |
| 487 | | window->renderer().resize(wp->new_width(), wp->new_height()); |
| 488 | 479 | |
| 489 | | window->blit_surface_size(wp->new_width(), wp->new_height()); |
| 480 | #if (SDLMAME_SDL2) |
| 481 | SDL_SetWindowSize(window->sdl_window(), width, height); |
| 482 | SDL_GetWindowSize(window->sdl_window(), &window->m_width, &window->m_height); |
| 483 | #else |
| 484 | SDL_FreeSurface(window->m_sdlsurf); |
| 490 | 485 | |
| 491 | | window->window_clear(); |
| 486 | window->m_sdlsurf = SDL_SetVideoMode(width, height, 0, |
| 487 | SDL_SWSURFACE | SDL_ANYFORMAT | window->m_extra_flags); |
| 492 | 488 | |
| 489 | window->m_width = window->m_sdlsurf->w; |
| 490 | window->m_height = window->m_sdlsurf->h; |
| 491 | #endif |
| 492 | |
| 493 | window->blit_surface_size(window->m_width, window->m_height); |
| 494 | |
| 495 | window->clear(); |
| 496 | |
| 493 | 497 | osd_free(wp); |
| 494 | 498 | return NULL; |
| 495 | 499 | } |
| 496 | 500 | |
| 497 | | void sdl_window_info::window_resize(INT32 width, INT32 height) |
| 501 | void sdl_window_info::resize(INT32 width, INT32 height) |
| 498 | 502 | { |
| 499 | 503 | ASSERT_MAIN_THREAD(); |
| 500 | 504 | |
| 501 | | if (width == this->m_width && height == this->m_height) |
| 505 | if (width == this->width() && height == this->height()) |
| 502 | 506 | return; |
| 503 | 507 | |
| 504 | 508 | execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height)); |
| r243410 | r243411 | |
| 522 | 526 | return NULL; |
| 523 | 527 | } |
| 524 | 528 | |
| 525 | | void sdl_window_info::window_clear() |
| 529 | void sdl_window_info::clear() |
| 526 | 530 | { |
| 527 | 531 | worker_param wp; |
| 528 | 532 | |
| r243410 | r243411 | |
| 554 | 558 | // If we are going fullscreen (leaving windowed) remember our windowed size |
| 555 | 559 | if (!window->fullscreen()) |
| 556 | 560 | { |
| 557 | | window->m_windowed_width = window->m_width; |
| 558 | | window->m_windowed_height = window->m_height; |
| 561 | window->m_windowed_width = window->width(); |
| 562 | window->m_windowed_height = window->height(); |
| 559 | 563 | } |
| 560 | 564 | |
| 561 | 565 | window->renderer().destroy(); |
| 562 | | sdlinput_release_keys(wp->machine()); |
| 563 | 566 | |
| 567 | #if (SDLMAME_SDL2) |
| 568 | if (window->fullscreen() && video_config.switchres) |
| 569 | { |
| 570 | SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode |
| 571 | SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode |
| 572 | SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 573 | } |
| 574 | SDL_DestroyWindow(window->sdl_window()); |
| 575 | #else |
| 576 | if (window->m_sdlsurf) |
| 577 | { |
| 578 | SDL_FreeSurface(window->m_sdlsurf); |
| 579 | window->m_sdlsurf = NULL; |
| 580 | } |
| 581 | #endif |
| 582 | |
| 583 | |
| 584 | sdlinput_release_keys(); |
| 585 | |
| 564 | 586 | // toggle the window mode |
| 565 | 587 | window->set_fullscreen(!window->fullscreen()); |
| 566 | 588 | |
| r243410 | r243411 | |
| 569 | 591 | return NULL; |
| 570 | 592 | } |
| 571 | 593 | |
| 572 | | void sdl_window_info::toggle_full_screen(running_machine &machine) |
| 594 | void sdl_window_info::toggle_full_screen() |
| 573 | 595 | { |
| 574 | 596 | ASSERT_MAIN_THREAD(); |
| 575 | 597 | |
| 576 | | execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(machine, this)); |
| 598 | execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(this)); |
| 577 | 599 | } |
| 578 | 600 | |
| 579 | 601 | OSDWORK_CALLBACK( sdl_window_info::destroy_all_textures_wt ) |
| r243410 | r243411 | |
| 588 | 610 | return NULL; |
| 589 | 611 | } |
| 590 | 612 | |
| 591 | | void sdl_window_info::modify_prescale(running_machine &machine, int dir) |
| 613 | void sdl_window_info::modify_prescale(int dir) |
| 592 | 614 | { |
| 593 | | worker_param wp = worker_param(machine, this); |
| 594 | | int new_prescale = m_prescale; |
| 615 | worker_param wp = worker_param(this); |
| 616 | int new_prescale = prescale(); |
| 595 | 617 | |
| 596 | | if (dir > 0 && m_prescale < 3) |
| 597 | | new_prescale = m_prescale + 1; |
| 598 | | if (dir < 0 && m_prescale > 1) |
| 599 | | new_prescale = m_prescale - 1; |
| 618 | if (dir > 0 && prescale() < 3) |
| 619 | new_prescale = prescale() + 1; |
| 620 | if (dir < 0 && prescale() > 1) |
| 621 | new_prescale = prescale() - 1; |
| 600 | 622 | |
| 601 | | if (new_prescale != m_prescale) |
| 623 | if (new_prescale != prescale()) |
| 602 | 624 | { |
| 603 | 625 | if (m_fullscreen && video_config.switchres) |
| 604 | 626 | { |
| r243410 | r243411 | |
| 614 | 636 | execute_async_wait(destroy_all_textures_wt, wp); |
| 615 | 637 | m_prescale = new_prescale; |
| 616 | 638 | } |
| 617 | | machine.ui().popup_time(1, "Prescale %d", m_prescale); |
| 639 | machine().ui().popup_time(1, "Prescale %d", prescale()); |
| 618 | 640 | } |
| 619 | 641 | } |
| 620 | 642 | |
| r243410 | r243411 | |
| 623 | 645 | // (main or window thread) |
| 624 | 646 | //============================================================ |
| 625 | 647 | |
| 626 | | static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window) |
| 648 | void sdl_window_info::update_cursor_state() |
| 627 | 649 | { |
| 628 | 650 | #if (USE_XINPUT) |
| 629 | 651 | // Hack for wii-lightguns: |
| r243410 | r243411 | |
| 638 | 660 | #if (SDLMAME_SDL2) |
| 639 | 661 | // do not do mouse capture if the debugger's enabled to avoid |
| 640 | 662 | // the possibility of losing control |
| 641 | | if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 663 | if (!(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 642 | 664 | { |
| 643 | 665 | //FIXME: SDL1.3: really broken: the whole SDL code |
| 644 | 666 | // will only work correct with relative mouse movements ... |
| 645 | | if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine)) |
| 667 | if (!fullscreen() && !sdlinput_should_hide_mouse()) |
| 646 | 668 | { |
| 647 | 669 | SDL_ShowCursor(SDL_ENABLE); |
| 648 | | if (SDL_GetWindowGrab(window->m_sdl_window )) |
| 649 | | SDL_SetWindowGrab(window->m_sdl_window, SDL_FALSE); |
| 670 | if (SDL_GetWindowGrab(sdl_window() )) |
| 671 | SDL_SetWindowGrab(sdl_window(), SDL_FALSE); |
| 650 | 672 | SDL_SetRelativeMouseMode(SDL_FALSE); |
| 651 | 673 | } |
| 652 | 674 | else |
| 653 | 675 | { |
| 654 | 676 | SDL_ShowCursor(SDL_DISABLE); |
| 655 | | if (!SDL_GetWindowGrab(window->m_sdl_window)) |
| 656 | | SDL_SetWindowGrab(window->m_sdl_window, SDL_TRUE); |
| 677 | if (!SDL_GetWindowGrab(sdl_window())) |
| 678 | SDL_SetWindowGrab(sdl_window(), SDL_TRUE); |
| 657 | 679 | SDL_SetRelativeMouseMode(SDL_TRUE); |
| 658 | 680 | } |
| 659 | 681 | SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility |
| r243410 | r243411 | |
| 662 | 684 | #else |
| 663 | 685 | // do not do mouse capture if the debugger's enabled to avoid |
| 664 | 686 | // the possibility of losing control |
| 665 | | if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 687 | if (!(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 666 | 688 | { |
| 667 | | if ( window->fullscreen() || sdlinput_should_hide_mouse(machine) ) |
| 689 | if ( fullscreen() || sdlinput_should_hide_mouse() ) |
| 668 | 690 | { |
| 669 | 691 | SDL_ShowCursor(SDL_DISABLE); |
| 670 | 692 | if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| r243410 | r243411 | |
| 685 | 707 | #endif |
| 686 | 708 | } |
| 687 | 709 | |
| 688 | | static OSDWORK_CALLBACK( sdlwindow_update_cursor_state_wt ) |
| 710 | OSDWORK_CALLBACK( sdl_window_info::update_cursor_state_wt ) |
| 689 | 711 | { |
| 690 | 712 | worker_param * wp = (worker_param *) param; |
| 691 | | //sdl_window_info * window = wp->window; |
| 713 | sdl_window_info * window = wp->window(); |
| 692 | 714 | |
| 693 | | sdlwindow_update_cursor_state(wp->machine(), wp->window()); |
| 715 | window->update_cursor_state(); |
| 694 | 716 | |
| 695 | 717 | osd_free(wp); |
| 696 | 718 | return NULL; |
| r243410 | r243411 | |
| 706 | 728 | // (main thread) |
| 707 | 729 | //============================================================ |
| 708 | 730 | |
| 709 | | int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config) |
| 731 | int sdl_window_info::window_init() |
| 710 | 732 | { |
| 711 | | sdl_window_info *window; |
| 712 | 733 | worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param)); |
| 713 | 734 | int result; |
| 714 | 735 | |
| 715 | 736 | ASSERT_MAIN_THREAD(); |
| 716 | 737 | |
| 717 | | // allocate a new window object |
| 718 | | window = global_alloc(sdl_window_info(&machine, monitor, index, config)); |
| 719 | | |
| 720 | 738 | // set the initial maximized state |
| 721 | 739 | // FIXME: Does not belong here |
| 722 | | sdl_options &options = downcast<sdl_options &>(machine.options()); |
| 723 | | window->m_startmaximized = options.maximize(); |
| 740 | sdl_options &options = downcast<sdl_options &>(m_machine.options()); |
| 741 | m_startmaximized = options.maximize(); |
| 724 | 742 | |
| 725 | 743 | // add us to the list |
| 726 | | *last_window_ptr = window; |
| 727 | | last_window_ptr = &window->m_next; |
| 744 | *last_window_ptr = this; |
| 745 | last_window_ptr = &this->m_next; |
| 728 | 746 | |
| 729 | | window->set_renderer(draw.create(window)); |
| 747 | set_renderer(draw.create(this)); |
| 730 | 748 | |
| 731 | 749 | // create an event that we can use to skip blitting |
| 732 | | window->m_rendered_event = osd_event_alloc(FALSE, TRUE); |
| 750 | m_rendered_event = osd_event_alloc(FALSE, TRUE); |
| 733 | 751 | |
| 734 | 752 | // load the layout |
| 735 | | window->m_target = machine.render().target_alloc(); |
| 753 | m_target = m_machine.render().target_alloc(); |
| 736 | 754 | |
| 737 | 755 | // set the specific view |
| 738 | | set_starting_view(machine, index, window, options.view(), options.view(index)); |
| 756 | set_starting_view(m_machine, m_index, options.view(), options.view(m_index)); |
| 739 | 757 | |
| 740 | 758 | // make the window title |
| 741 | 759 | if (video_config.numscreens == 1) |
| 742 | | sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name); |
| 760 | sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().description, m_machine.system().name); |
| 743 | 761 | else |
| 744 | | sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index); |
| 762 | sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().description, m_machine.system().name, m_index); |
| 745 | 763 | |
| 746 | | wp->set_window(window); |
| 764 | wp->set_window(this); |
| 747 | 765 | |
| 748 | 766 | // FIXME: pass error back in a different way |
| 749 | 767 | if (multithreading_enabled) |
| r243410 | r243411 | |
| 765 | 783 | return 0; |
| 766 | 784 | |
| 767 | 785 | error: |
| 768 | | window->video_window_destroy(machine); |
| 769 | | // free the window itself |
| 770 | | global_free(window); |
| 786 | destroy(); |
| 771 | 787 | return 1; |
| 772 | 788 | } |
| 773 | 789 | |
| r243410 | r243411 | |
| 787 | 803 | // free the textures etc |
| 788 | 804 | window->renderer().destroy(); |
| 789 | 805 | |
| 806 | #if (SDLMAME_SDL2) |
| 807 | if (window->fullscreen() && video_config.switchres) |
| 808 | { |
| 809 | SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode |
| 810 | SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode |
| 811 | SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode |
| 812 | } |
| 813 | SDL_DestroyWindow(window->sdl_window()); |
| 814 | #else |
| 815 | if (window->m_sdlsurf) |
| 816 | { |
| 817 | SDL_FreeSurface(window->m_sdlsurf); |
| 818 | window->m_sdlsurf = NULL; |
| 819 | } |
| 820 | #endif |
| 821 | |
| 790 | 822 | // release all keys ... |
| 791 | | sdlinput_release_keys(wp->machine()); |
| 823 | sdlinput_release_keys(); |
| 792 | 824 | |
| 793 | 825 | |
| 794 | 826 | osd_free(wp); |
| 795 | 827 | return NULL; |
| 796 | 828 | } |
| 797 | 829 | |
| 798 | | void sdl_window_info::video_window_destroy(running_machine &machine) |
| 830 | void sdl_window_info::destroy() |
| 799 | 831 | { |
| 800 | 832 | sdl_window_info **prevptr; |
| 801 | 833 | |
| r243410 | r243411 | |
| 816 | 848 | } |
| 817 | 849 | |
| 818 | 850 | // free the textures etc |
| 819 | | execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this)); |
| 851 | execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(this)); |
| 820 | 852 | |
| 821 | 853 | // free the render target, after the textures! |
| 822 | 854 | this->machine().render().target_free(m_target); |
| r243410 | r243411 | |
| 843 | 875 | m_target->compute_minimum_size(minimum_width, minimum_height); |
| 844 | 876 | |
| 845 | 877 | // use those as the target for now |
| 846 | | target_width = minimum_width * MAX(1, m_prescale); |
| 847 | | target_height = minimum_height * MAX(1, m_prescale); |
| 878 | target_width = minimum_width * MAX(1, prescale()); |
| 879 | target_height = minimum_height * MAX(1, prescale()); |
| 848 | 880 | |
| 849 | 881 | // if we're not stretching, allow some slop on the minimum since we can handle it |
| 850 | 882 | { |
| r243410 | r243411 | |
| 910 | 942 | m_target->compute_minimum_size(minimum_width, minimum_height); |
| 911 | 943 | |
| 912 | 944 | // use those as the target for now |
| 913 | | target_width = minimum_width * MAX(1, m_prescale); |
| 914 | | target_height = minimum_height * MAX(1, m_prescale); |
| 945 | target_width = minimum_width * MAX(1, prescale()); |
| 946 | target_height = minimum_height * MAX(1, prescale()); |
| 915 | 947 | |
| 916 | 948 | // if we're not stretching, allow some slop on the minimum since we can handle it |
| 917 | 949 | { |
| r243410 | r243411 | |
| 979 | 1011 | // (main thread) |
| 980 | 1012 | //============================================================ |
| 981 | 1013 | |
| 982 | | void sdl_window_info::video_window_update(running_machine &machine) |
| 1014 | void sdl_window_info::update() |
| 983 | 1015 | { |
| 984 | 1016 | osd_ticks_t event_wait_ticks; |
| 985 | 1017 | ASSERT_MAIN_THREAD(); |
| r243410 | r243411 | |
| 987 | 1019 | // adjust the cursor state |
| 988 | 1020 | //sdlwindow_update_cursor_state(machine, window); |
| 989 | 1021 | |
| 990 | | execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this)); |
| 1022 | execute_async(&update_cursor_state_wt, worker_param(this)); |
| 991 | 1023 | |
| 992 | 1024 | // if we're visible and running and not in the middle of a resize, draw |
| 993 | 1025 | if (m_target != NULL) |
| r243410 | r243411 | |
| 1003 | 1035 | |
| 1004 | 1036 | if (!this->m_fullscreen) |
| 1005 | 1037 | { |
| 1006 | | blit_surface_size(m_width, m_height); |
| 1038 | blit_surface_size(width(), height()); |
| 1007 | 1039 | //Don't resize window without user interaction; |
| 1008 | 1040 | //window_resize(blitwidth, blitheight); |
| 1009 | 1041 | } |
| 1010 | 1042 | else if (video_config.switchres) |
| 1011 | 1043 | { |
| 1012 | 1044 | this->pick_best_mode(&tempwidth, &tempheight); |
| 1013 | | window_resize(tempwidth, tempheight); |
| 1045 | resize(tempwidth, tempheight); |
| 1014 | 1046 | } |
| 1015 | 1047 | } |
| 1016 | 1048 | |
| r243410 | r243411 | |
| 1031 | 1063 | } |
| 1032 | 1064 | |
| 1033 | 1065 | // ensure the target bounds are up-to-date, and then get the primitives |
| 1034 | | renderer().set_target_bounds(); |
| 1035 | 1066 | |
| 1067 | m_target->set_bounds(m_blitwidth, m_blitheight, monitor()->aspect()); |
| 1068 | |
| 1036 | 1069 | render_primitive_list &primlist = m_target->get_primitives(); |
| 1037 | 1070 | |
| 1038 | 1071 | // and redraw now |
| 1039 | 1072 | |
| 1040 | | execute_async(&draw_video_contents_wt, worker_param(machine, this, primlist)); |
| 1073 | execute_async(&draw_video_contents_wt, worker_param(this, primlist)); |
| 1041 | 1074 | } |
| 1042 | 1075 | } |
| 1043 | 1076 | } |
| r243410 | r243411 | |
| 1048 | 1081 | // (main thread) |
| 1049 | 1082 | //============================================================ |
| 1050 | 1083 | |
| 1051 | | static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view) |
| 1084 | void sdl_window_info::set_starting_view(running_machine &machine, int index, const char *defview, const char *view) |
| 1052 | 1085 | { |
| 1053 | 1086 | int viewindex; |
| 1054 | 1087 | |
| r243410 | r243411 | |
| 1059 | 1092 | view = defview; |
| 1060 | 1093 | |
| 1061 | 1094 | // query the video system to help us pick a view |
| 1062 | | viewindex = window->m_target->configured_view(view, index, video_config.numscreens); |
| 1095 | viewindex = target()->configured_view(view, index, video_config.numscreens); |
| 1063 | 1096 | |
| 1064 | 1097 | // set the view |
| 1065 | | window->m_target->set_view(viewindex); |
| 1066 | | window->m_start_viewscreen=viewindex; |
| 1098 | target()->set_view(viewindex); |
| 1099 | m_start_viewscreen=viewindex; |
| 1067 | 1100 | } |
| 1068 | 1101 | |
| 1069 | 1102 | |
| r243410 | r243411 | |
| 1119 | 1152 | } |
| 1120 | 1153 | } |
| 1121 | 1154 | |
| 1155 | |
| 1156 | // create the window ..... |
| 1157 | |
| 1158 | /* FIXME: On Ubuntu and potentially other Linux OS you should use |
| 1159 | * to disable panning. This has to be done before every invocation of mame. |
| 1160 | * |
| 1161 | * xrandr --output HDMI-0 --panning 0x0+0+0 --fb 0x0 |
| 1162 | * |
| 1163 | */ |
| 1164 | osd_printf_verbose("Enter sdl_info::create\n"); |
| 1165 | |
| 1166 | #if (SDLMAME_SDL2) |
| 1167 | |
| 1168 | if (window->renderer().check_flag(osd_renderer::FLAG_NEEDS_OPENGL)) |
| 1169 | { |
| 1170 | SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); |
| 1171 | |
| 1172 | /* FIXME: A reminder that gamma is wrong throughout MAME. Currently, SDL2.0 doesn't seem to |
| 1173 | * support the following attribute although my hardware lists GL_ARB_framebuffer_sRGB as an extension. |
| 1174 | * |
| 1175 | * SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 ); |
| 1176 | * |
| 1177 | */ |
| 1178 | window->m_extra_flags = SDL_WINDOW_OPENGL; |
| 1179 | } |
| 1180 | else |
| 1181 | window->m_extra_flags = 0; |
| 1182 | |
| 1183 | // create the SDL window |
| 1184 | // soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS |
| 1185 | window->m_extra_flags |= (window->fullscreen() ? |
| 1186 | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); |
| 1187 | |
| 1188 | #if defined(SDLMAME_WIN32) |
| 1189 | SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); |
| 1190 | #endif |
| 1191 | // create the SDL window |
| 1192 | window->m_sdl_window = SDL_CreateWindow(window->m_title, |
| 1193 | window->monitor()->position_size().x, window->monitor()->position_size().y, |
| 1194 | tempwidth, tempheight, window->m_extra_flags); |
| 1195 | //window().sdl_window() = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
| 1196 | // width, height, m_extra_flags); |
| 1197 | |
| 1198 | if ( window->m_sdl_window == NULL ) |
| 1199 | { |
| 1200 | if (window->renderer().check_flag(osd_renderer::FLAG_NEEDS_OPENGL)) |
| 1201 | osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); |
| 1202 | else |
| 1203 | osd_printf_error("Window creation failed: %s\n", SDL_GetError()); |
| 1204 | return (void *) &result[1]; |
| 1205 | } |
| 1206 | |
| 1207 | if (window->fullscreen() && video_config.switchres) |
| 1208 | { |
| 1209 | SDL_DisplayMode mode; |
| 1210 | //SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode); |
| 1211 | SDL_GetWindowDisplayMode(window->sdl_window(), &mode); |
| 1212 | window->m_original_mode = mode; |
| 1213 | mode.w = tempwidth; |
| 1214 | mode.h = tempheight; |
| 1215 | if (window->m_refresh) |
| 1216 | mode.refresh_rate = window->m_refresh; |
| 1217 | |
| 1218 | SDL_SetWindowDisplayMode(window->sdl_window(), &mode); // Try to set mode |
| 1219 | #ifndef SDLMAME_WIN32 |
| 1220 | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| 1221 | * is in place after the mode switch - which will most likely be the case |
| 1222 | * This is a hack to work around a deficiency in SDL2 |
| 1223 | */ |
| 1224 | SDL_WarpMouseInWindow(window->sdl_window(), 1, 1); |
| 1225 | #endif |
| 1226 | } |
| 1227 | else |
| 1228 | { |
| 1229 | //SDL_SetWindowDisplayMode(window().sdl_window(), NULL); // Use desktop |
| 1230 | } |
| 1231 | |
| 1232 | // show window |
| 1233 | |
| 1234 | SDL_ShowWindow(window->sdl_window()); |
| 1235 | //SDL_SetWindowFullscreen(window().sdl_window(), window().fullscreen); |
| 1236 | SDL_RaiseWindow(window->sdl_window()); |
| 1237 | |
| 1238 | SDL_GetWindowSize(window->sdl_window(), &window->m_width, &window->m_height); |
| 1239 | |
| 1240 | #else |
| 1241 | window->m_extra_flags = (window->fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE); |
| 1242 | |
| 1243 | if (window->renderer().check_flag(osd_renderer::FLAG_NEEDS_DOUBLEBUF)) |
| 1244 | window->m_extra_flags |= SDL_DOUBLEBUF; |
| 1245 | if (window->renderer().check_flag(osd_renderer::FLAG_NEEDS_ASYNCBLIT)) |
| 1246 | window->m_extra_flags |= SDL_ASYNCBLIT; |
| 1247 | |
| 1248 | if (window->renderer().check_flag(osd_renderer::FLAG_NEEDS_OPENGL)) |
| 1249 | { |
| 1250 | window->m_extra_flags |= SDL_DOUBLEBUF | SDL_OPENGL; |
| 1251 | SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); |
| 1252 | #if (SDL_VERSION_ATLEAST(1,2,10)) && (!defined(SDLMAME_EMSCRIPTEN)) |
| 1253 | SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0); |
| 1254 | #endif |
| 1255 | //load_gl_lib(window->machine()); |
| 1256 | } |
| 1257 | |
| 1258 | // create the SDL surface (which creates the window in windowed mode) |
| 1259 | window->m_sdlsurf = SDL_SetVideoMode(tempwidth, tempheight, |
| 1260 | 0, SDL_SWSURFACE | SDL_ANYFORMAT | window->m_extra_flags); |
| 1261 | |
| 1262 | if (!window->m_sdlsurf) |
| 1263 | return (void *) &result[1]; |
| 1264 | if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(window->m_sdlsurf->flags & SDL_OPENGL) ) |
| 1265 | { |
| 1266 | osd_printf_error("OpenGL not supported on this driver!\n"); |
| 1267 | return (void *) &result[1]; |
| 1268 | } |
| 1269 | |
| 1270 | window->m_width = window->m_sdlsurf->w; |
| 1271 | window->m_height = window->m_sdlsurf->h; |
| 1272 | |
| 1273 | // set the window title |
| 1274 | SDL_WM_SetCaption(window->m_title, "SDLMAME"); |
| 1275 | #endif |
| 1276 | |
| 1122 | 1277 | // initialize the drawing backend |
| 1123 | | if (window->renderer().create(tempwidth, tempheight)) |
| 1278 | if (window->renderer().create()) |
| 1124 | 1279 | return (void *) &result[1]; |
| 1125 | 1280 | |
| 1126 | 1281 | // Make sure we have a consistent state |
| r243410 | r243411 | |
| 1188 | 1343 | ASSERT_REDRAW_THREAD(); |
| 1189 | 1344 | |
| 1190 | 1345 | // Some configurations require events to be polled in the worker thread |
| 1191 | | sdlinput_process_events_buf(wp->machine()); |
| 1346 | sdlinput_process_events_buf(); |
| 1192 | 1347 | |
| 1193 | 1348 | window->m_primlist = wp->list(); |
| 1194 | 1349 | |
trunk/src/osd/windows/drawd3d.c
| r243410 | r243411 | |
| 179 | 179 | |
| 180 | 180 | // core functions |
| 181 | 181 | static void drawd3d_exit(void); |
| 182 | | static int drawd3d_window_init(win_window_info *window); |
| 183 | | static void drawd3d_window_destroy(win_window_info *window); |
| 184 | | static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window); |
| 185 | | static void drawd3d_window_save(win_window_info *window); |
| 186 | | static void drawd3d_window_record(win_window_info *window); |
| 187 | | static void drawd3d_window_toggle_fsfx(win_window_info *window); |
| 188 | | static int drawd3d_window_draw(win_window_info *window, HDC dc, int update); |
| 189 | 182 | |
| 190 | | |
| 191 | 183 | //============================================================ |
| 192 | 184 | // drawd3d_window_init |
| 193 | 185 | //============================================================ |
| 194 | 186 | |
| 195 | | static int drawd3d_window_init(win_window_info *window) |
| 187 | int d3d::renderer::init() |
| 196 | 188 | { |
| 197 | | // allocate memory for our structures |
| 198 | | d3d::renderer *d3d = global_alloc(d3d::renderer(window)); |
| 199 | | window->m_drawdata = d3d; |
| 200 | | |
| 201 | | if (!d3d->initialize()) |
| 189 | if (!initialize()) |
| 202 | 190 | { |
| 203 | | drawd3d_window_destroy(window); |
| 191 | destroy(); |
| 204 | 192 | osd_printf_error("Unable to initialize Direct3D.\n"); |
| 205 | 193 | return 1; |
| 206 | 194 | } |
| r243410 | r243411 | |
| 218 | 206 | (*d3dintf->d3d.release)(d3dintf); |
| 219 | 207 | } |
| 220 | 208 | |
| 221 | | static void drawd3d_window_toggle_fsfx(win_window_info *window) |
| 209 | void d3d::renderer::toggle_fsfx() |
| 222 | 210 | { |
| 223 | | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 224 | | d3d->set_restarting(true); |
| 211 | set_restarting(true); |
| 225 | 212 | } |
| 226 | 213 | |
| 227 | | static void drawd3d_window_record(win_window_info *window) |
| 214 | void d3d::renderer::record() |
| 228 | 215 | { |
| 229 | | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 230 | | d3d->get_shaders()->window_record(); |
| 216 | get_shaders()->window_record(); |
| 231 | 217 | } |
| 232 | 218 | |
| 233 | | static void drawd3d_window_save(win_window_info *window) |
| 219 | void d3d::renderer::save() |
| 234 | 220 | { |
| 235 | | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 236 | | d3d->get_shaders()->window_save(); |
| 221 | get_shaders()->window_save(); |
| 237 | 222 | } |
| 238 | 223 | |
| 239 | 224 | |
| r243410 | r243411 | |
| 242 | 227 | // drawd3d_window_destroy |
| 243 | 228 | //============================================================ |
| 244 | 229 | |
| 245 | | static void drawd3d_window_destroy(win_window_info *window) |
| 230 | void d3d::renderer::destroy() |
| 246 | 231 | { |
| 247 | | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 232 | if (get_shaders() != NULL && get_shaders()->recording()) |
| 233 | get_shaders()->window_record(); |
| 248 | 234 | |
| 249 | | // skip if nothing |
| 250 | | if (d3d == NULL) |
| 251 | | return; |
| 252 | | |
| 253 | | if (d3d->get_shaders() != NULL && d3d->get_shaders()->recording()) |
| 254 | | d3d->get_shaders()->window_record(); |
| 255 | | |
| 256 | | // free the memory in the window |
| 257 | | global_free(d3d); |
| 258 | | window->m_drawdata = NULL; |
| 259 | 235 | } |
| 260 | 236 | |
| 261 | 237 | |
| r243410 | r243411 | |
| 264 | 240 | // drawd3d_window_get_primitives |
| 265 | 241 | //============================================================ |
| 266 | 242 | |
| 267 | | static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window) |
| 243 | render_primitive_list *d3d::renderer::get_primitives() |
| 268 | 244 | { |
| 269 | | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 270 | 245 | RECT client; |
| 271 | 246 | |
| 272 | | GetClientRectExceptMenu(window->m_hwnd, &client, window->m_fullscreen); |
| 247 | GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen); |
| 273 | 248 | if (rect_width(&client) > 0 && rect_height(&client) > 0) |
| 274 | 249 | { |
| 275 | | window->m_target->set_bounds(rect_width(&client), rect_height(&client), window->m_monitor->get_aspect()); |
| 276 | | window->m_target->set_max_update_rate((d3d->get_refresh() == 0) ? d3d->get_origmode().RefreshRate : d3d->get_refresh()); |
| 250 | window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect()); |
| 251 | window().m_target->set_max_update_rate((get_refresh() == 0) ? get_origmode().RefreshRate : get_refresh()); |
| 277 | 252 | } |
| 278 | | return &window->m_target->get_primitives(); |
| 253 | return &window().m_target->get_primitives(); |
| 279 | 254 | } |
| 280 | 255 | |
| 281 | | int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks) |
| 256 | //============================================================ |
| 257 | // drawnone_create |
| 258 | //============================================================ |
| 259 | |
| 260 | static osd_renderer *drawd3d_create(win_window_info *window) |
| 282 | 261 | { |
| 262 | return global_alloc(d3d::renderer(window)); |
| 263 | } |
| 264 | |
| 265 | int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks) |
| 266 | { |
| 283 | 267 | d3dintf = NULL; |
| 284 | 268 | |
| 285 | 269 | // Use Direct3D9 |
| r243410 | r243411 | |
| 295 | 279 | // fill in the callbacks |
| 296 | 280 | memset(callbacks, 0, sizeof(*callbacks)); |
| 297 | 281 | callbacks->exit = drawd3d_exit; |
| 298 | | callbacks->window_init = drawd3d_window_init; |
| 299 | | callbacks->window_get_primitives = drawd3d_window_get_primitives; |
| 300 | | callbacks->window_draw = drawd3d_window_draw; |
| 301 | | callbacks->window_save = drawd3d_window_save; |
| 302 | | callbacks->window_record = drawd3d_window_record; |
| 303 | | callbacks->window_toggle_fsfx = drawd3d_window_toggle_fsfx; |
| 304 | | callbacks->window_destroy = drawd3d_window_destroy; |
| 282 | callbacks->create = drawd3d_create; |
| 305 | 283 | return 0; |
| 306 | 284 | } |
| 307 | 285 | |
| r243410 | r243411 | |
| 309 | 287 | // drawd3d_window_draw |
| 310 | 288 | //============================================================ |
| 311 | 289 | |
| 312 | | static int drawd3d_window_draw(win_window_info *window, HDC dc, int update) |
| 290 | int d3d::renderer::draw(HDC dc, int update) |
| 313 | 291 | { |
| 314 | | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 315 | | |
| 316 | | // if we haven't been created, just punt |
| 317 | | if (d3d == NULL) |
| 318 | | return 1; |
| 319 | | |
| 320 | | int check = d3d->pre_window_draw_check(); |
| 292 | int check = pre_window_draw_check(); |
| 321 | 293 | if (check >= 0) |
| 322 | 294 | return check; |
| 323 | 295 | |
| 324 | | d3d->begin_frame(); |
| 325 | | d3d->process_primitives(); |
| 326 | | d3d->end_frame(); |
| 296 | begin_frame(); |
| 297 | process_primitives(); |
| 298 | end_frame(); |
| 327 | 299 | |
| 328 | 300 | return 0; |
| 329 | 301 | } |
| r243410 | r243411 | |
| 496 | 468 | osd_printf_verbose("Direct3D: YUV format = %s\n", (m_yuv_format == D3DFMT_YUY2) ? "YUY2" : (m_yuv_format == D3DFMT_UYVY) ? "UYVY" : "RGB"); |
| 497 | 469 | |
| 498 | 470 | // set the max texture size |
| 499 | | d3d->get_window()->m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height); |
| 471 | d3d->window().m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height); |
| 500 | 472 | osd_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height); |
| 501 | 473 | } |
| 502 | 474 | |
| r243410 | r243411 | |
| 508 | 480 | { |
| 509 | 481 | // experimental: load a PNG to use for vector rendering; it is treated |
| 510 | 482 | // as a brightness map |
| 511 | | emu_file file(m_renderer->get_window()->machine().options().art_path(), OPEN_FLAG_READ); |
| 483 | emu_file file(m_renderer->window().machine().options().art_path(), OPEN_FLAG_READ); |
| 512 | 484 | render_load_png(m_vector_bitmap, file, NULL, "vector.png"); |
| 513 | 485 | if (m_vector_bitmap.valid()) |
| 514 | 486 | { |
| r243410 | r243411 | |
| 650 | 622 | } |
| 651 | 623 | |
| 652 | 624 | renderer::renderer(win_window_info *window) |
| 625 | : osd_renderer(window, FLAG_NONE) |
| 653 | 626 | { |
| 654 | 627 | m_device = NULL; |
| 655 | 628 | m_restarting = false; |
| 656 | | m_window = window; |
| 657 | 629 | m_shaders = NULL; |
| 658 | 630 | m_numverts = 0; |
| 659 | 631 | m_numpolys = 0; |
| r243410 | r243411 | |
| 672 | 644 | return false; |
| 673 | 645 | |
| 674 | 646 | // create the device immediately for the full screen case (defer for window mode) |
| 675 | | if (m_window->m_fullscreen && device_create()) |
| 647 | if (window().m_fullscreen && device_create()) |
| 676 | 648 | return false; |
| 677 | 649 | |
| 678 | 650 | return true; |
| r243410 | r243411 | |
| 681 | 653 | int renderer::pre_window_draw_check() |
| 682 | 654 | { |
| 683 | 655 | // if we're in the middle of resizing, leave things alone |
| 684 | | if (m_window->m_resize_state == RESIZE_STATE_RESIZING) |
| 656 | if (window().m_resize_state == RESIZE_STATE_RESIZING) |
| 685 | 657 | return 0; |
| 686 | 658 | |
| 687 | 659 | // if we're restarting the renderer, leave things alone |
| r243410 | r243411 | |
| 706 | 678 | } |
| 707 | 679 | |
| 708 | 680 | // in window mode, we need to track the window size |
| 709 | | if (!m_window->m_fullscreen || m_device == NULL) |
| 681 | if (!window().m_fullscreen || m_device == NULL) |
| 710 | 682 | { |
| 711 | 683 | // if the size changes, skip this update since the render target will be out of date |
| 712 | 684 | if (update_window_size()) |
| r243410 | r243411 | |
| 722 | 694 | |
| 723 | 695 | void texture_manager::update_textures() |
| 724 | 696 | { |
| 725 | | for (render_primitive *prim = m_renderer->get_window()->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 697 | for (render_primitive *prim = m_renderer->window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 726 | 698 | { |
| 727 | 699 | if (prim->texture.base != NULL) |
| 728 | 700 | { |
| r243410 | r243411 | |
| 759 | 731 | |
| 760 | 732 | m_shaders->begin_frame(); |
| 761 | 733 | |
| 762 | | m_window->m_primlist->acquire_lock(); |
| 734 | window().m_primlist->acquire_lock(); |
| 763 | 735 | |
| 764 | 736 | // first update any textures |
| 765 | 737 | m_texture_manager->update_textures(); |
| r243410 | r243411 | |
| 780 | 752 | m_line_count = 0; |
| 781 | 753 | |
| 782 | 754 | // loop over primitives |
| 783 | | for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 755 | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 784 | 756 | if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags)) |
| 785 | 757 | m_line_count++; |
| 786 | 758 | } |
| r243410 | r243411 | |
| 788 | 760 | void renderer::process_primitives() |
| 789 | 761 | { |
| 790 | 762 | // Rotating index for vector time offsets |
| 791 | | for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 763 | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 792 | 764 | { |
| 793 | 765 | switch (prim->type) |
| 794 | 766 | { |
| r243410 | r243411 | |
| 818 | 790 | |
| 819 | 791 | void renderer::end_frame() |
| 820 | 792 | { |
| 821 | | m_window->m_primlist->release_lock(); |
| 793 | window().m_primlist->release_lock(); |
| 822 | 794 | |
| 823 | 795 | // flush any pending polygons |
| 824 | 796 | primitive_flush_pending(); |
| r243410 | r243411 | |
| 893 | 865 | m_presentation.BackBufferCount = video_config.triplebuf ? 2 : 1; |
| 894 | 866 | m_presentation.MultiSampleType = D3DMULTISAMPLE_NONE; |
| 895 | 867 | m_presentation.SwapEffect = D3DSWAPEFFECT_DISCARD; |
| 896 | | m_presentation.hDeviceWindow = m_window->m_hwnd; |
| 897 | | m_presentation.Windowed = !m_window->m_fullscreen || win_has_menu(m_window); |
| 868 | m_presentation.hDeviceWindow = window().m_hwnd; |
| 869 | m_presentation.Windowed = !window().m_fullscreen || win_has_menu(&window()); |
| 898 | 870 | m_presentation.EnableAutoDepthStencil = FALSE; |
| 899 | 871 | m_presentation.AutoDepthStencilFormat = D3DFMT_D16; |
| 900 | 872 | m_presentation.Flags = 0; |
| 901 | 873 | m_presentation.FullScreen_RefreshRateInHz = m_refresh; |
| 902 | | m_presentation.PresentationInterval = ((video_config.triplebuf && m_window->m_fullscreen) || |
| 874 | m_presentation.PresentationInterval = ((video_config.triplebuf && window().m_fullscreen) || |
| 903 | 875 | video_config.waitvsync || video_config.syncrefresh) ? |
| 904 | 876 | D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; |
| 905 | 877 | |
| 906 | 878 | // create the D3D device |
| 907 | | result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_window->m_focus_hwnd, |
| 879 | result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, window().m_focus_hwnd, |
| 908 | 880 | D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device); |
| 909 | 881 | if (result != D3D_OK) |
| 910 | 882 | { |
| r243410 | r243411 | |
| 927 | 899 | osd_printf_verbose("Direct3D: Device created at %dx%d\n", m_width, m_height); |
| 928 | 900 | |
| 929 | 901 | // set the gamma if we need to |
| 930 | | if (m_window->m_fullscreen) |
| 902 | if (window().m_fullscreen) |
| 931 | 903 | { |
| 932 | 904 | // only set the gamma if it's not 1.0f |
| 933 | | windows_options &options = downcast<windows_options &>(m_window->machine().options()); |
| 905 | windows_options &options = downcast<windows_options &>(window().machine().options()); |
| 934 | 906 | float brightness = options.full_screen_brightness(); |
| 935 | 907 | float contrast = options.full_screen_contrast(); |
| 936 | 908 | float gamma = options.full_screen_gamma(); |
| r243410 | r243411 | |
| 1092 | 1064 | int retval = 0; |
| 1093 | 1065 | |
| 1094 | 1066 | m_shaders = global_alloc_clear(shaders); |
| 1095 | | m_shaders->init(d3dintf, m_window); |
| 1067 | m_shaders->init(d3dintf, &window()); |
| 1096 | 1068 | |
| 1097 | 1069 | DWORD tempcaps; |
| 1098 | 1070 | HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps); |
| r243410 | r243411 | |
| 1231 | 1203 | } |
| 1232 | 1204 | |
| 1233 | 1205 | // choose a resolution: window mode case |
| 1234 | | if (!m_window->m_fullscreen || !video_config.switchres || win_has_menu(m_window)) |
| 1206 | if (!window().m_fullscreen || !video_config.switchres || win_has_menu(&window())) |
| 1235 | 1207 | { |
| 1236 | 1208 | RECT client; |
| 1237 | 1209 | |
| 1238 | 1210 | // bounds are from the window client rect |
| 1239 | | GetClientRectExceptMenu(m_window->m_hwnd, &client, m_window->m_fullscreen); |
| 1211 | GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen); |
| 1240 | 1212 | m_width = client.right - client.left; |
| 1241 | 1213 | m_height = client.bottom - client.top; |
| 1242 | 1214 | |
| r243410 | r243411 | |
| 1247 | 1219 | // make sure it's a pixel format we can get behind |
| 1248 | 1220 | if (m_pixformat != D3DFMT_X1R5G5B5 && m_pixformat != D3DFMT_R5G6B5 && m_pixformat != D3DFMT_X8R8G8B8) |
| 1249 | 1221 | { |
| 1250 | | char *utf8_device = utf8_from_tstring(m_window->m_monitor->info.szDevice); |
| 1222 | char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice); |
| 1251 | 1223 | if (utf8_device != NULL) |
| 1252 | 1224 | { |
| 1253 | 1225 | osd_printf_error("Device %s currently in an unsupported mode\n", utf8_device); |
| r243410 | r243411 | |
| 1272 | 1244 | } |
| 1273 | 1245 | |
| 1274 | 1246 | // see if we can handle the device type |
| 1275 | | result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !m_window->m_fullscreen); |
| 1247 | result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().m_fullscreen); |
| 1276 | 1248 | if (result != D3D_OK) |
| 1277 | 1249 | { |
| 1278 | | char *utf8_device = utf8_from_tstring(m_window->m_monitor->info.szDevice); |
| 1250 | char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice); |
| 1279 | 1251 | if (utf8_device != NULL) |
| 1280 | 1252 | { |
| 1281 | 1253 | osd_printf_error("Proposed video mode not supported on device %s\n", utf8_device); |
| r243410 | r243411 | |
| 1303 | 1275 | HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum); |
| 1304 | 1276 | |
| 1305 | 1277 | // if we match the proposed monitor, this is it |
| 1306 | | if (curmonitor == m_window->m_monitor->handle) |
| 1278 | if (curmonitor == window().m_monitor->handle) |
| 1307 | 1279 | { |
| 1308 | 1280 | return adapternum; |
| 1309 | 1281 | } |
| r243410 | r243411 | |
| 1326 | 1298 | float best_score = 0.0f; |
| 1327 | 1299 | |
| 1328 | 1300 | // determine the refresh rate of the primary screen |
| 1329 | | const screen_device *primary_screen = m_window->machine().config().first_screen(); |
| 1301 | const screen_device *primary_screen = window().machine().config().first_screen(); |
| 1330 | 1302 | if (primary_screen != NULL) |
| 1331 | 1303 | { |
| 1332 | 1304 | target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh_attoseconds()); |
| r243410 | r243411 | |
| 1336 | 1308 | // note: technically we should not be calling this from an alternate window |
| 1337 | 1309 | // thread; however, it is only done during init time, and the init code on |
| 1338 | 1310 | // the main thread is waiting for us to finish, so it is safe to do so here |
| 1339 | | m_window->m_target->compute_minimum_size(minwidth, minheight); |
| 1311 | window().m_target->compute_minimum_size(minwidth, minheight); |
| 1340 | 1312 | |
| 1341 | 1313 | // use those as the target for now |
| 1342 | 1314 | INT32 target_width = minwidth; |
| r243410 | r243411 | |
| 1371 | 1343 | size_score *= 0.1f; |
| 1372 | 1344 | |
| 1373 | 1345 | // if we're looking for a particular mode, that's a winner |
| 1374 | | if (mode.Width == m_window->m_maxwidth && mode.Height == m_window->m_maxheight) |
| 1346 | if (mode.Width == window().m_maxwidth && mode.Height == window().m_maxheight) |
| 1375 | 1347 | size_score = 2.0f; |
| 1376 | 1348 | |
| 1377 | 1349 | // compute refresh score |
| r243410 | r243411 | |
| 1382 | 1354 | refresh_score *= 0.1f; |
| 1383 | 1355 | |
| 1384 | 1356 | // if we're looking for a particular refresh, make sure it matches |
| 1385 | | if (mode.RefreshRate == m_window->m_refresh) |
| 1357 | if (mode.RefreshRate == window().m_refresh) |
| 1386 | 1358 | refresh_score = 2.0f; |
| 1387 | 1359 | |
| 1388 | 1360 | // weight size and refresh equally |
| r243410 | r243411 | |
| 1412 | 1384 | { |
| 1413 | 1385 | // get the current window bounds |
| 1414 | 1386 | RECT client; |
| 1415 | | GetClientRectExceptMenu(m_window->m_hwnd, &client, m_window->m_fullscreen); |
| 1387 | GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen); |
| 1416 | 1388 | |
| 1417 | 1389 | // if we have a device and matching width/height, nothing to do |
| 1418 | 1390 | if (m_device != NULL && rect_width(&client) == m_width && rect_height(&client) == m_height) |
| 1419 | 1391 | { |
| 1420 | 1392 | // clear out any pending resizing if the area didn't change |
| 1421 | | if (m_window->m_resize_state == RESIZE_STATE_PENDING) |
| 1422 | | m_window->m_resize_state = RESIZE_STATE_NORMAL; |
| 1393 | if (window().m_resize_state == RESIZE_STATE_PENDING) |
| 1394 | window().m_resize_state = RESIZE_STATE_NORMAL; |
| 1423 | 1395 | return FALSE; |
| 1424 | 1396 | } |
| 1425 | 1397 | |
| 1426 | 1398 | // if we're in the middle of resizing, leave it alone as well |
| 1427 | | if (m_window->m_resize_state == RESIZE_STATE_RESIZING) |
| 1399 | if (window().m_resize_state == RESIZE_STATE_RESIZING) |
| 1428 | 1400 | return FALSE; |
| 1429 | 1401 | |
| 1430 | 1402 | // set the new bounds and create the device again |
| r243410 | r243411 | |
| 1434 | 1406 | return FALSE; |
| 1435 | 1407 | |
| 1436 | 1408 | // reset the resize state to normal, and indicate we made a change |
| 1437 | | m_window->m_resize_state = RESIZE_STATE_NORMAL; |
| 1409 | window().m_resize_state = RESIZE_STATE_NORMAL; |
| 1438 | 1410 | return TRUE; |
| 1439 | 1411 | } |
| 1440 | 1412 | |
| r243410 | r243411 | |
| 1444 | 1416 | |
| 1445 | 1417 | void renderer::batch_vectors() |
| 1446 | 1418 | { |
| 1447 | | windows_options &options = downcast<windows_options &>(m_window->machine().options()); |
| 1419 | windows_options &options = downcast<windows_options &>(window().machine().options()); |
| 1448 | 1420 | |
| 1449 | 1421 | int vector_size = (options.antialias() ? 24 : 6); |
| 1450 | 1422 | m_vectorbatch = mesh_alloc(m_line_count * vector_size); |
| r243410 | r243411 | |
| 1454 | 1426 | int line_index = 0; |
| 1455 | 1427 | float period = options.screen_vector_time_period(); |
| 1456 | 1428 | UINT32 cached_flags = 0; |
| 1457 | | for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 1429 | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 1458 | 1430 | { |
| 1459 | 1431 | switch (prim->type) |
| 1460 | 1432 | { |
trunk/src/osd/windows/drawdd.c
| r243410 | r243411 | |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | /* dd_info is the information about DirectDraw for the current screen */ |
| 39 | | struct dd_info |
| 39 | class renderer_dd : public osd_renderer |
| 40 | 40 | { |
| 41 | public: |
| 42 | renderer_dd(win_window_info *window) |
| 43 | : osd_renderer(window, FLAG_NONE), |
| 44 | //adapter(0), |
| 45 | adapter_ptr(NULL), |
| 46 | clearouter(0), |
| 47 | blitwidth(0), blitheight(0), |
| 48 | //lastdest |
| 49 | ddraw(NULL), |
| 50 | primary(NULL), |
| 51 | back(NULL), |
| 52 | blit(NULL), |
| 53 | clipper(NULL), |
| 54 | gamma(NULL), |
| 55 | //DDSURFACEDESC2 primarydesc; |
| 56 | //DDSURFACEDESC2 blitdesc; |
| 57 | //DDSURFACEDESC2 origmode; |
| 58 | //ddcaps(0), |
| 59 | //helcaps(0), |
| 60 | membuffer(NULL), |
| 61 | membuffersize(NULL) |
| 62 | { } |
| 63 | |
| 64 | virtual ~renderer_dd() { } |
| 65 | |
| 66 | virtual int init(); |
| 67 | virtual render_primitive_list *get_primitives(); |
| 68 | virtual int draw(HDC dc, int update); |
| 69 | virtual void save() {}; |
| 70 | virtual void record() {}; |
| 71 | virtual void toggle_fsfx() {}; |
| 72 | virtual void destroy(); |
| 73 | |
| 74 | int width, height; // current width, height |
| 75 | int refresh; // current refresh rate |
| 76 | |
| 77 | private: |
| 78 | |
| 79 | inline void update_outer_rects(); |
| 80 | |
| 81 | // surface management |
| 82 | int ddraw_create(); |
| 83 | int ddraw_create_surfaces(); |
| 84 | void ddraw_delete(); |
| 85 | void ddraw_delete_surfaces(); |
| 86 | int ddraw_verify_caps(); |
| 87 | int ddraw_test_cooperative(); |
| 88 | HRESULT create_surface(DDSURFACEDESC2 *desc, IDirectDrawSurface7 **surface, const char *type); |
| 89 | int create_clipper(); |
| 90 | |
| 91 | // drawing helpers |
| 92 | void compute_blit_surface_size(); |
| 93 | void blit_to_primary(int srcwidth, int srcheight); |
| 94 | |
| 95 | // video modes |
| 96 | int config_adapter_mode(); |
| 97 | void get_adapter_for_monitor(win_monitor_info *monitor); |
| 98 | void pick_best_mode(); |
| 99 | |
| 100 | // various |
| 101 | void calc_fullscreen_margins(DWORD desc_width, DWORD desc_height, RECT *margins); |
| 102 | |
| 103 | |
| 41 | 104 | GUID adapter; // current display adapter |
| 42 | 105 | GUID * adapter_ptr; // pointer to current display adapter |
| 43 | | int width, height; // current width, height |
| 44 | | int refresh; // current refresh rate |
| 45 | 106 | int clearouter; // clear the outer areas? |
| 46 | 107 | |
| 47 | 108 | INT32 blitwidth, blitheight; // current blit width/height values |
| r243410 | r243411 | |
| 79 | 140 | /* mode_enum_info holds information during a display mode enumeration */ |
| 80 | 141 | struct mode_enum_info |
| 81 | 142 | { |
| 82 | | win_window_info * window; |
| 143 | win_window_info * window; |
| 83 | 144 | INT32 minimum_width, minimum_height; |
| 84 | 145 | INT32 target_width, target_height; |
| 85 | 146 | double target_refresh; |
| r243410 | r243411 | |
| 102 | 163 | // INLINES |
| 103 | 164 | //============================================================ |
| 104 | 165 | |
| 105 | | INLINE void update_outer_rects(dd_info *dd) |
| 166 | inline void renderer_dd::update_outer_rects() |
| 106 | 167 | { |
| 107 | | dd->clearouter = (dd->back != NULL) ? 3 : 1; |
| 168 | clearouter = (back != NULL) ? 3 : 1; |
| 108 | 169 | } |
| 109 | 170 | |
| 110 | 171 | |
| r243410 | r243411 | |
| 123 | 184 | |
| 124 | 185 | // core functions |
| 125 | 186 | static void drawdd_exit(void); |
| 126 | | static int drawdd_window_init(win_window_info *window); |
| 127 | | static void drawdd_window_destroy(win_window_info *window); |
| 128 | | static render_primitive_list *drawdd_window_get_primitives(win_window_info *window); |
| 129 | | static int drawdd_window_draw(win_window_info *window, HDC dc, int update); |
| 130 | 187 | |
| 131 | | // surface management |
| 132 | | static int ddraw_create(win_window_info *window); |
| 133 | | static int ddraw_create_surfaces(win_window_info *window); |
| 134 | | static void ddraw_delete(win_window_info *window); |
| 135 | | static void ddraw_delete_surfaces(win_window_info *window); |
| 136 | | static int ddraw_verify_caps(dd_info *dd); |
| 137 | | static int ddraw_test_cooperative(win_window_info *window); |
| 138 | | static HRESULT create_surface(dd_info *dd, DDSURFACEDESC2 *desc, IDirectDrawSurface7 **surface, const char *type); |
| 139 | | static int create_clipper(win_window_info *window); |
| 140 | 188 | |
| 141 | | // drawing helpers |
| 142 | | static void compute_blit_surface_size(win_window_info *window); |
| 143 | | static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight); |
| 144 | 189 | |
| 145 | | // video modes |
| 146 | | static int config_adapter_mode(win_window_info *window); |
| 147 | | static void get_adapter_for_monitor(dd_info *dd, win_monitor_info *monitor); |
| 148 | | static void pick_best_mode(win_window_info *window); |
| 190 | //============================================================ |
| 191 | // drawnone_create |
| 192 | //============================================================ |
| 149 | 193 | |
| 194 | static osd_renderer *drawdd_create(win_window_info *window) |
| 195 | { |
| 196 | return global_alloc(renderer_dd(window)); |
| 197 | } |
| 150 | 198 | |
| 151 | 199 | |
| 152 | 200 | //============================================================ |
| 153 | 201 | // drawdd_init |
| 154 | 202 | //============================================================ |
| 155 | 203 | |
| 156 | | int drawdd_init(running_machine &machine, win_draw_callbacks *callbacks) |
| 204 | int drawdd_init(running_machine &machine, osd_draw_callbacks *callbacks) |
| 157 | 205 | { |
| 158 | 206 | // dynamically grab the create function from ddraw.dll |
| 159 | 207 | dllhandle = LoadLibrary(TEXT("ddraw.dll")); |
| r243410 | r243411 | |
| 186 | 234 | // fill in the callbacks |
| 187 | 235 | memset(callbacks, 0, sizeof(*callbacks)); |
| 188 | 236 | callbacks->exit = drawdd_exit; |
| 189 | | callbacks->window_init = drawdd_window_init; |
| 190 | | callbacks->window_get_primitives = drawdd_window_get_primitives; |
| 191 | | callbacks->window_draw = drawdd_window_draw; |
| 192 | | callbacks->window_destroy = drawdd_window_destroy; |
| 237 | callbacks->create = drawdd_create; |
| 193 | 238 | |
| 194 | 239 | osd_printf_verbose("DirectDraw: Using DirectDraw 7\n"); |
| 195 | 240 | return 0; |
| r243410 | r243411 | |
| 213 | 258 | // drawdd_window_init |
| 214 | 259 | //============================================================ |
| 215 | 260 | |
| 216 | | static int drawdd_window_init(win_window_info *window) |
| 261 | int renderer_dd::init() |
| 217 | 262 | { |
| 218 | | dd_info *dd; |
| 219 | | |
| 220 | | // allocate memory for our structures |
| 221 | | dd = global_alloc_clear(dd_info); |
| 222 | | window->m_drawdata = dd; |
| 223 | | |
| 224 | 263 | // configure the adapter for the mode we want |
| 225 | | if (config_adapter_mode(window)) |
| 264 | if (config_adapter_mode()) |
| 226 | 265 | goto error; |
| 227 | 266 | |
| 228 | 267 | // create the ddraw object |
| 229 | | if (ddraw_create(window)) |
| 268 | if (ddraw_create()) |
| 230 | 269 | goto error; |
| 231 | 270 | |
| 232 | 271 | return 0; |
| 233 | 272 | |
| 234 | 273 | error: |
| 235 | | drawdd_window_destroy(window); |
| 274 | destroy(); |
| 236 | 275 | osd_printf_error("Unable to initialize DirectDraw.\n"); |
| 237 | 276 | return 1; |
| 238 | 277 | } |
| r243410 | r243411 | |
| 243 | 282 | // drawdd_window_destroy |
| 244 | 283 | //============================================================ |
| 245 | 284 | |
| 246 | | static void drawdd_window_destroy(win_window_info *window) |
| 285 | void renderer_dd::destroy() |
| 247 | 286 | { |
| 248 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 249 | | |
| 250 | | // skip if nothing |
| 251 | | if (dd == NULL) |
| 252 | | return; |
| 253 | | |
| 254 | 287 | // delete the ddraw object |
| 255 | | ddraw_delete(window); |
| 256 | | |
| 257 | | // free the memory in the window |
| 258 | | global_free(dd); |
| 259 | | window->m_drawdata = NULL; |
| 288 | ddraw_delete(); |
| 260 | 289 | } |
| 261 | 290 | |
| 262 | 291 | |
| r243410 | r243411 | |
| 265 | 294 | // drawdd_window_get_primitives |
| 266 | 295 | //============================================================ |
| 267 | 296 | |
| 268 | | static render_primitive_list *drawdd_window_get_primitives(win_window_info *window) |
| 297 | render_primitive_list *renderer_dd::get_primitives() |
| 269 | 298 | { |
| 270 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 299 | compute_blit_surface_size(); |
| 300 | window().m_target->set_bounds(blitwidth, blitheight, 0); |
| 301 | window().m_target->set_max_update_rate((refresh == 0) ? origmode.dwRefreshRate : refresh); |
| 271 | 302 | |
| 272 | | compute_blit_surface_size(window); |
| 273 | | window->m_target->set_bounds(dd->blitwidth, dd->blitheight, 0); |
| 274 | | window->m_target->set_max_update_rate((dd->refresh == 0) ? dd->origmode.dwRefreshRate : dd->refresh); |
| 275 | | |
| 276 | | return &window->m_target->get_primitives(); |
| 303 | return &window().m_target->get_primitives(); |
| 277 | 304 | } |
| 278 | 305 | |
| 279 | 306 | |
| r243410 | r243411 | |
| 282 | 309 | // drawdd_window_draw |
| 283 | 310 | //============================================================ |
| 284 | 311 | |
| 285 | | static int drawdd_window_draw(win_window_info *window, HDC dc, int update) |
| 312 | int renderer_dd::draw(HDC dc, int update) |
| 286 | 313 | { |
| 287 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 288 | 314 | render_primitive *prim; |
| 289 | 315 | int usemembuffer = FALSE; |
| 290 | 316 | HRESULT result; |
| 291 | 317 | |
| 292 | | // if we haven't been created, just punt |
| 293 | | if (dd == NULL) |
| 294 | | return 1; |
| 295 | | |
| 296 | 318 | // if we're updating, remember to erase the outer stuff |
| 297 | 319 | if (update) |
| 298 | | update_outer_rects(dd); |
| 320 | update_outer_rects(); |
| 299 | 321 | |
| 300 | 322 | // if we have a ddraw object, check the cooperative level |
| 301 | | if (ddraw_test_cooperative(window)) |
| 323 | if (ddraw_test_cooperative()) |
| 302 | 324 | return 1; |
| 303 | 325 | |
| 304 | 326 | // get the size; if we're too small, delete the existing surfaces |
| 305 | | if (dd->blitwidth > dd->blitdesc.dwWidth || dd->blitheight > dd->blitdesc.dwHeight) |
| 306 | | ddraw_delete_surfaces(window); |
| 327 | if (blitwidth > blitdesc.dwWidth || blitheight > blitdesc.dwHeight) |
| 328 | ddraw_delete_surfaces(); |
| 307 | 329 | |
| 308 | 330 | // if we need to create surfaces, do it now |
| 309 | | if (dd->blit == NULL && ddraw_create_surfaces(window) != 0) |
| 331 | if (blit == NULL && ddraw_create_surfaces() != 0) |
| 310 | 332 | return 1; |
| 311 | 333 | |
| 312 | 334 | // select our surface and lock it |
| 313 | | result = IDirectDrawSurface7_Lock(dd->blit, NULL, &dd->blitdesc, DDLOCK_WAIT, NULL); |
| 335 | result = IDirectDrawSurface7_Lock(blit, NULL, &blitdesc, DDLOCK_WAIT, NULL); |
| 314 | 336 | if (result == DDERR_SURFACELOST) |
| 315 | 337 | { |
| 316 | 338 | osd_printf_verbose("DirectDraw: Lost surfaces; deleting and retrying next frame\n"); |
| 317 | | ddraw_delete_surfaces(window); |
| 339 | ddraw_delete_surfaces(); |
| 318 | 340 | return 1; |
| 319 | 341 | } |
| 320 | 342 | if (result != DD_OK) |
| r243410 | r243411 | |
| 324 | 346 | } |
| 325 | 347 | |
| 326 | 348 | // render to it |
| 327 | | window->m_primlist->acquire_lock(); |
| 349 | window().m_primlist->acquire_lock(); |
| 328 | 350 | |
| 329 | 351 | // scan the list of primitives for tricky stuff |
| 330 | | for (prim = window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 352 | for (prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 331 | 353 | if (PRIMFLAG_GET_BLENDMODE(prim->flags) != BLENDMODE_NONE || |
| 332 | 354 | (prim->texture.base != NULL && PRIMFLAG_GET_TEXFORMAT(prim->flags) == TEXFORMAT_ARGB32)) |
| 333 | 355 | { |
| r243410 | r243411 | |
| 341 | 363 | int x, y; |
| 342 | 364 | |
| 343 | 365 | // based on the target format, use one of our standard renderers |
| 344 | | switch (dd->blitdesc.ddpfPixelFormat.dwRBitMask) |
| 366 | switch (blitdesc.ddpfPixelFormat.dwRBitMask) |
| 345 | 367 | { |
| 346 | | case 0x00ff0000: software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth); break; |
| 347 | | case 0x000000ff: software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth); break; |
| 348 | | case 0xf800: software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth); break; |
| 349 | | case 0x7c00: software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth); break; |
| 368 | case 0x00ff0000: software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window().m_primlist, membuffer, blitwidth, blitheight, blitwidth); break; |
| 369 | case 0x000000ff: software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window().m_primlist, membuffer, blitwidth, blitheight, blitwidth); break; |
| 370 | case 0xf800: software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window().m_primlist, membuffer, blitwidth, blitheight, blitwidth); break; |
| 371 | case 0x7c00: software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window().m_primlist, membuffer, blitwidth, blitheight, blitwidth); break; |
| 350 | 372 | default: |
| 351 | | osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)dd->blitdesc.ddpfPixelFormat.dwRBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwGBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwBBitMask); |
| 373 | osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)blitdesc.ddpfPixelFormat.dwRBitMask, (int)blitdesc.ddpfPixelFormat.dwGBitMask, (int)blitdesc.ddpfPixelFormat.dwBBitMask); |
| 352 | 374 | break; |
| 353 | 375 | } |
| 354 | 376 | |
| 355 | 377 | // handle copying to both 16bpp and 32bpp destinations |
| 356 | | for (y = 0; y < dd->blitheight; y++) |
| 378 | for (y = 0; y < blitheight; y++) |
| 357 | 379 | { |
| 358 | | if (dd->blitdesc.ddpfPixelFormat.dwRGBBitCount == 32) |
| 380 | if (blitdesc.ddpfPixelFormat.dwRGBBitCount == 32) |
| 359 | 381 | { |
| 360 | | UINT32 *src = (UINT32 *)dd->membuffer + y * dd->blitwidth; |
| 361 | | UINT32 *dst = (UINT32 *)((UINT8 *)dd->blitdesc.lpSurface + y * dd->blitdesc.lPitch); |
| 362 | | for (x = 0; x < dd->blitwidth; x++) |
| 382 | UINT32 *src = (UINT32 *)membuffer + y * blitwidth; |
| 383 | UINT32 *dst = (UINT32 *)((UINT8 *)blitdesc.lpSurface + y * blitdesc.lPitch); |
| 384 | for (x = 0; x < blitwidth; x++) |
| 363 | 385 | *dst++ = *src++; |
| 364 | 386 | } |
| 365 | | else if (dd->blitdesc.ddpfPixelFormat.dwRGBBitCount == 16) |
| 387 | else if (blitdesc.ddpfPixelFormat.dwRGBBitCount == 16) |
| 366 | 388 | { |
| 367 | | UINT16 *src = (UINT16 *)dd->membuffer + y * dd->blitwidth; |
| 368 | | UINT16 *dst = (UINT16 *)((UINT8 *)dd->blitdesc.lpSurface + y * dd->blitdesc.lPitch); |
| 369 | | for (x = 0; x < dd->blitwidth; x++) |
| 389 | UINT16 *src = (UINT16 *)membuffer + y * blitwidth; |
| 390 | UINT16 *dst = (UINT16 *)((UINT8 *)blitdesc.lpSurface + y * blitdesc.lPitch); |
| 391 | for (x = 0; x < blitwidth; x++) |
| 370 | 392 | *dst++ = *src++; |
| 371 | 393 | } |
| 372 | 394 | } |
| r243410 | r243411 | |
| 377 | 399 | else |
| 378 | 400 | { |
| 379 | 401 | // based on the target format, use one of our standard renderers |
| 380 | | switch (dd->blitdesc.ddpfPixelFormat.dwRBitMask) |
| 402 | switch (blitdesc.ddpfPixelFormat.dwRBitMask) |
| 381 | 403 | { |
| 382 | | case 0x00ff0000: software_renderer<UINT32, 0,0,0, 16,8,0, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 4); break; |
| 383 | | case 0x000000ff: software_renderer<UINT32, 0,0,0, 0,8,16, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 4); break; |
| 384 | | case 0xf800: software_renderer<UINT16, 3,2,3, 11,5,0, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 2); break; |
| 385 | | case 0x7c00: software_renderer<UINT16, 3,3,3, 10,5,0, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 2); break; |
| 404 | case 0x00ff0000: software_renderer<UINT32, 0,0,0, 16,8,0, true>::draw_primitives(*window().m_primlist, blitdesc.lpSurface, blitwidth, blitheight, blitdesc.lPitch / 4); break; |
| 405 | case 0x000000ff: software_renderer<UINT32, 0,0,0, 0,8,16, true>::draw_primitives(*window().m_primlist, blitdesc.lpSurface, blitwidth, blitheight, blitdesc.lPitch / 4); break; |
| 406 | case 0xf800: software_renderer<UINT16, 3,2,3, 11,5,0, true>::draw_primitives(*window().m_primlist, blitdesc.lpSurface, blitwidth, blitheight, blitdesc.lPitch / 2); break; |
| 407 | case 0x7c00: software_renderer<UINT16, 3,3,3, 10,5,0, true>::draw_primitives(*window().m_primlist, blitdesc.lpSurface, blitwidth, blitheight, blitdesc.lPitch / 2); break; |
| 386 | 408 | default: |
| 387 | | osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)dd->blitdesc.ddpfPixelFormat.dwRBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwGBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwBBitMask); |
| 409 | osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)blitdesc.ddpfPixelFormat.dwRBitMask, (int)blitdesc.ddpfPixelFormat.dwGBitMask, (int)blitdesc.ddpfPixelFormat.dwBBitMask); |
| 388 | 410 | break; |
| 389 | 411 | } |
| 390 | 412 | } |
| 391 | | window->m_primlist->release_lock(); |
| 413 | window().m_primlist->release_lock(); |
| 392 | 414 | |
| 393 | 415 | // unlock and blit |
| 394 | | result = IDirectDrawSurface7_Unlock(dd->blit, NULL); |
| 416 | result = IDirectDrawSurface7_Unlock(blit, NULL); |
| 395 | 417 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X unlocking blit surface\n", (int)result); |
| 396 | 418 | |
| 397 | 419 | // sync to VBLANK |
| 398 | | if ((video_config.waitvsync || video_config.syncrefresh) && window->machine().video().throttled() && (!window->m_fullscreen || dd->back == NULL)) |
| 420 | if ((video_config.waitvsync || video_config.syncrefresh) && window().machine().video().throttled() && (!window().m_fullscreen || back == NULL)) |
| 399 | 421 | { |
| 400 | | result = IDirectDraw7_WaitForVerticalBlank(dd->ddraw, DDWAITVB_BLOCKBEGIN, NULL); |
| 422 | result = IDirectDraw7_WaitForVerticalBlank(ddraw, DDWAITVB_BLOCKBEGIN, NULL); |
| 401 | 423 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result); |
| 402 | 424 | } |
| 403 | 425 | |
| 404 | 426 | // complete the blitting |
| 405 | | blit_to_primary(window, dd->blitwidth, dd->blitheight); |
| 427 | blit_to_primary(blitwidth, blitheight); |
| 406 | 428 | return 0; |
| 407 | 429 | } |
| 408 | 430 | |
| r243410 | r243411 | |
| 412 | 434 | // ddraw_create |
| 413 | 435 | //============================================================ |
| 414 | 436 | |
| 415 | | static int ddraw_create(win_window_info *window) |
| 437 | int renderer_dd::ddraw_create() |
| 416 | 438 | { |
| 417 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 418 | 439 | HRESULT result; |
| 419 | 440 | int verify; |
| 420 | 441 | |
| 421 | 442 | // if a device exists, free it |
| 422 | | if (dd->ddraw != NULL) |
| 423 | | ddraw_delete(window); |
| 443 | if (ddraw != NULL) |
| 444 | ddraw_delete(); |
| 424 | 445 | |
| 425 | 446 | // create the DirectDraw object |
| 426 | | result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 447 | result = (*directdrawcreateex)(adapter_ptr, (LPVOID *)&ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 427 | 448 | if (result != DD_OK) |
| 428 | 449 | { |
| 429 | 450 | osd_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); |
| r243410 | r243411 | |
| 431 | 452 | } |
| 432 | 453 | |
| 433 | 454 | // verify the caps |
| 434 | | verify = ddraw_verify_caps(dd); |
| 455 | verify = ddraw_verify_caps(); |
| 435 | 456 | if (verify == 2) |
| 436 | 457 | { |
| 437 | 458 | osd_printf_error("DirectDraw: Error - Device does not meet minimum requirements for DirectDraw rendering\n"); |
| r243410 | r243411 | |
| 442 | 463 | |
| 443 | 464 | // set the cooperative level |
| 444 | 465 | // for non-window modes, we will use full screen here |
| 445 | | result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, win_window_list->m_hwnd, DDSCL_SETFOCUSWINDOW); |
| 466 | result = IDirectDraw7_SetCooperativeLevel(ddraw, win_window_list->m_hwnd, DDSCL_SETFOCUSWINDOW); |
| 446 | 467 | if (result != DD_OK) |
| 447 | 468 | { |
| 448 | 469 | osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(FOCUSWINDOW) call\n", (int)result); |
| 449 | 470 | goto error; |
| 450 | 471 | } |
| 451 | | result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->m_hwnd, DDSCL_SETDEVICEWINDOW | (window->m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL)); |
| 472 | result = IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_SETDEVICEWINDOW | (window().m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL)); |
| 452 | 473 | if (result != DD_OK) |
| 453 | 474 | { |
| 454 | 475 | osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(DEVICEWINDOW) call\n", (int)result); |
| r243410 | r243411 | |
| 456 | 477 | } |
| 457 | 478 | |
| 458 | 479 | // full screen mode: set the resolution |
| 459 | | if (window->m_fullscreen && video_config.switchres) |
| 480 | if (window().m_fullscreen && video_config.switchres) |
| 460 | 481 | { |
| 461 | | result = IDirectDraw7_SetDisplayMode(dd->ddraw, dd->width, dd->height, 32, dd->refresh, 0); |
| 482 | result = IDirectDraw7_SetDisplayMode(ddraw, width, height, 32, refresh, 0); |
| 462 | 483 | if (result != DD_OK) |
| 463 | 484 | { |
| 464 | | osd_printf_verbose("DirectDraw: Error %08X attempting to set video mode %dx%d@%d call\n", (int)result, dd->width, dd->height, dd->refresh); |
| 485 | osd_printf_verbose("DirectDraw: Error %08X attempting to set video mode %dx%d@%d call\n", (int)result, width, height, refresh); |
| 465 | 486 | goto error; |
| 466 | 487 | } |
| 467 | 488 | } |
| 468 | 489 | |
| 469 | | return ddraw_create_surfaces(window); |
| 490 | return ddraw_create_surfaces(); |
| 470 | 491 | |
| 471 | 492 | error: |
| 472 | | ddraw_delete(window); |
| 493 | ddraw_delete(); |
| 473 | 494 | return 1; |
| 474 | 495 | } |
| 475 | 496 | |
| r243410 | r243411 | |
| 479 | 500 | // ddraw_create_surfaces |
| 480 | 501 | //============================================================ |
| 481 | 502 | |
| 482 | | static int ddraw_create_surfaces(win_window_info *window) |
| 503 | int renderer_dd::ddraw_create_surfaces() |
| 483 | 504 | { |
| 484 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 485 | 505 | HRESULT result; |
| 486 | 506 | |
| 487 | 507 | // make a description of the primary surface |
| 488 | | memset(&dd->primarydesc, 0, sizeof(dd->primarydesc)); |
| 489 | | dd->primarydesc.dwSize = sizeof(dd->primarydesc); |
| 490 | | dd->primarydesc.dwFlags = DDSD_CAPS; |
| 491 | | dd->primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
| 508 | memset(&primarydesc, 0, sizeof(primarydesc)); |
| 509 | primarydesc.dwSize = sizeof(primarydesc); |
| 510 | primarydesc.dwFlags = DDSD_CAPS; |
| 511 | primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
| 492 | 512 | |
| 493 | 513 | // for triple-buffered full screen mode, allocate flipping surfaces |
| 494 | | if (window->m_fullscreen && video_config.triplebuf) |
| 514 | if (window().m_fullscreen && video_config.triplebuf) |
| 495 | 515 | { |
| 496 | | dd->primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT; |
| 497 | | dd->primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
| 498 | | dd->primarydesc.dwBackBufferCount = 2; |
| 516 | primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT; |
| 517 | primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
| 518 | primarydesc.dwBackBufferCount = 2; |
| 499 | 519 | } |
| 500 | 520 | |
| 501 | 521 | // create the primary surface and report errors |
| 502 | | result = create_surface(dd, &dd->primarydesc, &dd->primary, "primary"); |
| 522 | result = create_surface(&primarydesc, &primary, "primary"); |
| 503 | 523 | if (result != DD_OK) goto error; |
| 504 | 524 | |
| 505 | 525 | // full screen mode: get the back surface |
| 506 | | dd->back = NULL; |
| 507 | | if (window->m_fullscreen && video_config.triplebuf) |
| 526 | back = NULL; |
| 527 | if (window().m_fullscreen && video_config.triplebuf) |
| 508 | 528 | { |
| 509 | 529 | DDSCAPS2 caps = { DDSCAPS_BACKBUFFER }; |
| 510 | | result = IDirectDrawSurface7_GetAttachedSurface(dd->primary, &caps, &dd->back); |
| 530 | result = IDirectDrawSurface7_GetAttachedSurface(primary, &caps, &back); |
| 511 | 531 | if (result != DD_OK) |
| 512 | 532 | { |
| 513 | 533 | osd_printf_verbose("DirectDraw: Error %08X getting attached back surface\n", (int)result); |
| r243410 | r243411 | |
| 516 | 536 | } |
| 517 | 537 | |
| 518 | 538 | // now make a description of our blit surface, based on the primary surface |
| 519 | | if (dd->blitwidth == 0 || dd->blitheight == 0) |
| 520 | | compute_blit_surface_size(window); |
| 521 | | dd->blitdesc = dd->primarydesc; |
| 522 | | dd->blitdesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; |
| 523 | | dd->blitdesc.dwWidth = dd->blitwidth; |
| 524 | | dd->blitdesc.dwHeight = dd->blitheight; |
| 525 | | dd->blitdesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; |
| 539 | if (blitwidth == 0 || blitheight == 0) |
| 540 | compute_blit_surface_size(); |
| 541 | blitdesc = primarydesc; |
| 542 | blitdesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; |
| 543 | blitdesc.dwWidth = blitwidth; |
| 544 | blitdesc.dwHeight = blitheight; |
| 545 | blitdesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; |
| 526 | 546 | |
| 527 | 547 | // then create the blit surface, fall back to system memory if video mem doesn't work |
| 528 | | result = create_surface(dd, &dd->blitdesc, &dd->blit, "blit"); |
| 548 | result = create_surface(&blitdesc, &blit, "blit"); |
| 529 | 549 | if (result != DD_OK) |
| 530 | 550 | { |
| 531 | | dd->blitdesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY; |
| 532 | | result = create_surface(dd, &dd->blitdesc, &dd->blit, "blit"); |
| 551 | blitdesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY; |
| 552 | result = create_surface(&blitdesc, &blit, "blit"); |
| 533 | 553 | } |
| 534 | 554 | if (result != DD_OK) goto error; |
| 535 | 555 | |
| 536 | 556 | // create a memory buffer for offscreen drawing |
| 537 | | if (dd->membuffersize < dd->blitwidth * dd->blitheight * 4) |
| 557 | if (membuffersize < blitwidth * blitheight * 4) |
| 538 | 558 | { |
| 539 | | dd->membuffersize = dd->blitwidth * dd->blitheight * 4; |
| 540 | | global_free_array(dd->membuffer); |
| 541 | | dd->membuffer = global_alloc_array(UINT8, dd->membuffersize); |
| 559 | membuffersize = blitwidth * blitheight * 4; |
| 560 | global_free_array(membuffer); |
| 561 | membuffer = global_alloc_array(UINT8, membuffersize); |
| 542 | 562 | } |
| 543 | | if (dd->membuffer == NULL) |
| 563 | if (membuffer == NULL) |
| 544 | 564 | goto error; |
| 545 | 565 | |
| 546 | 566 | // create a clipper for windowed mode |
| 547 | | if (!window->m_fullscreen && create_clipper(window)) |
| 567 | if (!window().m_fullscreen && create_clipper()) |
| 548 | 568 | goto error; |
| 549 | 569 | |
| 550 | 570 | // full screen mode: set the gamma |
| 551 | | if (window->m_fullscreen) |
| 571 | if (window().m_fullscreen) |
| 552 | 572 | { |
| 553 | 573 | // only set the gamma if it's not 1.0f |
| 554 | | windows_options &options = downcast<windows_options &>(window->machine().options()); |
| 574 | windows_options &options = downcast<windows_options &>(window().machine().options()); |
| 555 | 575 | float brightness = options.full_screen_brightness(); |
| 556 | 576 | float contrast = options.full_screen_contrast(); |
| 557 | | float gamma = options.full_screen_gamma(); |
| 558 | | if (brightness != 1.0f || contrast != 1.0f || gamma != 1.0f) |
| 577 | float fgamma = options.full_screen_gamma(); |
| 578 | if (brightness != 1.0f || contrast != 1.0f || fgamma != 1.0f) |
| 559 | 579 | { |
| 560 | 580 | // see if we can get a GammaControl object |
| 561 | | result = IDirectDrawSurface_QueryInterface(dd->primary, WRAP_REFIID(IID_IDirectDrawGammaControl), (void **)&dd->gamma); |
| 581 | result = IDirectDrawSurface_QueryInterface(primary, WRAP_REFIID(IID_IDirectDrawGammaControl), (void **)&gamma); |
| 562 | 582 | if (result != DD_OK) |
| 563 | 583 | { |
| 564 | 584 | osd_printf_warning("DirectDraw: Warning - device does not support full screen gamma correction.\n"); |
| 565 | | dd->gamma = NULL; |
| 585 | this->gamma = NULL; |
| 566 | 586 | } |
| 567 | 587 | |
| 568 | 588 | // proceed if we can |
| 569 | | if (dd->gamma != NULL) |
| 589 | if (this->gamma != NULL) |
| 570 | 590 | { |
| 571 | 591 | DDGAMMARAMP ramp; |
| 572 | 592 | int i; |
| 573 | 593 | |
| 574 | 594 | // create a standard ramp and set it |
| 575 | 595 | for (i = 0; i < 256; i++) |
| 576 | | ramp.red[i] = ramp.green[i] = ramp.blue[i] = apply_brightness_contrast_gamma(i, brightness, contrast, gamma) << 8; |
| 596 | ramp.red[i] = ramp.green[i] = ramp.blue[i] = apply_brightness_contrast_gamma(i, brightness, contrast, fgamma) << 8; |
| 577 | 597 | |
| 578 | 598 | // attempt to set it |
| 579 | | result = IDirectDrawGammaControl_SetGammaRamp(dd->gamma, 0, &ramp); |
| 599 | result = IDirectDrawGammaControl_SetGammaRamp(this->gamma, 0, &ramp); |
| 580 | 600 | if (result != DD_OK) |
| 581 | 601 | osd_printf_verbose("DirectDraw: Error %08X attempting to set gamma correction.\n", (int)result); |
| 582 | 602 | } |
| r243410 | r243411 | |
| 584 | 604 | } |
| 585 | 605 | |
| 586 | 606 | // force some updates |
| 587 | | update_outer_rects(dd); |
| 607 | update_outer_rects(); |
| 588 | 608 | return 0; |
| 589 | 609 | |
| 590 | 610 | error: |
| 591 | | ddraw_delete_surfaces(window); |
| 611 | ddraw_delete_surfaces(); |
| 592 | 612 | return 1; |
| 593 | 613 | } |
| 594 | 614 | |
| r243410 | r243411 | |
| 598 | 618 | // ddraw_delete |
| 599 | 619 | //============================================================ |
| 600 | 620 | |
| 601 | | static void ddraw_delete(win_window_info *window) |
| 621 | void renderer_dd::ddraw_delete() |
| 602 | 622 | { |
| 603 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 604 | | |
| 605 | 623 | // free surfaces |
| 606 | | ddraw_delete_surfaces(window); |
| 624 | ddraw_delete_surfaces(); |
| 607 | 625 | |
| 608 | 626 | // restore resolutions |
| 609 | | if (dd->ddraw != NULL) |
| 610 | | IDirectDraw7_RestoreDisplayMode(dd->ddraw); |
| 627 | if (ddraw != NULL) |
| 628 | IDirectDraw7_RestoreDisplayMode(ddraw); |
| 611 | 629 | |
| 612 | 630 | // reset cooperative level |
| 613 | | if (dd->ddraw != NULL && window->m_hwnd != NULL) |
| 614 | | IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->m_hwnd, DDSCL_NORMAL); |
| 631 | if (ddraw != NULL && window().m_hwnd != NULL) |
| 632 | IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_NORMAL); |
| 615 | 633 | |
| 616 | 634 | // release the DirectDraw object itself |
| 617 | | if (dd->ddraw != NULL) |
| 618 | | IDirectDraw7_Release(dd->ddraw); |
| 619 | | dd->ddraw = NULL; |
| 635 | if (ddraw != NULL) |
| 636 | IDirectDraw7_Release(ddraw); |
| 637 | ddraw = NULL; |
| 620 | 638 | } |
| 621 | 639 | |
| 622 | 640 | |
| r243410 | r243411 | |
| 625 | 643 | // ddraw_delete_surfaces |
| 626 | 644 | //============================================================ |
| 627 | 645 | |
| 628 | | static void ddraw_delete_surfaces(win_window_info *window) |
| 646 | void renderer_dd::ddraw_delete_surfaces() |
| 629 | 647 | { |
| 630 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 631 | | |
| 632 | 648 | // release the gamma control |
| 633 | | if (dd->gamma != NULL) |
| 634 | | IDirectDrawGammaControl_Release(dd->gamma); |
| 635 | | dd->gamma = NULL; |
| 649 | if (gamma != NULL) |
| 650 | IDirectDrawGammaControl_Release(gamma); |
| 651 | gamma = NULL; |
| 636 | 652 | |
| 637 | 653 | // release the clipper |
| 638 | | if (dd->clipper != NULL) |
| 639 | | IDirectDrawClipper_Release(dd->clipper); |
| 640 | | dd->clipper = NULL; |
| 654 | if (clipper != NULL) |
| 655 | IDirectDrawClipper_Release(clipper); |
| 656 | clipper = NULL; |
| 641 | 657 | |
| 642 | 658 | // free the memory buffer |
| 643 | | global_free_array(dd->membuffer); |
| 644 | | dd->membuffer = NULL; |
| 645 | | dd->membuffersize = 0; |
| 659 | global_free_array(membuffer); |
| 660 | membuffer = NULL; |
| 661 | membuffersize = 0; |
| 646 | 662 | |
| 647 | 663 | // release the blit surface |
| 648 | | if (dd->blit != NULL) |
| 649 | | IDirectDrawSurface7_Release(dd->blit); |
| 650 | | dd->blit = NULL; |
| 664 | if (blit != NULL) |
| 665 | IDirectDrawSurface7_Release(blit); |
| 666 | blit = NULL; |
| 651 | 667 | |
| 652 | 668 | // release the back surface |
| 653 | | if (dd->back != NULL) |
| 654 | | IDirectDrawSurface7_Release(dd->back); |
| 655 | | dd->back = NULL; |
| 669 | if (back != NULL) |
| 670 | IDirectDrawSurface7_Release(back); |
| 671 | back = NULL; |
| 656 | 672 | |
| 657 | 673 | // release the primary surface |
| 658 | | if (dd->primary != NULL) |
| 659 | | IDirectDrawSurface7_Release(dd->primary); |
| 660 | | dd->primary = NULL; |
| 674 | if (primary != NULL) |
| 675 | IDirectDrawSurface7_Release(primary); |
| 676 | primary = NULL; |
| 661 | 677 | } |
| 662 | 678 | |
| 663 | 679 | |
| r243410 | r243411 | |
| 666 | 682 | // ddraw_verify_caps |
| 667 | 683 | //============================================================ |
| 668 | 684 | |
| 669 | | static int ddraw_verify_caps(dd_info *dd) |
| 685 | int renderer_dd::ddraw_verify_caps() |
| 670 | 686 | { |
| 671 | 687 | int retval = 0; |
| 672 | 688 | HRESULT result; |
| 673 | 689 | |
| 674 | 690 | // get the capabilities |
| 675 | | dd->ddcaps.dwSize = sizeof(dd->ddcaps); |
| 676 | | dd->helcaps.dwSize = sizeof(dd->helcaps); |
| 677 | | result = IDirectDraw7_GetCaps(dd->ddraw, &dd->ddcaps, &dd->helcaps); |
| 691 | ddcaps.dwSize = sizeof(ddcaps); |
| 692 | helcaps.dwSize = sizeof(helcaps); |
| 693 | result = IDirectDraw7_GetCaps(ddraw, &ddcaps, &helcaps); |
| 678 | 694 | if (result != DD_OK) |
| 679 | 695 | { |
| 680 | 696 | osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_GetCaps call\n", (int)result); |
| r243410 | r243411 | |
| 682 | 698 | } |
| 683 | 699 | |
| 684 | 700 | // determine if hardware stretching is available |
| 685 | | if ((dd->ddcaps.dwCaps & DDCAPS_BLTSTRETCH) == 0) |
| 701 | if ((ddcaps.dwCaps & DDCAPS_BLTSTRETCH) == 0) |
| 686 | 702 | { |
| 687 | 703 | osd_printf_verbose("DirectDraw: Warning - Device does not support hardware stretching\n"); |
| 688 | 704 | retval = 1; |
| r243410 | r243411 | |
| 697 | 713 | // ddraw_test_cooperative |
| 698 | 714 | //============================================================ |
| 699 | 715 | |
| 700 | | static int ddraw_test_cooperative(win_window_info *window) |
| 716 | int renderer_dd::ddraw_test_cooperative() |
| 701 | 717 | { |
| 702 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 703 | 718 | HRESULT result; |
| 704 | 719 | |
| 705 | 720 | // check our current status; if we lost the device, punt to GDI |
| 706 | | result = IDirectDraw7_TestCooperativeLevel(dd->ddraw); |
| 721 | result = IDirectDraw7_TestCooperativeLevel(ddraw); |
| 707 | 722 | switch (result) |
| 708 | 723 | { |
| 709 | 724 | // punt to GDI if someone else has exclusive mode |
| 710 | 725 | case DDERR_NOEXCLUSIVEMODE: |
| 711 | 726 | case DDERR_EXCLUSIVEMODEALREADYSET: |
| 712 | | ddraw_delete_surfaces(window); |
| 727 | ddraw_delete_surfaces(); |
| 713 | 728 | return 1; |
| 714 | 729 | |
| 715 | 730 | // if we're ok, but we don't have a primary surface, create one |
| 716 | 731 | default: |
| 717 | 732 | case DD_OK: |
| 718 | | if (dd->primary == NULL) |
| 719 | | return ddraw_create_surfaces(window); |
| 733 | if (primary == NULL) |
| 734 | return ddraw_create_surfaces(); |
| 720 | 735 | return 0; |
| 721 | 736 | } |
| 722 | 737 | } |
| r243410 | r243411 | |
| 727 | 742 | // create_surface |
| 728 | 743 | //============================================================ |
| 729 | 744 | |
| 730 | | static HRESULT create_surface(dd_info *dd, DDSURFACEDESC2 *desc, IDirectDrawSurface7 **surface, const char *type) |
| 745 | HRESULT renderer_dd::create_surface(DDSURFACEDESC2 *desc, IDirectDrawSurface7 **surface, const char *type) |
| 731 | 746 | { |
| 732 | 747 | HRESULT result; |
| 733 | 748 | |
| 734 | 749 | // create the surface as requested |
| 735 | | result = IDirectDraw7_CreateSurface(dd->ddraw, desc, surface, NULL); |
| 750 | result = IDirectDraw7_CreateSurface(ddraw, desc, surface, NULL); |
| 736 | 751 | if (result != DD_OK) |
| 737 | 752 | { |
| 738 | 753 | osd_printf_verbose("DirectDraw: Error %08X creating %s surface\n", (int)result, type); |
| r243410 | r243411 | |
| 767 | 782 | // create_clipper |
| 768 | 783 | //============================================================ |
| 769 | 784 | |
| 770 | | static int create_clipper(win_window_info *window) |
| 785 | int renderer_dd::create_clipper() |
| 771 | 786 | { |
| 772 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 773 | 787 | HRESULT result; |
| 774 | 788 | |
| 775 | 789 | // create a clipper for the primary surface |
| 776 | | result = IDirectDraw7_CreateClipper(dd->ddraw, 0, &dd->clipper, NULL); |
| 790 | result = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL); |
| 777 | 791 | if (result != DD_OK) |
| 778 | 792 | { |
| 779 | 793 | osd_printf_verbose("DirectDraw: Error %08X creating clipper\n", (int)result); |
| r243410 | r243411 | |
| 781 | 795 | } |
| 782 | 796 | |
| 783 | 797 | // set the clipper's hwnd |
| 784 | | result = IDirectDrawClipper_SetHWnd(dd->clipper, 0, window->m_hwnd); |
| 798 | result = IDirectDrawClipper_SetHWnd(clipper, 0, window().m_hwnd); |
| 785 | 799 | if (result != DD_OK) |
| 786 | 800 | { |
| 787 | 801 | osd_printf_verbose("DirectDraw: Error %08X setting clipper hwnd\n", (int)result); |
| r243410 | r243411 | |
| 789 | 803 | } |
| 790 | 804 | |
| 791 | 805 | // set the clipper on the primary surface |
| 792 | | result = IDirectDrawSurface7_SetClipper(dd->primary, dd->clipper); |
| 806 | result = IDirectDrawSurface7_SetClipper(primary, clipper); |
| 793 | 807 | if (result != DD_OK) |
| 794 | 808 | { |
| 795 | 809 | osd_printf_verbose("DirectDraw: Error %08X setting clipper on primary surface\n", (int)result); |
| r243410 | r243411 | |
| 804 | 818 | // compute_blit_surface_size |
| 805 | 819 | //============================================================ |
| 806 | 820 | |
| 807 | | static void compute_blit_surface_size(win_window_info *window) |
| 821 | void renderer_dd::compute_blit_surface_size() |
| 808 | 822 | { |
| 809 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 810 | 823 | INT32 newwidth, newheight; |
| 811 | 824 | int xscale, yscale; |
| 812 | 825 | RECT client; |
| 813 | 826 | |
| 814 | 827 | // start with the minimum size |
| 815 | | window->m_target->compute_minimum_size(newwidth, newheight); |
| 828 | window().m_target->compute_minimum_size(newwidth, newheight); |
| 816 | 829 | |
| 817 | 830 | // get the window's client rectangle |
| 818 | | GetClientRect(window->m_hwnd, &client); |
| 831 | GetClientRect(window().m_hwnd, &client); |
| 819 | 832 | |
| 820 | 833 | // hardware stretch case: apply prescale |
| 821 | 834 | if (video_config.hwstretch) |
| r243410 | r243411 | |
| 841 | 854 | // compute the appropriate visible area if we're trying to keepaspect |
| 842 | 855 | if (video_config.keepaspect) |
| 843 | 856 | { |
| 844 | | win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL); |
| 845 | | window->m_target->compute_visible_area(target_width, target_height, monitor->get_aspect(), window->m_target->orientation(), target_width, target_height); |
| 857 | win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL); |
| 858 | window().m_target->compute_visible_area(target_width, target_height, monitor->get_aspect(), window().m_target->orientation(), target_width, target_height); |
| 846 | 859 | desired_aspect = (float)target_width / (float)target_height; |
| 847 | 860 | } |
| 848 | 861 | |
| r243410 | r243411 | |
| 884 | 897 | // apply the final scale |
| 885 | 898 | newwidth *= xscale; |
| 886 | 899 | newheight *= yscale; |
| 887 | | if (newwidth != dd->blitwidth || newheight != dd->blitheight) |
| 900 | if (newwidth != blitwidth || newheight != blitheight) |
| 888 | 901 | { |
| 889 | 902 | // force some updates |
| 890 | | update_outer_rects(dd); |
| 903 | update_outer_rects(); |
| 891 | 904 | osd_printf_verbose("DirectDraw: New blit size = %dx%d\n", newwidth, newheight); |
| 892 | 905 | } |
| 893 | | dd->blitwidth = newwidth; |
| 894 | | dd->blitheight = newheight; |
| 906 | blitwidth = newwidth; |
| 907 | blitheight = newheight; |
| 895 | 908 | } |
| 896 | 909 | |
| 897 | 910 | |
| r243410 | r243411 | |
| 900 | 913 | // calc_fullscreen_margins |
| 901 | 914 | //============================================================ |
| 902 | 915 | |
| 903 | | static void calc_fullscreen_margins(win_window_info *window, DWORD desc_width, DWORD desc_height, RECT *margins) |
| 916 | void renderer_dd::calc_fullscreen_margins(DWORD desc_width, DWORD desc_height, RECT *margins) |
| 904 | 917 | { |
| 905 | 918 | margins->left = 0; |
| 906 | 919 | margins->top = 0; |
| 907 | 920 | margins->right = desc_width; |
| 908 | 921 | margins->bottom = desc_height; |
| 909 | 922 | |
| 910 | | if (win_has_menu(window)) |
| 923 | if (win_has_menu(&window())) |
| 911 | 924 | { |
| 912 | 925 | static int height_with_menubar = 0; |
| 913 | 926 | if (height_with_menubar == 0) |
| r243410 | r243411 | |
| 928 | 941 | // blit_to_primary |
| 929 | 942 | //============================================================ |
| 930 | 943 | |
| 931 | | static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight) |
| 944 | void renderer_dd::blit_to_primary(int srcwidth, int srcheight) |
| 932 | 945 | { |
| 933 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 934 | | IDirectDrawSurface7 *target = (dd->back != NULL) ? dd->back : dd->primary; |
| 935 | | win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL); |
| 946 | IDirectDrawSurface7 *target = (back != NULL) ? back : primary; |
| 947 | win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL); |
| 936 | 948 | DDBLTFX blitfx = { sizeof(DDBLTFX) }; |
| 937 | 949 | RECT clear, outer, dest, source; |
| 938 | 950 | INT32 dstwidth, dstheight; |
| r243410 | r243411 | |
| 944 | 956 | source.bottom = srcheight; |
| 945 | 957 | |
| 946 | 958 | // compute outer rect -- windowed version |
| 947 | | if (!window->m_fullscreen) |
| 959 | if (!window().m_fullscreen) |
| 948 | 960 | { |
| 949 | | GetClientRect(window->m_hwnd, &outer); |
| 950 | | ClientToScreen(window->m_hwnd, &((LPPOINT)&outer)[0]); |
| 951 | | ClientToScreen(window->m_hwnd, &((LPPOINT)&outer)[1]); |
| 961 | GetClientRect(window().m_hwnd, &outer); |
| 962 | ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[0]); |
| 963 | ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[1]); |
| 952 | 964 | |
| 953 | 965 | // adjust to be relative to the monitor |
| 954 | 966 | outer.left -= monitor->info.rcMonitor.left; |
| r243410 | r243411 | |
| 960 | 972 | // compute outer rect -- full screen version |
| 961 | 973 | else |
| 962 | 974 | { |
| 963 | | calc_fullscreen_margins(window, dd->primarydesc.dwWidth, dd->primarydesc.dwHeight, &outer); |
| 975 | calc_fullscreen_margins(primarydesc.dwWidth, primarydesc.dwHeight, &outer); |
| 964 | 976 | } |
| 965 | 977 | |
| 966 | 978 | // if we're respecting the aspect ratio, we need to adjust to fit |
| r243410 | r243411 | |
| 987 | 999 | else if (video_config.keepaspect) |
| 988 | 1000 | { |
| 989 | 1001 | // compute the appropriate visible area |
| 990 | | window->m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window->m_target->orientation(), dstwidth, dstheight); |
| 1002 | window().m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().m_target->orientation(), dstwidth, dstheight); |
| 991 | 1003 | } |
| 992 | 1004 | |
| 993 | 1005 | // center within |
| r243410 | r243411 | |
| 997 | 1009 | dest.bottom = dest.top + dstheight; |
| 998 | 1010 | |
| 999 | 1011 | // compare against last destination; if different, force a redraw |
| 1000 | | if (dest.left != dd->lastdest.left || dest.right != dd->lastdest.right || dest.top != dd->lastdest.top || dest.bottom != dd->lastdest.bottom) |
| 1012 | if (dest.left != lastdest.left || dest.right != lastdest.right || dest.top != lastdest.top || dest.bottom != lastdest.bottom) |
| 1001 | 1013 | { |
| 1002 | | dd->lastdest = dest; |
| 1003 | | update_outer_rects(dd); |
| 1014 | lastdest = dest; |
| 1015 | update_outer_rects(); |
| 1004 | 1016 | } |
| 1005 | 1017 | |
| 1006 | 1018 | // clear outer rects if we need to |
| 1007 | | if (dd->clearouter != 0) |
| 1019 | if (clearouter != 0) |
| 1008 | 1020 | { |
| 1009 | | dd->clearouter--; |
| 1021 | clearouter--; |
| 1010 | 1022 | |
| 1011 | 1023 | // clear the left edge |
| 1012 | 1024 | if (dest.left > outer.left) |
| r243410 | r243411 | |
| 1046 | 1058 | } |
| 1047 | 1059 | |
| 1048 | 1060 | // do the blit |
| 1049 | | result = IDirectDrawSurface7_Blt(target, &dest, dd->blit, &source, DDBLT_WAIT, NULL); |
| 1061 | result = IDirectDrawSurface7_Blt(target, &dest, blit, &source, DDBLT_WAIT, NULL); |
| 1050 | 1062 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X blitting to the screen\n", (int)result); |
| 1051 | 1063 | |
| 1052 | 1064 | // page flip if triple buffered |
| 1053 | | if (window->m_fullscreen && dd->back != NULL) |
| 1065 | if (window().m_fullscreen && back != NULL) |
| 1054 | 1066 | { |
| 1055 | | result = IDirectDrawSurface7_Flip(dd->primary, NULL, DDFLIP_WAIT); |
| 1067 | result = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT); |
| 1056 | 1068 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result); |
| 1057 | 1069 | } |
| 1058 | 1070 | } |
| r243410 | r243411 | |
| 1063 | 1075 | // config_adapter_mode |
| 1064 | 1076 | //============================================================ |
| 1065 | 1077 | |
| 1066 | | static int config_adapter_mode(win_window_info *window) |
| 1078 | int renderer_dd::config_adapter_mode() |
| 1067 | 1079 | { |
| 1068 | 1080 | DDDEVICEIDENTIFIER2 identifier; |
| 1069 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 1070 | 1081 | HRESULT result; |
| 1071 | 1082 | |
| 1072 | 1083 | // choose the monitor number |
| 1073 | | get_adapter_for_monitor(dd, window->m_monitor); |
| 1084 | get_adapter_for_monitor(window().m_monitor); |
| 1074 | 1085 | |
| 1075 | 1086 | // create a temporary DirectDraw object |
| 1076 | | result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 1087 | result = (*directdrawcreateex)(adapter_ptr, (LPVOID *)&ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 1077 | 1088 | if (result != DD_OK) |
| 1078 | 1089 | { |
| 1079 | 1090 | osd_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); |
| r243410 | r243411 | |
| 1081 | 1092 | } |
| 1082 | 1093 | |
| 1083 | 1094 | // get the identifier |
| 1084 | | result = IDirectDraw7_GetDeviceIdentifier(dd->ddraw, &identifier, 0); |
| 1095 | result = IDirectDraw7_GetDeviceIdentifier(ddraw, &identifier, 0); |
| 1085 | 1096 | if (result != DD_OK) |
| 1086 | 1097 | { |
| 1087 | 1098 | osd_printf_error("Error getting identifier for device\n"); |
| r243410 | r243411 | |
| 1090 | 1101 | osd_printf_verbose("DirectDraw: Configuring device %s\n", identifier.szDescription); |
| 1091 | 1102 | |
| 1092 | 1103 | // get the current display mode |
| 1093 | | memset(&dd->origmode, 0, sizeof(dd->origmode)); |
| 1094 | | dd->origmode.dwSize = sizeof(dd->origmode); |
| 1095 | | result = IDirectDraw7_GetDisplayMode(dd->ddraw, &dd->origmode); |
| 1104 | memset(&origmode, 0, sizeof(origmode)); |
| 1105 | origmode.dwSize = sizeof(origmode); |
| 1106 | result = IDirectDraw7_GetDisplayMode(ddraw, &origmode); |
| 1096 | 1107 | if (result != DD_OK) |
| 1097 | 1108 | { |
| 1098 | 1109 | osd_printf_verbose("DirectDraw: Error %08X getting current display mode\n", (int)result); |
| 1099 | | IDirectDraw7_Release(dd->ddraw); |
| 1110 | IDirectDraw7_Release(ddraw); |
| 1100 | 1111 | return 1; |
| 1101 | 1112 | } |
| 1102 | 1113 | |
| 1103 | 1114 | // choose a resolution: full screen mode case |
| 1104 | | if (window->m_fullscreen) |
| 1115 | if (window().m_fullscreen) |
| 1105 | 1116 | { |
| 1106 | 1117 | // default to the current mode exactly |
| 1107 | | dd->width = dd->origmode.dwWidth; |
| 1108 | | dd->height = dd->origmode.dwHeight; |
| 1109 | | dd->refresh = dd->origmode.dwRefreshRate; |
| 1118 | width = origmode.dwWidth; |
| 1119 | height = origmode.dwHeight; |
| 1120 | refresh = origmode.dwRefreshRate; |
| 1110 | 1121 | |
| 1111 | 1122 | // if we're allowed to switch resolutions, override with something better |
| 1112 | 1123 | if (video_config.switchres) |
| 1113 | | pick_best_mode(window); |
| 1124 | pick_best_mode(); |
| 1114 | 1125 | } |
| 1115 | 1126 | |
| 1116 | 1127 | // release the DirectDraw object |
| 1117 | | IDirectDraw7_Release(dd->ddraw); |
| 1118 | | dd->ddraw = NULL; |
| 1128 | IDirectDraw7_Release(ddraw); |
| 1129 | ddraw = NULL; |
| 1119 | 1130 | |
| 1120 | 1131 | // if we're not changing resolutions, make sure we have a resolution we can handle |
| 1121 | | if (!window->m_fullscreen || !video_config.switchres) |
| 1132 | if (!window().m_fullscreen || !video_config.switchres) |
| 1122 | 1133 | { |
| 1123 | | switch (dd->origmode.ddpfPixelFormat.dwRBitMask) |
| 1134 | switch (origmode.ddpfPixelFormat.dwRBitMask) |
| 1124 | 1135 | { |
| 1125 | 1136 | case 0x00ff0000: |
| 1126 | 1137 | case 0x000000ff: |
| r243410 | r243411 | |
| 1129 | 1140 | break; |
| 1130 | 1141 | |
| 1131 | 1142 | default: |
| 1132 | | osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)dd->origmode.ddpfPixelFormat.dwRBitMask, (int)dd->origmode.ddpfPixelFormat.dwGBitMask, (int)dd->origmode.ddpfPixelFormat.dwBBitMask); |
| 1143 | osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)origmode.ddpfPixelFormat.dwRBitMask, (int)origmode.ddpfPixelFormat.dwGBitMask, (int)origmode.ddpfPixelFormat.dwBBitMask); |
| 1133 | 1144 | return 1; |
| 1134 | 1145 | } |
| 1135 | 1146 | } |
| r243410 | r243411 | |
| 1164 | 1175 | // get_adapter_for_monitor |
| 1165 | 1176 | //============================================================ |
| 1166 | 1177 | |
| 1167 | | static void get_adapter_for_monitor(dd_info *dd, win_monitor_info *monitor) |
| 1178 | void renderer_dd::get_adapter_for_monitor(win_monitor_info *monitor) |
| 1168 | 1179 | { |
| 1169 | 1180 | monitor_enum_info einfo; |
| 1170 | 1181 | HRESULT result; |
| r243410 | r243411 | |
| 1178 | 1189 | // set up the adapter |
| 1179 | 1190 | if (einfo.foundit && einfo.guid_ptr != NULL) |
| 1180 | 1191 | { |
| 1181 | | dd->adapter = einfo.guid; |
| 1182 | | dd->adapter_ptr = &dd->adapter; |
| 1192 | adapter = einfo.guid; |
| 1193 | adapter_ptr = &adapter; |
| 1183 | 1194 | } |
| 1184 | 1195 | else |
| 1185 | | dd->adapter_ptr = NULL; |
| 1196 | adapter_ptr = NULL; |
| 1186 | 1197 | } |
| 1187 | 1198 | |
| 1188 | 1199 | |
| r243410 | r243411 | |
| 1195 | 1206 | { |
| 1196 | 1207 | float size_score, refresh_score, final_score; |
| 1197 | 1208 | mode_enum_info *einfo = (mode_enum_info *)context; |
| 1198 | | dd_info *dd = (dd_info *)einfo->window->m_drawdata; |
| 1209 | renderer_dd *dd = dynamic_cast<renderer_dd *>(einfo->window->m_renderer); |
| 1199 | 1210 | |
| 1200 | 1211 | // skip non-32 bit modes |
| 1201 | 1212 | if (desc->ddpfPixelFormat.dwRGBBitCount != 32) |
| r243410 | r243411 | |
| 1248 | 1259 | // pick_best_mode |
| 1249 | 1260 | //============================================================ |
| 1250 | 1261 | |
| 1251 | | static void pick_best_mode(win_window_info *window) |
| 1262 | void renderer_dd::pick_best_mode() |
| 1252 | 1263 | { |
| 1253 | | dd_info *dd = (dd_info *)window->m_drawdata; |
| 1254 | 1264 | mode_enum_info einfo; |
| 1255 | 1265 | HRESULT result; |
| 1256 | 1266 | |
| r243410 | r243411 | |
| 1258 | 1268 | // note: technically we should not be calling this from an alternate window |
| 1259 | 1269 | // thread; however, it is only done during init time, and the init code on |
| 1260 | 1270 | // the main thread is waiting for us to finish, so it is safe to do so here |
| 1261 | | window->m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height); |
| 1271 | window().m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height); |
| 1262 | 1272 | |
| 1263 | 1273 | // use those as the target for now |
| 1264 | 1274 | einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale); |
| r243410 | r243411 | |
| 1266 | 1276 | |
| 1267 | 1277 | // determine the refresh rate of the primary screen |
| 1268 | 1278 | einfo.target_refresh = 60.0; |
| 1269 | | const screen_device *primary_screen = window->machine().config().first_screen(); |
| 1279 | const screen_device *primary_screen = window().machine().config().first_screen(); |
| 1270 | 1280 | if (primary_screen != NULL) |
| 1271 | 1281 | einfo.target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh_attoseconds()); |
| 1272 | 1282 | printf("Target refresh = %f\n", einfo.target_refresh); |
| r243410 | r243411 | |
| 1286 | 1296 | } |
| 1287 | 1297 | |
| 1288 | 1298 | // fill in the rest of the data |
| 1289 | | einfo.window = window; |
| 1299 | einfo.window = &window(); |
| 1290 | 1300 | einfo.best_score = 0.0f; |
| 1291 | 1301 | |
| 1292 | 1302 | // enumerate the modes |
| 1293 | 1303 | osd_printf_verbose("DirectDraw: Selecting video mode...\n"); |
| 1294 | | result = IDirectDraw7_EnumDisplayModes(dd->ddraw, DDEDM_REFRESHRATES, NULL, &einfo, enum_modes_callback); |
| 1304 | result = IDirectDraw7_EnumDisplayModes(ddraw, DDEDM_REFRESHRATES, NULL, &einfo, enum_modes_callback); |
| 1295 | 1305 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X during EnumDisplayModes call\n", (int)result); |
| 1296 | | osd_printf_verbose("DirectDraw: Mode selected = %4dx%4d@%3dHz\n", dd->width, dd->height, dd->refresh); |
| 1306 | osd_printf_verbose("DirectDraw: Mode selected = %4dx%4d@%3dHz\n", width, height, refresh); |
| 1297 | 1307 | } |