trunk/src/mame/drivers/segas16b.c
| r243409 | r243410 | |
| 79 | 79 | Sega System 16B Hardware Overview |
| 80 | 80 | --------------------------------- |
| 81 | 81 | |
| 82 | | The games on this system include... |
| 82 | The games on this system include... (there may be more??) //todo |
| 83 | 83 | Ace Attacker (C) Sega/Jaleco, 1989 |
| 84 | 84 | Alien Syndrome (C) Sega, 1987 |
| 85 | 85 | Altered Beast / Jyuohki (C) Sega, 1988 |
| r243409 | r243410 | |
| 386 | 386 | -----------------|--------------------------------------------------------------------------------------------------| |
| 387 | 387 | Shinobi |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 388 | 388 | CPU - 317-0049 |--------------------------------------------------------------------------------------------------| |
| 389 | | 8751 - n/a |EPR11280 EPR11281 - EPR11282 EPR11283 - EPR11287 EPR11288 EPR11289 - - | |
| 389 | 8751 - |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 | |
| r243409 | r243410 | |
| 430 | 430 | -----------------|--------------------------------------------------------------------------------------------------| |
| 431 | 431 | Sonic Boom |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 432 | 432 | CPU - 317-0053 |--------------------------------------------------------------------------------------------------| |
| 433 | | 8751 - n/a |EPR11340 EPR11341 - EPR11342 EPR11343 - EPR11347 EPR11348 EPR11349 - - | |
| 433 | 8751 - |EPR11340 EPR11341 - EPR11342 EPR11343 - EPR11347 EPR11348 EPR11349 - - | |
| 434 | 434 | |--------------------------------------------------------------------------------------------------| |
| 435 | 435 | | | |
| 436 | 436 | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243409 | r243410 | |
| 441 | 441 | -----------------|--------------------------------------------------------------------------------------------------| |
| 442 | 442 | Passing Shot |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 443 | 443 | CPU - 317-0080 |--------------------------------------------------------------------------------------------------| |
| 444 | | 8751 - n/a |EPR11870 - - EPR11871 - - EPR11857 EPR11858 EPR11859 EPR11860 EPR11861| |
| 444 | 8751 - |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 | |
| r243409 | r243410 | |
| 452 | 452 | -----------------|--------------------------------------------------------------------------------------------------| |
| 453 | 453 | Bullet |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 454 | 454 | CPU - 317-0041 |--------------------------------------------------------------------------------------------------| |
| 455 | | 8751 - n/a |EPR11007 EPR11008 EPR11009 EPR11010 EPR11011 EPR11012 EPR10997 EPR10998 - - - | |
| 455 | 8751 - |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 | |
| r243409 | r243410 | |
| 463 | 463 | -----------------|--------------------------------------------------------------------------------------------------| |
| 464 | 464 | Tetris |A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 | |
| 465 | 465 | CPU - 317-0091 |--------------------------------------------------------------------------------------------------| |
| 466 | | 8751 - n/a |EPR12163 - - EPR12164 - - EPR12168 - - - - | |
| 466 | 8751 - |EPR12163 - - EPR12164 - - EPR12168 - - - - | |
| 467 | 467 | |--------------------------------------------------------------------------------------------------| |
| 468 | 468 | | | |
| 469 | 469 | |B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 | |
| r243409 | r243410 | |
| 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 - n/a |EPR12198 EPR12199 - EPR12100 EPR12101 - EPR12127 - - - - | |
| 477 | 8751 - |EPR12198 EPR12199 - EPR12100 EPR12101 - EPR12127 - - - - | |
| 478 | 478 | |--------------------------------------------------------------------------------------------------| |
| 479 | 479 | | | |
| 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| |
| 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| |
| 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 | | 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| |
| 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| |
| 494 | 494 | -----------------|--------------------------------------------------------------------------------------------------| |
| 495 | | J6 jumper tied from lower left side of 256 jumper to upper right side of 512 jumper like this: / |
| 495 | |
| 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 | | 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| |
| 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| |
| 505 | 505 | -----------------|--------------------------------------------------------------------------------------------------| |
| 506 | 506 | |
| 507 | 507 | -----------------|--------------------------------------------------------------------------------------------------| |
| r243409 | r243410 | |
| 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 |
| 595 | S1-S16 - Jumpers to configure ROM sizes //usage TODO |
| 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 | |
| r243409 | r243410 | |
| 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 |
| 717 | S1-S18 - Jumpers to configure ROM sizes //usage TODO |
| 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 |
| r243409 | r243410 | |
| 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 - n/a |- - - - EPR12539 EPR12519 EPR12540 EPR12521 EPR12390 MPR12384 - EPR12385 EPR12386 EPR12387| |
| 740 | 8751 - |- - - - 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 | |
| r243409 | r243410 | |
| 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 | |
| r243409 | r243410 | |
| 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 - n/a |- - - - EPR12192 - EPR12193 - EPR12168 - - EPR12165 EPR12166 EPR12167| |
| 861 | 8751 - |- - - - 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 | | S2 S3 S6 S7 S9 |--------------------------------------------------------------------------------------------------------------------------------------| |
| 866 | | S11 S13 S15 S17 |EPR12194 - - - EPR12195 - - - - - - - - - - | |
| 865 | |--------------------------------------------------------------------------------------------------------------------------------------| |
| 866 | |EPR - - - EPR - - - - - - - - - - | |
| 867 | 867 | -----------------|--------------------------------------------------------------------------------------------------------------------------------------| |
| 868 | Sega part number for B1 & B5 unknown |
| 868 | 869 | |
| 869 | 870 | ***************************************************************************/ |
| 870 | 871 | |
| r243409 | r243410 | |
| 3645 | 3646 | ROM_LOAD( "opr-11673.a12", 0x30000, 0x20000, CRC(400c4a36) SHA1(de4bdfa91734410e0a7f6a16bf8336db172f458a) ) |
| 3646 | 3647 | |
| 3647 | 3648 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 3648 | | ROM_LOAD( "317-0078.c2", 0x00000, 0x1000, NO_DUMP ) |
| 3649 | ROM_LOAD( "317-0078.mcu", 0x00000, 0x1000, NO_DUMP ) |
| 3649 | 3650 | ROM_END |
| 3650 | 3651 | |
| 3651 | 3652 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 3688 | 3689 | ROM_LOAD( "opr-11673.a12", 0x30000, 0x20000, CRC(400c4a36) SHA1(de4bdfa91734410e0a7f6a16bf8336db172f458a) ) |
| 3689 | 3690 | |
| 3690 | 3691 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 3691 | | ROM_LOAD( "317-0077.c2", 0x00000, 0x1000, NO_DUMP ) |
| 3692 | ROM_LOAD( "317-0077.mcu", 0x00000, 0x1000, NO_DUMP ) |
| 3692 | 3693 | ROM_END |
| 3693 | 3694 | |
| 3694 | 3695 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 3731 | 3732 | ROM_LOAD( "opr-11673.a12", 0x30000, 0x20000, CRC(400c4a36) SHA1(de4bdfa91734410e0a7f6a16bf8336db172f458a) ) |
| 3732 | 3733 | |
| 3733 | 3734 | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 3734 | | ROM_LOAD( "317-0076.c2", 0x00000, 0x1000, NO_DUMP ) |
| 3735 | ROM_LOAD( "317-0076.mcu", 0x00000, 0x1000, NO_DUMP ) |
| 3735 | 3736 | ROM_END |
| 3736 | 3737 | |
| 3737 | 3738 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 4694 | 4695 | ROM_REGION( 0x10000, "soundcpu", 0 ) // sound CPU |
| 4695 | 4696 | ROM_LOAD( "epr-11916.a10", 0x0000, 0x8000, CRC(7ab541cf) SHA1(feb88022ca1796d020e53e95ad345159bd415530) ) |
| 4696 | 4697 | |
| 4697 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 4698 | | ROM_LOAD( "317-0095.c2", 0x00000, 0x1000, NO_DUMP ) |
| 4698 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 4699 | ROM_LOAD( "317-0095.bin", 0x00000, 0x1000, NO_DUMP ) |
| 4699 | 4700 | ROM_END |
| 4700 | 4701 | |
| 4701 | 4702 | |
| r243409 | r243410 | |
| 4853 | 4854 | ROM_LOAD16_BYTE( "epr-12680.a3", 0x180001, 0x20000, CRC(f321452c) SHA1(cdccd8facc2941745f05fba25ad7d76b445eb873) ) |
| 4854 | 4855 | ROM_LOAD16_BYTE( "epr-12699.b12",0x180000, 0x20000, CRC(ac329586) SHA1(98994f41ee2f0fa5cd800f565b277ba21f2bb0c3) ) |
| 4855 | 4856 | |
| 4857 | |
| 4856 | 4858 | ROM_REGION( 0x90000, "soundcpu", 0 ) // sound CPU |
| 4857 | 4859 | ROM_LOAD( "epr-12685.a10", 0x00000, 0x08000, CRC(5d0c16d7) SHA1(7ab13376c2a1da0566689ccbc258f94d1f4de487) ) |
| 4858 | 4860 | ROM_LOAD( "mpr-12686.a11", 0x10000, 0x20000, CRC(f451705e) SHA1(2b3d1b3ffbc6ba2285c4141e6fd3447252a31c8b) ) |
| r243409 | r243410 | |
| 4869 | 4871 | // |
| 4870 | 4872 | ROM_START( exctleag ) |
| 4871 | 4873 | ROM_REGION( 0x60000, "maincpu", 0 ) // 68000 code |
| 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) ) |
| 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) ) |
| 4878 | 4880 | |
| 4879 | 4881 | ROM_REGION( 0x2000, "maincpu:key", 0 ) // decryption key |
| 4880 | 4882 | ROM_LOAD( "317-0079.key", 0x0000, 0x2000, CRC(effefa1c) SHA1(f42e87f60c9589862ea2c05a29b1b15dc7194051) ) |
| r243409 | r243410 | |
| 4885 | 4887 | ROM_LOAD( "epr-11944.b11", 0x20000, 0x10000, CRC(a75cae80) SHA1(17c148a33b09b5403e68f5d96e506545c2ced206) ) |
| 4886 | 4888 | |
| 4887 | 4889 | ROM_REGION16_BE( 0x80000, "sprites", 0 ) // sprites |
| 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) ) |
| 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) ) |
| 4896 | 4898 | |
| 4897 | 4899 | ROM_REGION( 0x50000, "soundcpu", 0 ) // sound CPU |
| 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) ) |
| 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) ) |
| 4901 | 4903 | ROM_LOAD( "epr-11142.a10", 0x30000, 0x8000, CRC(25d26c66) SHA1(2485afb859f84a9cc90b2091e9ae4eef263f42b3) ) |
| 4902 | 4904 | ROM_LOAD( "epr-11143.a11", 0x40000, 0x8000, CRC(848b7b77) SHA1(8903a39f8f0ffb4ce32117d33282876196516c30) ) |
| 4903 | 4905 | ROM_END |
| r243409 | r243410 | |
| 5039 | 5041 | ROM_LOAD( "epr-12390.ic8", 0x00000, 0x08000, CRC(399fc5f5) SHA1(6f290b36dc71ff4759598e2a9c185a8945a3c9e7) ) |
| 5040 | 5042 | ROM_LOAD( "mpr-12384.ic6", 0x10000, 0x20000, CRC(6218d8e7) SHA1(5a745c750efb4a61716f99befb7ed14cc84e9973) ) |
| 5041 | 5043 | |
| 5042 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 5043 | | ROM_LOAD( "317-0123a.c2", 0x00000, 0x1000, NO_DUMP ) |
| 5044 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 5045 | ROM_LOAD( "317-0123a.bin", 0x00000, 0x1000, NO_DUMP ) |
| 5044 | 5046 | ROM_END |
| 5045 | 5047 | |
| 5046 | 5048 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 5199 | 5201 | ROM_LOAD( "epr-12390.a10", 0x00000, 0x08000, CRC(399fc5f5) SHA1(6f290b36dc71ff4759598e2a9c185a8945a3c9e7) ) |
| 5200 | 5202 | ROM_LOAD( "mpr-12384.a11", 0x10000, 0x20000, CRC(6218d8e7) SHA1(5a745c750efb4a61716f99befb7ed14cc84e9973) ) |
| 5201 | 5203 | |
| 5202 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 5203 | | ROM_LOAD( "317-0112.c2", 0x00000, 0x1000, NO_DUMP ) |
| 5204 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 5205 | ROM_LOAD( "317-0112.bin", 0x00000, 0x1000, NO_DUMP ) |
| 5204 | 5206 | ROM_END |
| 5205 | 5207 | |
| 5206 | 5208 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 6014 | 6016 | // |
| 6015 | 6017 | ROM_START( suprleag ) |
| 6016 | 6018 | ROM_REGION( 0x60000, "maincpu", 0 ) // 68000 code |
| 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) ) |
| 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) ) |
| 6023 | 6025 | |
| 6024 | 6026 | ROM_REGION( 0x2000, "maincpu:key", 0 ) // decryption key |
| 6025 | 6027 | ROM_LOAD( "317-0045.key", 0x0000, 0x2000, CRC(0594cc2e) SHA1(8aec3fffd00cbfd50d7cfb92e4748e2653fbb504) ) |
| 6026 | 6028 | |
| 6027 | 6029 | ROM_REGION( 0x30000, "gfx1", 0 ) // tiles |
| 6028 | | ROM_LOAD( "epr-11136.b9", 0x00000, 0x10000, CRC(c3860ce4) SHA1(af7618f3b5a0e8d6374877c7815ba69fff218a45) ) |
| 6030 | ROM_LOAD( "epr-11136.b09", 0x00000, 0x10000, CRC(c3860ce4) SHA1(af7618f3b5a0e8d6374877c7815ba69fff218a45) ) |
| 6029 | 6031 | ROM_LOAD( "epr-11137.b10", 0x10000, 0x10000, CRC(92d96187) SHA1(45138795992b9842d5b0c86a96b300445bf12060) ) |
| 6030 | 6032 | ROM_LOAD( "epr-11138.b11", 0x20000, 0x10000, CRC(c01dc773) SHA1(b27da906186e1272cdd6f8d5e5a979f6623255ac) ) |
| 6031 | 6033 | |
| 6032 | 6034 | ROM_REGION16_BE( 0x80000, "sprites", 0 ) // sprites |
| 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) ) |
| 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) ) |
| 6041 | 6043 | |
| 6042 | 6044 | ROM_REGION( 0x50000, "soundcpu", 0 ) // sound CPU |
| 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) ) |
| 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) ) |
| 6046 | 6048 | ROM_LOAD( "epr-11142.a10", 0x30000, 0x08000, CRC(25d26c66) SHA1(2485afb859f84a9cc90b2091e9ae4eef263f42b3) ) |
| 6047 | 6049 | ROM_LOAD( "epr-11143.a11", 0x40000, 0x08000, CRC(848b7b77) SHA1(8903a39f8f0ffb4ce32117d33282876196516c30) ) |
| 6048 | 6050 | ROM_END |
| r243409 | r243410 | |
| 6220 | 6222 | ROM_LOAD( "opr-12329.a11", 0x10000, 0x10000, CRC(ed9a686d) SHA1(da433033d501ee871429ee676b3972b14179df9f) ) // speech |
| 6221 | 6223 | ROM_LOAD( "opr-12330.a12", 0x20000, 0x10000, CRC(fb762bca) SHA1(ff9191c5ec38c711ebb7c2ad043f62b6d7e2203c) ) |
| 6222 | 6224 | |
| 6223 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6224 | | ROM_LOAD( "317-0104.c2", 0x00000, 0x1000, NO_DUMP ) |
| 6225 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6226 | ROM_LOAD( "317-0104.bin", 0x00000, 0x1000, NO_DUMP ) |
| 6225 | 6227 | ROM_END |
| 6226 | 6228 | |
| 6227 | 6229 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 6232 | 6234 | // |
| 6233 | 6235 | ROM_START( tturfu ) |
| 6234 | 6236 | ROM_REGION( 0x40000, "maincpu", 0 ) // 68000 code |
| 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) ) |
| 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) ) |
| 6239 | 6241 | |
| 6240 | 6242 | ROM_REGION( 0x30000, "gfx1", 0 ) // tiles |
| 6241 | 6243 | ROM_LOAD( "epr-12268.a14", 0x00000, 0x10000, CRC(e0dac07f) SHA1(c7f6de42eb93a8f34afdc300628735b5f40a34c2) ) |
| r243409 | r243410 | |
| 6259 | 6261 | ROM_LOAD( "epr-12274.a10", 0x30000, 0x8000, CRC(8207f0c4) SHA1(169914861a52fa731a305e1ee2d230aa0d0d97fe) ) |
| 6260 | 6262 | ROM_LOAD( "epr-12275.a11", 0x40000, 0x8000, CRC(182f3c3d) SHA1(1482fe08a05a721e315b1a3aa5bef4dddc72e26e) ) |
| 6261 | 6263 | |
| 6262 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6263 | | ROM_LOAD( "317-0099.c2", 0x00000, 0x1000, CRC(f676e3e4) SHA1(b71bad46c8b5f7328fd8d48f18624a620f0d34ce) ) |
| 6264 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6265 | ROM_LOAD( "317-0099.bin", 0x00000, 0x1000, CRC(f676e3e4) SHA1(b71bad46c8b5f7328fd8d48f18624a620f0d34ce) ) |
| 6264 | 6266 | ROM_END |
| 6265 | 6267 | |
| 6266 | 6268 | |
| r243409 | r243410 | |
| 6294 | 6296 | ROM_REGION( 0x10000, "soundcpu", 0 ) // sound CPU |
| 6295 | 6297 | ROM_LOAD( "epr-12127.a10", 0x0000, 0x8000, CRC(0bb901bb) SHA1(c81b198df8e3b0ec568032c76addf0d1a1711194) ) |
| 6296 | 6298 | |
| 6297 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6298 | | ROM_LOAD( "317-0098.c2", 0x00000, 0x1000, NO_DUMP ) |
| 6299 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6300 | ROM_LOAD( "317-0098.bin", 0x00000, 0x1000, NO_DUMP ) |
| 6299 | 6301 | ROM_END |
| 6300 | 6302 | |
| 6301 | 6303 | |
| r243409 | r243410 | |
| 6384 | 6386 | ROM_START( wb32 ) |
| 6385 | 6387 | ROM_REGION( 0x40000, "maincpu", 0 ) // 68000 code |
| 6386 | 6388 | ROM_LOAD16_BYTE( "epr-12098.a1", 0x000001, 0x10000, CRC(d998e5e5) SHA1(a7398b7338a33451a650c2f1d382dad2e5130528) ) |
| 6387 | | ROM_LOAD16_BYTE( "epr-12100.a4", 0x000000, 0x10000, CRC(f5ca4abc) SHA1(1331db10cf99905fb13c1606a3f4d8bbf3d681b6) ) |
| 6389 | ROM_LOAD16_BYTE( "epr-12100.a6", 0x000000, 0x10000, CRC(f5ca4abc) SHA1(1331db10cf99905fb13c1606a3f4d8bbf3d681b6) ) |
| 6388 | 6390 | ROM_LOAD16_BYTE( "epr-12099.a2", 0x020001, 0x10000, CRC(3e243b45) SHA1(2a079553d1b61aaf18025847570003b79c8d6edf) ) |
| 6389 | 6391 | ROM_LOAD16_BYTE( "epr-12101.a5", 0x020000, 0x10000, CRC(6146492b) SHA1(93515578a6ccf770944fea86d2f3200fa08f5075) ) |
| 6390 | 6392 | |
| r243409 | r243410 | |
| 6468 | 6470 | ROM_LOAD( "mpr-12148.a11", 0x10000, 0x20000, CRC(fb9a7f29) SHA1(7ba79c18ab4e586be2deccd78e4479d55eb75a7e) ) |
| 6469 | 6471 | ROM_LOAD( "mpr-12149.a12", 0x30000, 0x20000, CRC(d6617b19) SHA1(aa36d257eaa52c8c871a39aaa2f29c203525dbaf) ) |
| 6470 | 6472 | |
| 6471 | | ROM_REGION( 0x1000, "mcu", 0 ) // Intel i8751 protection MCU |
| 6472 | | ROM_LOAD( "317-0103.c2", 0x00000, 0x1000, CRC(aa0710f5) SHA1(61ba8d23d045806b0a7b75184766be00f872cc72) ) |
| 6473 | ROM_REGION( 0x1000, "mcu", 0 ) // protection MCU |
| 6474 | ROM_LOAD( "317-0103.bin", 0x00000, 0x1000, CRC(aa0710f5) SHA1(61ba8d23d045806b0a7b75184766be00f872cc72) ) |
| 6473 | 6475 | ROM_END |
| 6474 | 6476 | |
| 6475 | 6477 | //************************************************************************************************************************* |
| r243409 | r243410 | |
| 6563 | 6565 | // Sega operated this game on actual System 16 PCBs for various events, |
| 6564 | 6566 | // it was also included in the PS2 Sega Ages collection Vol 33. |
| 6565 | 6567 | // Various bootlegs were sourced from this version. The dump will have to |
| 6566 | | // be verified if the official PCB ever gets into MAME-friendly hands. |
| 6568 | // be verified if the official PCB ever gets into MAME friendly hands. |
| 6567 | 6569 | // |
| 6568 | 6570 | // There is also a demo version of the game available on the PC, but |
| 6569 | 6571 | // attempting to use those ROMs on a real PCB / emulator will result |
trunk/src/mame/drivers/sidearms.c
| r243409 | r243410 | |
| 768 | 768 | ROM_LOAD( "63s081.3j", 0x0300, 0x0020, CRC(c5817816) SHA1(cc642daafa0bcb160ee04e74e2d168fd44087608) ) // unknown |
| 769 | 769 | ROM_END |
| 770 | 770 | |
| 771 | | ROM_START( sidearmsu ) |
| 771 | ROM_START( sidearmsr ) |
| 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 */ |
| 818 | 773 | ROM_LOAD( "03", 0x00000, 0x08000, CRC(9a799c45) SHA1(cf6836108506929ee2449546a4867a7cbf00bcc8) ) /* CODE */ |
| 819 | 774 | ROM_LOAD( "a_14e.rom", 0x10000, 0x08000, CRC(4925ed03) SHA1(b11dbd9889db89cff008ca21beb6b1b70d983e16) ) /* 0+1 */ |
| 820 | 775 | ROM_LOAD( "a_12e.rom", 0x18000, 0x08000, CRC(81d0ece7) SHA1(5c1d154f9c1de6b5f5d7abf5d413e9c493461e6f) ) /* 2+3 */ |
| r243409 | r243410 | |
| 1151 | 1106 | m_gameid = 3; |
| 1152 | 1107 | } |
| 1153 | 1108 | |
| 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 ) |
| 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 ) |
| 1162 | 1113 | GAME( 1988, turtshipj,turtship, turtship, turtship, sidearms_state, turtship, ROT0, "Philko (Pacific Games license)", "Turtle Ship (Japan)", 0 ) |
| 1163 | | GAME( 1988, turtshipk,turtship, turtship, turtship, sidearms_state, turtship, ROT0, "Philko", "Turtle Ship (Korea)", 0 ) |
| 1164 | | |
| 1114 | GAME( 1988, turtshipk,turtship, turtship, turtship, sidearms_state, turtship, ROT0, "Philko", "Turtle Ship (Korea)", 0 ) |
| 1165 | 1115 | GAME( 1989, dyger, 0, turtship, dyger, sidearms_state, dyger, ROT270, "Philko", "Dyger (Korea set 1)", 0 ) |
| 1166 | 1116 | GAME( 1989, dygera, dyger, turtship, dyger, sidearms_state, dyger, ROT270, "Philko", "Dyger (Korea set 2)", 0 ) |
| 1167 | | |
| 1168 | 1117 | GAME( 1989, twinfalc, 0, whizz, whizz, sidearms_state, whizz, ROT0, "Philko (Poara Enterprises license)", "Twin Falcons", 0 ) |
| 1169 | | GAME( 1989, whizz, twinfalc, whizz, whizz, sidearms_state, whizz, ROT0, "Philko", "Whizz", 0 ) |
| 1118 | GAME( 1989, whizz, twinfalc, whizz, whizz, sidearms_state, whizz, ROT0, "Philko", "Whizz", 0 ) |
trunk/src/mess/drivers/ti74.c
| r243409 | r243410 | |
| 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 | |
| r243409 | r243410 | |
| 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)") |
| r243409 | r243410 | |
| 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") |
| r243409 | r243410 | |
| 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") |
| r243409 | r243410 | |
| 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") |
| r243409 | r243410 | |
| 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") |
| r243409 | r243410 | |
| 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
| r243409 | r243410 | |
| 118 | 118 | |
| 119 | 119 | private: |
| 120 | 120 | Uint32 m_sdl_access; |
| 121 | | SDL_Renderer * m_sdl_renderer; |
| 121 | SDL_Renderer * m_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 |
| r243409 | r243410 | |
| 143 | 143 | { |
| 144 | 144 | public: |
| 145 | 145 | sdl_info13(sdl_window_info *w) |
| 146 | | : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL), |
| 146 | : osd_renderer(w), m_blittimer(0), m_renderer(NULL), |
| 147 | 147 | m_last_hofs(0), m_last_vofs(0), |
| 148 | | m_last_width(0), m_last_height(0), |
| 148 | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 149 | 149 | m_last_blit_time(0), m_last_blit_pixels(0) |
| 150 | 150 | {} |
| 151 | 151 | |
| 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); |
| 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); |
| 155 | 157 | /* virtual */ void destroy_all_textures(); |
| 156 | 158 | /* virtual */ void destroy(); |
| 157 | 159 | /* virtual */ void clear(); |
| r243409 | r243410 | |
| 162 | 164 | texture_info *texture_update(const render_primitive &prim); |
| 163 | 165 | |
| 164 | 166 | INT32 m_blittimer; |
| 167 | UINT32 m_extra_flags; |
| 165 | 168 | |
| 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; |
| 169 | SDL_Renderer * m_renderer; |
| 174 | 170 | simple_list<texture_info> m_texlist; // list of active textures |
| 175 | 171 | |
| 176 | 172 | float m_last_hofs; |
| 177 | 173 | float m_last_vofs; |
| 178 | 174 | |
| 179 | | int m_last_width; |
| 180 | | int m_last_height; |
| 175 | // resize information |
| 181 | 176 | |
| 177 | UINT8 m_resize_pending; |
| 178 | UINT32 m_resize_width; |
| 179 | UINT32 m_resize_height; |
| 180 | |
| 182 | 181 | // Stats |
| 183 | 182 | INT64 m_last_blit_time; |
| 184 | 183 | INT64 m_last_blit_pixels; |
| 184 | |
| 185 | // Original display_mode |
| 186 | SDL_DisplayMode m_original_mode; |
| 185 | 187 | }; |
| 186 | 188 | |
| 187 | 189 | struct copy_info_t { |
| r243409 | r243410 | |
| 200 | 202 | copy_info_t *next; |
| 201 | 203 | }; |
| 202 | 204 | |
| 203 | | |
| 204 | 205 | //============================================================ |
| 205 | 206 | // PROTOTYPES |
| 206 | 207 | //============================================================ |
| r243409 | r243410 | |
| 385 | 386 | |
| 386 | 387 | SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); |
| 387 | 388 | set_coloralphamode(m_texture_id, &prim->color); |
| 388 | | SDL_RenderCopy(m_sdl_renderer, m_texture_id, NULL, &target_rect); |
| 389 | SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); |
| 389 | 390 | } |
| 390 | 391 | |
| 391 | 392 | void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) |
| r243409 | r243410 | |
| 419 | 420 | UINT32 sb = (UINT32)(255.0f * prim->color.b); |
| 420 | 421 | UINT32 sa = (UINT32)(255.0f * prim->color.a); |
| 421 | 422 | |
| 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); |
| 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); |
| 425 | 426 | } |
| 426 | 427 | } |
| 427 | 428 | |
| r243409 | r243410 | |
| 453 | 454 | } |
| 454 | 455 | |
| 455 | 456 | //============================================================ |
| 456 | | // drawsdl_init |
| 457 | // drawsdl2_init |
| 457 | 458 | //============================================================ |
| 458 | 459 | |
| 459 | 460 | static void add_list(copy_info_t **head, copy_info_t *element, Uint32 bm) |
| r243409 | r243410 | |
| 517 | 518 | else |
| 518 | 519 | osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); |
| 519 | 520 | |
| 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 | |
| 520 | 534 | return 0; |
| 521 | 535 | } |
| 522 | 536 | |
| 523 | 537 | |
| 524 | 538 | //============================================================ |
| 525 | | // drawsdl_exit |
| 539 | // drawsdl2_exit |
| 526 | 540 | //============================================================ |
| 527 | 541 | |
| 528 | 542 | static void drawsdl2_exit(void) |
| r243409 | r243410 | |
| 572 | 586 | // a |
| 573 | 587 | //============================================================ |
| 574 | 588 | |
| 575 | | int sdl_info13::create() |
| 589 | int sdl_info13::create(int width, int height) |
| 576 | 590 | { |
| 577 | | #if (SDLMAME_SDL2) |
| 578 | | // create renderer |
| 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 | */ |
| 579 | 597 | |
| 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) |
| 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 ) |
| 585 | 613 | { |
| 586 | | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); |
| 614 | osd_printf_error("Window creation failed: %s\n", SDL_GetError()); |
| 615 | return 1; |
| 587 | 616 | } |
| 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 | } |
| 588 | 638 | else |
| 589 | 639 | { |
| 590 | | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); |
| 640 | //SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop |
| 591 | 641 | } |
| 642 | // create renderer |
| 592 | 643 | |
| 593 | 644 | if (video_config.waitvsync) |
| 594 | | m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 645 | m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 595 | 646 | else |
| 596 | | m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_ACCELERATED); |
| 647 | m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED); |
| 597 | 648 | |
| 598 | | if (!m_sdl_renderer) |
| 649 | if (!m_renderer) |
| 599 | 650 | { |
| 600 | 651 | fatalerror("Error on creating renderer: %s\n", SDL_GetError()); |
| 601 | 652 | } |
| 602 | 653 | |
| 603 | 654 | //SDL_SelectRenderer(window().sdl_window); |
| 604 | 655 | |
| 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 | |
| 605 | 664 | m_blittimer = 3; |
| 606 | 665 | |
| 607 | | SDL_RenderPresent(m_sdl_renderer); |
| 666 | SDL_RenderPresent(m_renderer); |
| 608 | 667 | osd_printf_verbose("Leave sdl_info13::create\n"); |
| 609 | | |
| 610 | | #else |
| 611 | | |
| 612 | | #endif |
| 613 | 668 | return 0; |
| 614 | 669 | } |
| 615 | 670 | |
| 616 | | |
| 617 | 671 | //============================================================ |
| 618 | | // sdl_info::destroy |
| 672 | // sdl_info::resize |
| 619 | 673 | //============================================================ |
| 620 | 674 | |
| 621 | | void sdl_info13::destroy() |
| 675 | void sdl_info13::resize(int width, int height) |
| 622 | 676 | { |
| 623 | | destroy_all_textures(); |
| 624 | | } |
| 677 | m_resize_pending = 1; |
| 678 | m_resize_height = height; |
| 679 | m_resize_width = width; |
| 625 | 680 | |
| 626 | | //============================================================ |
| 627 | | // sdl_info::clear |
| 628 | | //============================================================ |
| 681 | window().m_width = width; |
| 682 | window().m_height = height; |
| 629 | 683 | |
| 630 | | void sdl_info13::clear() |
| 631 | | { |
| 632 | | m_blittimer = 2; |
| 684 | m_blittimer = 3; |
| 685 | |
| 633 | 686 | } |
| 634 | 687 | |
| 635 | | |
| 636 | 688 | //============================================================ |
| 637 | 689 | // drawsdl_xy_to_render_target |
| 638 | 690 | //============================================================ |
| r243409 | r243410 | |
| 642 | 694 | |
| 643 | 695 | *xt = x - m_last_hofs; |
| 644 | 696 | *yt = y - m_last_vofs; |
| 645 | | if (*xt<0 || *xt >= window().blitwidth()) |
| 697 | if (*xt<0 || *xt >= window().m_blitwidth) |
| 646 | 698 | return 0; |
| 647 | | if (*yt<0 || *yt >= window().blitheight()) |
| 699 | if (*yt<0 || *yt >= window().m_blitheight) |
| 648 | 700 | return 0; |
| 649 | 701 | return 1; |
| 650 | 702 | } |
| 651 | 703 | |
| 652 | 704 | //============================================================ |
| 653 | | // drawsdl_destroy_all_textures |
| 705 | // sdl_info::get_primitives |
| 654 | 706 | //============================================================ |
| 655 | 707 | |
| 656 | | void sdl_info13::destroy_all_textures() |
| 708 | void sdl_info13::set_target_bounds() |
| 657 | 709 | { |
| 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(); |
| 710 | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 666 | 711 | } |
| 667 | 712 | |
| 668 | 713 | //============================================================ |
| r243409 | r243410 | |
| 681 | 726 | return 0; |
| 682 | 727 | } |
| 683 | 728 | |
| 684 | | if ((window().width() != m_last_width) || (window().height() != m_last_height)) |
| 729 | if (m_resize_pending) |
| 685 | 730 | { |
| 686 | | m_last_width = window().width(); |
| 687 | | m_last_height = window().height(); |
| 688 | | SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 689 | | m_blittimer = 3; |
| 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 | |
| 690 | 737 | } |
| 738 | |
| 691 | 739 | //SDL_SelectRenderer(window().sdl_window); |
| 692 | 740 | |
| 693 | 741 | if (m_blittimer > 0) |
| 694 | 742 | { |
| 695 | 743 | /* SDL Underlays need alpha = 0 ! */ |
| 696 | | SDL_SetRenderDrawBlendMode(m_sdl_renderer, SDL_BLENDMODE_NONE); |
| 744 | SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE); |
| 697 | 745 | //SDL_SetRenderDrawColor(0,0,0,255); |
| 698 | | SDL_SetRenderDrawColor(m_sdl_renderer, 0,0,0,0); |
| 699 | | SDL_RenderFillRect(m_sdl_renderer, NULL); |
| 746 | SDL_SetRenderDrawColor(m_renderer, 0,0,0,0); |
| 747 | SDL_RenderFillRect(m_renderer, NULL); |
| 700 | 748 | m_blittimer--; |
| 701 | 749 | } |
| 702 | 750 | |
| r243409 | r243410 | |
| 714 | 762 | } |
| 715 | 763 | else |
| 716 | 764 | { |
| 717 | | ch = window().height(); |
| 718 | | cw = window().width(); |
| 765 | ch = window().m_height; |
| 766 | cw = window().m_width; |
| 719 | 767 | } |
| 720 | 768 | |
| 721 | 769 | if (video_config.centerv) |
| 722 | 770 | { |
| 723 | | vofs = (ch - window().blitheight()) / 2.0f; |
| 771 | vofs = (ch - window().m_blitheight) / 2.0f; |
| 724 | 772 | } |
| 725 | 773 | if (video_config.centerh) |
| 726 | 774 | { |
| 727 | | hofs = (cw - window().blitwidth()) / 2.0f; |
| 775 | hofs = (cw - window().m_blitwidth) / 2.0f; |
| 728 | 776 | } |
| 729 | 777 | } |
| 730 | 778 | |
| r243409 | r243410 | |
| 746 | 794 | sb = (int)(255.0f * prim->color.b); |
| 747 | 795 | sa = (int)(255.0f * prim->color.a); |
| 748 | 796 | |
| 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, |
| 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, |
| 752 | 800 | prim->bounds.x1 + hofs, prim->bounds.y1 + vofs); |
| 753 | 801 | break; |
| 754 | 802 | case render_primitive::QUAD: |
| r243409 | r243410 | |
| 768 | 816 | |
| 769 | 817 | m_last_blit_pixels = blit_pixels; |
| 770 | 818 | m_last_blit_time = -osd_ticks(); |
| 771 | | SDL_RenderPresent(m_sdl_renderer); |
| 819 | SDL_RenderPresent(m_renderer); |
| 772 | 820 | m_last_blit_time += osd_ticks(); |
| 773 | 821 | |
| 774 | 822 | return 0; |
| r243409 | r243410 | |
| 776 | 824 | |
| 777 | 825 | |
| 778 | 826 | //============================================================ |
| 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 | //============================================================ |
| 779 | 858 | // texture handling |
| 780 | 859 | //============================================================ |
| 781 | 860 | |
| r243409 | r243410 | |
| 794 | 873 | if ((m_is_rotated == bi->blitter->m_is_rot) |
| 795 | 874 | && (m_sdl_blendmode == bi->bm_mask)) |
| 796 | 875 | { |
| 797 | | if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 876 | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 798 | 877 | { |
| 799 | 878 | int perf = bi->perf; |
| 800 | 879 | if (perf == 0) |
| r243409 | r243410 | |
| 814 | 893 | { |
| 815 | 894 | if ((m_is_rotated == bi->blitter->m_is_rot) |
| 816 | 895 | && (m_sdl_blendmode == bi->bm_mask)) |
| 817 | | if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 896 | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 818 | 897 | return bi; |
| 819 | 898 | } |
| 820 | 899 | //FIXME: crash implement a -do nothing handler */ |
| r243409 | r243410 | |
| 852 | 931 | texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags) |
| 853 | 932 | { |
| 854 | 933 | // fill in the core data |
| 855 | | m_sdl_renderer = renderer; |
| 934 | m_renderer = renderer; |
| 856 | 935 | m_hash = texture_compute_hash(texsource, flags); |
| 857 | 936 | m_flags = flags; |
| 858 | 937 | m_texinfo = texsource; |
| r243409 | r243410 | |
| 901 | 980 | |
| 902 | 981 | m_copyinfo = compute_size_type(); |
| 903 | 982 | |
| 904 | | m_texture_id = SDL_CreateTexture(m_sdl_renderer, m_copyinfo->dst_fmt, m_sdl_access, |
| 983 | m_texture_id = SDL_CreateTexture(m_renderer, m_copyinfo->dst_fmt, m_sdl_access, |
| 905 | 984 | m_setup.rotwidth, m_setup.rotheight); |
| 906 | 985 | |
| 907 | 986 | if (!m_texture_id) |
| r243409 | r243410 | |
| 1074 | 1153 | // if we didn't find one, create a new texture |
| 1075 | 1154 | if (texture == NULL && prim.texture.base != NULL) |
| 1076 | 1155 | { |
| 1077 | | texture = global_alloc(texture_info(m_sdl_renderer, prim.texture, setup, prim.flags)); |
| 1156 | texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags)); |
| 1078 | 1157 | /* add us to the texture list */ |
| 1079 | 1158 | m_texlist.prepend(*texture); |
| 1080 | 1159 | |
| r243409 | r243410 | |
| 1093 | 1172 | return texture; |
| 1094 | 1173 | } |
| 1095 | 1174 | |
| 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
| r243409 | r243410 | |
| 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 width, GLsizei height); |
| 61 | typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum m_target, GLenum internalformat, GLsizei m_width, GLsizei m_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 |
| r243409 | r243410 | |
| 156 | 156 | // TYPES |
| 157 | 157 | //============================================================ |
| 158 | 158 | |
| 159 | | //============================================================ |
| 160 | | // Textures |
| 161 | | //============================================================ |
| 159 | struct texture_info; |
| 162 | 160 | |
| 163 | 161 | /* texture_info holds information about a texture */ |
| 164 | | class texture_info |
| 162 | struct texture_info |
| 165 | 163 | { |
| 166 | | public: |
| 167 | 164 | texture_info() |
| 168 | | : hash(0), flags(0), rawwidth(0), rawheight(0), |
| 165 | : hash(0), flags(0), rawwidth(0), rawheight(0), |
| 169 | 166 | rawwidth_create(0), rawheight_create(0), |
| 170 | 167 | type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0), |
| 171 | 168 | texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL), |
| r243409 | r243410 | |
| 222 | 219 | { |
| 223 | 220 | public: |
| 224 | 221 | sdl_info_ogl(sdl_window_info *window) |
| 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), |
| 222 | : osd_renderer(window), m_blittimer(0), m_extra_flags(0), |
| 228 | 223 | #if (SDLMAME_SDL2) |
| 229 | 224 | m_gl_context_id(0), |
| 230 | 225 | #else |
| 226 | m_sdlsurf(NULL), |
| 231 | 227 | #endif |
| 232 | 228 | m_initialized(0), |
| 233 | 229 | m_last_blendmode(0), |
| r243409 | r243410 | |
| 252 | 248 | m_texVerticex[i] = 0.0f; |
| 253 | 249 | } |
| 254 | 250 | |
| 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); |
| 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); |
| 258 | 256 | /* virtual */ void destroy_all_textures(); |
| 259 | 257 | /* virtual */ void destroy(); |
| 260 | 258 | /* virtual */ void clear(); |
| r243409 | r243410 | |
| 278 | 276 | void texture_all_disable(); |
| 279 | 277 | |
| 280 | 278 | INT32 m_blittimer; |
| 281 | | int m_screen_width; |
| 282 | | int m_screen_height; |
| 283 | | int m_last_width; |
| 284 | | int m_last_height; |
| 279 | UINT32 m_extra_flags; |
| 285 | 280 | |
| 281 | |
| 286 | 282 | #if (SDLMAME_SDL2) |
| 283 | // Original display_mode |
| 284 | SDL_DisplayMode m_original_mode; |
| 285 | |
| 287 | 286 | SDL_GLContext m_gl_context_id; |
| 288 | 287 | #else |
| 288 | // SDL surface |
| 289 | SDL_Surface *m_sdlsurf; |
| 289 | 290 | #endif |
| 290 | 291 | |
| 291 | 292 | int m_initialized; // is everything well initialized, i.e. all GL stuff etc. |
| r243409 | r243410 | |
| 392 | 393 | |
| 393 | 394 | // core functions |
| 394 | 395 | |
| 395 | | //============================================================ |
| 396 | | // STATIC VARIABLES |
| 397 | | //============================================================ |
| 398 | | |
| 399 | 396 | static void drawogl_exit(void); |
| 400 | 397 | static void load_gl_lib(running_machine &machine); |
| 401 | 398 | |
| r243409 | r243410 | |
| 443 | 440 | static int dll_loaded = 0; |
| 444 | 441 | |
| 445 | 442 | //============================================================ |
| 446 | | // drawsdl_init |
| 443 | // drawogl_init |
| 447 | 444 | //============================================================ |
| 448 | 445 | |
| 449 | 446 | static osd_renderer *drawogl_create(sdl_window_info *window) |
| r243409 | r243410 | |
| 459 | 456 | |
| 460 | 457 | dll_loaded = 0; |
| 461 | 458 | |
| 462 | | load_gl_lib(machine); |
| 463 | 459 | if (SDLMAME_SDL2) |
| 464 | 460 | { |
| 465 | 461 | osd_printf_verbose("Using SDL multi-window OpenGL driver (SDL 2.0+)\n"); |
| 462 | load_gl_lib(machine); |
| 466 | 463 | } |
| 467 | 464 | else |
| 468 | 465 | osd_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n"); |
| r243409 | r243410 | |
| 711 | 708 | // a |
| 712 | 709 | //============================================================ |
| 713 | 710 | |
| 714 | | int sdl_info_ogl::create() |
| 711 | int sdl_info_ogl::create(int width, int height) |
| 715 | 712 | { |
| 713 | #if (SDLMAME_SDL2) |
| 716 | 714 | |
| 717 | | #if (SDLMAME_SDL2) |
| 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 | } |
| 718 | 774 | // create renderer |
| 719 | 775 | |
| 720 | | m_gl_context_id = SDL_GL_CreateContext(window().sdl_window()); |
| 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); |
| 721 | 788 | if (!m_gl_context_id) |
| 722 | 789 | { |
| 723 | 790 | osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); |
| r243409 | r243410 | |
| 727 | 794 | SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0); |
| 728 | 795 | |
| 729 | 796 | #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 | |
| 730 | 829 | #endif |
| 731 | 830 | |
| 732 | | m_screen_width = 0; |
| 733 | | m_screen_height = 0; |
| 734 | | |
| 735 | 831 | m_blittimer = 0; |
| 736 | 832 | m_surf_w = 0; |
| 737 | 833 | m_surf_h = 0; |
| r243409 | r243410 | |
| 756 | 852 | return 0; |
| 757 | 853 | } |
| 758 | 854 | |
| 759 | | |
| 760 | 855 | //============================================================ |
| 761 | | // sdl_info::destroy |
| 856 | // sdl_info::resize |
| 762 | 857 | //============================================================ |
| 763 | 858 | |
| 764 | | void sdl_info_ogl::destroy() |
| 859 | void sdl_info_ogl::resize(int width, int height) |
| 765 | 860 | { |
| 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); |
| 766 | 868 | |
| 767 | | // free the memory in the window |
| 869 | m_sdlsurf = SDL_SetVideoMode(width, height, 0, |
| 870 | SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags); |
| 768 | 871 | |
| 769 | | destroy_all_textures(); |
| 770 | | |
| 771 | | #if (SDLMAME_SDL2) |
| 772 | | SDL_GL_DeleteContext(m_gl_context_id); |
| 872 | window().m_width = m_sdlsurf->w; |
| 873 | window().m_height = m_sdlsurf->h; |
| 773 | 874 | #endif |
| 875 | m_init_context = 1; |
| 774 | 876 | |
| 775 | 877 | } |
| 776 | 878 | |
| 777 | 879 | //============================================================ |
| 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 | | //============================================================ |
| 788 | 880 | // drawsdl_xy_to_render_target |
| 789 | 881 | //============================================================ |
| 790 | 882 | |
| 791 | 883 | int sdl_info_ogl::xy_to_render_target(int x, int y, int *xt, int *yt) |
| 792 | 884 | { |
| 793 | | |
| 794 | 885 | *xt = x - m_last_hofs; |
| 795 | 886 | *yt = y - m_last_vofs; |
| 796 | | if (*xt<0 || *xt >= window().blitwidth()) |
| 887 | if (*xt<0 || *xt >= window().m_blitwidth) |
| 797 | 888 | return 0; |
| 798 | | if (*yt<0 || *yt >= window().blitheight()) |
| 889 | if (*yt<0 || *yt >= window().m_blitheight) |
| 799 | 890 | return 0; |
| 800 | 891 | return 1; |
| 801 | 892 | } |
| 802 | 893 | |
| 803 | 894 | //============================================================ |
| 804 | | // drawsdl_destroy_all_textures |
| 895 | // sdl_info::get_primitives |
| 805 | 896 | //============================================================ |
| 806 | 897 | |
| 807 | | void sdl_info_ogl::destroy_all_textures() |
| 898 | void sdl_info_ogl::set_target_bounds() |
| 808 | 899 | { |
| 809 | | texture_info *texture = NULL; |
| 810 | | int lock=FALSE; |
| 811 | | int i; |
| 900 | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 901 | } |
| 812 | 902 | |
| 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 | | } |
| 887 | 903 | //============================================================ |
| 888 | 904 | // loadGLExtensions |
| 889 | 905 | //============================================================ |
| r243409 | r243410 | |
| 1102 | 1118 | |
| 1103 | 1119 | if ( m_useglsl ) |
| 1104 | 1120 | { |
| 1105 | | if ( window().prescale() != 1 ) |
| 1121 | if ( window().m_prescale != 1 ) |
| 1106 | 1122 | { |
| 1107 | 1123 | m_useglsl = 0; |
| 1108 | 1124 | if (_once) |
| r243409 | r243410 | |
| 1195 | 1211 | } |
| 1196 | 1212 | |
| 1197 | 1213 | //============================================================ |
| 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 | //============================================================ |
| 1198 | 1244 | // sdl_info::draw |
| 1199 | 1245 | //============================================================ |
| 1200 | 1246 | |
| r243409 | r243410 | |
| 1211 | 1257 | return 0; |
| 1212 | 1258 | } |
| 1213 | 1259 | |
| 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(); |
| 1218 | 1260 | #if (SDLMAME_SDL2) |
| 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); |
| 1261 | SDL_GL_MakeCurrent(window().m_sdl_window, m_gl_context_id); |
| 1226 | 1262 | #else |
| 1227 | 1263 | if (!m_init_context) |
| 1228 | 1264 | { |
| r243409 | r243410 | |
| 1231 | 1267 | { |
| 1232 | 1268 | if (window().index() == 0) |
| 1233 | 1269 | { |
| 1234 | | if ((screen->width() != m_screen_width) || (screen->height() != m_screen_height)) |
| 1270 | if ((screen->width() != window().m_screen_width) || (screen->height() != window().m_screen_height)) |
| 1235 | 1271 | { |
| 1236 | | m_screen_width = screen->width(); |
| 1237 | | m_screen_height = screen->height(); |
| 1272 | window().m_screen_width = screen->width(); |
| 1273 | window().m_screen_height = screen->height(); |
| 1238 | 1274 | |
| 1239 | 1275 | // force all textures to be regenerated |
| 1240 | 1276 | destroy_all_textures(); |
| r243409 | r243410 | |
| 1285 | 1321 | } |
| 1286 | 1322 | |
| 1287 | 1323 | if ( !m_initialized || |
| 1288 | | window().width()!= m_surf_w || window().height()!= m_surf_h ) |
| 1324 | window().m_width!= m_surf_w || window().m_height!= m_surf_h ) |
| 1289 | 1325 | { |
| 1290 | 1326 | if ( !m_initialized ) |
| 1291 | 1327 | { |
| 1292 | 1328 | loadGLExtensions(); |
| 1293 | 1329 | } |
| 1294 | 1330 | |
| 1295 | | m_surf_w=window().width(); |
| 1296 | | m_surf_h=window().height(); |
| 1331 | m_surf_w=window().m_width; |
| 1332 | m_surf_h=window().m_height; |
| 1297 | 1333 | |
| 1298 | 1334 | // we're doing nothing 3d, so the Z-buffer is currently not interesting |
| 1299 | 1335 | glDisable(GL_DEPTH_TEST); |
| r243409 | r243410 | |
| 1334 | 1370 | // |_________| |
| 1335 | 1371 | // (0,h) (w,h) |
| 1336 | 1372 | |
| 1337 | | glViewport(0.0, 0.0, (GLsizei)window().width(), (GLsizei)window().height()); |
| 1373 | glViewport(0.0, 0.0, (GLsizei)window().m_width, (GLsizei)window().m_height); |
| 1338 | 1374 | glMatrixMode(GL_PROJECTION); |
| 1339 | 1375 | glLoadIdentity(); |
| 1340 | | glOrtho(0.0, (GLdouble)window().width(), (GLdouble)window().height(), 0.0, 0.0, -1.0); |
| 1376 | glOrtho(0.0, (GLdouble)window().m_width, (GLdouble)window().m_height, 0.0, 0.0, -1.0); |
| 1341 | 1377 | glMatrixMode(GL_MODELVIEW); |
| 1342 | 1378 | glLoadIdentity(); |
| 1343 | 1379 | |
| r243409 | r243410 | |
| 1364 | 1400 | } |
| 1365 | 1401 | else |
| 1366 | 1402 | { |
| 1367 | | ch = window().height(); |
| 1368 | | cw = window().width(); |
| 1403 | ch = window().m_height; |
| 1404 | cw = window().m_width; |
| 1369 | 1405 | } |
| 1370 | 1406 | |
| 1371 | 1407 | if (video_config.centerv) |
| 1372 | 1408 | { |
| 1373 | | vofs = (ch - window().blitheight()) / 2.0f; |
| 1409 | vofs = (ch - window().m_blitheight) / 2.0f; |
| 1374 | 1410 | } |
| 1375 | 1411 | if (video_config.centerh) |
| 1376 | 1412 | { |
| 1377 | | hofs = (cw - window().blitwidth()) / 2.0f; |
| 1413 | hofs = (cw - window().m_blitwidth) / 2.0f; |
| 1378 | 1414 | } |
| 1379 | 1415 | } |
| 1380 | 1416 | |
| r243409 | r243410 | |
| 1450 | 1486 | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1451 | 1487 | |
| 1452 | 1488 | // compute the effective width based on the direction of the line |
| 1453 | | effwidth = prim->width(); |
| 1489 | effwidth = prim->m_width; |
| 1454 | 1490 | if (effwidth < 0.5f) |
| 1455 | 1491 | effwidth = 0.5f; |
| 1456 | 1492 | |
| r243409 | r243410 | |
| 1555 | 1591 | // 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1) on texture dimensions |
| 1556 | 1592 | m_texVerticex[0]=(GLfloat)0.0; |
| 1557 | 1593 | m_texVerticex[1]=(GLfloat)0.0; |
| 1558 | | m_texVerticex[2]=(GLfloat)window().width(); |
| 1594 | m_texVerticex[2]=(GLfloat)window().m_width; |
| 1559 | 1595 | m_texVerticex[3]=(GLfloat)0.0; |
| 1560 | | m_texVerticex[4]=(GLfloat)window().width(); |
| 1561 | | m_texVerticex[5]=(GLfloat)window().height(); |
| 1596 | m_texVerticex[4]=(GLfloat)window().m_width; |
| 1597 | m_texVerticex[5]=(GLfloat)window().m_height; |
| 1562 | 1598 | m_texVerticex[6]=(GLfloat)0.0; |
| 1563 | | m_texVerticex[7]=(GLfloat)window().height(); |
| 1599 | m_texVerticex[7]=(GLfloat)window().m_height; |
| 1564 | 1600 | } |
| 1565 | 1601 | |
| 1566 | 1602 | if(i>0) // first fetch already done |
| r243409 | r243410 | |
| 1606 | 1642 | #if (!SDLMAME_SDL2) |
| 1607 | 1643 | SDL_GL_SwapBuffers(); |
| 1608 | 1644 | #else |
| 1609 | | SDL_GL_SwapWindow(window().sdl_window()); |
| 1645 | SDL_GL_SwapWindow(window().m_sdl_window); |
| 1610 | 1646 | #endif |
| 1611 | 1647 | return 0; |
| 1612 | 1648 | } |
| r243409 | r243410 | |
| 1764 | 1800 | texture->xprescale--; |
| 1765 | 1801 | while (texture->yprescale > 1 && height_create * texture->yprescale > m_texture_max_height) |
| 1766 | 1802 | 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); |
| 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); |
| 1769 | 1805 | |
| 1770 | 1806 | width *= texture->xprescale; |
| 1771 | 1807 | height *= texture->yprescale; |
| r243409 | r243410 | |
| 1944 | 1980 | { |
| 1945 | 1981 | int uniform_location; |
| 1946 | 1982 | int i; |
| 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); |
| 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); |
| 1949 | 1985 | |
| 1950 | 1986 | assert ( texture->type==TEXTURE_TYPE_SHADER ); |
| 1951 | 1987 | |
| r243409 | r243410 | |
| 1992 | 2028 | pfn_glUniform2fvARB(uniform_location, 1, &(color_texture_pow2_sz[0])); |
| 1993 | 2029 | GL_CHECK_ERROR_NORMAL(); |
| 1994 | 2030 | |
| 1995 | | GLfloat screen_texture_sz[2] = { (GLfloat)window().blitwidth(), (GLfloat)window().blitheight() }; |
| 2031 | GLfloat screen_texture_sz[2] = { (GLfloat)window().m_blitwidth, (GLfloat)window().m_blitheight }; |
| 1996 | 2032 | uniform_location = pfn_glGetUniformLocationARB(m_glsl_program[i], "screen_texture_sz"); |
| 1997 | 2033 | pfn_glUniform2fvARB(uniform_location, 1, &(screen_texture_sz[0])); |
| 1998 | 2034 | GL_CHECK_ERROR_NORMAL(); |
| r243409 | r243410 | |
| 2048 | 2084 | } |
| 2049 | 2085 | |
| 2050 | 2086 | osd_printf_verbose("GL texture: mpass screen-bmp 2x %dx%d (pow2 %dx%d)\n", |
| 2051 | | window().width(), window().height(), surf_w_pow2, surf_h_pow2); |
| 2087 | window().m_width, window().m_height, surf_w_pow2, surf_h_pow2); |
| 2052 | 2088 | } |
| 2053 | 2089 | |
| 2054 | 2090 | // GL_TEXTURE0 |
| r243409 | r243410 | |
| 2127 | 2163 | texture->texinfo.seqid = -1; // force set data |
| 2128 | 2164 | if (PRIMFLAG_GET_SCREENTEX(flags)) |
| 2129 | 2165 | { |
| 2130 | | texture->xprescale = window().prescale(); |
| 2131 | | texture->yprescale = window().prescale(); |
| 2166 | texture->xprescale = window().m_prescale; |
| 2167 | texture->yprescale = window().m_prescale; |
| 2132 | 2168 | } |
| 2133 | 2169 | else |
| 2134 | 2170 | { |
| r243409 | r243410 | |
| 2758 | 2794 | } |
| 2759 | 2795 | else if ( texture->type == TEXTURE_TYPE_SHADER && shaderIdx>m_glsl_program_mb2sc ) |
| 2760 | 2796 | { |
| 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); |
| 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); |
| 2763 | 2799 | |
| 2764 | | ustop = (float)(window().width()) / (float)surf_w_pow2; |
| 2765 | | vstop = (float)(window().height()) / (float)surf_h_pow2; |
| 2800 | ustop = (float)(window().m_width) / (float)surf_w_pow2; |
| 2801 | vstop = (float)(window().m_height) / (float)surf_h_pow2; |
| 2766 | 2802 | } |
| 2767 | 2803 | else |
| 2768 | 2804 | { |
| r243409 | r243410 | |
| 3050 | 3086 | } |
| 3051 | 3087 | } |
| 3052 | 3088 | |
| 3089 | void sdl_info_ogl::destroy_all_textures() |
| 3090 | { |
| 3091 | texture_info *texture = NULL; |
| 3092 | int lock=FALSE; |
| 3093 | int i; |
| 3053 | 3094 | |
| 3095 | if ( !m_initialized ) |
| 3096 | return; |
| 3054 | 3097 | |
| 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
| r243409 | r243410 | |
| 50 | 50 | { |
| 51 | 51 | public: |
| 52 | 52 | |
| 53 | | sdl_info(sdl_window_info *w, int extra_flags) |
| 54 | | : osd_renderer(w, extra_flags), |
| 53 | sdl_info(sdl_window_info *w) |
| 54 | : osd_renderer(w), |
| 55 | m_blittimer(0), |
| 56 | m_extra_flags(0), |
| 57 | |
| 55 | 58 | #if (SDLMAME_SDL2) |
| 56 | 59 | m_sdl_renderer(NULL), |
| 57 | 60 | m_texture_id(NULL), |
| 58 | 61 | #else |
| 62 | m_sdlsurf(NULL), |
| 59 | 63 | m_yuvsurf(NULL), |
| 60 | 64 | #endif |
| 61 | 65 | m_yuv_lookup(NULL), |
| r243409 | r243410 | |
| 65 | 69 | m_last_hofs(0), |
| 66 | 70 | m_last_vofs(0), |
| 67 | 71 | m_old_blitwidth(0), |
| 68 | | m_old_blitheight(0), |
| 69 | | m_last_width(0), |
| 70 | | m_last_height(0) |
| 72 | m_old_blitheight(0) |
| 71 | 73 | { } |
| 72 | 74 | |
| 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); |
| 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); |
| 76 | 80 | /* virtual */ void destroy_all_textures(); |
| 77 | 81 | /* virtual */ void destroy(); |
| 78 | 82 | /* virtual */ void clear(); |
| r243409 | r243410 | |
| 89 | 93 | #endif |
| 90 | 94 | |
| 91 | 95 | INT32 m_blittimer; |
| 96 | UINT32 m_extra_flags; |
| 92 | 97 | |
| 93 | 98 | #if (SDLMAME_SDL2) |
| 99 | // Original display_mode |
| 100 | SDL_DisplayMode m_original_mode; |
| 101 | |
| 94 | 102 | SDL_Renderer *m_sdl_renderer; |
| 95 | 103 | SDL_Texture *m_texture_id; |
| 96 | 104 | #else |
| 105 | // SDL surface |
| 106 | SDL_Surface *m_sdlsurf; |
| 97 | 107 | SDL_Overlay *m_yuvsurf; |
| 98 | 108 | #endif |
| 99 | 109 | |
| r243409 | r243410 | |
| 108 | 118 | int m_last_vofs; |
| 109 | 119 | int m_old_blitwidth; |
| 110 | 120 | int m_old_blitheight; |
| 111 | | int m_last_width; |
| 112 | | int m_last_height; |
| 113 | 121 | }; |
| 114 | 122 | |
| 115 | 123 | struct sdl_scale_mode |
| r243409 | r243410 | |
| 157 | 165 | |
| 158 | 166 | static const sdl_scale_mode scale_modes[] = |
| 159 | 167 | { |
| 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 }, |
| 168 | { "none", 0, 0, 1, 1, SDL_DOUBLEBUF, 0, 0 }, |
| 169 | { "async", 0, 0, 1, 1, SDL_DOUBLEBUF | SDL_ASYNCBLIT, 0, 0 }, |
| 162 | 170 | { "yv12", 1, 1, 1, 1, 0, SDL_YV12_OVERLAY, yuv_RGB_to_YV12 }, |
| 163 | 171 | { "yv12x2", 1, 1, 2, 2, 0, SDL_YV12_OVERLAY, yuv_RGB_to_YV12X2 }, |
| 164 | 172 | { "yuy2", 1, 1, 1, 1, 0, SDL_YUY2_OVERLAY, yuv_RGB_to_YUY2 }, |
| r243409 | r243410 | |
| 171 | 179 | { "none", 0, 0, 1, 1, DRAW2_SCALEMODE_NEAREST, 0, 0 }, |
| 172 | 180 | { "hwblit", 1, 0, 1, 1, DRAW2_SCALEMODE_LINEAR, 0, 0 }, |
| 173 | 181 | { "hwbest", 1, 0, 1, 1, DRAW2_SCALEMODE_BEST, 0, 0 }, |
| 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 }, |
| 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 }, |
| 179 | 186 | { NULL } |
| 180 | 187 | }; |
| 181 | 188 | #endif |
| r243409 | r243410 | |
| 214 | 221 | return -1; |
| 215 | 222 | } |
| 216 | 223 | |
| 224 | //============================================================ |
| 225 | // drawsdl_init |
| 226 | //============================================================ |
| 217 | 227 | |
| 218 | 228 | static osd_renderer *drawsdl_create(sdl_window_info *window) |
| 219 | 229 | { |
| 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 |
| 230 | return global_alloc(sdl_info(window)); |
| 227 | 231 | } |
| 228 | 232 | |
| 229 | | //============================================================ |
| 230 | | // drawsdl_init |
| 231 | | //============================================================ |
| 232 | 233 | |
| 233 | 234 | int drawsdl_init(sdl_draw_info *callbacks) |
| 234 | 235 | { |
| r243409 | r243410 | |
| 253 | 254 | } |
| 254 | 255 | |
| 255 | 256 | //============================================================ |
| 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 | //============================================================ |
| 256 | 266 | // setup_texture for window |
| 257 | 267 | //============================================================ |
| 258 | 268 | |
| r243409 | r243410 | |
| 279 | 289 | int m_hw_scale_width =0; |
| 280 | 290 | int m_hw_scale_height = 0; |
| 281 | 291 | |
| 282 | | window().target()->compute_minimum_size(m_hw_scale_width, m_hw_scale_height); |
| 292 | window().m_target->compute_minimum_size(m_hw_scale_width, m_hw_scale_height); |
| 283 | 293 | if (video_config.prescale) |
| 284 | 294 | { |
| 285 | 295 | m_hw_scale_width *= video_config.prescale; |
| r243409 | r243410 | |
| 315 | 325 | const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; |
| 316 | 326 | int minimum_width, minimum_height; |
| 317 | 327 | |
| 318 | | window().target()->compute_minimum_size(minimum_width, minimum_height); |
| 328 | window().m_target->compute_minimum_size(minimum_width, minimum_height); |
| 319 | 329 | |
| 320 | 330 | if (video_config.prescale) |
| 321 | 331 | { |
| r243409 | r243410 | |
| 339 | 349 | m_yuv_bitmap = global_alloc_array(UINT16, minimum_width*minimum_height); |
| 340 | 350 | |
| 341 | 351 | m_yuvsurf = SDL_CreateYUVOverlay(minimum_width * sdl_sm->mult_w, minimum_height * sdl_sm->mult_h, |
| 342 | | sdl_sm->pixel_format, window().sdl_surface()); |
| 352 | sdl_sm->pixel_format, m_sdlsurf); |
| 343 | 353 | |
| 344 | 354 | if ( m_yuvsurf == NULL ) { |
| 345 | 355 | osd_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError()); |
| r243409 | r243410 | |
| 419 | 429 | // a |
| 420 | 430 | //============================================================ |
| 421 | 431 | |
| 422 | | int sdl_info::create() |
| 432 | int sdl_info::create(int width, int height) |
| 423 | 433 | { |
| 434 | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 424 | 435 | |
| 425 | 436 | #if (SDLMAME_SDL2) |
| 426 | | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 427 | 437 | |
| 428 | | // create renderer |
| 438 | osd_printf_verbose("Enter sdl_info::create\n"); |
| 429 | 439 | |
| 430 | 440 | /* set hints ... */ |
| 431 | 441 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode); |
| 432 | 442 | |
| 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); |
| 433 | 447 | |
| 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); |
| 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); |
| 438 | 456 | |
| 439 | | if (!m_sdl_renderer) |
| 457 | if (!window().m_sdl_window ) |
| 440 | 458 | { |
| 441 | | fatalerror("Error on creating renderer: %s\n", SDL_GetError()); |
| 459 | osd_printf_error("Unable to create window: %s\n", SDL_GetError()); |
| 460 | return 1; |
| 442 | 461 | } |
| 443 | 462 | |
| 463 | if (window().fullscreen() && video_config.switchres) |
| 444 | 464 | { |
| 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 | { |
| 445 | 513 | struct SDL_RendererInfo render_info; |
| 446 | 514 | |
| 447 | 515 | SDL_GetRendererInfo(m_sdl_renderer, &render_info); |
| r243409 | r243410 | |
| 465 | 533 | } |
| 466 | 534 | } |
| 467 | 535 | |
| 468 | | setup_texture(window().width(), window().height()); |
| 536 | setup_texture(width, height); |
| 469 | 537 | #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 | |
| 470 | 555 | #endif |
| 471 | 556 | |
| 472 | 557 | m_yuv_lookup = NULL; |
| r243409 | r243410 | |
| 478 | 563 | } |
| 479 | 564 | |
| 480 | 565 | //============================================================ |
| 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 | //============================================================ |
| 481 | 602 | // sdl_info::destroy |
| 482 | 603 | //============================================================ |
| 483 | 604 | |
| 484 | 605 | void sdl_info::destroy() |
| 485 | 606 | { |
| 486 | 607 | |
| 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 |
| 487 | 633 | // free the memory in the window |
| 488 | 634 | |
| 489 | | destroy_all_textures(); |
| 490 | | |
| 491 | 635 | if (m_yuv_lookup != NULL) |
| 492 | 636 | { |
| 493 | 637 | global_free_array(m_yuv_lookup); |
| r243409 | r243410 | |
| 501 | 645 | } |
| 502 | 646 | |
| 503 | 647 | //============================================================ |
| 504 | | // sdl_info::clear |
| 648 | // sdl_info::draw |
| 505 | 649 | //============================================================ |
| 506 | 650 | |
| 507 | 651 | void sdl_info::clear() |
| 508 | 652 | { |
| 509 | | //FIXME: Handled in sdl_info::draw as well |
| 510 | 653 | m_blittimer = 3; |
| 511 | 654 | } |
| 512 | 655 | |
| r243409 | r243410 | |
| 516 | 659 | |
| 517 | 660 | int sdl_info::xy_to_render_target(int x, int y, int *xt, int *yt) |
| 518 | 661 | { |
| 662 | // const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 663 | |
| 519 | 664 | *xt = x - m_last_hofs; |
| 520 | 665 | *yt = y - m_last_vofs; |
| 521 | | if (*xt<0 || *xt >= window().blitwidth()) |
| 666 | if (*xt<0 || *xt >= window().m_blitwidth) |
| 522 | 667 | return 0; |
| 523 | | if (*yt<0 || *yt >= window().blitheight()) |
| 668 | if (*yt<0 || *xt >= window().m_blitheight) |
| 524 | 669 | return 0; |
| 525 | 670 | return 1; |
| 526 | 671 | } |
| 527 | 672 | |
| 528 | 673 | //============================================================ |
| 529 | | // drawsdl_destroy_all_textures |
| 674 | // drawsdl_window_get_primitives |
| 530 | 675 | //============================================================ |
| 531 | 676 | |
| 532 | | void sdl_info::destroy_all_textures() |
| 677 | void sdl_info::set_target_bounds() |
| 533 | 678 | { |
| 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 |
| 679 | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 544 | 680 | } |
| 545 | 681 | |
| 546 | | |
| 547 | 682 | //============================================================ |
| 548 | | // sdl_info::draw |
| 683 | // drawsdl_window_draw |
| 549 | 684 | //============================================================ |
| 550 | 685 | |
| 551 | 686 | int sdl_info::draw(UINT32 dc, int update) |
| r243409 | r243410 | |
| 565 | 700 | return 0; |
| 566 | 701 | } |
| 567 | 702 | |
| 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 | | |
| 583 | 703 | // lock it if we need it |
| 584 | 704 | #if (!SDLMAME_SDL2) |
| 585 | 705 | |
| 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; |
| 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; |
| 591 | 711 | // amask = sdlsurf->format->Amask; |
| 592 | 712 | |
| 593 | | if (window().blitwidth() != m_old_blitwidth || window().blitheight() != m_old_blitheight) |
| 713 | if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight) |
| 594 | 714 | { |
| 595 | 715 | if (sm->is_yuv) |
| 596 | 716 | yuv_overlay_init(); |
| 597 | | m_old_blitwidth = window().blitwidth(); |
| 598 | | m_old_blitheight = window().blitheight(); |
| 717 | m_old_blitwidth = window().m_blitwidth; |
| 718 | m_old_blitheight = window().m_blitheight; |
| 599 | 719 | m_blittimer = 3; |
| 600 | 720 | } |
| 601 | 721 | |
| 602 | | if (SDL_MUSTLOCK(window().sdl_surface())) |
| 603 | | SDL_LockSurface(window().sdl_surface()); |
| 722 | if (SDL_MUSTLOCK(m_sdlsurf)) |
| 723 | SDL_LockSurface(m_sdlsurf); |
| 604 | 724 | |
| 605 | 725 | // Clear if necessary |
| 606 | 726 | if (m_blittimer > 0) |
| 607 | 727 | { |
| 608 | | memset(window().sdl_surface()->pixels, 0, window().height() * window().sdl_surface()->pitch); |
| 728 | memset(m_sdlsurf->pixels, 0, window().m_height * m_sdlsurf->pitch); |
| 609 | 729 | m_blittimer--; |
| 610 | 730 | } |
| 611 | 731 | |
| r243409 | r243410 | |
| 623 | 743 | #endif |
| 624 | 744 | } |
| 625 | 745 | else |
| 626 | | surfptr = (UINT8 *)window().sdl_surface()->pixels; |
| 746 | surfptr = (UINT8 *)m_sdlsurf->pixels; |
| 627 | 747 | #else |
| 628 | 748 | //SDL_SelectRenderer(window().sdl_window); |
| 629 | 749 | |
| 630 | | if (window().blitwidth() != m_old_blitwidth || window().blitheight() != m_old_blitheight) |
| 750 | if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight) |
| 631 | 751 | { |
| 632 | | //SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 752 | SDL_RenderSetViewport(m_sdl_renderer, NULL); |
| 633 | 753 | |
| 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(); |
| 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; |
| 639 | 758 | m_blittimer = 3; |
| 640 | 759 | } |
| 641 | 760 | |
| r243409 | r243410 | |
| 663 | 782 | #endif |
| 664 | 783 | // get ready to center the image |
| 665 | 784 | vofs = hofs = 0; |
| 666 | | blitwidth = window().blitwidth(); |
| 667 | | blitheight = window().blitheight(); |
| 785 | blitwidth = window().m_blitwidth; |
| 786 | blitheight = window().m_blitheight; |
| 668 | 787 | |
| 669 | 788 | // figure out what coordinate system to use for centering - in window mode it's always the |
| 670 | 789 | // SDL surface size. in fullscreen the surface covers all monitors, so center according to |
| r243409 | r243410 | |
| 676 | 795 | } |
| 677 | 796 | else |
| 678 | 797 | { |
| 679 | | ch = window().height(); |
| 680 | | cw = window().width(); |
| 798 | ch = window().m_height; |
| 799 | cw = window().m_width; |
| 681 | 800 | } |
| 682 | 801 | |
| 683 | 802 | // do not crash if the window's smaller than the blit area |
| r243409 | r243410 | |
| 687 | 806 | } |
| 688 | 807 | else if (video_config.centerv) |
| 689 | 808 | { |
| 690 | | vofs = (ch - window().blitheight()) / 2; |
| 809 | vofs = (ch - window().m_blitheight) / 2; |
| 691 | 810 | } |
| 692 | 811 | |
| 693 | 812 | if (blitwidth > cw) |
| r243409 | r243410 | |
| 696 | 815 | } |
| 697 | 816 | else if (video_config.centerh) |
| 698 | 817 | { |
| 699 | | hofs = (cw - window().blitwidth()) / 2; |
| 818 | hofs = (cw - window().m_blitwidth) / 2; |
| 700 | 819 | } |
| 701 | 820 | |
| 702 | 821 | m_last_hofs = hofs; |
| r243409 | r243410 | |
| 710 | 829 | if (!sm->is_yuv) |
| 711 | 830 | { |
| 712 | 831 | surfptr += ((vofs * pitch) + (hofs * bpp)); |
| 713 | | mamewidth = blitwidth; //sdl_surface()->w; |
| 714 | | mameheight = blitheight; //sdl_surface()->h; |
| 832 | mamewidth = blitwidth; //m_sdlsurf->w; |
| 833 | mameheight = blitheight; //m_sdlsurf->h; |
| 715 | 834 | } |
| 716 | 835 | else |
| 717 | 836 | { |
| r243409 | r243410 | |
| 736 | 855 | |
| 737 | 856 | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 738 | 857 | { |
| 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); |
| 858 | prim->bounds.x0 *= fw; |
| 859 | prim->bounds.x1 *= fw; |
| 860 | prim->bounds.y0 *= fh; |
| 861 | prim->bounds.y1 *= fh; |
| 743 | 862 | } |
| 744 | 863 | |
| 745 | 864 | // render to it |
| r243409 | r243410 | |
| 784 | 903 | |
| 785 | 904 | // unlock and flip |
| 786 | 905 | #if (!SDLMAME_SDL2) |
| 787 | | if (SDL_MUSTLOCK(window().sdl_surface())) SDL_UnlockSurface(window().sdl_surface()); |
| 906 | if (SDL_MUSTLOCK(m_sdlsurf)) SDL_UnlockSurface(m_sdlsurf); |
| 788 | 907 | if (!sm->is_yuv) |
| 789 | 908 | { |
| 790 | | SDL_Flip(window().sdl_surface()); |
| 909 | SDL_Flip(m_sdlsurf); |
| 791 | 910 | } |
| 792 | 911 | else |
| 793 | 912 | { |
trunk/src/osd/sdl/window.c
| r243409 | r243410 | |
| 100 | 100 | |
| 101 | 101 | struct worker_param { |
| 102 | 102 | worker_param() |
| 103 | | : m_window(NULL), m_list(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 103 | : m_window(NULL), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 104 | 104 | { |
| 105 | 105 | } |
| 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) |
| 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) |
| 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 | } |
| 110 | 114 | worker_param(sdl_window_info *awindow, int anew_width, int anew_height) |
| 111 | | : m_window(awindow), m_list(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height) |
| 115 | : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height) |
| 112 | 116 | { |
| 113 | 117 | } |
| 114 | 118 | worker_param(sdl_window_info *awindow) |
| 115 | | : m_window(awindow), m_list(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 119 | : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 116 | 120 | { |
| 117 | 121 | } |
| 122 | running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } |
| 118 | 123 | sdl_window_info *window() const { assert(m_window != NULL); return m_window; } |
| 119 | 124 | render_primitive_list *list() const { return m_list; } |
| 120 | 125 | int new_width() const { return m_resize_new_width; } |
| r243409 | r243410 | |
| 124 | 129 | private: |
| 125 | 130 | sdl_window_info *m_window; |
| 126 | 131 | render_primitive_list *m_list; |
| 132 | running_machine *m_machine; |
| 127 | 133 | int m_resize_new_width; |
| 128 | 134 | int m_resize_new_height; |
| 129 | 135 | }; |
| r243409 | r243410 | |
| 133 | 139 | // PROTOTYPES |
| 134 | 140 | //============================================================ |
| 135 | 141 | |
| 142 | static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window); |
| 136 | 143 | static void sdlwindow_sync(void); |
| 137 | 144 | |
| 145 | static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view); |
| 146 | |
| 138 | 147 | //============================================================ |
| 139 | 148 | // execute_async |
| 140 | 149 | //============================================================ |
| r243409 | r243410 | |
| 266 | 275 | SDL_HINT_RENDER_VSYNC, |
| 267 | 276 | SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XINERAMA, |
| 268 | 277 | SDL_HINT_VIDEO_X11_XRANDR, SDL_HINT_GRAB_KEYBOARD, |
| 278 | SDL_HINT_MOUSE_RELATIVE_MODE_WARP, |
| 269 | 279 | SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_IDLE_TIMER_DISABLED, |
| 270 | 280 | SDL_HINT_ORIENTATIONS, |
| 271 | 281 | SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG, |
| r243409 | r243410 | |
| 275 | 285 | SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER, |
| 276 | 286 | SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, |
| 277 | 287 | SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, |
| 278 | | SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_HINT_MOUSE_RELATIVE_MODE_WARP, |
| 288 | SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, |
| 279 | 289 | #endif |
| 280 | 290 | #if SDL_VERSION_ATLEAST(2, 0, 3) |
| 281 | 291 | SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED, |
| r243409 | r243410 | |
| 345 | 355 | { |
| 346 | 356 | sdl_window_info *temp = sdl_window_list; |
| 347 | 357 | sdl_window_list = temp->m_next; |
| 348 | | temp->destroy(); |
| 358 | temp->video_window_destroy(machine()); |
| 349 | 359 | // free the window itself |
| 350 | 360 | global_free(temp); |
| 351 | 361 | } |
| r243409 | r243410 | |
| 454 | 464 | newwidth = window_width; |
| 455 | 465 | |
| 456 | 466 | if ((m_blitwidth != newwidth) || (m_blitheight != newheight)) |
| 457 | | clear(); |
| 467 | window_clear(); |
| 458 | 468 | |
| 459 | 469 | m_blitwidth = newwidth; |
| 460 | 470 | m_blitheight = newheight; |
| r243409 | r243410 | |
| 470 | 480 | { |
| 471 | 481 | worker_param * wp = (worker_param *) param; |
| 472 | 482 | sdl_window_info * window = wp->window(); |
| 473 | | int width = wp->new_width(); |
| 474 | | int height = wp->new_height(); |
| 475 | 483 | |
| 476 | 484 | ASSERT_WINDOW_THREAD(); |
| 477 | 485 | |
| 478 | 486 | window->renderer().destroy_all_textures(); |
| 487 | window->renderer().resize(wp->new_width(), wp->new_height()); |
| 479 | 488 | |
| 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); |
| 489 | window->blit_surface_size(wp->new_width(), wp->new_height()); |
| 485 | 490 | |
| 486 | | window->m_sdlsurf = SDL_SetVideoMode(width, height, 0, |
| 487 | | SDL_SWSURFACE | SDL_ANYFORMAT | window->m_extra_flags); |
| 491 | window->window_clear(); |
| 488 | 492 | |
| 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 | | |
| 497 | 493 | osd_free(wp); |
| 498 | 494 | return NULL; |
| 499 | 495 | } |
| 500 | 496 | |
| 501 | | void sdl_window_info::resize(INT32 width, INT32 height) |
| 497 | void sdl_window_info::window_resize(INT32 width, INT32 height) |
| 502 | 498 | { |
| 503 | 499 | ASSERT_MAIN_THREAD(); |
| 504 | 500 | |
| 505 | | if (width == this->width() && height == this->height()) |
| 501 | if (width == this->m_width && height == this->m_height) |
| 506 | 502 | return; |
| 507 | 503 | |
| 508 | 504 | execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height)); |
| r243409 | r243410 | |
| 526 | 522 | return NULL; |
| 527 | 523 | } |
| 528 | 524 | |
| 529 | | void sdl_window_info::clear() |
| 525 | void sdl_window_info::window_clear() |
| 530 | 526 | { |
| 531 | 527 | worker_param wp; |
| 532 | 528 | |
| r243409 | r243410 | |
| 558 | 554 | // If we are going fullscreen (leaving windowed) remember our windowed size |
| 559 | 555 | if (!window->fullscreen()) |
| 560 | 556 | { |
| 561 | | window->m_windowed_width = window->width(); |
| 562 | | window->m_windowed_height = window->height(); |
| 557 | window->m_windowed_width = window->m_width; |
| 558 | window->m_windowed_height = window->m_height; |
| 563 | 559 | } |
| 564 | 560 | |
| 565 | 561 | window->renderer().destroy(); |
| 562 | sdlinput_release_keys(wp->machine()); |
| 566 | 563 | |
| 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 | | |
| 586 | 564 | // toggle the window mode |
| 587 | 565 | window->set_fullscreen(!window->fullscreen()); |
| 588 | 566 | |
| r243409 | r243410 | |
| 591 | 569 | return NULL; |
| 592 | 570 | } |
| 593 | 571 | |
| 594 | | void sdl_window_info::toggle_full_screen() |
| 572 | void sdl_window_info::toggle_full_screen(running_machine &machine) |
| 595 | 573 | { |
| 596 | 574 | ASSERT_MAIN_THREAD(); |
| 597 | 575 | |
| 598 | | execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(this)); |
| 576 | execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(machine, this)); |
| 599 | 577 | } |
| 600 | 578 | |
| 601 | 579 | OSDWORK_CALLBACK( sdl_window_info::destroy_all_textures_wt ) |
| r243409 | r243410 | |
| 610 | 588 | return NULL; |
| 611 | 589 | } |
| 612 | 590 | |
| 613 | | void sdl_window_info::modify_prescale(int dir) |
| 591 | void sdl_window_info::modify_prescale(running_machine &machine, int dir) |
| 614 | 592 | { |
| 615 | | worker_param wp = worker_param(this); |
| 616 | | int new_prescale = prescale(); |
| 593 | worker_param wp = worker_param(machine, this); |
| 594 | int new_prescale = m_prescale; |
| 617 | 595 | |
| 618 | | if (dir > 0 && prescale() < 3) |
| 619 | | new_prescale = prescale() + 1; |
| 620 | | if (dir < 0 && prescale() > 1) |
| 621 | | new_prescale = prescale() - 1; |
| 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; |
| 622 | 600 | |
| 623 | | if (new_prescale != prescale()) |
| 601 | if (new_prescale != m_prescale) |
| 624 | 602 | { |
| 625 | 603 | if (m_fullscreen && video_config.switchres) |
| 626 | 604 | { |
| r243409 | r243410 | |
| 636 | 614 | execute_async_wait(destroy_all_textures_wt, wp); |
| 637 | 615 | m_prescale = new_prescale; |
| 638 | 616 | } |
| 639 | | machine().ui().popup_time(1, "Prescale %d", prescale()); |
| 617 | machine.ui().popup_time(1, "Prescale %d", m_prescale); |
| 640 | 618 | } |
| 641 | 619 | } |
| 642 | 620 | |
| r243409 | r243410 | |
| 645 | 623 | // (main or window thread) |
| 646 | 624 | //============================================================ |
| 647 | 625 | |
| 648 | | void sdl_window_info::update_cursor_state() |
| 626 | static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window) |
| 649 | 627 | { |
| 650 | 628 | #if (USE_XINPUT) |
| 651 | 629 | // Hack for wii-lightguns: |
| r243409 | r243410 | |
| 660 | 638 | #if (SDLMAME_SDL2) |
| 661 | 639 | // do not do mouse capture if the debugger's enabled to avoid |
| 662 | 640 | // the possibility of losing control |
| 663 | | if (!(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 641 | if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 664 | 642 | { |
| 665 | 643 | //FIXME: SDL1.3: really broken: the whole SDL code |
| 666 | 644 | // will only work correct with relative mouse movements ... |
| 667 | | if (!fullscreen() && !sdlinput_should_hide_mouse()) |
| 645 | if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine)) |
| 668 | 646 | { |
| 669 | 647 | SDL_ShowCursor(SDL_ENABLE); |
| 670 | | if (SDL_GetWindowGrab(sdl_window() )) |
| 671 | | SDL_SetWindowGrab(sdl_window(), SDL_FALSE); |
| 648 | if (SDL_GetWindowGrab(window->m_sdl_window )) |
| 649 | SDL_SetWindowGrab(window->m_sdl_window, SDL_FALSE); |
| 672 | 650 | SDL_SetRelativeMouseMode(SDL_FALSE); |
| 673 | 651 | } |
| 674 | 652 | else |
| 675 | 653 | { |
| 676 | 654 | SDL_ShowCursor(SDL_DISABLE); |
| 677 | | if (!SDL_GetWindowGrab(sdl_window())) |
| 678 | | SDL_SetWindowGrab(sdl_window(), SDL_TRUE); |
| 655 | if (!SDL_GetWindowGrab(window->m_sdl_window)) |
| 656 | SDL_SetWindowGrab(window->m_sdl_window, SDL_TRUE); |
| 679 | 657 | SDL_SetRelativeMouseMode(SDL_TRUE); |
| 680 | 658 | } |
| 681 | 659 | SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility |
| r243409 | r243410 | |
| 684 | 662 | #else |
| 685 | 663 | // do not do mouse capture if the debugger's enabled to avoid |
| 686 | 664 | // the possibility of losing control |
| 687 | | if (!(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 665 | if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 688 | 666 | { |
| 689 | | if ( fullscreen() || sdlinput_should_hide_mouse() ) |
| 667 | if ( window->fullscreen() || sdlinput_should_hide_mouse(machine) ) |
| 690 | 668 | { |
| 691 | 669 | SDL_ShowCursor(SDL_DISABLE); |
| 692 | 670 | if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| r243409 | r243410 | |
| 707 | 685 | #endif |
| 708 | 686 | } |
| 709 | 687 | |
| 710 | | OSDWORK_CALLBACK( sdl_window_info::update_cursor_state_wt ) |
| 688 | static OSDWORK_CALLBACK( sdlwindow_update_cursor_state_wt ) |
| 711 | 689 | { |
| 712 | 690 | worker_param * wp = (worker_param *) param; |
| 713 | | sdl_window_info * window = wp->window(); |
| 691 | //sdl_window_info * window = wp->window; |
| 714 | 692 | |
| 715 | | window->update_cursor_state(); |
| 693 | sdlwindow_update_cursor_state(wp->machine(), wp->window()); |
| 716 | 694 | |
| 717 | 695 | osd_free(wp); |
| 718 | 696 | return NULL; |
| r243409 | r243410 | |
| 728 | 706 | // (main thread) |
| 729 | 707 | //============================================================ |
| 730 | 708 | |
| 731 | | int sdl_window_info::window_init() |
| 709 | int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config) |
| 732 | 710 | { |
| 711 | sdl_window_info *window; |
| 733 | 712 | worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param)); |
| 734 | 713 | int result; |
| 735 | 714 | |
| 736 | 715 | ASSERT_MAIN_THREAD(); |
| 737 | 716 | |
| 717 | // allocate a new window object |
| 718 | window = global_alloc(sdl_window_info(&machine, monitor, index, config)); |
| 719 | |
| 738 | 720 | // set the initial maximized state |
| 739 | 721 | // FIXME: Does not belong here |
| 740 | | sdl_options &options = downcast<sdl_options &>(m_machine.options()); |
| 741 | | m_startmaximized = options.maximize(); |
| 722 | sdl_options &options = downcast<sdl_options &>(machine.options()); |
| 723 | window->m_startmaximized = options.maximize(); |
| 742 | 724 | |
| 743 | 725 | // add us to the list |
| 744 | | *last_window_ptr = this; |
| 745 | | last_window_ptr = &this->m_next; |
| 726 | *last_window_ptr = window; |
| 727 | last_window_ptr = &window->m_next; |
| 746 | 728 | |
| 747 | | set_renderer(draw.create(this)); |
| 729 | window->set_renderer(draw.create(window)); |
| 748 | 730 | |
| 749 | 731 | // create an event that we can use to skip blitting |
| 750 | | m_rendered_event = osd_event_alloc(FALSE, TRUE); |
| 732 | window->m_rendered_event = osd_event_alloc(FALSE, TRUE); |
| 751 | 733 | |
| 752 | 734 | // load the layout |
| 753 | | m_target = m_machine.render().target_alloc(); |
| 735 | window->m_target = machine.render().target_alloc(); |
| 754 | 736 | |
| 755 | 737 | // set the specific view |
| 756 | | set_starting_view(m_machine, m_index, options.view(), options.view(m_index)); |
| 738 | set_starting_view(machine, index, window, options.view(), options.view(index)); |
| 757 | 739 | |
| 758 | 740 | // make the window title |
| 759 | 741 | if (video_config.numscreens == 1) |
| 760 | | sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().description, m_machine.system().name); |
| 742 | sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name); |
| 761 | 743 | else |
| 762 | | sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().description, m_machine.system().name, m_index); |
| 744 | sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index); |
| 763 | 745 | |
| 764 | | wp->set_window(this); |
| 746 | wp->set_window(window); |
| 765 | 747 | |
| 766 | 748 | // FIXME: pass error back in a different way |
| 767 | 749 | if (multithreading_enabled) |
| r243409 | r243410 | |
| 783 | 765 | return 0; |
| 784 | 766 | |
| 785 | 767 | error: |
| 786 | | destroy(); |
| 768 | window->video_window_destroy(machine); |
| 769 | // free the window itself |
| 770 | global_free(window); |
| 787 | 771 | return 1; |
| 788 | 772 | } |
| 789 | 773 | |
| r243409 | r243410 | |
| 803 | 787 | // free the textures etc |
| 804 | 788 | window->renderer().destroy(); |
| 805 | 789 | |
| 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 | | |
| 822 | 790 | // release all keys ... |
| 823 | | sdlinput_release_keys(); |
| 791 | sdlinput_release_keys(wp->machine()); |
| 824 | 792 | |
| 825 | 793 | |
| 826 | 794 | osd_free(wp); |
| 827 | 795 | return NULL; |
| 828 | 796 | } |
| 829 | 797 | |
| 830 | | void sdl_window_info::destroy() |
| 798 | void sdl_window_info::video_window_destroy(running_machine &machine) |
| 831 | 799 | { |
| 832 | 800 | sdl_window_info **prevptr; |
| 833 | 801 | |
| r243409 | r243410 | |
| 848 | 816 | } |
| 849 | 817 | |
| 850 | 818 | // free the textures etc |
| 851 | | execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(this)); |
| 819 | execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this)); |
| 852 | 820 | |
| 853 | 821 | // free the render target, after the textures! |
| 854 | 822 | this->machine().render().target_free(m_target); |
| r243409 | r243410 | |
| 875 | 843 | m_target->compute_minimum_size(minimum_width, minimum_height); |
| 876 | 844 | |
| 877 | 845 | // use those as the target for now |
| 878 | | target_width = minimum_width * MAX(1, prescale()); |
| 879 | | target_height = minimum_height * MAX(1, prescale()); |
| 846 | target_width = minimum_width * MAX(1, m_prescale); |
| 847 | target_height = minimum_height * MAX(1, m_prescale); |
| 880 | 848 | |
| 881 | 849 | // if we're not stretching, allow some slop on the minimum since we can handle it |
| 882 | 850 | { |
| r243409 | r243410 | |
| 942 | 910 | m_target->compute_minimum_size(minimum_width, minimum_height); |
| 943 | 911 | |
| 944 | 912 | // use those as the target for now |
| 945 | | target_width = minimum_width * MAX(1, prescale()); |
| 946 | | target_height = minimum_height * MAX(1, prescale()); |
| 913 | target_width = minimum_width * MAX(1, m_prescale); |
| 914 | target_height = minimum_height * MAX(1, m_prescale); |
| 947 | 915 | |
| 948 | 916 | // if we're not stretching, allow some slop on the minimum since we can handle it |
| 949 | 917 | { |
| r243409 | r243410 | |
| 1011 | 979 | // (main thread) |
| 1012 | 980 | //============================================================ |
| 1013 | 981 | |
| 1014 | | void sdl_window_info::update() |
| 982 | void sdl_window_info::video_window_update(running_machine &machine) |
| 1015 | 983 | { |
| 1016 | 984 | osd_ticks_t event_wait_ticks; |
| 1017 | 985 | ASSERT_MAIN_THREAD(); |
| r243409 | r243410 | |
| 1019 | 987 | // adjust the cursor state |
| 1020 | 988 | //sdlwindow_update_cursor_state(machine, window); |
| 1021 | 989 | |
| 1022 | | execute_async(&update_cursor_state_wt, worker_param(this)); |
| 990 | execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this)); |
| 1023 | 991 | |
| 1024 | 992 | // if we're visible and running and not in the middle of a resize, draw |
| 1025 | 993 | if (m_target != NULL) |
| r243409 | r243410 | |
| 1035 | 1003 | |
| 1036 | 1004 | if (!this->m_fullscreen) |
| 1037 | 1005 | { |
| 1038 | | blit_surface_size(width(), height()); |
| 1006 | blit_surface_size(m_width, m_height); |
| 1039 | 1007 | //Don't resize window without user interaction; |
| 1040 | 1008 | //window_resize(blitwidth, blitheight); |
| 1041 | 1009 | } |
| 1042 | 1010 | else if (video_config.switchres) |
| 1043 | 1011 | { |
| 1044 | 1012 | this->pick_best_mode(&tempwidth, &tempheight); |
| 1045 | | resize(tempwidth, tempheight); |
| 1013 | window_resize(tempwidth, tempheight); |
| 1046 | 1014 | } |
| 1047 | 1015 | } |
| 1048 | 1016 | |
| r243409 | r243410 | |
| 1063 | 1031 | } |
| 1064 | 1032 | |
| 1065 | 1033 | // ensure the target bounds are up-to-date, and then get the primitives |
| 1034 | renderer().set_target_bounds(); |
| 1066 | 1035 | |
| 1067 | | m_target->set_bounds(m_blitwidth, m_blitheight, monitor()->aspect()); |
| 1068 | | |
| 1069 | 1036 | render_primitive_list &primlist = m_target->get_primitives(); |
| 1070 | 1037 | |
| 1071 | 1038 | // and redraw now |
| 1072 | 1039 | |
| 1073 | | execute_async(&draw_video_contents_wt, worker_param(this, primlist)); |
| 1040 | execute_async(&draw_video_contents_wt, worker_param(machine, this, primlist)); |
| 1074 | 1041 | } |
| 1075 | 1042 | } |
| 1076 | 1043 | } |
| r243409 | r243410 | |
| 1081 | 1048 | // (main thread) |
| 1082 | 1049 | //============================================================ |
| 1083 | 1050 | |
| 1084 | | void sdl_window_info::set_starting_view(running_machine &machine, int index, const char *defview, const char *view) |
| 1051 | static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view) |
| 1085 | 1052 | { |
| 1086 | 1053 | int viewindex; |
| 1087 | 1054 | |
| r243409 | r243410 | |
| 1092 | 1059 | view = defview; |
| 1093 | 1060 | |
| 1094 | 1061 | // query the video system to help us pick a view |
| 1095 | | viewindex = target()->configured_view(view, index, video_config.numscreens); |
| 1062 | viewindex = window->m_target->configured_view(view, index, video_config.numscreens); |
| 1096 | 1063 | |
| 1097 | 1064 | // set the view |
| 1098 | | target()->set_view(viewindex); |
| 1099 | | m_start_viewscreen=viewindex; |
| 1065 | window->m_target->set_view(viewindex); |
| 1066 | window->m_start_viewscreen=viewindex; |
| 1100 | 1067 | } |
| 1101 | 1068 | |
| 1102 | 1069 | |
| r243409 | r243410 | |
| 1152 | 1119 | } |
| 1153 | 1120 | } |
| 1154 | 1121 | |
| 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 | | |
| 1277 | 1122 | // initialize the drawing backend |
| 1278 | | if (window->renderer().create()) |
| 1123 | if (window->renderer().create(tempwidth, tempheight)) |
| 1279 | 1124 | return (void *) &result[1]; |
| 1280 | 1125 | |
| 1281 | 1126 | // Make sure we have a consistent state |
| r243409 | r243410 | |
| 1343 | 1188 | ASSERT_REDRAW_THREAD(); |
| 1344 | 1189 | |
| 1345 | 1190 | // Some configurations require events to be polled in the worker thread |
| 1346 | | sdlinput_process_events_buf(); |
| 1191 | sdlinput_process_events_buf(wp->machine()); |
| 1347 | 1192 | |
| 1348 | 1193 | window->m_primlist = wp->list(); |
| 1349 | 1194 | |
trunk/src/osd/windows/drawd3d.c
| r243409 | r243410 | |
| 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); |
| 182 | 189 | |
| 190 | |
| 183 | 191 | //============================================================ |
| 184 | 192 | // drawd3d_window_init |
| 185 | 193 | //============================================================ |
| 186 | 194 | |
| 187 | | int d3d::renderer::init() |
| 195 | static int drawd3d_window_init(win_window_info *window) |
| 188 | 196 | { |
| 189 | | if (!initialize()) |
| 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()) |
| 190 | 202 | { |
| 191 | | destroy(); |
| 203 | drawd3d_window_destroy(window); |
| 192 | 204 | osd_printf_error("Unable to initialize Direct3D.\n"); |
| 193 | 205 | return 1; |
| 194 | 206 | } |
| r243409 | r243410 | |
| 206 | 218 | (*d3dintf->d3d.release)(d3dintf); |
| 207 | 219 | } |
| 208 | 220 | |
| 209 | | void d3d::renderer::toggle_fsfx() |
| 221 | static void drawd3d_window_toggle_fsfx(win_window_info *window) |
| 210 | 222 | { |
| 211 | | set_restarting(true); |
| 223 | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 224 | d3d->set_restarting(true); |
| 212 | 225 | } |
| 213 | 226 | |
| 214 | | void d3d::renderer::record() |
| 227 | static void drawd3d_window_record(win_window_info *window) |
| 215 | 228 | { |
| 216 | | get_shaders()->window_record(); |
| 229 | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 230 | d3d->get_shaders()->window_record(); |
| 217 | 231 | } |
| 218 | 232 | |
| 219 | | void d3d::renderer::save() |
| 233 | static void drawd3d_window_save(win_window_info *window) |
| 220 | 234 | { |
| 221 | | get_shaders()->window_save(); |
| 235 | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 236 | d3d->get_shaders()->window_save(); |
| 222 | 237 | } |
| 223 | 238 | |
| 224 | 239 | |
| r243409 | r243410 | |
| 227 | 242 | // drawd3d_window_destroy |
| 228 | 243 | //============================================================ |
| 229 | 244 | |
| 230 | | void d3d::renderer::destroy() |
| 245 | static void drawd3d_window_destroy(win_window_info *window) |
| 231 | 246 | { |
| 232 | | if (get_shaders() != NULL && get_shaders()->recording()) |
| 233 | | get_shaders()->window_record(); |
| 247 | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 234 | 248 | |
| 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; |
| 235 | 259 | } |
| 236 | 260 | |
| 237 | 261 | |
| r243409 | r243410 | |
| 240 | 264 | // drawd3d_window_get_primitives |
| 241 | 265 | //============================================================ |
| 242 | 266 | |
| 243 | | render_primitive_list *d3d::renderer::get_primitives() |
| 267 | static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window) |
| 244 | 268 | { |
| 269 | d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata; |
| 245 | 270 | RECT client; |
| 246 | 271 | |
| 247 | | GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen); |
| 272 | GetClientRectExceptMenu(window->m_hwnd, &client, window->m_fullscreen); |
| 248 | 273 | if (rect_width(&client) > 0 && rect_height(&client) > 0) |
| 249 | 274 | { |
| 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()); |
| 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()); |
| 252 | 277 | } |
| 253 | | return &window().m_target->get_primitives(); |
| 278 | return &window->m_target->get_primitives(); |
| 254 | 279 | } |
| 255 | 280 | |
| 256 | | //============================================================ |
| 257 | | // drawnone_create |
| 258 | | //============================================================ |
| 259 | | |
| 260 | | static osd_renderer *drawd3d_create(win_window_info *window) |
| 281 | int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks) |
| 261 | 282 | { |
| 262 | | return global_alloc(d3d::renderer(window)); |
| 263 | | } |
| 264 | | |
| 265 | | int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks) |
| 266 | | { |
| 267 | 283 | d3dintf = NULL; |
| 268 | 284 | |
| 269 | 285 | // Use Direct3D9 |
| r243409 | r243410 | |
| 279 | 295 | // fill in the callbacks |
| 280 | 296 | memset(callbacks, 0, sizeof(*callbacks)); |
| 281 | 297 | callbacks->exit = drawd3d_exit; |
| 282 | | callbacks->create = drawd3d_create; |
| 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; |
| 283 | 305 | return 0; |
| 284 | 306 | } |
| 285 | 307 | |
| r243409 | r243410 | |
| 287 | 309 | // drawd3d_window_draw |
| 288 | 310 | //============================================================ |
| 289 | 311 | |
| 290 | | int d3d::renderer::draw(HDC dc, int update) |
| 312 | static int drawd3d_window_draw(win_window_info *window, HDC dc, int update) |
| 291 | 313 | { |
| 292 | | int check = pre_window_draw_check(); |
| 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(); |
| 293 | 321 | if (check >= 0) |
| 294 | 322 | return check; |
| 295 | 323 | |
| 296 | | begin_frame(); |
| 297 | | process_primitives(); |
| 298 | | end_frame(); |
| 324 | d3d->begin_frame(); |
| 325 | d3d->process_primitives(); |
| 326 | d3d->end_frame(); |
| 299 | 327 | |
| 300 | 328 | return 0; |
| 301 | 329 | } |
| r243409 | r243410 | |
| 468 | 496 | osd_printf_verbose("Direct3D: YUV format = %s\n", (m_yuv_format == D3DFMT_YUY2) ? "YUY2" : (m_yuv_format == D3DFMT_UYVY) ? "UYVY" : "RGB"); |
| 469 | 497 | |
| 470 | 498 | // set the max texture size |
| 471 | | d3d->window().m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height); |
| 499 | d3d->get_window()->m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height); |
| 472 | 500 | osd_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height); |
| 473 | 501 | } |
| 474 | 502 | |
| r243409 | r243410 | |
| 480 | 508 | { |
| 481 | 509 | // experimental: load a PNG to use for vector rendering; it is treated |
| 482 | 510 | // as a brightness map |
| 483 | | emu_file file(m_renderer->window().machine().options().art_path(), OPEN_FLAG_READ); |
| 511 | emu_file file(m_renderer->get_window()->machine().options().art_path(), OPEN_FLAG_READ); |
| 484 | 512 | render_load_png(m_vector_bitmap, file, NULL, "vector.png"); |
| 485 | 513 | if (m_vector_bitmap.valid()) |
| 486 | 514 | { |
| r243409 | r243410 | |
| 622 | 650 | } |
| 623 | 651 | |
| 624 | 652 | renderer::renderer(win_window_info *window) |
| 625 | | : osd_renderer(window, FLAG_NONE) |
| 626 | 653 | { |
| 627 | 654 | m_device = NULL; |
| 628 | 655 | m_restarting = false; |
| 656 | m_window = window; |
| 629 | 657 | m_shaders = NULL; |
| 630 | 658 | m_numverts = 0; |
| 631 | 659 | m_numpolys = 0; |
| r243409 | r243410 | |
| 644 | 672 | return false; |
| 645 | 673 | |
| 646 | 674 | // create the device immediately for the full screen case (defer for window mode) |
| 647 | | if (window().m_fullscreen && device_create()) |
| 675 | if (m_window->m_fullscreen && device_create()) |
| 648 | 676 | return false; |
| 649 | 677 | |
| 650 | 678 | return true; |
| r243409 | r243410 | |
| 653 | 681 | int renderer::pre_window_draw_check() |
| 654 | 682 | { |
| 655 | 683 | // if we're in the middle of resizing, leave things alone |
| 656 | | if (window().m_resize_state == RESIZE_STATE_RESIZING) |
| 684 | if (m_window->m_resize_state == RESIZE_STATE_RESIZING) |
| 657 | 685 | return 0; |
| 658 | 686 | |
| 659 | 687 | // if we're restarting the renderer, leave things alone |
| r243409 | r243410 | |
| 678 | 706 | } |
| 679 | 707 | |
| 680 | 708 | // in window mode, we need to track the window size |
| 681 | | if (!window().m_fullscreen || m_device == NULL) |
| 709 | if (!m_window->m_fullscreen || m_device == NULL) |
| 682 | 710 | { |
| 683 | 711 | // if the size changes, skip this update since the render target will be out of date |
| 684 | 712 | if (update_window_size()) |
| r243409 | r243410 | |
| 694 | 722 | |
| 695 | 723 | void texture_manager::update_textures() |
| 696 | 724 | { |
| 697 | | for (render_primitive *prim = m_renderer->window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 725 | for (render_primitive *prim = m_renderer->get_window()->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 698 | 726 | { |
| 699 | 727 | if (prim->texture.base != NULL) |
| 700 | 728 | { |
| r243409 | r243410 | |
| 731 | 759 | |
| 732 | 760 | m_shaders->begin_frame(); |
| 733 | 761 | |
| 734 | | window().m_primlist->acquire_lock(); |
| 762 | m_window->m_primlist->acquire_lock(); |
| 735 | 763 | |
| 736 | 764 | // first update any textures |
| 737 | 765 | m_texture_manager->update_textures(); |
| r243409 | r243410 | |
| 752 | 780 | m_line_count = 0; |
| 753 | 781 | |
| 754 | 782 | // loop over primitives |
| 755 | | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 783 | for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 756 | 784 | if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags)) |
| 757 | 785 | m_line_count++; |
| 758 | 786 | } |
| r243409 | r243410 | |
| 760 | 788 | void renderer::process_primitives() |
| 761 | 789 | { |
| 762 | 790 | // Rotating index for vector time offsets |
| 763 | | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 791 | for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 764 | 792 | { |
| 765 | 793 | switch (prim->type) |
| 766 | 794 | { |
| r243409 | r243410 | |
| 790 | 818 | |
| 791 | 819 | void renderer::end_frame() |
| 792 | 820 | { |
| 793 | | window().m_primlist->release_lock(); |
| 821 | m_window->m_primlist->release_lock(); |
| 794 | 822 | |
| 795 | 823 | // flush any pending polygons |
| 796 | 824 | primitive_flush_pending(); |
| r243409 | r243410 | |
| 865 | 893 | m_presentation.BackBufferCount = video_config.triplebuf ? 2 : 1; |
| 866 | 894 | m_presentation.MultiSampleType = D3DMULTISAMPLE_NONE; |
| 867 | 895 | m_presentation.SwapEffect = D3DSWAPEFFECT_DISCARD; |
| 868 | | m_presentation.hDeviceWindow = window().m_hwnd; |
| 869 | | m_presentation.Windowed = !window().m_fullscreen || win_has_menu(&window()); |
| 896 | m_presentation.hDeviceWindow = m_window->m_hwnd; |
| 897 | m_presentation.Windowed = !m_window->m_fullscreen || win_has_menu(m_window); |
| 870 | 898 | m_presentation.EnableAutoDepthStencil = FALSE; |
| 871 | 899 | m_presentation.AutoDepthStencilFormat = D3DFMT_D16; |
| 872 | 900 | m_presentation.Flags = 0; |
| 873 | 901 | m_presentation.FullScreen_RefreshRateInHz = m_refresh; |
| 874 | | m_presentation.PresentationInterval = ((video_config.triplebuf && window().m_fullscreen) || |
| 902 | m_presentation.PresentationInterval = ((video_config.triplebuf && m_window->m_fullscreen) || |
| 875 | 903 | video_config.waitvsync || video_config.syncrefresh) ? |
| 876 | 904 | D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; |
| 877 | 905 | |
| 878 | 906 | // create the D3D device |
| 879 | | result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, window().m_focus_hwnd, |
| 907 | result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_window->m_focus_hwnd, |
| 880 | 908 | D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device); |
| 881 | 909 | if (result != D3D_OK) |
| 882 | 910 | { |
| r243409 | r243410 | |
| 899 | 927 | osd_printf_verbose("Direct3D: Device created at %dx%d\n", m_width, m_height); |
| 900 | 928 | |
| 901 | 929 | // set the gamma if we need to |
| 902 | | if (window().m_fullscreen) |
| 930 | if (m_window->m_fullscreen) |
| 903 | 931 | { |
| 904 | 932 | // only set the gamma if it's not 1.0f |
| 905 | | windows_options &options = downcast<windows_options &>(window().machine().options()); |
| 933 | windows_options &options = downcast<windows_options &>(m_window->machine().options()); |
| 906 | 934 | float brightness = options.full_screen_brightness(); |
| 907 | 935 | float contrast = options.full_screen_contrast(); |
| 908 | 936 | float gamma = options.full_screen_gamma(); |
| r243409 | r243410 | |
| 1064 | 1092 | int retval = 0; |
| 1065 | 1093 | |
| 1066 | 1094 | m_shaders = global_alloc_clear(shaders); |
| 1067 | | m_shaders->init(d3dintf, &window()); |
| 1095 | m_shaders->init(d3dintf, m_window); |
| 1068 | 1096 | |
| 1069 | 1097 | DWORD tempcaps; |
| 1070 | 1098 | HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps); |
| r243409 | r243410 | |
| 1203 | 1231 | } |
| 1204 | 1232 | |
| 1205 | 1233 | // choose a resolution: window mode case |
| 1206 | | if (!window().m_fullscreen || !video_config.switchres || win_has_menu(&window())) |
| 1234 | if (!m_window->m_fullscreen || !video_config.switchres || win_has_menu(m_window)) |
| 1207 | 1235 | { |
| 1208 | 1236 | RECT client; |
| 1209 | 1237 | |
| 1210 | 1238 | // bounds are from the window client rect |
| 1211 | | GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen); |
| 1239 | GetClientRectExceptMenu(m_window->m_hwnd, &client, m_window->m_fullscreen); |
| 1212 | 1240 | m_width = client.right - client.left; |
| 1213 | 1241 | m_height = client.bottom - client.top; |
| 1214 | 1242 | |
| r243409 | r243410 | |
| 1219 | 1247 | // make sure it's a pixel format we can get behind |
| 1220 | 1248 | if (m_pixformat != D3DFMT_X1R5G5B5 && m_pixformat != D3DFMT_R5G6B5 && m_pixformat != D3DFMT_X8R8G8B8) |
| 1221 | 1249 | { |
| 1222 | | char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice); |
| 1250 | char *utf8_device = utf8_from_tstring(m_window->m_monitor->info.szDevice); |
| 1223 | 1251 | if (utf8_device != NULL) |
| 1224 | 1252 | { |
| 1225 | 1253 | osd_printf_error("Device %s currently in an unsupported mode\n", utf8_device); |
| r243409 | r243410 | |
| 1244 | 1272 | } |
| 1245 | 1273 | |
| 1246 | 1274 | // see if we can handle the device type |
| 1247 | | result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().m_fullscreen); |
| 1275 | result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !m_window->m_fullscreen); |
| 1248 | 1276 | if (result != D3D_OK) |
| 1249 | 1277 | { |
| 1250 | | char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice); |
| 1278 | char *utf8_device = utf8_from_tstring(m_window->m_monitor->info.szDevice); |
| 1251 | 1279 | if (utf8_device != NULL) |
| 1252 | 1280 | { |
| 1253 | 1281 | osd_printf_error("Proposed video mode not supported on device %s\n", utf8_device); |
| r243409 | r243410 | |
| 1275 | 1303 | HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum); |
| 1276 | 1304 | |
| 1277 | 1305 | // if we match the proposed monitor, this is it |
| 1278 | | if (curmonitor == window().m_monitor->handle) |
| 1306 | if (curmonitor == m_window->m_monitor->handle) |
| 1279 | 1307 | { |
| 1280 | 1308 | return adapternum; |
| 1281 | 1309 | } |
| r243409 | r243410 | |
| 1298 | 1326 | float best_score = 0.0f; |
| 1299 | 1327 | |
| 1300 | 1328 | // determine the refresh rate of the primary screen |
| 1301 | | const screen_device *primary_screen = window().machine().config().first_screen(); |
| 1329 | const screen_device *primary_screen = m_window->machine().config().first_screen(); |
| 1302 | 1330 | if (primary_screen != NULL) |
| 1303 | 1331 | { |
| 1304 | 1332 | target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh_attoseconds()); |
| r243409 | r243410 | |
| 1308 | 1336 | // note: technically we should not be calling this from an alternate window |
| 1309 | 1337 | // thread; however, it is only done during init time, and the init code on |
| 1310 | 1338 | // the main thread is waiting for us to finish, so it is safe to do so here |
| 1311 | | window().m_target->compute_minimum_size(minwidth, minheight); |
| 1339 | m_window->m_target->compute_minimum_size(minwidth, minheight); |
| 1312 | 1340 | |
| 1313 | 1341 | // use those as the target for now |
| 1314 | 1342 | INT32 target_width = minwidth; |
| r243409 | r243410 | |
| 1343 | 1371 | size_score *= 0.1f; |
| 1344 | 1372 | |
| 1345 | 1373 | // if we're looking for a particular mode, that's a winner |
| 1346 | | if (mode.Width == window().m_maxwidth && mode.Height == window().m_maxheight) |
| 1374 | if (mode.Width == m_window->m_maxwidth && mode.Height == m_window->m_maxheight) |
| 1347 | 1375 | size_score = 2.0f; |
| 1348 | 1376 | |
| 1349 | 1377 | // compute refresh score |
| r243409 | r243410 | |
| 1354 | 1382 | refresh_score *= 0.1f; |
| 1355 | 1383 | |
| 1356 | 1384 | // if we're looking for a particular refresh, make sure it matches |
| 1357 | | if (mode.RefreshRate == window().m_refresh) |
| 1385 | if (mode.RefreshRate == m_window->m_refresh) |
| 1358 | 1386 | refresh_score = 2.0f; |
| 1359 | 1387 | |
| 1360 | 1388 | // weight size and refresh equally |
| r243409 | r243410 | |
| 1384 | 1412 | { |
| 1385 | 1413 | // get the current window bounds |
| 1386 | 1414 | RECT client; |
| 1387 | | GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen); |
| 1415 | GetClientRectExceptMenu(m_window->m_hwnd, &client, m_window->m_fullscreen); |
| 1388 | 1416 | |
| 1389 | 1417 | // if we have a device and matching width/height, nothing to do |
| 1390 | 1418 | if (m_device != NULL && rect_width(&client) == m_width && rect_height(&client) == m_height) |
| 1391 | 1419 | { |
| 1392 | 1420 | // clear out any pending resizing if the area didn't change |
| 1393 | | if (window().m_resize_state == RESIZE_STATE_PENDING) |
| 1394 | | window().m_resize_state = RESIZE_STATE_NORMAL; |
| 1421 | if (m_window->m_resize_state == RESIZE_STATE_PENDING) |
| 1422 | m_window->m_resize_state = RESIZE_STATE_NORMAL; |
| 1395 | 1423 | return FALSE; |
| 1396 | 1424 | } |
| 1397 | 1425 | |
| 1398 | 1426 | // if we're in the middle of resizing, leave it alone as well |
| 1399 | | if (window().m_resize_state == RESIZE_STATE_RESIZING) |
| 1427 | if (m_window->m_resize_state == RESIZE_STATE_RESIZING) |
| 1400 | 1428 | return FALSE; |
| 1401 | 1429 | |
| 1402 | 1430 | // set the new bounds and create the device again |
| r243409 | r243410 | |
| 1406 | 1434 | return FALSE; |
| 1407 | 1435 | |
| 1408 | 1436 | // reset the resize state to normal, and indicate we made a change |
| 1409 | | window().m_resize_state = RESIZE_STATE_NORMAL; |
| 1437 | m_window->m_resize_state = RESIZE_STATE_NORMAL; |
| 1410 | 1438 | return TRUE; |
| 1411 | 1439 | } |
| 1412 | 1440 | |
| r243409 | r243410 | |
| 1416 | 1444 | |
| 1417 | 1445 | void renderer::batch_vectors() |
| 1418 | 1446 | { |
| 1419 | | windows_options &options = downcast<windows_options &>(window().machine().options()); |
| 1447 | windows_options &options = downcast<windows_options &>(m_window->machine().options()); |
| 1420 | 1448 | |
| 1421 | 1449 | int vector_size = (options.antialias() ? 24 : 6); |
| 1422 | 1450 | m_vectorbatch = mesh_alloc(m_line_count * vector_size); |
| r243409 | r243410 | |
| 1426 | 1454 | int line_index = 0; |
| 1427 | 1455 | float period = options.screen_vector_time_period(); |
| 1428 | 1456 | UINT32 cached_flags = 0; |
| 1429 | | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 1457 | for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 1430 | 1458 | { |
| 1431 | 1459 | switch (prim->type) |
| 1432 | 1460 | { |
trunk/src/osd/windows/drawdd.c
| r243409 | r243410 | |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | /* dd_info is the information about DirectDraw for the current screen */ |
| 39 | | class renderer_dd : public osd_renderer |
| 39 | struct dd_info |
| 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 | | |
| 104 | 41 | GUID adapter; // current display adapter |
| 105 | 42 | GUID * adapter_ptr; // pointer to current display adapter |
| 43 | int width, height; // current width, height |
| 44 | int refresh; // current refresh rate |
| 106 | 45 | int clearouter; // clear the outer areas? |
| 107 | 46 | |
| 108 | 47 | INT32 blitwidth, blitheight; // current blit width/height values |
| r243409 | r243410 | |
| 140 | 79 | /* mode_enum_info holds information during a display mode enumeration */ |
| 141 | 80 | struct mode_enum_info |
| 142 | 81 | { |
| 143 | | win_window_info * window; |
| 82 | win_window_info * window; |
| 144 | 83 | INT32 minimum_width, minimum_height; |
| 145 | 84 | INT32 target_width, target_height; |
| 146 | 85 | double target_refresh; |
| r243409 | r243410 | |
| 163 | 102 | // INLINES |
| 164 | 103 | //============================================================ |
| 165 | 104 | |
| 166 | | inline void renderer_dd::update_outer_rects() |
| 105 | INLINE void update_outer_rects(dd_info *dd) |
| 167 | 106 | { |
| 168 | | clearouter = (back != NULL) ? 3 : 1; |
| 107 | dd->clearouter = (dd->back != NULL) ? 3 : 1; |
| 169 | 108 | } |
| 170 | 109 | |
| 171 | 110 | |
| r243409 | r243410 | |
| 184 | 123 | |
| 185 | 124 | // core functions |
| 186 | 125 | 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); |
| 187 | 130 | |
| 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); |
| 188 | 140 | |
| 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); |
| 189 | 144 | |
| 190 | | //============================================================ |
| 191 | | // drawnone_create |
| 192 | | //============================================================ |
| 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); |
| 193 | 149 | |
| 194 | | static osd_renderer *drawdd_create(win_window_info *window) |
| 195 | | { |
| 196 | | return global_alloc(renderer_dd(window)); |
| 197 | | } |
| 198 | 150 | |
| 199 | 151 | |
| 200 | 152 | //============================================================ |
| 201 | 153 | // drawdd_init |
| 202 | 154 | //============================================================ |
| 203 | 155 | |
| 204 | | int drawdd_init(running_machine &machine, osd_draw_callbacks *callbacks) |
| 156 | int drawdd_init(running_machine &machine, win_draw_callbacks *callbacks) |
| 205 | 157 | { |
| 206 | 158 | // dynamically grab the create function from ddraw.dll |
| 207 | 159 | dllhandle = LoadLibrary(TEXT("ddraw.dll")); |
| r243409 | r243410 | |
| 234 | 186 | // fill in the callbacks |
| 235 | 187 | memset(callbacks, 0, sizeof(*callbacks)); |
| 236 | 188 | callbacks->exit = drawdd_exit; |
| 237 | | callbacks->create = drawdd_create; |
| 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; |
| 238 | 193 | |
| 239 | 194 | osd_printf_verbose("DirectDraw: Using DirectDraw 7\n"); |
| 240 | 195 | return 0; |
| r243409 | r243410 | |
| 258 | 213 | // drawdd_window_init |
| 259 | 214 | //============================================================ |
| 260 | 215 | |
| 261 | | int renderer_dd::init() |
| 216 | static int drawdd_window_init(win_window_info *window) |
| 262 | 217 | { |
| 218 | dd_info *dd; |
| 219 | |
| 220 | // allocate memory for our structures |
| 221 | dd = global_alloc_clear(dd_info); |
| 222 | window->m_drawdata = dd; |
| 223 | |
| 263 | 224 | // configure the adapter for the mode we want |
| 264 | | if (config_adapter_mode()) |
| 225 | if (config_adapter_mode(window)) |
| 265 | 226 | goto error; |
| 266 | 227 | |
| 267 | 228 | // create the ddraw object |
| 268 | | if (ddraw_create()) |
| 229 | if (ddraw_create(window)) |
| 269 | 230 | goto error; |
| 270 | 231 | |
| 271 | 232 | return 0; |
| 272 | 233 | |
| 273 | 234 | error: |
| 274 | | destroy(); |
| 235 | drawdd_window_destroy(window); |
| 275 | 236 | osd_printf_error("Unable to initialize DirectDraw.\n"); |
| 276 | 237 | return 1; |
| 277 | 238 | } |
| r243409 | r243410 | |
| 282 | 243 | // drawdd_window_destroy |
| 283 | 244 | //============================================================ |
| 284 | 245 | |
| 285 | | void renderer_dd::destroy() |
| 246 | static void drawdd_window_destroy(win_window_info *window) |
| 286 | 247 | { |
| 248 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 249 | |
| 250 | // skip if nothing |
| 251 | if (dd == NULL) |
| 252 | return; |
| 253 | |
| 287 | 254 | // delete the ddraw object |
| 288 | | ddraw_delete(); |
| 255 | ddraw_delete(window); |
| 256 | |
| 257 | // free the memory in the window |
| 258 | global_free(dd); |
| 259 | window->m_drawdata = NULL; |
| 289 | 260 | } |
| 290 | 261 | |
| 291 | 262 | |
| r243409 | r243410 | |
| 294 | 265 | // drawdd_window_get_primitives |
| 295 | 266 | //============================================================ |
| 296 | 267 | |
| 297 | | render_primitive_list *renderer_dd::get_primitives() |
| 268 | static render_primitive_list *drawdd_window_get_primitives(win_window_info *window) |
| 298 | 269 | { |
| 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); |
| 270 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 302 | 271 | |
| 303 | | return &window().m_target->get_primitives(); |
| 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(); |
| 304 | 277 | } |
| 305 | 278 | |
| 306 | 279 | |
| r243409 | r243410 | |
| 309 | 282 | // drawdd_window_draw |
| 310 | 283 | //============================================================ |
| 311 | 284 | |
| 312 | | int renderer_dd::draw(HDC dc, int update) |
| 285 | static int drawdd_window_draw(win_window_info *window, HDC dc, int update) |
| 313 | 286 | { |
| 287 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 314 | 288 | render_primitive *prim; |
| 315 | 289 | int usemembuffer = FALSE; |
| 316 | 290 | HRESULT result; |
| 317 | 291 | |
| 292 | // if we haven't been created, just punt |
| 293 | if (dd == NULL) |
| 294 | return 1; |
| 295 | |
| 318 | 296 | // if we're updating, remember to erase the outer stuff |
| 319 | 297 | if (update) |
| 320 | | update_outer_rects(); |
| 298 | update_outer_rects(dd); |
| 321 | 299 | |
| 322 | 300 | // if we have a ddraw object, check the cooperative level |
| 323 | | if (ddraw_test_cooperative()) |
| 301 | if (ddraw_test_cooperative(window)) |
| 324 | 302 | return 1; |
| 325 | 303 | |
| 326 | 304 | // get the size; if we're too small, delete the existing surfaces |
| 327 | | if (blitwidth > blitdesc.dwWidth || blitheight > blitdesc.dwHeight) |
| 328 | | ddraw_delete_surfaces(); |
| 305 | if (dd->blitwidth > dd->blitdesc.dwWidth || dd->blitheight > dd->blitdesc.dwHeight) |
| 306 | ddraw_delete_surfaces(window); |
| 329 | 307 | |
| 330 | 308 | // if we need to create surfaces, do it now |
| 331 | | if (blit == NULL && ddraw_create_surfaces() != 0) |
| 309 | if (dd->blit == NULL && ddraw_create_surfaces(window) != 0) |
| 332 | 310 | return 1; |
| 333 | 311 | |
| 334 | 312 | // select our surface and lock it |
| 335 | | result = IDirectDrawSurface7_Lock(blit, NULL, &blitdesc, DDLOCK_WAIT, NULL); |
| 313 | result = IDirectDrawSurface7_Lock(dd->blit, NULL, &dd->blitdesc, DDLOCK_WAIT, NULL); |
| 336 | 314 | if (result == DDERR_SURFACELOST) |
| 337 | 315 | { |
| 338 | 316 | osd_printf_verbose("DirectDraw: Lost surfaces; deleting and retrying next frame\n"); |
| 339 | | ddraw_delete_surfaces(); |
| 317 | ddraw_delete_surfaces(window); |
| 340 | 318 | return 1; |
| 341 | 319 | } |
| 342 | 320 | if (result != DD_OK) |
| r243409 | r243410 | |
| 346 | 324 | } |
| 347 | 325 | |
| 348 | 326 | // render to it |
| 349 | | window().m_primlist->acquire_lock(); |
| 327 | window->m_primlist->acquire_lock(); |
| 350 | 328 | |
| 351 | 329 | // scan the list of primitives for tricky stuff |
| 352 | | for (prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 330 | for (prim = window->m_primlist->first(); prim != NULL; prim = prim->next()) |
| 353 | 331 | if (PRIMFLAG_GET_BLENDMODE(prim->flags) != BLENDMODE_NONE || |
| 354 | 332 | (prim->texture.base != NULL && PRIMFLAG_GET_TEXFORMAT(prim->flags) == TEXFORMAT_ARGB32)) |
| 355 | 333 | { |
| r243409 | r243410 | |
| 363 | 341 | int x, y; |
| 364 | 342 | |
| 365 | 343 | // based on the target format, use one of our standard renderers |
| 366 | | switch (blitdesc.ddpfPixelFormat.dwRBitMask) |
| 344 | switch (dd->blitdesc.ddpfPixelFormat.dwRBitMask) |
| 367 | 345 | { |
| 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; |
| 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; |
| 372 | 350 | default: |
| 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); |
| 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); |
| 374 | 352 | break; |
| 375 | 353 | } |
| 376 | 354 | |
| 377 | 355 | // handle copying to both 16bpp and 32bpp destinations |
| 378 | | for (y = 0; y < blitheight; y++) |
| 356 | for (y = 0; y < dd->blitheight; y++) |
| 379 | 357 | { |
| 380 | | if (blitdesc.ddpfPixelFormat.dwRGBBitCount == 32) |
| 358 | if (dd->blitdesc.ddpfPixelFormat.dwRGBBitCount == 32) |
| 381 | 359 | { |
| 382 | | UINT32 *src = (UINT32 *)membuffer + y * blitwidth; |
| 383 | | UINT32 *dst = (UINT32 *)((UINT8 *)blitdesc.lpSurface + y * blitdesc.lPitch); |
| 384 | | for (x = 0; x < blitwidth; x++) |
| 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++) |
| 385 | 363 | *dst++ = *src++; |
| 386 | 364 | } |
| 387 | | else if (blitdesc.ddpfPixelFormat.dwRGBBitCount == 16) |
| 365 | else if (dd->blitdesc.ddpfPixelFormat.dwRGBBitCount == 16) |
| 388 | 366 | { |
| 389 | | UINT16 *src = (UINT16 *)membuffer + y * blitwidth; |
| 390 | | UINT16 *dst = (UINT16 *)((UINT8 *)blitdesc.lpSurface + y * blitdesc.lPitch); |
| 391 | | for (x = 0; x < blitwidth; x++) |
| 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++) |
| 392 | 370 | *dst++ = *src++; |
| 393 | 371 | } |
| 394 | 372 | } |
| r243409 | r243410 | |
| 399 | 377 | else |
| 400 | 378 | { |
| 401 | 379 | // based on the target format, use one of our standard renderers |
| 402 | | switch (blitdesc.ddpfPixelFormat.dwRBitMask) |
| 380 | switch (dd->blitdesc.ddpfPixelFormat.dwRBitMask) |
| 403 | 381 | { |
| 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; |
| 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; |
| 408 | 386 | default: |
| 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); |
| 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); |
| 410 | 388 | break; |
| 411 | 389 | } |
| 412 | 390 | } |
| 413 | | window().m_primlist->release_lock(); |
| 391 | window->m_primlist->release_lock(); |
| 414 | 392 | |
| 415 | 393 | // unlock and blit |
| 416 | | result = IDirectDrawSurface7_Unlock(blit, NULL); |
| 394 | result = IDirectDrawSurface7_Unlock(dd->blit, NULL); |
| 417 | 395 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X unlocking blit surface\n", (int)result); |
| 418 | 396 | |
| 419 | 397 | // sync to VBLANK |
| 420 | | if ((video_config.waitvsync || video_config.syncrefresh) && window().machine().video().throttled() && (!window().m_fullscreen || back == NULL)) |
| 398 | if ((video_config.waitvsync || video_config.syncrefresh) && window->machine().video().throttled() && (!window->m_fullscreen || dd->back == NULL)) |
| 421 | 399 | { |
| 422 | | result = IDirectDraw7_WaitForVerticalBlank(ddraw, DDWAITVB_BLOCKBEGIN, NULL); |
| 400 | result = IDirectDraw7_WaitForVerticalBlank(dd->ddraw, DDWAITVB_BLOCKBEGIN, NULL); |
| 423 | 401 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result); |
| 424 | 402 | } |
| 425 | 403 | |
| 426 | 404 | // complete the blitting |
| 427 | | blit_to_primary(blitwidth, blitheight); |
| 405 | blit_to_primary(window, dd->blitwidth, dd->blitheight); |
| 428 | 406 | return 0; |
| 429 | 407 | } |
| 430 | 408 | |
| r243409 | r243410 | |
| 434 | 412 | // ddraw_create |
| 435 | 413 | //============================================================ |
| 436 | 414 | |
| 437 | | int renderer_dd::ddraw_create() |
| 415 | static int ddraw_create(win_window_info *window) |
| 438 | 416 | { |
| 417 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 439 | 418 | HRESULT result; |
| 440 | 419 | int verify; |
| 441 | 420 | |
| 442 | 421 | // if a device exists, free it |
| 443 | | if (ddraw != NULL) |
| 444 | | ddraw_delete(); |
| 422 | if (dd->ddraw != NULL) |
| 423 | ddraw_delete(window); |
| 445 | 424 | |
| 446 | 425 | // create the DirectDraw object |
| 447 | | result = (*directdrawcreateex)(adapter_ptr, (LPVOID *)&ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 426 | result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 448 | 427 | if (result != DD_OK) |
| 449 | 428 | { |
| 450 | 429 | osd_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); |
| r243409 | r243410 | |
| 452 | 431 | } |
| 453 | 432 | |
| 454 | 433 | // verify the caps |
| 455 | | verify = ddraw_verify_caps(); |
| 434 | verify = ddraw_verify_caps(dd); |
| 456 | 435 | if (verify == 2) |
| 457 | 436 | { |
| 458 | 437 | osd_printf_error("DirectDraw: Error - Device does not meet minimum requirements for DirectDraw rendering\n"); |
| r243409 | r243410 | |
| 463 | 442 | |
| 464 | 443 | // set the cooperative level |
| 465 | 444 | // for non-window modes, we will use full screen here |
| 466 | | result = IDirectDraw7_SetCooperativeLevel(ddraw, win_window_list->m_hwnd, DDSCL_SETFOCUSWINDOW); |
| 445 | result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, win_window_list->m_hwnd, DDSCL_SETFOCUSWINDOW); |
| 467 | 446 | if (result != DD_OK) |
| 468 | 447 | { |
| 469 | 448 | osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(FOCUSWINDOW) call\n", (int)result); |
| 470 | 449 | goto error; |
| 471 | 450 | } |
| 472 | | result = IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_SETDEVICEWINDOW | (window().m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL)); |
| 451 | result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->m_hwnd, DDSCL_SETDEVICEWINDOW | (window->m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL)); |
| 473 | 452 | if (result != DD_OK) |
| 474 | 453 | { |
| 475 | 454 | osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(DEVICEWINDOW) call\n", (int)result); |
| r243409 | r243410 | |
| 477 | 456 | } |
| 478 | 457 | |
| 479 | 458 | // full screen mode: set the resolution |
| 480 | | if (window().m_fullscreen && video_config.switchres) |
| 459 | if (window->m_fullscreen && video_config.switchres) |
| 481 | 460 | { |
| 482 | | result = IDirectDraw7_SetDisplayMode(ddraw, width, height, 32, refresh, 0); |
| 461 | result = IDirectDraw7_SetDisplayMode(dd->ddraw, dd->width, dd->height, 32, dd->refresh, 0); |
| 483 | 462 | if (result != DD_OK) |
| 484 | 463 | { |
| 485 | | osd_printf_verbose("DirectDraw: Error %08X attempting to set video mode %dx%d@%d call\n", (int)result, width, height, refresh); |
| 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); |
| 486 | 465 | goto error; |
| 487 | 466 | } |
| 488 | 467 | } |
| 489 | 468 | |
| 490 | | return ddraw_create_surfaces(); |
| 469 | return ddraw_create_surfaces(window); |
| 491 | 470 | |
| 492 | 471 | error: |
| 493 | | ddraw_delete(); |
| 472 | ddraw_delete(window); |
| 494 | 473 | return 1; |
| 495 | 474 | } |
| 496 | 475 | |
| r243409 | r243410 | |
| 500 | 479 | // ddraw_create_surfaces |
| 501 | 480 | //============================================================ |
| 502 | 481 | |
| 503 | | int renderer_dd::ddraw_create_surfaces() |
| 482 | static int ddraw_create_surfaces(win_window_info *window) |
| 504 | 483 | { |
| 484 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 505 | 485 | HRESULT result; |
| 506 | 486 | |
| 507 | 487 | // make a description of the primary surface |
| 508 | | memset(&primarydesc, 0, sizeof(primarydesc)); |
| 509 | | primarydesc.dwSize = sizeof(primarydesc); |
| 510 | | primarydesc.dwFlags = DDSD_CAPS; |
| 511 | | primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
| 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; |
| 512 | 492 | |
| 513 | 493 | // for triple-buffered full screen mode, allocate flipping surfaces |
| 514 | | if (window().m_fullscreen && video_config.triplebuf) |
| 494 | if (window->m_fullscreen && video_config.triplebuf) |
| 515 | 495 | { |
| 516 | | primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT; |
| 517 | | primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
| 518 | | primarydesc.dwBackBufferCount = 2; |
| 496 | dd->primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT; |
| 497 | dd->primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
| 498 | dd->primarydesc.dwBackBufferCount = 2; |
| 519 | 499 | } |
| 520 | 500 | |
| 521 | 501 | // create the primary surface and report errors |
| 522 | | result = create_surface(&primarydesc, &primary, "primary"); |
| 502 | result = create_surface(dd, &dd->primarydesc, &dd->primary, "primary"); |
| 523 | 503 | if (result != DD_OK) goto error; |
| 524 | 504 | |
| 525 | 505 | // full screen mode: get the back surface |
| 526 | | back = NULL; |
| 527 | | if (window().m_fullscreen && video_config.triplebuf) |
| 506 | dd->back = NULL; |
| 507 | if (window->m_fullscreen && video_config.triplebuf) |
| 528 | 508 | { |
| 529 | 509 | DDSCAPS2 caps = { DDSCAPS_BACKBUFFER }; |
| 530 | | result = IDirectDrawSurface7_GetAttachedSurface(primary, &caps, &back); |
| 510 | result = IDirectDrawSurface7_GetAttachedSurface(dd->primary, &caps, &dd->back); |
| 531 | 511 | if (result != DD_OK) |
| 532 | 512 | { |
| 533 | 513 | osd_printf_verbose("DirectDraw: Error %08X getting attached back surface\n", (int)result); |
| r243409 | r243410 | |
| 536 | 516 | } |
| 537 | 517 | |
| 538 | 518 | // now make a description of our blit surface, based on the primary surface |
| 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; |
| 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; |
| 546 | 526 | |
| 547 | 527 | // then create the blit surface, fall back to system memory if video mem doesn't work |
| 548 | | result = create_surface(&blitdesc, &blit, "blit"); |
| 528 | result = create_surface(dd, &dd->blitdesc, &dd->blit, "blit"); |
| 549 | 529 | if (result != DD_OK) |
| 550 | 530 | { |
| 551 | | blitdesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY; |
| 552 | | result = create_surface(&blitdesc, &blit, "blit"); |
| 531 | dd->blitdesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY; |
| 532 | result = create_surface(dd, &dd->blitdesc, &dd->blit, "blit"); |
| 553 | 533 | } |
| 554 | 534 | if (result != DD_OK) goto error; |
| 555 | 535 | |
| 556 | 536 | // create a memory buffer for offscreen drawing |
| 557 | | if (membuffersize < blitwidth * blitheight * 4) |
| 537 | if (dd->membuffersize < dd->blitwidth * dd->blitheight * 4) |
| 558 | 538 | { |
| 559 | | membuffersize = blitwidth * blitheight * 4; |
| 560 | | global_free_array(membuffer); |
| 561 | | membuffer = global_alloc_array(UINT8, membuffersize); |
| 539 | dd->membuffersize = dd->blitwidth * dd->blitheight * 4; |
| 540 | global_free_array(dd->membuffer); |
| 541 | dd->membuffer = global_alloc_array(UINT8, dd->membuffersize); |
| 562 | 542 | } |
| 563 | | if (membuffer == NULL) |
| 543 | if (dd->membuffer == NULL) |
| 564 | 544 | goto error; |
| 565 | 545 | |
| 566 | 546 | // create a clipper for windowed mode |
| 567 | | if (!window().m_fullscreen && create_clipper()) |
| 547 | if (!window->m_fullscreen && create_clipper(window)) |
| 568 | 548 | goto error; |
| 569 | 549 | |
| 570 | 550 | // full screen mode: set the gamma |
| 571 | | if (window().m_fullscreen) |
| 551 | if (window->m_fullscreen) |
| 572 | 552 | { |
| 573 | 553 | // only set the gamma if it's not 1.0f |
| 574 | | windows_options &options = downcast<windows_options &>(window().machine().options()); |
| 554 | windows_options &options = downcast<windows_options &>(window->machine().options()); |
| 575 | 555 | float brightness = options.full_screen_brightness(); |
| 576 | 556 | float contrast = options.full_screen_contrast(); |
| 577 | | float fgamma = options.full_screen_gamma(); |
| 578 | | if (brightness != 1.0f || contrast != 1.0f || fgamma != 1.0f) |
| 557 | float gamma = options.full_screen_gamma(); |
| 558 | if (brightness != 1.0f || contrast != 1.0f || gamma != 1.0f) |
| 579 | 559 | { |
| 580 | 560 | // see if we can get a GammaControl object |
| 581 | | result = IDirectDrawSurface_QueryInterface(primary, WRAP_REFIID(IID_IDirectDrawGammaControl), (void **)&gamma); |
| 561 | result = IDirectDrawSurface_QueryInterface(dd->primary, WRAP_REFIID(IID_IDirectDrawGammaControl), (void **)&dd->gamma); |
| 582 | 562 | if (result != DD_OK) |
| 583 | 563 | { |
| 584 | 564 | osd_printf_warning("DirectDraw: Warning - device does not support full screen gamma correction.\n"); |
| 585 | | this->gamma = NULL; |
| 565 | dd->gamma = NULL; |
| 586 | 566 | } |
| 587 | 567 | |
| 588 | 568 | // proceed if we can |
| 589 | | if (this->gamma != NULL) |
| 569 | if (dd->gamma != NULL) |
| 590 | 570 | { |
| 591 | 571 | DDGAMMARAMP ramp; |
| 592 | 572 | int i; |
| 593 | 573 | |
| 594 | 574 | // create a standard ramp and set it |
| 595 | 575 | for (i = 0; i < 256; i++) |
| 596 | | ramp.red[i] = ramp.green[i] = ramp.blue[i] = apply_brightness_contrast_gamma(i, brightness, contrast, fgamma) << 8; |
| 576 | ramp.red[i] = ramp.green[i] = ramp.blue[i] = apply_brightness_contrast_gamma(i, brightness, contrast, gamma) << 8; |
| 597 | 577 | |
| 598 | 578 | // attempt to set it |
| 599 | | result = IDirectDrawGammaControl_SetGammaRamp(this->gamma, 0, &ramp); |
| 579 | result = IDirectDrawGammaControl_SetGammaRamp(dd->gamma, 0, &ramp); |
| 600 | 580 | if (result != DD_OK) |
| 601 | 581 | osd_printf_verbose("DirectDraw: Error %08X attempting to set gamma correction.\n", (int)result); |
| 602 | 582 | } |
| r243409 | r243410 | |
| 604 | 584 | } |
| 605 | 585 | |
| 606 | 586 | // force some updates |
| 607 | | update_outer_rects(); |
| 587 | update_outer_rects(dd); |
| 608 | 588 | return 0; |
| 609 | 589 | |
| 610 | 590 | error: |
| 611 | | ddraw_delete_surfaces(); |
| 591 | ddraw_delete_surfaces(window); |
| 612 | 592 | return 1; |
| 613 | 593 | } |
| 614 | 594 | |
| r243409 | r243410 | |
| 618 | 598 | // ddraw_delete |
| 619 | 599 | //============================================================ |
| 620 | 600 | |
| 621 | | void renderer_dd::ddraw_delete() |
| 601 | static void ddraw_delete(win_window_info *window) |
| 622 | 602 | { |
| 603 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 604 | |
| 623 | 605 | // free surfaces |
| 624 | | ddraw_delete_surfaces(); |
| 606 | ddraw_delete_surfaces(window); |
| 625 | 607 | |
| 626 | 608 | // restore resolutions |
| 627 | | if (ddraw != NULL) |
| 628 | | IDirectDraw7_RestoreDisplayMode(ddraw); |
| 609 | if (dd->ddraw != NULL) |
| 610 | IDirectDraw7_RestoreDisplayMode(dd->ddraw); |
| 629 | 611 | |
| 630 | 612 | // reset cooperative level |
| 631 | | if (ddraw != NULL && window().m_hwnd != NULL) |
| 632 | | IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_NORMAL); |
| 613 | if (dd->ddraw != NULL && window->m_hwnd != NULL) |
| 614 | IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->m_hwnd, DDSCL_NORMAL); |
| 633 | 615 | |
| 634 | 616 | // release the DirectDraw object itself |
| 635 | | if (ddraw != NULL) |
| 636 | | IDirectDraw7_Release(ddraw); |
| 637 | | ddraw = NULL; |
| 617 | if (dd->ddraw != NULL) |
| 618 | IDirectDraw7_Release(dd->ddraw); |
| 619 | dd->ddraw = NULL; |
| 638 | 620 | } |
| 639 | 621 | |
| 640 | 622 | |
| r243409 | r243410 | |
| 643 | 625 | // ddraw_delete_surfaces |
| 644 | 626 | //============================================================ |
| 645 | 627 | |
| 646 | | void renderer_dd::ddraw_delete_surfaces() |
| 628 | static void ddraw_delete_surfaces(win_window_info *window) |
| 647 | 629 | { |
| 630 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 631 | |
| 648 | 632 | // release the gamma control |
| 649 | | if (gamma != NULL) |
| 650 | | IDirectDrawGammaControl_Release(gamma); |
| 651 | | gamma = NULL; |
| 633 | if (dd->gamma != NULL) |
| 634 | IDirectDrawGammaControl_Release(dd->gamma); |
| 635 | dd->gamma = NULL; |
| 652 | 636 | |
| 653 | 637 | // release the clipper |
| 654 | | if (clipper != NULL) |
| 655 | | IDirectDrawClipper_Release(clipper); |
| 656 | | clipper = NULL; |
| 638 | if (dd->clipper != NULL) |
| 639 | IDirectDrawClipper_Release(dd->clipper); |
| 640 | dd->clipper = NULL; |
| 657 | 641 | |
| 658 | 642 | // free the memory buffer |
| 659 | | global_free_array(membuffer); |
| 660 | | membuffer = NULL; |
| 661 | | membuffersize = 0; |
| 643 | global_free_array(dd->membuffer); |
| 644 | dd->membuffer = NULL; |
| 645 | dd->membuffersize = 0; |
| 662 | 646 | |
| 663 | 647 | // release the blit surface |
| 664 | | if (blit != NULL) |
| 665 | | IDirectDrawSurface7_Release(blit); |
| 666 | | blit = NULL; |
| 648 | if (dd->blit != NULL) |
| 649 | IDirectDrawSurface7_Release(dd->blit); |
| 650 | dd->blit = NULL; |
| 667 | 651 | |
| 668 | 652 | // release the back surface |
| 669 | | if (back != NULL) |
| 670 | | IDirectDrawSurface7_Release(back); |
| 671 | | back = NULL; |
| 653 | if (dd->back != NULL) |
| 654 | IDirectDrawSurface7_Release(dd->back); |
| 655 | dd->back = NULL; |
| 672 | 656 | |
| 673 | 657 | // release the primary surface |
| 674 | | if (primary != NULL) |
| 675 | | IDirectDrawSurface7_Release(primary); |
| 676 | | primary = NULL; |
| 658 | if (dd->primary != NULL) |
| 659 | IDirectDrawSurface7_Release(dd->primary); |
| 660 | dd->primary = NULL; |
| 677 | 661 | } |
| 678 | 662 | |
| 679 | 663 | |
| r243409 | r243410 | |
| 682 | 666 | // ddraw_verify_caps |
| 683 | 667 | //============================================================ |
| 684 | 668 | |
| 685 | | int renderer_dd::ddraw_verify_caps() |
| 669 | static int ddraw_verify_caps(dd_info *dd) |
| 686 | 670 | { |
| 687 | 671 | int retval = 0; |
| 688 | 672 | HRESULT result; |
| 689 | 673 | |
| 690 | 674 | // get the capabilities |
| 691 | | ddcaps.dwSize = sizeof(ddcaps); |
| 692 | | helcaps.dwSize = sizeof(helcaps); |
| 693 | | result = IDirectDraw7_GetCaps(ddraw, &ddcaps, &helcaps); |
| 675 | dd->ddcaps.dwSize = sizeof(dd->ddcaps); |
| 676 | dd->helcaps.dwSize = sizeof(dd->helcaps); |
| 677 | result = IDirectDraw7_GetCaps(dd->ddraw, &dd->ddcaps, &dd->helcaps); |
| 694 | 678 | if (result != DD_OK) |
| 695 | 679 | { |
| 696 | 680 | osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_GetCaps call\n", (int)result); |
| r243409 | r243410 | |
| 698 | 682 | } |
| 699 | 683 | |
| 700 | 684 | // determine if hardware stretching is available |
| 701 | | if ((ddcaps.dwCaps & DDCAPS_BLTSTRETCH) == 0) |
| 685 | if ((dd->ddcaps.dwCaps & DDCAPS_BLTSTRETCH) == 0) |
| 702 | 686 | { |
| 703 | 687 | osd_printf_verbose("DirectDraw: Warning - Device does not support hardware stretching\n"); |
| 704 | 688 | retval = 1; |
| r243409 | r243410 | |
| 713 | 697 | // ddraw_test_cooperative |
| 714 | 698 | //============================================================ |
| 715 | 699 | |
| 716 | | int renderer_dd::ddraw_test_cooperative() |
| 700 | static int ddraw_test_cooperative(win_window_info *window) |
| 717 | 701 | { |
| 702 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 718 | 703 | HRESULT result; |
| 719 | 704 | |
| 720 | 705 | // check our current status; if we lost the device, punt to GDI |
| 721 | | result = IDirectDraw7_TestCooperativeLevel(ddraw); |
| 706 | result = IDirectDraw7_TestCooperativeLevel(dd->ddraw); |
| 722 | 707 | switch (result) |
| 723 | 708 | { |
| 724 | 709 | // punt to GDI if someone else has exclusive mode |
| 725 | 710 | case DDERR_NOEXCLUSIVEMODE: |
| 726 | 711 | case DDERR_EXCLUSIVEMODEALREADYSET: |
| 727 | | ddraw_delete_surfaces(); |
| 712 | ddraw_delete_surfaces(window); |
| 728 | 713 | return 1; |
| 729 | 714 | |
| 730 | 715 | // if we're ok, but we don't have a primary surface, create one |
| 731 | 716 | default: |
| 732 | 717 | case DD_OK: |
| 733 | | if (primary == NULL) |
| 734 | | return ddraw_create_surfaces(); |
| 718 | if (dd->primary == NULL) |
| 719 | return ddraw_create_surfaces(window); |
| 735 | 720 | return 0; |
| 736 | 721 | } |
| 737 | 722 | } |
| r243409 | r243410 | |
| 742 | 727 | // create_surface |
| 743 | 728 | //============================================================ |
| 744 | 729 | |
| 745 | | HRESULT renderer_dd::create_surface(DDSURFACEDESC2 *desc, IDirectDrawSurface7 **surface, const char *type) |
| 730 | static HRESULT create_surface(dd_info *dd, DDSURFACEDESC2 *desc, IDirectDrawSurface7 **surface, const char *type) |
| 746 | 731 | { |
| 747 | 732 | HRESULT result; |
| 748 | 733 | |
| 749 | 734 | // create the surface as requested |
| 750 | | result = IDirectDraw7_CreateSurface(ddraw, desc, surface, NULL); |
| 735 | result = IDirectDraw7_CreateSurface(dd->ddraw, desc, surface, NULL); |
| 751 | 736 | if (result != DD_OK) |
| 752 | 737 | { |
| 753 | 738 | osd_printf_verbose("DirectDraw: Error %08X creating %s surface\n", (int)result, type); |
| r243409 | r243410 | |
| 782 | 767 | // create_clipper |
| 783 | 768 | //============================================================ |
| 784 | 769 | |
| 785 | | int renderer_dd::create_clipper() |
| 770 | static int create_clipper(win_window_info *window) |
| 786 | 771 | { |
| 772 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 787 | 773 | HRESULT result; |
| 788 | 774 | |
| 789 | 775 | // create a clipper for the primary surface |
| 790 | | result = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL); |
| 776 | result = IDirectDraw7_CreateClipper(dd->ddraw, 0, &dd->clipper, NULL); |
| 791 | 777 | if (result != DD_OK) |
| 792 | 778 | { |
| 793 | 779 | osd_printf_verbose("DirectDraw: Error %08X creating clipper\n", (int)result); |
| r243409 | r243410 | |
| 795 | 781 | } |
| 796 | 782 | |
| 797 | 783 | // set the clipper's hwnd |
| 798 | | result = IDirectDrawClipper_SetHWnd(clipper, 0, window().m_hwnd); |
| 784 | result = IDirectDrawClipper_SetHWnd(dd->clipper, 0, window->m_hwnd); |
| 799 | 785 | if (result != DD_OK) |
| 800 | 786 | { |
| 801 | 787 | osd_printf_verbose("DirectDraw: Error %08X setting clipper hwnd\n", (int)result); |
| r243409 | r243410 | |
| 803 | 789 | } |
| 804 | 790 | |
| 805 | 791 | // set the clipper on the primary surface |
| 806 | | result = IDirectDrawSurface7_SetClipper(primary, clipper); |
| 792 | result = IDirectDrawSurface7_SetClipper(dd->primary, dd->clipper); |
| 807 | 793 | if (result != DD_OK) |
| 808 | 794 | { |
| 809 | 795 | osd_printf_verbose("DirectDraw: Error %08X setting clipper on primary surface\n", (int)result); |
| r243409 | r243410 | |
| 818 | 804 | // compute_blit_surface_size |
| 819 | 805 | //============================================================ |
| 820 | 806 | |
| 821 | | void renderer_dd::compute_blit_surface_size() |
| 807 | static void compute_blit_surface_size(win_window_info *window) |
| 822 | 808 | { |
| 809 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 823 | 810 | INT32 newwidth, newheight; |
| 824 | 811 | int xscale, yscale; |
| 825 | 812 | RECT client; |
| 826 | 813 | |
| 827 | 814 | // start with the minimum size |
| 828 | | window().m_target->compute_minimum_size(newwidth, newheight); |
| 815 | window->m_target->compute_minimum_size(newwidth, newheight); |
| 829 | 816 | |
| 830 | 817 | // get the window's client rectangle |
| 831 | | GetClientRect(window().m_hwnd, &client); |
| 818 | GetClientRect(window->m_hwnd, &client); |
| 832 | 819 | |
| 833 | 820 | // hardware stretch case: apply prescale |
| 834 | 821 | if (video_config.hwstretch) |
| r243409 | r243410 | |
| 854 | 841 | // compute the appropriate visible area if we're trying to keepaspect |
| 855 | 842 | if (video_config.keepaspect) |
| 856 | 843 | { |
| 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); |
| 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); |
| 859 | 846 | desired_aspect = (float)target_width / (float)target_height; |
| 860 | 847 | } |
| 861 | 848 | |
| r243409 | r243410 | |
| 897 | 884 | // apply the final scale |
| 898 | 885 | newwidth *= xscale; |
| 899 | 886 | newheight *= yscale; |
| 900 | | if (newwidth != blitwidth || newheight != blitheight) |
| 887 | if (newwidth != dd->blitwidth || newheight != dd->blitheight) |
| 901 | 888 | { |
| 902 | 889 | // force some updates |
| 903 | | update_outer_rects(); |
| 890 | update_outer_rects(dd); |
| 904 | 891 | osd_printf_verbose("DirectDraw: New blit size = %dx%d\n", newwidth, newheight); |
| 905 | 892 | } |
| 906 | | blitwidth = newwidth; |
| 907 | | blitheight = newheight; |
| 893 | dd->blitwidth = newwidth; |
| 894 | dd->blitheight = newheight; |
| 908 | 895 | } |
| 909 | 896 | |
| 910 | 897 | |
| r243409 | r243410 | |
| 913 | 900 | // calc_fullscreen_margins |
| 914 | 901 | //============================================================ |
| 915 | 902 | |
| 916 | | void renderer_dd::calc_fullscreen_margins(DWORD desc_width, DWORD desc_height, RECT *margins) |
| 903 | static void calc_fullscreen_margins(win_window_info *window, DWORD desc_width, DWORD desc_height, RECT *margins) |
| 917 | 904 | { |
| 918 | 905 | margins->left = 0; |
| 919 | 906 | margins->top = 0; |
| 920 | 907 | margins->right = desc_width; |
| 921 | 908 | margins->bottom = desc_height; |
| 922 | 909 | |
| 923 | | if (win_has_menu(&window())) |
| 910 | if (win_has_menu(window)) |
| 924 | 911 | { |
| 925 | 912 | static int height_with_menubar = 0; |
| 926 | 913 | if (height_with_menubar == 0) |
| r243409 | r243410 | |
| 941 | 928 | // blit_to_primary |
| 942 | 929 | //============================================================ |
| 943 | 930 | |
| 944 | | void renderer_dd::blit_to_primary(int srcwidth, int srcheight) |
| 931 | static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight) |
| 945 | 932 | { |
| 946 | | IDirectDrawSurface7 *target = (back != NULL) ? back : primary; |
| 947 | | win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL); |
| 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); |
| 948 | 936 | DDBLTFX blitfx = { sizeof(DDBLTFX) }; |
| 949 | 937 | RECT clear, outer, dest, source; |
| 950 | 938 | INT32 dstwidth, dstheight; |
| r243409 | r243410 | |
| 956 | 944 | source.bottom = srcheight; |
| 957 | 945 | |
| 958 | 946 | // compute outer rect -- windowed version |
| 959 | | if (!window().m_fullscreen) |
| 947 | if (!window->m_fullscreen) |
| 960 | 948 | { |
| 961 | | GetClientRect(window().m_hwnd, &outer); |
| 962 | | ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[0]); |
| 963 | | ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[1]); |
| 949 | GetClientRect(window->m_hwnd, &outer); |
| 950 | ClientToScreen(window->m_hwnd, &((LPPOINT)&outer)[0]); |
| 951 | ClientToScreen(window->m_hwnd, &((LPPOINT)&outer)[1]); |
| 964 | 952 | |
| 965 | 953 | // adjust to be relative to the monitor |
| 966 | 954 | outer.left -= monitor->info.rcMonitor.left; |
| r243409 | r243410 | |
| 972 | 960 | // compute outer rect -- full screen version |
| 973 | 961 | else |
| 974 | 962 | { |
| 975 | | calc_fullscreen_margins(primarydesc.dwWidth, primarydesc.dwHeight, &outer); |
| 963 | calc_fullscreen_margins(window, dd->primarydesc.dwWidth, dd->primarydesc.dwHeight, &outer); |
| 976 | 964 | } |
| 977 | 965 | |
| 978 | 966 | // if we're respecting the aspect ratio, we need to adjust to fit |
| r243409 | r243410 | |
| 999 | 987 | else if (video_config.keepaspect) |
| 1000 | 988 | { |
| 1001 | 989 | // compute the appropriate visible area |
| 1002 | | window().m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().m_target->orientation(), dstwidth, dstheight); |
| 990 | window->m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window->m_target->orientation(), dstwidth, dstheight); |
| 1003 | 991 | } |
| 1004 | 992 | |
| 1005 | 993 | // center within |
| r243409 | r243410 | |
| 1009 | 997 | dest.bottom = dest.top + dstheight; |
| 1010 | 998 | |
| 1011 | 999 | // compare against last destination; if different, force a redraw |
| 1012 | | if (dest.left != lastdest.left || dest.right != lastdest.right || dest.top != lastdest.top || dest.bottom != lastdest.bottom) |
| 1000 | if (dest.left != dd->lastdest.left || dest.right != dd->lastdest.right || dest.top != dd->lastdest.top || dest.bottom != dd->lastdest.bottom) |
| 1013 | 1001 | { |
| 1014 | | lastdest = dest; |
| 1015 | | update_outer_rects(); |
| 1002 | dd->lastdest = dest; |
| 1003 | update_outer_rects(dd); |
| 1016 | 1004 | } |
| 1017 | 1005 | |
| 1018 | 1006 | // clear outer rects if we need to |
| 1019 | | if (clearouter != 0) |
| 1007 | if (dd->clearouter != 0) |
| 1020 | 1008 | { |
| 1021 | | clearouter--; |
| 1009 | dd->clearouter--; |
| 1022 | 1010 | |
| 1023 | 1011 | // clear the left edge |
| 1024 | 1012 | if (dest.left > outer.left) |
| r243409 | r243410 | |
| 1058 | 1046 | } |
| 1059 | 1047 | |
| 1060 | 1048 | // do the blit |
| 1061 | | result = IDirectDrawSurface7_Blt(target, &dest, blit, &source, DDBLT_WAIT, NULL); |
| 1049 | result = IDirectDrawSurface7_Blt(target, &dest, dd->blit, &source, DDBLT_WAIT, NULL); |
| 1062 | 1050 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X blitting to the screen\n", (int)result); |
| 1063 | 1051 | |
| 1064 | 1052 | // page flip if triple buffered |
| 1065 | | if (window().m_fullscreen && back != NULL) |
| 1053 | if (window->m_fullscreen && dd->back != NULL) |
| 1066 | 1054 | { |
| 1067 | | result = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT); |
| 1055 | result = IDirectDrawSurface7_Flip(dd->primary, NULL, DDFLIP_WAIT); |
| 1068 | 1056 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result); |
| 1069 | 1057 | } |
| 1070 | 1058 | } |
| r243409 | r243410 | |
| 1075 | 1063 | // config_adapter_mode |
| 1076 | 1064 | //============================================================ |
| 1077 | 1065 | |
| 1078 | | int renderer_dd::config_adapter_mode() |
| 1066 | static int config_adapter_mode(win_window_info *window) |
| 1079 | 1067 | { |
| 1080 | 1068 | DDDEVICEIDENTIFIER2 identifier; |
| 1069 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 1081 | 1070 | HRESULT result; |
| 1082 | 1071 | |
| 1083 | 1072 | // choose the monitor number |
| 1084 | | get_adapter_for_monitor(window().m_monitor); |
| 1073 | get_adapter_for_monitor(dd, window->m_monitor); |
| 1085 | 1074 | |
| 1086 | 1075 | // create a temporary DirectDraw object |
| 1087 | | result = (*directdrawcreateex)(adapter_ptr, (LPVOID *)&ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 1076 | result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
| 1088 | 1077 | if (result != DD_OK) |
| 1089 | 1078 | { |
| 1090 | 1079 | osd_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); |
| r243409 | r243410 | |
| 1092 | 1081 | } |
| 1093 | 1082 | |
| 1094 | 1083 | // get the identifier |
| 1095 | | result = IDirectDraw7_GetDeviceIdentifier(ddraw, &identifier, 0); |
| 1084 | result = IDirectDraw7_GetDeviceIdentifier(dd->ddraw, &identifier, 0); |
| 1096 | 1085 | if (result != DD_OK) |
| 1097 | 1086 | { |
| 1098 | 1087 | osd_printf_error("Error getting identifier for device\n"); |
| r243409 | r243410 | |
| 1101 | 1090 | osd_printf_verbose("DirectDraw: Configuring device %s\n", identifier.szDescription); |
| 1102 | 1091 | |
| 1103 | 1092 | // get the current display mode |
| 1104 | | memset(&origmode, 0, sizeof(origmode)); |
| 1105 | | origmode.dwSize = sizeof(origmode); |
| 1106 | | result = IDirectDraw7_GetDisplayMode(ddraw, &origmode); |
| 1093 | memset(&dd->origmode, 0, sizeof(dd->origmode)); |
| 1094 | dd->origmode.dwSize = sizeof(dd->origmode); |
| 1095 | result = IDirectDraw7_GetDisplayMode(dd->ddraw, &dd->origmode); |
| 1107 | 1096 | if (result != DD_OK) |
| 1108 | 1097 | { |
| 1109 | 1098 | osd_printf_verbose("DirectDraw: Error %08X getting current display mode\n", (int)result); |
| 1110 | | IDirectDraw7_Release(ddraw); |
| 1099 | IDirectDraw7_Release(dd->ddraw); |
| 1111 | 1100 | return 1; |
| 1112 | 1101 | } |
| 1113 | 1102 | |
| 1114 | 1103 | // choose a resolution: full screen mode case |
| 1115 | | if (window().m_fullscreen) |
| 1104 | if (window->m_fullscreen) |
| 1116 | 1105 | { |
| 1117 | 1106 | // default to the current mode exactly |
| 1118 | | width = origmode.dwWidth; |
| 1119 | | height = origmode.dwHeight; |
| 1120 | | refresh = origmode.dwRefreshRate; |
| 1107 | dd->width = dd->origmode.dwWidth; |
| 1108 | dd->height = dd->origmode.dwHeight; |
| 1109 | dd->refresh = dd->origmode.dwRefreshRate; |
| 1121 | 1110 | |
| 1122 | 1111 | // if we're allowed to switch resolutions, override with something better |
| 1123 | 1112 | if (video_config.switchres) |
| 1124 | | pick_best_mode(); |
| 1113 | pick_best_mode(window); |
| 1125 | 1114 | } |
| 1126 | 1115 | |
| 1127 | 1116 | // release the DirectDraw object |
| 1128 | | IDirectDraw7_Release(ddraw); |
| 1129 | | ddraw = NULL; |
| 1117 | IDirectDraw7_Release(dd->ddraw); |
| 1118 | dd->ddraw = NULL; |
| 1130 | 1119 | |
| 1131 | 1120 | // if we're not changing resolutions, make sure we have a resolution we can handle |
| 1132 | | if (!window().m_fullscreen || !video_config.switchres) |
| 1121 | if (!window->m_fullscreen || !video_config.switchres) |
| 1133 | 1122 | { |
| 1134 | | switch (origmode.ddpfPixelFormat.dwRBitMask) |
| 1123 | switch (dd->origmode.ddpfPixelFormat.dwRBitMask) |
| 1135 | 1124 | { |
| 1136 | 1125 | case 0x00ff0000: |
| 1137 | 1126 | case 0x000000ff: |
| r243409 | r243410 | |
| 1140 | 1129 | break; |
| 1141 | 1130 | |
| 1142 | 1131 | default: |
| 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); |
| 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); |
| 1144 | 1133 | return 1; |
| 1145 | 1134 | } |
| 1146 | 1135 | } |
| r243409 | r243410 | |
| 1175 | 1164 | // get_adapter_for_monitor |
| 1176 | 1165 | //============================================================ |
| 1177 | 1166 | |
| 1178 | | void renderer_dd::get_adapter_for_monitor(win_monitor_info *monitor) |
| 1167 | static void get_adapter_for_monitor(dd_info *dd, win_monitor_info *monitor) |
| 1179 | 1168 | { |
| 1180 | 1169 | monitor_enum_info einfo; |
| 1181 | 1170 | HRESULT result; |
| r243409 | r243410 | |
| 1189 | 1178 | // set up the adapter |
| 1190 | 1179 | if (einfo.foundit && einfo.guid_ptr != NULL) |
| 1191 | 1180 | { |
| 1192 | | adapter = einfo.guid; |
| 1193 | | adapter_ptr = &adapter; |
| 1181 | dd->adapter = einfo.guid; |
| 1182 | dd->adapter_ptr = &dd->adapter; |
| 1194 | 1183 | } |
| 1195 | 1184 | else |
| 1196 | | adapter_ptr = NULL; |
| 1185 | dd->adapter_ptr = NULL; |
| 1197 | 1186 | } |
| 1198 | 1187 | |
| 1199 | 1188 | |
| r243409 | r243410 | |
| 1206 | 1195 | { |
| 1207 | 1196 | float size_score, refresh_score, final_score; |
| 1208 | 1197 | mode_enum_info *einfo = (mode_enum_info *)context; |
| 1209 | | renderer_dd *dd = dynamic_cast<renderer_dd *>(einfo->window->m_renderer); |
| 1198 | dd_info *dd = (dd_info *)einfo->window->m_drawdata; |
| 1210 | 1199 | |
| 1211 | 1200 | // skip non-32 bit modes |
| 1212 | 1201 | if (desc->ddpfPixelFormat.dwRGBBitCount != 32) |
| r243409 | r243410 | |
| 1259 | 1248 | // pick_best_mode |
| 1260 | 1249 | //============================================================ |
| 1261 | 1250 | |
| 1262 | | void renderer_dd::pick_best_mode() |
| 1251 | static void pick_best_mode(win_window_info *window) |
| 1263 | 1252 | { |
| 1253 | dd_info *dd = (dd_info *)window->m_drawdata; |
| 1264 | 1254 | mode_enum_info einfo; |
| 1265 | 1255 | HRESULT result; |
| 1266 | 1256 | |
| r243409 | r243410 | |
| 1268 | 1258 | // note: technically we should not be calling this from an alternate window |
| 1269 | 1259 | // thread; however, it is only done during init time, and the init code on |
| 1270 | 1260 | // the main thread is waiting for us to finish, so it is safe to do so here |
| 1271 | | window().m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height); |
| 1261 | window->m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height); |
| 1272 | 1262 | |
| 1273 | 1263 | // use those as the target for now |
| 1274 | 1264 | einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale); |
| r243409 | r243410 | |
| 1276 | 1266 | |
| 1277 | 1267 | // determine the refresh rate of the primary screen |
| 1278 | 1268 | einfo.target_refresh = 60.0; |
| 1279 | | const screen_device *primary_screen = window().machine().config().first_screen(); |
| 1269 | const screen_device *primary_screen = window->machine().config().first_screen(); |
| 1280 | 1270 | if (primary_screen != NULL) |
| 1281 | 1271 | einfo.target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh_attoseconds()); |
| 1282 | 1272 | printf("Target refresh = %f\n", einfo.target_refresh); |
| r243409 | r243410 | |
| 1296 | 1286 | } |
| 1297 | 1287 | |
| 1298 | 1288 | // fill in the rest of the data |
| 1299 | | einfo.window = &window(); |
| 1289 | einfo.window = window; |
| 1300 | 1290 | einfo.best_score = 0.0f; |
| 1301 | 1291 | |
| 1302 | 1292 | // enumerate the modes |
| 1303 | 1293 | osd_printf_verbose("DirectDraw: Selecting video mode...\n"); |
| 1304 | | result = IDirectDraw7_EnumDisplayModes(ddraw, DDEDM_REFRESHRATES, NULL, &einfo, enum_modes_callback); |
| 1294 | result = IDirectDraw7_EnumDisplayModes(dd->ddraw, DDEDM_REFRESHRATES, NULL, &einfo, enum_modes_callback); |
| 1305 | 1295 | if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X during EnumDisplayModes call\n", (int)result); |
| 1306 | | osd_printf_verbose("DirectDraw: Mode selected = %4dx%4d@%3dHz\n", width, height, refresh); |
| 1296 | osd_printf_verbose("DirectDraw: Mode selected = %4dx%4d@%3dHz\n", dd->width, dd->height, dd->refresh); |
| 1307 | 1297 | } |