diff --git a/build/Rayman 2 (GOG).dxw b/build/Rayman 2 (GOG).dxw
new file mode 100644
index 0000000..98deccf
--- /dev/null
+++ b/build/Rayman 2 (GOG).dxw
@@ -0,0 +1,24 @@
+[target]
+title0=Rayman 2 (GOG)
+path0=D:\Games\GOG.com\Rayman 2\Rayman2.exe
+module0=
+opengllib0=
+ver0=1
+coord0=0
+flag0=402653217
+flagg0=1208025104
+flagh0=20
+flagi0=0
+tflag0=0
+initx0=0
+inity0=0
+minx0=0
+miny0=0
+maxx0=0
+maxy0=0
+posx0=50
+posy0=50
+sizx0=800
+sizy0=600
+maxfps0=0
+initts0=0
diff --git a/build/Rayman 2 Demo.dxw b/build/Rayman 2 Demo.dxw
new file mode 100644
index 0000000..eb2b35a
--- /dev/null
+++ b/build/Rayman 2 Demo.dxw
@@ -0,0 +1,24 @@
+[target]
+title0=Rayman 2 Demo
+path0=D:\Games\Rayman2Demo\Rayman2Demo.exe
+module0=
+opengllib0=
+ver0=1
+coord0=0
+flag0=402653217
+flagg0=1208025088
+flagh0=20
+flagi0=0
+tflag0=0
+initx0=0
+inity0=0
+minx0=0
+miny0=0
+maxx0=0
+maxy0=0
+posx0=50
+posy0=50
+sizx0=800
+sizy0=600
+maxfps0=0
+initts0=0
diff --git a/build/dxwnd.dll b/build/dxwnd.dll
index b829dd5..f262a2a 100644
--- a/build/dxwnd.dll
+++ b/build/dxwnd.dll
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:d1a209c794208ebc34f31a6cd07230ea4410cb8ec6cdeedff15725bd32ae783a
-size 425472
+oid sha256:9937414e8ef05dd175c44b487760617042c0a74574f8cab9f1e7486302cee68a
+size 424960
diff --git a/build/dxwnd.exe b/build/dxwnd.exe
index dc06231..c824a32 100644
--- a/build/dxwnd.exe
+++ b/build/dxwnd.exe
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:3d50219a90b39093171656814a8cf5e4b1782366c91e18f16a8972cee2075727
+oid sha256:e400384f655d2a3050893125cf7be2026964cb1800b9cebf94af7c1fb98c4d26
size 532480
diff --git a/build/dxwnd.ini b/build/dxwnd.ini
index a93fb10..e0e77e6 100644
--- a/build/dxwnd.ini
+++ b/build/dxwnd.ini
@@ -1271,7 +1271,7 @@ opengllib55=
ver55=0
coord55=0
flag55=134217730
-flagg55=143654912
+flagg55=135266304
flagh55=20
flagi55=0
tflag55=770
@@ -1655,17 +1655,17 @@ sizx71=800
sizy71=600
maxfps71=0
initts71=0
-title72=Rayman 2 (GOG)
-path72=D:\Games\GOG.com\Rayman 2\Rayman2.exe
+title72=Rayman2.exe
+path72=C:\Program Files\GOG.com\Rayman 2\Rayman2.exe
module72=
opengllib72=
ver72=1
coord72=0
-flag72=134217762
-flagg72=1208025088
-flagh72=20
+flag72=134217763
+flagg72=1208029184
+flagh72=2097172
flagi72=0
-tflag72=274
+tflag72=18
initx72=0
inity72=0
minx72=0
@@ -1676,107 +1676,107 @@ posx72=50
posy72=50
sizx72=800
sizy72=600
-maxfps72=0
+maxfps72=50
initts72=8
-title73=Rayman2.exe
-path73=C:\Program Files\GOG.com\Rayman 2\Rayman2.exe
+title73=Silent Hunter II (shell)
+path73=D:\Games\Silent Hunter II\Shell\Shell.exe
module73=
opengllib73=
-ver73=1
+ver73=0
coord73=0
-flag73=134217763
-flagg73=1208029184
-flagh73=2097172
+flag73=402653221
+flagg73=135266304
+flagh73=20
flagi73=0
-tflag73=18
+tflag73=2
initx73=0
inity73=0
minx73=0
miny73=0
-maxx73=0
-maxy73=0
+maxx73=800
+maxy73=600
posx73=50
posy73=50
sizx73=800
sizy73=600
-maxfps73=50
-initts73=8
-title74=Rayman 2 Demo
-path74=D:\Games\Rayman2Demo\Rayman2Demo.exe
+maxfps73=0
+initts73=0
+title74=Silent Hunter II (sim)
+path74=D:\Games\Silent Hunter II\Sim\Sim.exe
module74=
opengllib74=
-ver74=1
+ver74=0
coord74=0
-flag74=134217762
-flagg74=1207959552
+flag74=134217780
+flagg74=134217728
flagh74=20
flagi74=0
-tflag74=259
-initx74=0
-inity74=0
+tflag74=0
+initx74=400
+inity74=300
minx74=0
miny74=0
-maxx74=0
-maxy74=0
+maxx74=800
+maxy74=600
posx74=50
posy74=50
sizx74=800
sizy74=600
maxfps74=0
initts74=0
-title75=Silent Hunter II (shell)
-path75=D:\Games\Silent Hunter II\Shell\Shell.exe
+title75=Space Hack
+path75=D:\Games\Space Hack\main.exe
module75=
opengllib75=
ver75=0
coord75=0
-flag75=402653221
-flagg75=135266304
+flag75=671105058
+flagg75=134217728
flagh75=20
flagi75=0
-tflag75=2
+tflag75=258
initx75=0
inity75=0
minx75=0
miny75=0
-maxx75=800
-maxy75=600
+maxx75=0
+maxy75=0
posx75=50
posy75=50
sizx75=800
sizy75=600
maxfps75=0
initts75=0
-title76=Silent Hunter II (sim)
-path76=D:\Games\Silent Hunter II\Sim\Sim.exe
+title76=Tachyon The Fringe
+path76=D:\Games\TachyonTheFringe\space.exe
module76=
opengllib76=
ver76=0
coord76=0
-flag76=134217780
+flag76=134234148
flagg76=134217728
flagh76=20
flagi76=0
-tflag76=0
-initx76=400
-inity76=300
+tflag76=258
+initx76=0
+inity76=0
minx76=0
miny76=0
-maxx76=800
-maxy76=600
+maxx76=0
+maxy76=0
posx76=50
posy76=50
sizx76=800
sizy76=600
maxfps76=0
initts76=0
-title77=Space Hack
-path77=D:\Games\Space Hack\main.exe
+title77=Tanktics
+path77=D:\Games\Tanktics\tanktics.exe
module77=
opengllib77=
ver77=0
coord77=0
-flag77=671105058
+flag77=671088674
flagg77=134217728
flagh77=20
flagi77=0
@@ -1793,17 +1793,17 @@ sizx77=800
sizy77=600
maxfps77=0
initts77=0
-title78=Tachyon The Fringe
-path78=D:\Games\TachyonTheFringe\space.exe
+title78=TD5_D3D.exe
+path78=D:\Games\Test Drive 5\TD5_D3D.exe
module78=
opengllib78=
ver78=0
coord78=0
-flag78=134234148
-flagg78=134217728
+flag78=134217760
+flagg78=1207959552
flagh78=20
flagi78=0
-tflag78=258
+tflag78=64
initx78=0
inity78=0
minx78=0
@@ -1816,17 +1816,17 @@ sizx78=800
sizy78=600
maxfps78=0
initts78=0
-title79=Tanktics
-path79=D:\Games\Tanktics\tanktics.exe
+title79=The Sims
+path79=D:\Games\sims\Sims.exe
module79=
opengllib79=
ver79=0
coord79=0
-flag79=671088674
+flag79=671096866
flagg79=134217728
flagh79=20
flagi79=0
-tflag79=258
+tflag79=66
initx79=0
inity79=0
minx79=0
@@ -1839,17 +1839,17 @@ sizx79=800
sizy79=600
maxfps79=0
initts79=0
-title80=TD5_D3D.exe
-path80=D:\Games\Test Drive 5\TD5_D3D.exe
+title80=Tomb Raider - The Last Revelation
+path80=D:\Games\Tomb Raider - The Last Revelation\tomb4.exe
module80=
opengllib80=
ver80=0
coord80=0
-flag80=134217760
-flagg80=1207959552
+flag80=134217826
+flagg80=134217728
flagh80=20
flagi80=0
-tflag80=64
+tflag80=2
initx80=0
inity80=0
minx80=0
@@ -1862,17 +1862,17 @@ sizx80=800
sizy80=600
maxfps80=0
initts80=0
-title81=The Sims
-path81=D:\Games\sims\Sims.exe
+title81=TOMB2.EXE
+path81=D:\Games\Tomb Raider 2\TOMB2.EXE
module81=
opengllib81=
ver81=0
coord81=0
-flag81=671096866
-flagg81=134217728
-flagh81=20
+flag81=134217760
+flagg81=201326592
+flagh81=2068
flagi81=0
-tflag81=66
+tflag81=0
initx81=0
inity81=0
minx81=0
@@ -1885,17 +1885,17 @@ sizx81=800
sizy81=600
maxfps81=0
initts81=0
-title82=Tomb Raider - The Last Revelation
-path82=D:\Games\Tomb Raider - The Last Revelation\tomb4.exe
+title82=Vangers one of the Road
+path82=D:\Games\Vangers\road.exe
module82=
opengllib82=
-ver82=0
+ver82=1
coord82=0
-flag82=134217826
-flagg82=134217728
+flag82=406847650
+flagg82=671088640
flagh82=20
flagi82=0
-tflag82=2
+tflag82=258
initx82=0
inity82=0
minx82=0
@@ -1908,17 +1908,17 @@ sizx82=800
sizy82=600
maxfps82=0
initts82=0
-title83=TOMB2.EXE
-path83=D:\Games\Tomb Raider 2\TOMB2.EXE
+title83=wa.exe
+path83=D:\Games\worms_arma\Worms_2_Armageddon\wa.exe
module83=
opengllib83=
ver83=0
coord83=0
-flag83=134217760
-flagg83=201326592
-flagh83=2068
+flag83=713031712
+flagg83=134217728
+flagh83=20
flagi83=0
-tflag83=0
+tflag83=2
initx83=0
inity83=0
minx83=0
@@ -1931,17 +1931,17 @@ sizx83=800
sizy83=600
maxfps83=0
initts83=0
-title84=Vangers one of the Road
-path84=D:\Games\Vangers\road.exe
+title84=Wargames
+path84=D:\Games\WarGames\wargames.exe
module84=
opengllib84=
-ver84=1
+ver84=0
coord84=0
-flag84=406847650
-flagg84=671088640
-flagh84=262164
+flag84=134217762
+flagg84=1207959552
+flagh84=20
flagi84=0
-tflag84=258
+tflag84=66
initx84=0
inity84=0
minx84=0
@@ -1954,14 +1954,14 @@ sizx84=800
sizy84=600
maxfps84=0
initts84=0
-title85=wa.exe
-path85=D:\Games\worms_arma\Worms_2_Armageddon\wa.exe
+title85=Warlords 3
+path85=D:\Games\Warlords3\Darklord.exe
module85=
opengllib85=
ver85=0
coord85=0
-flag85=713031712
-flagg85=142606336
+flag85=-2013249502
+flagg85=135266304
flagh85=20
flagi85=0
tflag85=2
@@ -1977,17 +1977,17 @@ sizx85=800
sizy85=600
maxfps85=0
initts85=0
-title86=Wargames
-path86=D:\Games\WarGames\wargames.exe
+title86=Western Front
+path86=D:\Games\Western Front\wf.exe
module86=
opengllib86=
ver86=0
coord86=0
-flag86=134217762
-flagg86=1207959552
-flagh86=20
+flag86=679477282
+flagg86=135266304
+flagh86=16404
flagi86=0
-tflag86=66
+tflag86=0
initx86=0
inity86=0
minx86=0
@@ -2000,17 +2000,17 @@ sizx86=800
sizy86=600
maxfps86=0
initts86=0
-title87=Warlords 3
-path87=D:\Games\Warlords3\Darklord.exe
+title87=dw.exe
+path87=D:\Games\Devil.Whiskey\dw.exe
module87=
opengllib87=
-ver87=0
+ver87=7
coord87=0
-flag87=-2013249502
-flagg87=135266304
-flagh87=20
+flag87=671088674
+flagg87=1208090624
+flagh87=5
flagi87=0
-tflag87=2
+tflag87=64
initx87=0
inity87=0
minx87=0
@@ -2023,15 +2023,15 @@ sizx87=800
sizy87=600
maxfps87=0
initts87=0
-title88=Western Front
-path88=D:\Games\Western Front\wf.exe
+title88=Dungeon Lords MMXII
+path88=D:\Games\Dungeon Lords MMXII\dlords2012.exe
module88=
opengllib88=
ver88=0
-coord88=0
-flag88=679477282
-flagg88=135266304
-flagh88=16404
+coord88=2
+flag88=-2013265886
+flagg88=1207959552
+flagh88=20
flagi88=0
tflag88=0
initx88=0
@@ -2046,17 +2046,17 @@ sizx88=800
sizy88=600
maxfps88=0
initts88=0
-title89=dw.exe
-path89=D:\Games\Devil.Whiskey\dw.exe
+title89=Bunnies must die
+path89=D:\Games\Bunnies must die\bmd.exe
module89=
opengllib89=
ver89=7
coord89=0
flag89=671088674
-flagg89=1208090624
-flagh89=5
+flagg89=1209008128
+flagh89=4
flagi89=0
-tflag89=64
+tflag89=2
initx89=0
inity89=0
minx89=0
@@ -2069,17 +2069,17 @@ sizx89=800
sizy89=600
maxfps89=0
initts89=0
-title90=Dungeon Lords MMXII
-path90=D:\Games\Dungeon Lords MMXII\dlords2012.exe
+title90=Magic & Mayhem
+path90=D:\Games\Magic_&_Mayhem\Chaos.exe
module90=
opengllib90=
ver90=0
-coord90=2
-flag90=-2013265886
-flagg90=1207959552
+coord90=0
+flag90=138428450
+flagg90=1275068416
flagh90=20
flagi90=0
-tflag90=0
+tflag90=258
initx90=0
inity90=0
minx90=0
@@ -2092,15 +2092,15 @@ sizx90=800
sizy90=600
maxfps90=0
initts90=0
-title91=Bunnies must die
-path91=D:\Games\Bunnies must die\bmd.exe
+title91=Submarine Titans Demo
+path91=D:\Games\Submarine Titans Demo\st.exe
module91=
opengllib91=
-ver91=7
+ver91=0
coord91=0
-flag91=671088674
-flagg91=1209008128
-flagh91=4
+flag91=675282978
+flagg91=1207959552
+flagh91=20
flagi91=0
tflag91=2
initx91=0
@@ -2115,17 +2115,17 @@ sizx91=800
sizy91=600
maxfps91=0
initts91=0
-title92=Magic & Mayhem
-path92=D:\Games\Magic_&_Mayhem\Chaos.exe
+title92=Grand Prix Legends
+path92=D:\Games\gpl\gpl.exe
module92=
opengllib92=
ver92=0
-coord92=0
-flag92=138428450
-flagg92=1275068416
-flagh92=8388628
+coord92=2
+flag92=721420320
+flagg92=1207959568
+flagh92=20
flagi92=0
-tflag92=258
+tflag92=322
initx92=0
inity92=0
minx92=0
@@ -2138,17 +2138,17 @@ sizx92=800
sizy92=600
maxfps92=0
initts92=0
-title93=Submarine Titans Demo
-path93=D:\Games\Submarine Titans Demo\st.exe
+title93=Land of the Dead
+path93=D:\Games\Land of the Dead\System\LOTD.exe
module93=
opengllib93=
ver93=0
coord93=0
-flag93=675282978
+flag93=134217766
flagg93=1207959552
flagh93=20
flagi93=0
-tflag93=2
+tflag93=64
initx93=0
inity93=0
minx93=0
@@ -2161,17 +2161,17 @@ sizx93=800
sizy93=600
maxfps93=0
initts93=0
-title94=Grand Prix Legends
-path94=D:\Games\gpl\gpl.exe
+title94=Devastation
+path94=D:\Games\Devastation\System\Devastation.exe
module94=
opengllib94=
ver94=0
-coord94=2
-flag94=721420320
-flagg94=1207959568
-flagh94=20
+coord94=0
+flag94=671088674
+flagg94=1207959552
+flagh94=16
flagi94=0
-tflag94=322
+tflag94=66
initx94=0
inity94=0
minx94=0
@@ -2184,17 +2184,17 @@ sizx94=800
sizy94=600
maxfps94=0
initts94=0
-title95=Land of the Dead
-path95=D:\Games\Land of the Dead\System\LOTD.exe
+title95=RCRacers.exe
+path95=D:\Games\Sierra\RCRacing\RCRacers.exe
module95=
opengllib95=
ver95=0
coord95=0
-flag95=134217766
-flagg95=1207959552
-flagh95=20
+flag95=679477282
+flagg95=1209008128
+flagh95=65556
flagi95=0
-tflag95=64
+tflag95=66
initx95=0
inity95=0
minx95=0
@@ -2203,21 +2203,21 @@ maxx95=0
maxy95=0
posx95=50
posy95=50
-sizx95=800
-sizy95=600
+sizx95=400
+sizy95=300
maxfps95=0
initts95=0
-title96=Devastation
-path96=D:\Games\Devastation\System\Devastation.exe
+title96=Kiss Psycho Circus
+path96=D:\Games\Kiss\psycho.exe
module96=
opengllib96=
ver96=0
coord96=0
-flag96=671088674
+flag96=134217762
flagg96=1207959552
-flagh96=16
+flagh96=20
flagi96=0
-tflag96=66
+tflag96=64
initx96=0
inity96=0
minx96=0
@@ -2230,17 +2230,17 @@ sizx96=800
sizy96=600
maxfps96=0
initts96=0
-title97=RCRacers.exe
-path97=D:\Games\Sierra\RCRacing\RCRacers.exe
+title97=Hamsterball
+path97=D:\Games\Hamsterball\Hamsterball.exe
module97=
opengllib97=
-ver97=0
+ver97=8
coord97=0
-flag97=679477282
-flagg97=1209008128
-flagh97=65556
+flag97=134217762
+flagg97=1207959552
+flagh97=20
flagi97=0
-tflag97=66
+tflag97=323
initx97=0
inity97=0
minx97=0
@@ -2249,21 +2249,21 @@ maxx97=0
maxy97=0
posx97=50
posy97=50
-sizx97=400
-sizy97=300
+sizx97=800
+sizy97=600
maxfps97=0
initts97=0
-title98=Kiss Psycho Circus
-path98=D:\Games\Kiss\psycho.exe
+title98=Pharaoh's Ascent 1.4
+path98=D:\Games\Pharaohs_Ascent_1.4\Pharaoh.exe
module98=
opengllib98=
ver98=0
coord98=0
-flag98=134217762
-flagg98=1207959552
+flag98=947912739
+flagg98=1209008128
flagh98=20
flagi98=0
-tflag98=64
+tflag98=66
initx98=0
inity98=0
minx98=0
@@ -2276,17 +2276,17 @@ sizx98=800
sizy98=600
maxfps98=0
initts98=0
-title99=Hamsterball
-path99=D:\Games\Hamsterball\Hamsterball.exe
+title99=Praetorians
+path99=D:\Games\Praetorians\Praetorians.exe
module99=
opengllib99=
-ver99=8
+ver99=0
coord99=0
-flag99=134217762
+flag99=134217760
flagg99=1207959552
flagh99=20
flagi99=0
-tflag99=323
+tflag99=258
initx99=0
inity99=0
minx99=0
@@ -2299,17 +2299,17 @@ sizx99=800
sizy99=600
maxfps99=0
initts99=0
-title100=Pharaoh's Ascent 1.4
-path100=D:\Games\Pharaohs_Ascent_1.4\Pharaoh.exe
+title100=Chariots of War binkplay
+path100=D:\Games\Chariots of War\data\movies\binkplay.exe
module100=
opengllib100=
ver100=0
coord100=0
-flag100=947912739
-flagg100=1209008128
-flagh100=20
+flag100=671088674
+flagg100=1745879041
+flagh100=4
flagi100=0
-tflag100=66
+tflag100=2
initx100=0
inity100=0
minx100=0
@@ -2322,17 +2322,17 @@ sizx100=800
sizy100=600
maxfps100=0
initts100=0
-title101=Praetorians
-path101=D:\Games\Praetorians\Praetorians.exe
+title101=Jetboat Superchamps 2
+path101=D:\Games\Jetboat Superchamps 2\Jbs2.exe
module101=
opengllib101=
ver101=0
coord101=0
flag101=134217760
flagg101=1207959552
-flagh101=20
+flagh101=4
flagi101=0
-tflag101=258
+tflag101=2
initx101=0
inity101=0
minx101=0
@@ -2345,17 +2345,17 @@ sizx101=800
sizy101=600
maxfps101=0
initts101=0
-title102=Chariots of War binkplay
-path102=D:\Games\Chariots of War\data\movies\binkplay.exe
+title102=Star Force Deluxe
+path102=D:\Games\stardeluxe\DELUXE.EXE
module102=
opengllib102=
ver102=0
coord102=0
-flag102=671088674
-flagg102=1745879041
-flagh102=4
+flag102=1207959587
+flagg102=1828716544
+flagh102=2163220
flagi102=0
-tflag102=2
+tflag102=259
initx102=0
inity102=0
minx102=0
@@ -2364,21 +2364,21 @@ maxx102=0
maxy102=0
posx102=50
posy102=50
-sizx102=800
-sizy102=600
+sizx102=400
+sizy102=300
maxfps102=0
initts102=0
-title103=Jetboat Superchamps 2
-path103=D:\Games\Jetboat Superchamps 2\Jbs2.exe
+title103=Last Bronx
+path103=D:\Games\Last_Bronx\LB.EXE
module103=
opengllib103=
ver103=0
coord103=0
-flag103=134217760
+flag103=134217762
flagg103=1207959552
-flagh103=4
+flagh103=20
flagi103=0
-tflag103=2
+tflag103=259
initx103=0
inity103=0
minx103=0
@@ -2391,17 +2391,17 @@ sizx103=800
sizy103=600
maxfps103=0
initts103=0
-title104=Star Force Deluxe
-path104=D:\Games\stardeluxe\DELUXE.EXE
+title104=Riot Police
+path104=D:\Games\Riot Police\RPolice.exe
module104=
opengllib104=
ver104=0
coord104=0
-flag104=1207959587
-flagg104=1828716544
-flagh104=10551828
+flag104=134217762
+flagg104=1207959552
+flagh104=20
flagi104=0
-tflag104=259
+tflag104=2
initx104=0
inity104=0
minx104=0
@@ -2410,21 +2410,21 @@ maxx104=0
maxy104=0
posx104=50
posy104=50
-sizx104=400
-sizy104=300
+sizx104=800
+sizy104=600
maxfps104=0
initts104=0
-title105=Last Bronx
-path105=D:\Games\Last_Bronx\LB.EXE
+title105=Serious Sam Demo
+path105=D:\Games\Serious Sam Demo\Bin\SeriousSam.exe
module105=
opengllib105=
ver105=0
coord105=0
flag105=134217762
-flagg105=1207959552
+flagg105=1208090624
flagh105=20
flagi105=0
-tflag105=259
+tflag105=0
initx105=0
inity105=0
minx105=0
@@ -2437,17 +2437,17 @@ sizx105=800
sizy105=600
maxfps105=0
initts105=0
-title106=Riot Police
-path106=D:\Games\Riot Police\RPolice.exe
+title106=Space Rangers
+path106=D:\Games\Space Rangers\Rangers.exe
module106=
opengllib106=
-ver106=0
+ver106=1
coord106=0
-flag106=134217762
+flag106=134234146
flagg106=1207959552
flagh106=20
flagi106=0
-tflag106=2
+tflag106=0
initx106=0
inity106=0
minx106=0
@@ -2460,17 +2460,17 @@ sizx106=800
sizy106=600
maxfps106=0
initts106=0
-title107=Serious Sam Demo
-path107=D:\Games\Serious Sam Demo\Bin\SeriousSam.exe
+title107=Star Wars Shadow of the Empire
+path107=D:\Games\Star Wars Shadow of the Empire\game\SDATA\SHADOWS.EXE
module107=
opengllib107=
ver107=0
coord107=0
-flag107=134217762
-flagg107=1208090624
-flagh107=20
+flag107=201392162
+flagg107=1476919296
+flagh107=33554972
flagi107=0
-tflag107=0
+tflag107=275
initx107=0
inity107=0
minx107=0
@@ -2483,17 +2483,17 @@ sizx107=800
sizy107=600
maxfps107=0
initts107=0
-title108=Space Rangers
-path108=D:\Games\Space Rangers\Rangers.exe
+title108=Roswell Pinball
+path108=D:\Games\RoswellPinball\winpin.exe
module108=
opengllib108=
-ver108=1
+ver108=0
coord108=0
-flag108=134234146
+flag108=134217762
flagg108=1207959552
-flagh108=20
+flagh108=4
flagi108=0
-tflag108=0
+tflag108=258
initx108=0
inity108=0
minx108=0
@@ -2506,17 +2506,17 @@ sizx108=800
sizy108=600
maxfps108=0
initts108=0
-title109=Star Wars Shadow of the Empire
-path109=D:\Games\Star Wars Shadow of the Empire\game\SDATA\SHADOWS.EXE
+title109=Virtua Fighter PC
+path109=D:\Games\Virtua Fighter\VFPC.EXE
module109=
opengllib109=
ver109=0
coord109=0
-flag109=201392162
-flagg109=1476919296
-flagh109=41943580
+flag109=134219810
+flagg109=1207959556
+flagh109=167821334
flagi109=0
-tflag109=275
+tflag109=339
initx109=0
inity109=0
minx109=0
@@ -2528,18 +2528,18 @@ posy109=50
sizx109=800
sizy109=600
maxfps109=0
-initts109=0
-title110=Roswell Pinball
-path110=D:\Games\RoswellPinball\winpin.exe
+initts109=6
+title110=Theseus
+path110=D:\Games\theseus\Theseus.exe
module110=
opengllib110=
-ver110=0
+ver110=8
coord110=0
-flag110=134217762
+flag110=134217730
flagg110=1207959552
-flagh110=4
+flagh110=20
flagi110=0
-tflag110=258
+tflag110=0
initx110=0
inity110=0
minx110=0
@@ -2552,17 +2552,17 @@ sizx110=800
sizy110=600
maxfps110=0
initts110=0
-title111=Virtua Fighter PC
-path111=D:\Games\Virtua Fighter\VFPC.EXE
+title111=Star Wars Shadow of the Empire (DEMO)
+path111=D:\Games\shadowsdemo\shadows.exe
module111=
opengllib111=
ver111=0
coord111=0
-flag111=134219810
-flagg111=1207959556
-flagh111=998293526
+flag111=134217760
+flagg111=1208483840
+flagh111=33554452
flagi111=0
-tflag111=339
+tflag111=275
initx111=0
inity111=0
minx111=0
@@ -2574,18 +2574,18 @@ posy111=50
sizx111=800
sizy111=600
maxfps111=0
-initts111=6
-title112=Theseus
-path112=D:\Games\theseus\Theseus.exe
+initts111=0
+title112=Chocolate Duke 3D
+path112=D:\Games\Release Chocolate Duke3D\ChocolateDuke3D.exe
module112=
opengllib112=
-ver112=8
+ver112=0
coord112=0
-flag112=134217730
-flagg112=1207959552
-flagh112=20
+flag112=671088672
+flagg112=1207959808
+flagh112=98324
flagi112=0
-tflag112=0
+tflag112=3
initx112=0
inity112=0
minx112=0
@@ -2594,21 +2594,21 @@ maxx112=0
maxy112=0
posx112=50
posy112=50
-sizx112=800
-sizy112=600
+sizx112=400
+sizy112=300
maxfps112=0
initts112=0
-title113=Star Wars Shadow of the Empire (DEMO)
-path113=D:\Games\shadowsdemo\shadows.exe
+title113=Tomb Raider III (SW emulation)
+path113=D:\Games\Tomb Raider III\tomb3.exe
module113=
opengllib113=
ver113=0
coord113=0
-flag113=134217760
-flagg113=1208483840
-flagh113=58720276
+flag113=134217762
+flagg113=1241513984
+flagh113=33554452
flagi113=0
-tflag113=275
+tflag113=323
initx113=0
inity113=0
minx113=0
@@ -2621,17 +2621,17 @@ sizx113=800
sizy113=600
maxfps113=0
initts113=0
-title114=Chocolate Duke 3D
-path114=D:\Games\Release Chocolate Duke3D\ChocolateDuke3D.exe
+title114=Tomb Raider III (HW acceleration)
+path114=D:\Games\Tomb Raider III\tomb3.exe
module114=
opengllib114=
ver114=0
coord114=0
-flag114=671088672
-flagg114=1207959808
-flagh114=98324
+flag114=134217760
+flagg114=1241514000
+flagh114=4
flagi114=0
-tflag114=3
+tflag114=0
initx114=0
inity114=0
minx114=0
@@ -2640,21 +2640,21 @@ maxx114=0
maxy114=0
posx114=50
posy114=50
-sizx114=400
-sizy114=300
+sizx114=800
+sizy114=600
maxfps114=0
initts114=0
-title115=Tomb Raider III (SW emulation)
-path115=D:\Games\Tomb Raider III\tomb3.exe
+title115=Star Wars Phantom Menace
+path115=D:\Games\Star Wars Phantom Menace\WMAIN.EXE
module115=
opengllib115=
ver115=0
coord115=0
-flag115=134217762
-flagg115=1241513984
-flagh115=58720276
+flag115=939524129
+flagg115=1207959552
+flagh115=20
flagi115=0
-tflag115=323
+tflag115=0
initx115=0
inity115=0
minx115=0
@@ -2667,15 +2667,15 @@ sizx115=800
sizy115=600
maxfps115=0
initts115=0
-title116=Tomb Raider III (HW acceleration)
-path116=D:\Games\Tomb Raider III\tomb3.exe
+title116=Last Call
+path116=D:\Games\Last Call\fast.EXE
module116=
opengllib116=
ver116=0
coord116=0
-flag116=134217760
-flagg116=1241514000
-flagh116=25165828
+flag116=134217762
+flagg116=1207959552
+flagh116=20
flagi116=0
tflag116=0
initx116=0
@@ -2690,15 +2690,15 @@ sizx116=800
sizy116=600
maxfps116=0
initts116=0
-title117=Star Wars Phantom Menace
-path117=D:\Games\Star Wars Phantom Menace\WMAIN.EXE
+title117=Empire Earth
+path117=D:\Games\Empire Earth\Empire Earth.exe
module117=
opengllib117=
ver117=0
coord117=0
-flag117=939524129
+flag117=671088674
flagg117=1207959552
-flagh117=20
+flagh117=32788
flagi117=0
tflag117=0
initx117=0
@@ -2713,8 +2713,8 @@ sizx117=800
sizy117=600
maxfps117=0
initts117=0
-title118=Last Call
-path118=D:\Games\Last Call\fast.EXE
+title118=Warcraft 2 Battlenet Edition
+path118=D:\Games\Warcraft 2 Battlenet Ed\Warcraft II BNE.exe
module118=
opengllib118=
ver118=0
@@ -2736,15 +2736,15 @@ sizx118=800
sizy118=600
maxfps118=0
initts118=0
-title119=Empire Earth
-path119=D:\Games\Empire Earth\Empire Earth.exe
+title119=Lifestream
+path119=D:\Games\Lifestream\Lifestream.exe
module119=
opengllib119=
ver119=0
coord119=0
-flag119=671088674
+flag119=134217762
flagg119=1207959552
-flagh119=32788
+flagh119=20
flagi119=0
tflag119=0
initx119=0
@@ -2759,15 +2759,15 @@ sizx119=800
sizy119=600
maxfps119=0
initts119=0
-title120=Warcraft 2 Battlenet Edition
-path120=D:\Games\Warcraft 2 Battlenet Ed\Warcraft II BNE.exe
+title120=Rayman 2 (GOG)
+path120=D:\Games\GOG.com\Rayman 2\Rayman2.exe
module120=
opengllib120=
-ver120=0
+ver120=1
coord120=0
-flag120=134217762
-flagg120=1207959552
-flagh120=25165844
+flag120=402653217
+flagg120=1208025104
+flagh120=20
flagi120=0
tflag120=0
initx120=0
@@ -2782,14 +2782,14 @@ sizx120=800
sizy120=600
maxfps120=0
initts120=0
-title121=Lifestream
-path121=D:\Games\Lifestream\Lifestream.exe
+title121=Rayman 2 Demo
+path121=D:\Games\Rayman2Demo\Rayman2Demo.exe
module121=
opengllib121=
-ver121=0
+ver121=1
coord121=0
-flag121=134217762
-flagg121=1207959552
+flag121=402653217
+flagg121=1208025088
flagh121=20
flagi121=0
tflag121=0
diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt
index 59e1e26..6597f9d 100644
--- a/build/readme-relnotes.txt
+++ b/build/readme-relnotes.txt
@@ -280,5 +280,10 @@ Fixed a bug in GDI "Map DC to primary surface"mode.
Added palette display window to GUI
v2.02.41
-Added "suppress child process creation" flag. This flag is introduced to manage games such as "Heart of Iron 2" and "Chariots of War" that start intro movie by means of a separate process. Both games are starting the binkplay.exe program in the game's avi subfolder. This way you don't get a windowed movie, but completely suppress it.
-Added "fix ddraw ref counter" flag, to have primary directdraw object addref & release ref counters identical to those without dxwnd. Some games check for the value and show error messages, i.e. "Grand Prix World"!
\ No newline at end of file
+Added "suppress child process creation"flag. This flag is introduced to manage games such as "Heart of Iron 2" that start intro movie by means of a separate process. HoI2 is starting the binkplay.exe program in the game's avi subfolder. This way you don't get a windowed movie, but completely suppress it.
+
+v2.02.42
+added hook to kernel32.dll QueryPerformanceCounter API to enable time stretching to Rayman 2
+handled GetAttachedSurface emulation for FLIP capability on primary surface - that makes the intro movies of Empire Earth visible.
+Some code cleaning
+Cleared invisible debug flags ...
\ No newline at end of file
diff --git a/build/v2_02_42_build.rar b/build/v2_02_42_build.rar
new file mode 100644
index 0000000..f38f867
Binary files /dev/null and b/build/v2_02_42_build.rar differ
diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp
index 574a982..ad5f713 100644
--- a/dll/ddraw.cpp
+++ b/dll/ddraw.cpp
@@ -2791,19 +2791,10 @@ HRESULT WINAPI extGetAttachedSurface(int dxversion, GetAttachedSurface_Type pGet
return 0;
}
- if(!IsPrim){
- res=(*pGetAttachedSurface)(lpdds, lpddsc, lplpddas);
- if(res)
- OutTraceE("GetAttachedSurface(%d): ERROR res=%x(%s) at %d\n", dxversion, res, ExplainDDError(res), __LINE__);
- else
- OutTraceD("GetAttachedSurface(%d): attached=%x\n", dxversion, *lplpddas);
- return(res);
- }
-
// on primary surface return the lpDDSBack surface coming from either an explicit
// AddAttachedSurface, or a primary complex surface creation otherwise....
- if(lpddsc->dwCaps & DDSCAPS_BACKBUFFER){ // WIPWIP
+ if(IsPrim && (lpddsc->dwCaps & (DDSCAPS_BACKBUFFER|DDSCAPS_FLIP))) { // v2.02.42 added DDSCAPS_FLIP for Empire Earth
if (lpDDSBack) {
*lplpddas = lpDDSBack;
OutTraceD("GetAttachedSurface(%d): BACKBUFFER attached=%x\n", dxversion, *lplpddas);
@@ -2815,14 +2806,16 @@ HRESULT WINAPI extGetAttachedSurface(int dxversion, GetAttachedSurface_Type pGet
return DDERR_NOTFOUND;
}
}
- else{
- res=(*pGetAttachedSurface)(lpdds, lpddsc, lplpddas);
- if(res)
- OutTraceE("GetAttachedSurface(%d): ERROR res=%x(%s) at %d\n", dxversion, res, ExplainDDError(res), __LINE__);
- else
- OutTraceD("GetAttachedSurface(%d): attached=%x\n", dxversion, *lplpddas);
- return res;
- }
+
+ // proxy the call...
+
+ res=(*pGetAttachedSurface)(lpdds, lpddsc, lplpddas);
+ if(res)
+ OutTraceE("GetAttachedSurface(%d): ERROR res=%x(%s) at %d\n", dxversion, res, ExplainDDError(res), __LINE__);
+ else
+ OutTraceD("GetAttachedSurface(%d): attached=%x\n", dxversion, *lplpddas);
+ return res;
+
}
HRESULT WINAPI extGetAttachedSurface1(LPDIRECTDRAWSURFACE lpdds, LPDDSCAPS lpddsc, LPDIRECTDRAWSURFACE *lplpddas)
@@ -4191,19 +4184,6 @@ HRESULT WINAPI extGetCaps7S(LPDIRECTDRAWSURFACE lpdds, LPDDSCAPS2 caps)
return extGetCapsS(7, (GetCapsS_Type)pGetCaps7S, lpdds, (LPDDSCAPS)caps);
}
-#define FIXREFCOUNTERS 1
-#define ZEROREFCOUNTERS 0
-
-HRESULT WINAPI DumpHandle(LPDIRECTDRAWSURFACE lpDDSurface, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext)
-{
- OutTrace("lpdds=%x flags=%x(%s) caps=%x(%s); ",
- lpDDSurface,
- lpDDSurfaceDesc->dwFlags, ExplainFlags(lpDDSurfaceDesc->dwFlags),
- lpDDSurfaceDesc->ddsCaps.dwCaps, ExplainDDSCaps(lpDDSurfaceDesc->ddsCaps.dwCaps));
- lpDDSurface->Release();
- return DDENUMRET_OK;
-}
-
ULONG WINAPI extReleaseD(LPDIRECTDRAW lpdd)
{
ULONG ActualRef;
@@ -4216,15 +4196,9 @@ ULONG WINAPI extReleaseD(LPDIRECTDRAW lpdd)
ActualRef=(*pReleaseD)(lpdd);
VirtualRef=(LONG)ActualRef;
OutTraceD("Release(D): lpdd=%x service_lpdd=%x ref=%d\n", lpdd, lpPrimaryDD, ActualRef);
- if(IsDebug && ActualRef){
- OutTrace("Release(D): surfaces ");
- //(*pEnumSurfaces)(lpdd, DDENUMSURFACES_DOESEXIST|DDENUMSURFACES_ALL, NULL, NULL, DumpHandle);
- lpdd->EnumSurfaces(DDENUMSURFACES_DOESEXIST|DDENUMSURFACES_ALL, NULL, NULL, DumpHandle);
- OutTrace("\n");
- }
if (lpdd == lpPrimaryDD) { // v2.1.87: fix for Dungeon Keeper II
- if(FIXREFCOUNTERS){
+ if(dxw.dwFlags4 & FIXREFCOUNTER){
// v2.02.41: fix the ref counter to sumulate the unwindowed original situation
--VirtualRef; // why ????
if(lpDDSBack) --VirtualRef;
@@ -4247,9 +4221,6 @@ ULONG WINAPI extReleaseD(LPDIRECTDRAW lpdd)
lpDDSBack=NULL; // beware: Silent Hunter II seems to require the backbuffer ....
}
}
- if(ZEROREFCOUNTERS){
- VirtualRef=0;
- }
}
OutTraceD("Release(D): lpdd=%x ref=%x\n", lpdd, VirtualRef);
diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp
index 532eab8..416be65 100644
--- a/dll/dxwcore.cpp
+++ b/dll/dxwcore.cpp
@@ -831,6 +831,13 @@ DWORD dxwCore::StretchTime(DWORD dwTimer)
return dwTimer;
}
+DWORD dxwCore::StretchCounter(DWORD dwTimer)
+{
+ TimeShift=GetHookInfo()->TimeShift;
+ dwTimer = TimeShifter(dwTimer, TimeShift);
+ return dwTimer;
+}
+
void dxwCore::GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
{
DWORD dwTick;
diff --git a/dll/dxwcore.hpp b/dll/dxwcore.hpp
index e144ceb..eee6084 100644
--- a/dll/dxwcore.hpp
+++ b/dll/dxwcore.hpp
@@ -64,6 +64,7 @@ public: // methods
void GetSystemTime(LPSYSTEMTIME lpSystemTime);
void GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime);
DWORD StretchTime(DWORD);
+ DWORD StretchCounter(DWORD);
void ShowFPS(LPDIRECTDRAWSURFACE);
void ShowFPS(void);
void ShowFPS(HDC);
diff --git a/dll/dxwnd.aps b/dll/dxwnd.aps
index 4763a19..e290c46 100644
Binary files a/dll/dxwnd.aps and b/dll/dxwnd.aps differ
diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp
index 28d5898..7ff8e88 100644
--- a/dll/dxwnd.cpp
+++ b/dll/dxwnd.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see .
#include "dxwnd.h"
#include "dxwcore.hpp"
-#define VERSION "2.02.41"
+#define VERSION "2.02.42"
#define DDTHREADLOCK 1
diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo
index cb33925..4ac485d 100644
Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ
diff --git a/dll/gdi32.1.cpp b/dll/gdi32.1.cpp
deleted file mode 100644
index 2c8af2f..0000000
--- a/dll/gdi32.1.cpp
+++ /dev/null
@@ -1,1664 +0,0 @@
-#include "dxwnd.h"
-#include "dxwcore.hpp"
-#include "syslibs.h"
-#include "hddraw.h"
-#include "dxhook.h"
-#include "dxhelper.h"
-
-/*
- dlg->m_DCEmulationMode = 0;
- if(t->flags2 & HOOKGDI) dlg->m_DCEmulationMode = 1;
- if(t->flags3 & EMULATEDC) dlg->m_DCEmulationMode = 2;
- if(t->flags & MAPGDITOPRIMARY) dlg->m_DCEmulationMode = 3;
-*/
-
-static HookEntry_Type Hooks[]={
- {"GetDeviceCaps", (FARPROC)GetDeviceCaps, (FARPROC *)&pGDIGetDeviceCaps, (FARPROC)extGetDeviceCaps},
- {"ScaleWindowExtEx", (FARPROC)ScaleWindowExtEx, (FARPROC *)&pGDIScaleWindowExtEx, (FARPROC)extScaleWindowExtEx},
- {"SaveDC", (FARPROC)SaveDC, (FARPROC *)&pGDISaveDC, (FARPROC)extGDISaveDC},
- {"RestoreDC", (FARPROC)RestoreDC, (FARPROC *)&pGDIRestoreDC, (FARPROC)extGDIRestoreDC},
- {"CreatePalette", (FARPROC)CreatePalette, (FARPROC *)&pGDICreatePalette, (FARPROC)extGDICreatePalette},
- {"SelectPalette", (FARPROC)SelectPalette, (FARPROC *)&pGDISelectPalette, (FARPROC)extSelectPalette},
- {"RealizePalette", (FARPROC)RealizePalette, (FARPROC *)&pGDIRealizePalette, (FARPROC)extRealizePalette},
- {"GetSystemPaletteEntries", (FARPROC)GetSystemPaletteEntries, (FARPROC *)&pGDIGetSystemPaletteEntries, (FARPROC)extGetSystemPaletteEntries},
- {"StretchDIBits", (FARPROC)StretchDIBits, (FARPROC *)&pStretchDIBits, (FARPROC)extStretchDIBits},
- //{"SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice},
- //{"CreateCompatibleBitmap", (FARPROC)NULL, (FARPROC *)&pCreateCompatibleBitmap, (FARPROC)extCreateCompatibleBitmap},
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type RemapHooks[]={
- {"SetViewportOrgEx", (FARPROC)SetViewportOrgEx, (FARPROC *)&pSetViewportOrgEx, (FARPROC)extSetViewportOrgEx}, // needed in ShowBanner
- {"SetViewportExtEx", (FARPROC)NULL, (FARPROC *)&pSetViewportExtEx, (FARPROC)extSetViewportExtEx},
- {"GetViewportOrgEx", (FARPROC)NULL, (FARPROC *)&pGetViewportOrgEx, (FARPROC)extGetViewportOrgEx},
- {"GetWindowOrgEx", (FARPROC)NULL, (FARPROC *)&pGetWindowOrgEx, (FARPROC)extGetWindowOrgEx},
- {"SetWindowOrgEx", (FARPROC)NULL, (FARPROC *)&pSetWindowOrgEx, (FARPROC)extSetWindowOrgEx},
- {"GetCurrentPositionEx", (FARPROC)NULL, (FARPROC *)&pGetCurrentPositionEx, (FARPROC)extGetCurrentPositionEx},
- {"StretchDIBits", (FARPROC)StretchDIBits, (FARPROC *)&pStretchDIBits, (FARPROC)extStretchDIBits}, // unuseful
- {"SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice}, // does the stretching
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type ScaledHooks[]={
- {"Rectangle", (FARPROC)Rectangle, (FARPROC *)&pGDIRectangle, (FARPROC)extRectangle},
- {"TextOutA", (FARPROC)TextOutA, (FARPROC *)&pGDITextOutA, (FARPROC)extTextOutA},
- {"GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox},
- {"Polyline", (FARPROC)NULL, (FARPROC *)&pPolyline, (FARPROC)extPolyline},
- {"PolyBezierTo", (FARPROC)NULL, (FARPROC *)&pPolyBezierTo, (FARPROC)extPolyBezierTo},
- {"PolylineTo", (FARPROC)NULL, (FARPROC *)&pPolylineTo, (FARPROC)extPolylineTo},
- {"PolyDraw", (FARPROC)NULL, (FARPROC *)&pPolyDraw, (FARPROC)extPolyDraw},
- {"MoveToEx", (FARPROC)NULL, (FARPROC *)&pMoveToEx, (FARPROC)extMoveToEx},
- {"ArcTo", (FARPROC)NULL, (FARPROC *)&pArcTo, (FARPROC)extArcTo},
- {"LineTo", (FARPROC)NULL, (FARPROC *)&pLineTo, (FARPROC)extLineTo},
- {"SetPixel", (FARPROC)NULL, (FARPROC *)&pSetPixel, (FARPROC)extSetPixel},
- {"Ellipse", (FARPROC)NULL, (FARPROC *)&pEllipse, (FARPROC)extEllipse},
- {"Polygon", (FARPROC)NULL, (FARPROC *)&pPolygon, (FARPROC)extPolygon},
- {"Arc", (FARPROC)NULL, (FARPROC *)&pArc, (FARPROC)extArc},
- {"CreateEllipticRgn", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgn, (FARPROC)extCreateEllipticRgn},
- {"CreateEllipticRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgnIndirect, (FARPROC)extCreateEllipticRgnIndirect},
- {"CreateRectRgn", (FARPROC)NULL, (FARPROC *)&pCreateRectRgn, (FARPROC)extCreateRectRgn},
- {"CreateRectRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateRectRgnIndirect, (FARPROC)extCreateRectRgnIndirect},
- {"CreatePolygonRgn", (FARPROC)NULL, (FARPROC *)&pCreatePolygonRgn, (FARPROC)extCreatePolygonRgn},
- {"DrawTextA", (FARPROC)NULL, (FARPROC *)&pDrawText, (FARPROC)extDrawText},
- {"DrawTextExA", (FARPROC)NULL, (FARPROC *)&pDrawTextEx, (FARPROC)extDrawTextEx},
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type EmulateHooks[]={
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type DDHooks[]={
- {"CreateCompatibleDC", (FARPROC)CreateCompatibleDC, (FARPROC *)&pGDICreateCompatibleDC, (FARPROC)extDDCreateCompatibleDC},
- {"DeleteDC", (FARPROC)DeleteDC, (FARPROC *)&pGDIDeleteDC, (FARPROC)extDDDeleteDC},
- {"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extDDCreateDC},
- {"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extDDBitBlt},
- {"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extDDStretchBlt},
- // {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extDDPatBlt}, // missing one ...
- // {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt},
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type GDIHooks[]={
- {"CreateCompatibleDC", (FARPROC)CreateCompatibleDC, (FARPROC *)&pGDICreateCompatibleDC, (FARPROC)extGDICreateCompatibleDC},
- {"DeleteDC", (FARPROC)DeleteDC, (FARPROC *)&pGDIDeleteDC, (FARPROC)extGDIDeleteDC},
- {"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extGDICreateDC},
- {"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extGDIBitBlt},
- {"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extGDIStretchBlt},
- {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extGDIPatBlt},
- {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt},
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type EmuHooks[]={
- {"CreateFontA", (FARPROC)CreateFont, (FARPROC *)&pGDICreateFont, (FARPROC)extCreateFont},
- {"CreateFontIndirectA", (FARPROC)CreateFontIndirectA, (FARPROC *)&pGDICreateFontIndirect, (FARPROC)extCreateFontIndirect},
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type GammaHooks[]={
- {"SetDeviceGammaRamp", (FARPROC)SetDeviceGammaRamp, (FARPROC *)&pGDISetDeviceGammaRamp, (FARPROC)extSetDeviceGammaRamp},
- {"GetDeviceGammaRamp", (FARPROC)GetDeviceGammaRamp, (FARPROC *)&pGDIGetDeviceGammaRamp, (FARPROC)extGetDeviceGammaRamp},
- {0, NULL, 0, 0} // terminator
-};
-
-static HookEntry_Type FontHooks[]={
- {"CreateScalableFontResourceA", (FARPROC)NULL, (FARPROC *)&pCreateScalableFontResourceA, (FARPROC)extCreateScalableFontResourceA},
- {"CreateScalableFontResourceW", (FARPROC)NULL, (FARPROC *)&pCreateScalableFontResourceW, (FARPROC)extCreateScalableFontResourceW},
- {"AddFontResourceA", (FARPROC)NULL, (FARPROC *)&pAddFontResourceA, (FARPROC)extAddFontResourceA},
- {"AddFontResourceW", (FARPROC)NULL, (FARPROC *)&pAddFontResourceW, (FARPROC)extAddFontResourceW},
- {0, NULL, 0, 0} // terminator
-};
-
-extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *);
-extern HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *, LPDIRECTDRAW FAR *, REFIID, IUnknown FAR *);
-
-static char *libname = "gdi32.dll";
-
-void HookGDI32Init()
-{
- HookLibInit(Hooks);
- HookLibInit(RemapHooks);
- HookLibInit(DDHooks);
- HookLibInit(EmuHooks);
- HookLibInit(GammaHooks);
-}
-
-void HookGDI32(HMODULE module)
-{
- HookLibrary(module, Hooks, libname);
-
- if(dxw.dwFlags1 & CLIENTREMAPPING)
- HookLibrary(module, RemapHooks, libname);
-
- if(dxw.dwFlags3 & EMULATEDC)
- HookLibrary(module, EmulateHooks, libname);
- HookLibrary(module, ScaledHooks, libname);
- HookLibrary(module, GDIHooks, libname);
-
- if(dxw.dwFlags2 & HOOKGDI){
- HookLibrary(module, EmulateHooks, libname);
- HookLibrary(module, ScaledHooks, libname);
- HookLibrary(module, GDIHooks, libname);
- }
-
- if(dxw.dwFlags1 & MAPGDITOPRIMARY){
- HookLibrary(module, EmulateHooks, libname);
- HookLibrary(module, ScaledHooks, libname);
- HookLibrary(module, DDHooks, libname);
- }
-
- if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC))
- HookLibrary(module, EmuHooks, libname);
-
- if(dxw.dwFlags2 & DISABLEGAMMARAMP)
- HookLibrary(module, GammaHooks, libname);
-
- if(dxw.dwFlags3 & FONTBYPASS) // v2.02.33 - for "Stratego" compatibility option
- HookLibrary(module, FontHooks, libname);
-}
-
-FARPROC Remap_GDI32_ProcAddress(LPCSTR proc, HMODULE hModule)
-{
- FARPROC addr;
-
- if(addr=RemapLibrary(proc, hModule, Hooks)) return addr;
-
- if(dxw.dwFlags1 & CLIENTREMAPPING)
- if(addr=RemapLibrary(proc, hModule, RemapHooks)) return addr;
-
- if(dxw.dwFlags3 & EMULATEDC){
- if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
- if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
- if (addr=RemapLibrary(proc, hModule, GDIHooks)) return addr;
- }
-
- if(dxw.dwFlags2 & HOOKGDI){
- if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
- if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
- if (addr=RemapLibrary(proc, hModule, GDIHooks)) return addr;
- }
-
- if(dxw.dwFlags1 & MAPGDITOPRIMARY){
- if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
- if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
- if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr;
- }
-
- if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC))
- if(addr=RemapLibrary(proc, hModule, EmuHooks)) return addr;
-
- if(dxw.dwFlags2 & DISABLEGAMMARAMP)
- if(addr=RemapLibrary(proc, hModule, GammaHooks)) return addr;
-
- if(1) // v2.02.33 - for "Stratego" compatibility option
- if(addr=RemapLibrary(proc, hModule, FontHooks)) return addr;
-
- return NULL;
-}
-
-//--------------------------------------------------------------------------------------------
-//
-// extern and common functions
-//
-//--------------------------------------------------------------------------------------------
-
-extern DEVMODE *pSetDevMode;
-extern DWORD PaletteEntries[256];
-extern Unlock4_Type pUnlockMethod(LPDIRECTDRAWSURFACE);
-extern HRESULT WINAPI sBlt(char *, LPDIRECTDRAWSURFACE, LPRECT, LPDIRECTDRAWSURFACE, LPRECT, DWORD, LPDDBLTFX, BOOL);
-
-extern GetDC_Type pGetDC;
-extern ReleaseDC_Type pReleaseDC;
-
-static COLORREF GetMatchingColor(COLORREF crColor)
-{
- int iDistance, iMinDistance;
- int iColorIndex, iMinColorIndex;
- COLORREF PalColor;
-
- iMinDistance=0xFFFFFF;
- iMinColorIndex=0;
-
- for(iColorIndex=0; iColorIndex<256; iColorIndex++){
- int iDist;
- iDistance=0;
-
- PalColor=PaletteEntries[iColorIndex];
- switch(dxw.ActualPixelFormat.dwRGBBitCount){
- case 32:
- PalColor = ((PalColor & 0x00FF0000) >> 16) | (PalColor & 0x0000FF00) | ((PalColor & 0x000000FF) << 16);
- break;
- case 16:
- if(dxw.ActualPixelFormat.dwGBitMask==0x03E0){
- // RGB555 screen settings
- PalColor = ((PalColor & 0x7C00) >> 7) | ((PalColor & 0x03E0) << 6) | ((PalColor & 0x001F) << 19);
- }
- else {
- // RGB565 screen settings
- PalColor = ((PalColor & 0xF800) >> 8) | ((PalColor & 0x07E0) << 5) | ((PalColor & 0x001F) << 19);
- }
- break;
- }
-
- iDist = (crColor & 0x00FF0000) - (PalColor & 0x00FF0000);
- iDist >>= 16;
- if (iDist<0) iDist=-iDist;
- iDist *= iDist;
- iDistance += iDist;
-
- iDist = (crColor & 0x0000FF00) - (PalColor & 0x0000FF00);
- iDist >>= 8;
- if (iDist<0) iDist=-iDist;
- iDist *= iDist;
- iDistance += iDist;
-
- iDist = (crColor & 0x000000FF) - (PalColor & 0x000000FF);
- // iDist >>= 0;
- if (iDist<0) iDist=-iDist;
- iDist *= iDist;
- iDistance += iDist;
-
- if (iDistance < iMinDistance) {
- iMinDistance = iDistance;
- iMinColorIndex = iColorIndex;
- }
-
- if (iMinDistance==0) break; // got the perfect match!
- }
- OutTraceD("GetMatchingColor: color=%x matched with palette[%d]=%x dist=%d\n",
- crColor, iMinColorIndex, PaletteEntries[iMinColorIndex], iDistance);
- PalColor=PaletteEntries[iMinColorIndex];
- switch(dxw.ActualPixelFormat.dwRGBBitCount){
- case 32:
- crColor = ((PalColor & 0x00FF0000) >> 16) | (PalColor & 0x0000FF00) | ((PalColor & 0x000000FF) << 16);
- break;
- case 16:
- if(dxw.ActualPixelFormat.dwGBitMask==0x03E0){
- // RGB555 screen settings
- crColor = ((PalColor & 0x7C00) >> 7) | ((PalColor & 0x03E0) << 6) | ((PalColor & 0x001F) << 19);
- }
- else {
- // RGB565 screen settings
- crColor = ((PalColor & 0xF800) >> 8) | ((PalColor & 0x07E0) << 5) | ((PalColor & 0x001F) << 19);
- }
- break;
- }
- return crColor;
-}
-
-//--------------------------------------------------------------------------------------------
-//
-// API hookers
-//
-//--------------------------------------------------------------------------------------------
-
-int WINAPI extGetDeviceCaps(HDC hdc, int nindex)
-{
- DWORD res;
-
- res = (*pGDIGetDeviceCaps)(hdc, nindex);
- OutTraceD("GetDeviceCaps: hdc=%x index=%x(%s) res=%x\n",
- hdc, nindex, ExplainDeviceCaps(nindex), res);
-
-#ifdef GDIEMULATIONONLY
- switch(nindex){
- case VERTRES:
- res= dxw.GetScreenHeight();
- OutTraceD("GetDeviceCaps: fix(0) VERTRES cap=%d\n", res);
- break;
- case HORZRES:
- res= dxw.GetScreenWidth();
- OutTraceD("GetDeviceCaps: fix(0) HORZRES cap=%d\n", res);
- break;
- }
- return res;
-#endif
-
- // if you have a bypassed setting, use it first!
- if(pSetDevMode){
- switch(nindex){
- case BITSPIXEL:
- case COLORRES:
- res = pSetDevMode->dmBitsPerPel;
- OutTraceD("GetDeviceCaps: fix(1) BITSPIXEL/COLORRES cap=%x\n",res);
- return res;
- case HORZRES:
- res = pSetDevMode->dmPelsWidth;
- OutTraceD("GetDeviceCaps: fix(1) HORZRES cap=%d\n", res);
- return res;
- case VERTRES:
- res = pSetDevMode->dmPelsHeight;
- OutTraceD("GetDeviceCaps: fix(1) VERTRES cap=%d\n", res);
- return res;
- }
- }
-
- switch(nindex){
- case VERTRES:
- res= dxw.GetScreenHeight();
- OutTraceD("GetDeviceCaps: fix(2) VERTRES cap=%d\n", res);
- break;
- case HORZRES:
- res= dxw.GetScreenWidth();
- OutTraceD("GetDeviceCaps: fix(2) HORZRES cap=%d\n", res);
- break;
- // WARNING: in no-emu mode, the INIT8BPP and INIT16BPP flags expose capabilities that
- // are NOT implemented and may cause later troubles!
- case RASTERCAPS:
- if(dxw.dwFlags2 & INIT8BPP) {
- res |= RC_PALETTE; // v2.02.12
- OutTraceD("GetDeviceCaps: fix(2) RASTERCAPS setting RC_PALETTE cap=%x\n",res);
- }
- break;
- case BITSPIXEL:
- case COLORRES:
- if(dxw.dwFlags2 & (INIT8BPP|INIT16BPP)){ // v2.02.32 fix
- if(dxw.dwFlags2 & INIT8BPP) res = 8;
- if(dxw.dwFlags2 & INIT16BPP) res = 16;
- OutTraceD("GetDeviceCaps: fix(2) BITSPIXEL/COLORRES cap=%d\n",res);
- }
- break;
- //case NUMCOLORS: // numcolors windows bug fix....
- // if(res == -1) res=1;
- // return res;
- }
-
- if(dxw.dwFlags1 & EMULATESURFACE){
- switch(nindex){
- case RASTERCAPS:
- if((dxw.VirtualPixelFormat.dwRGBBitCount==8) || (dxw.dwFlags2 & INIT8BPP)){
- res = RC_PALETTE;
- OutTraceD("GetDeviceCaps: fix(3) RASTERCAPS setting RC_PALETTE cap=%x\n",res);
- }
- break;
- case BITSPIXEL:
- case COLORRES:
- int PrevRes;
- PrevRes=res;
- if(dxw.VirtualPixelFormat.dwRGBBitCount!=0) res = dxw.VirtualPixelFormat.dwRGBBitCount;
- if(dxw.dwFlags2 & INIT8BPP) res = 8;
- if(dxw.dwFlags2 & INIT16BPP) res = 16;
- if(PrevRes != res) OutTraceD("GetDeviceCaps: fix(3) BITSPIXEL/COLORRES cap=%d\n",res);
- break;
- case SIZEPALETTE:
- res = 256;
- OutTraceD("GetDeviceCaps: fix(3) SIZEPALETTE cap=%x\n",res);
- break;
- case NUMRESERVED:
- res = 0;
- OutTraceD("GetDeviceCaps: fix(3) NUMRESERVED cap=%x\n",res);
- break;
- }
- }
- return res;
-}
-
-BOOL WINAPI extTextOutA(HDC hdc, int nXStart, int nYStart, LPCTSTR lpString, int cchString)
-{
- BOOL ret;
- OutTraceD("TextOut: hdc=%x xy=(%d,%d) str=(%d)\"%s\"\n", hdc, nXStart, nYStart, cchString, lpString);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&nXStart, &nYStart);
- OutTraceD("TextOut: fixed dest=(%d,%d)\n", nXStart, nYStart);
- }
-
- ret=(*pGDITextOutA)(hdc, nXStart, nYStart, lpString, cchString);
- if(!ret) OutTraceE("TextOut: ERROR ret=%x\n", ret);
- return ret;
-}
-
-BOOL WINAPI extScaleWindowExtEx(HDC hdc, int Xnum, int Xdenom, int Ynum, int Ydenom, LPSIZE lpSize)
-{
- OutTraceD("ScaleWindowExtEx: hdc=%x num=(%d,%d) denom=(%d,%d) lpSize=%d\n",
- hdc, Xnum, Ynum, Xdenom, Ydenom, lpSize);
-
- MessageBox(0, "ScaleWindowExtEx", "to fix", MB_OK | MB_ICONEXCLAMATION);
-
- return (*pGDIScaleWindowExtEx)(hdc, Xnum, Xdenom, Ynum, Ydenom, lpSize);
-}
-
-BOOL WINAPI extRectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
-{
- int ret;
-
- OutTraceD("Rectangle: hdc=%x xy=(%d,%d)-(%d,%d)\n", hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&nLeftRect, &nTopRect, &nRightRect, &nBottomRect);
- OutTraceD("Rectangle: fixed dest=(%d,%d)-(%d,%d)\n", nLeftRect, nTopRect, nRightRect, nBottomRect);
- }
-
- ret=(*pGDIRectangle)(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
- if(!ret) OutTraceE("Rectangle: ERROR ret=%x\n", ret);
- return ret;
-}
-
-int WINAPI extGDISaveDC(HDC hdc)
-{
- int ret;
-
- ret=(*pGDISaveDC)(hdc);
- OutTraceD("GDI.SaveDC: hdc=%x ret=%x\n", hdc, ret);
- //AutoRefreshThread=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AutoRefresh, (LPVOID)hdc, 0, &dwThrdId);
- return ret;
-}
-
-BOOL WINAPI extGDIRestoreDC(HDC hdc, int nSavedDC)
-{
- BOOL ret;
-
- ret=(*pGDIRestoreDC)(hdc, nSavedDC);
- OutTraceD("GDI.RestoreDC: hdc=%x nSavedDC=%x ret=%x\n", hdc, nSavedDC, ret);
- //TerminateThread(AutoRefreshThread, 0);
- return ret;
-}
-
-/* --------------------------------------------------------------------------- */
-
-// v2.1.75: Hooking for GDI32 CreatePalette, SelectPalette, RealizePalette:
-// maps the GDI palette to the buffered DirectDraw one. This fixes the screen
-// output for "Dementia" (a.k.a. "Armed & Delirious").
-
-HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal)
-{
- HPALETTE ret;
- int idx;
-
- dxw.IsGDIPalette=TRUE;
- OutTraceD("GDI.CreatePalette: plpal=%x version=%x NumEntries=%x\n", plpal, plpal->palVersion, plpal->palNumEntries);
- ret=(*pGDICreatePalette)(plpal);
- if(IsDebug){
- OutTraceD("PalEntry[%x]= ", plpal->palNumEntries);
- for(idx=0; idxpalNumEntries; idx++) OutTraceD("(%x)", plpal->palPalEntry[idx]);
- OutTraceD("\n");
- }
- dxw.palVersion=plpal->palVersion;
- dxw.palNumEntries=plpal->palNumEntries;
- if(dxw.palNumEntries>256) dxw.palNumEntries=256;
- for(idx=0; idxpalPalEntry[idx];
- OutTraceD("GDI.CreatePalette: hPalette=%x\n", ret);
- return ret;
-}
-
-HPALETTE WINAPI extSelectPalette(HDC hdc, HPALETTE hpal, BOOL bForceBackground)
-{
- HPALETTE ret;
-
- ret=(*pGDISelectPalette)(hdc, hpal, bForceBackground);
- OutTraceD("GDI.SelectPalette: hdc=%x hpal=%x ForceBackground=%x ret=%x\n", hdc, hpal, bForceBackground, ret);
- return ret;
-}
-
-UINT WINAPI extRealizePalette(HDC hdc)
-{
- UINT ret;
- extern void mySetPalette(int, int, LPPALETTEENTRY);
-
- ret=(*pGDIRealizePalette)(hdc);
- OutTraceD("GDI.RealizePalette: hdc=%x ret=%x\n", hdc, ret);
-
- if(!dxw.IsGDIPalette) return ret;
-
- // quick & dirty implementation through a nasty global:
- // if the SelectPalette didn't force to the background (arg bForceBackground==FALSE)
- // then don't override the current palette set by the DirectDrawPalette class.
- // should be cleaned up a little....
- // maybe not: now both Diablo & Dementia colors are working...
- if(dxw.dwFlags1 & EMULATESURFACE)
- mySetPalette(0, dxw.palNumEntries, dxw.palPalEntry);
- // DEBUGGING
- if(IsDebug){
- int idx;
- OutTraceD("PaletteEntries[%x]= ", dxw.palNumEntries);
- for(idx=0; idxGetDC device context,
- // that is a memory device type associated to NULL (desktop) window, through GDI StretchBlt api. So, you shoud compensate
- // by scaling and offsetting to main window.
- dxw.MapWindow(&nXDest, &nYDest, &nWidth, &nHeight);
- }
- }
-
- res=(*pGDIStretchBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWSrc, nHSrc, dwRop);
- if (IsToScreen && (dxw.dwFlags2 & SHOWFPSOVERLAY)) dxw.ShowFPS(hdcDest);
- if(!res) OutTraceE("GDI.StretchBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
- return res;
-}
-
-BOOL WINAPI extGDIDeleteDC(HDC hdc)
-{
- BOOL res;
- OutTraceD("GDI.DeleteDC: hdc=%x\n", hdc);
- res=(*pGDIDeleteDC)(hdc);
- if(!res) OutTraceE("GDI.DeleteDC: ERROR err=%d at %d\n", GetLastError(), __LINE__);
- return res;
-}
-
-COLORREF WINAPI extSetTextColor(HDC hdc, COLORREF crColor)
-{
- COLORREF res;
-
- if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC) && (dxw.VirtualPixelFormat.dwRGBBitCount==8))
- crColor=GetMatchingColor(crColor);
-
- res=(*pGDISetTextColor)(hdc, crColor);
- OutTraceD("SetTextColor: color=%x res=%x%s\n", crColor, res, (res==CLR_INVALID)?"(CLR_INVALID)":"");
- return res;
-}
-
-COLORREF WINAPI extSetBkColor(HDC hdc, COLORREF crColor)
-{
- COLORREF res;
-
- if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC) && (dxw.VirtualPixelFormat.dwRGBBitCount==8))
- crColor=GetMatchingColor(crColor);
-
- res=(*pGDISetBkColor)(hdc, crColor);
- OutTraceD("SetBkColor: color=%x res=%x%s\n", crColor, res, (res==CLR_INVALID)?"(CLR_INVALID)":"");
- return res;
-}
-
-HFONT WINAPI extCreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int fnWeight,
- DWORD fdwItalic, DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fdwCharSet,
- DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality,
- DWORD fdwPitchAndFamily, LPCTSTR lpszFace)
-{
- OutTraceD("CreateFont: h=%d w=%d face=\"%s\"\n", nHeight, nWidth, lpszFace);
- if(dxw.dwFlags1 & FIXTEXTOUT) {
- if(nHeight > 0) dxw.MapClient(&nWidth, &nHeight);
- else {
- nHeight= -nHeight;
- dxw.MapClient(&nWidth, &nHeight);
- nHeight= -nHeight;
- }
- }
- return (*pGDICreateFont)(nHeight, nWidth, nEscapement, nOrientation, fnWeight,
- fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet,
- fdwOutputPrecision, fdwClipPrecision, NONANTIALIASED_QUALITY,
- fdwPitchAndFamily, lpszFace);
-}
-
-// CreateFontIndirect hook routine to avoid font aliasing that prevents reverse blitting working on palettized surfaces
-
-HFONT WINAPI extCreateFontIndirect(const LOGFONT* lplf)
-{
- LOGFONT lf;
- HFONT retHFont;
- OutTraceD("CreateFontIndirect: h=%d w=%d face=\"%s\"\n", lplf->lfHeight, lplf->lfWidth, lplf->lfFaceName);
- memcpy((char *)&lf, (char *)lplf, sizeof(LOGFONT));
- lf.lfQuality=NONANTIALIASED_QUALITY;
- if(dxw.dwFlags1 & FIXTEXTOUT) {
- if(lf.lfHeight > 0) dxw.MapClient((int *)&lf.lfWidth, (int *)&lf.lfHeight);
- else {
- lf.lfHeight= -lf.lfHeight;
- dxw.MapClient((int *)&lf.lfWidth, (int *)&lf.lfHeight);
- lf.lfHeight= -lf.lfHeight;
- }
- }
- retHFont=((*pGDICreateFontIndirect)(&lf));
- if(retHFont)
- OutTraceD("CreateFontIndirect: hfont=%x\n", retHFont);
- else
- OutTraceD("CreateFontIndirect: error=%d at %d\n", GetLastError(), __LINE__);
- return retHFont;
-}
-
-BOOL WINAPI extSetDeviceGammaRamp(HDC hDC, LPVOID lpRamp)
-{
- BOOL ret;
- OutTraceD("SetDeviceGammaRamp: hdc=%x\n", hDC);
- if(dxw.dwFlags2 & DISABLEGAMMARAMP) {
- OutTraceD("SetDeviceGammaRamp: SUPPRESSED\n");
- return TRUE;
- }
- ret=(*pGDISetDeviceGammaRamp)(hDC, lpRamp);
- if(!ret) OutTraceE("SetDeviceGammaRamp: ERROR err=%d\n", GetLastError());
- return ret;
-}
-
-BOOL WINAPI extGetDeviceGammaRamp(HDC hDC, LPVOID lpRamp)
-{
- BOOL ret;
- OutTraceD("GetDeviceGammaRamp: hdc=%x\n", hDC);
- ret=(*pGDIGetDeviceGammaRamp)(hDC, lpRamp);
- if(!ret) OutTraceE("GetDeviceGammaRamp: ERROR err=%d\n", GetLastError());
- return ret;
-}
-
-int WINAPI extGetClipBox(HDC hdc, LPRECT lprc)
-{
- // v2.02.31: needed in "Imperialism II" to avoid blit clipping
- int ret;
- char *sRetCodes[4]={"ERROR", "NULLREGION", "SIMPLEREGION", "COMPLEXREGION"};
- OutTraceD("GetClipBox: hdc=%x\n", hdc);
- ret=(*pGDIGetClipBox)(hdc, lprc);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc)) && (ret!=ERROR)){
- OutTraceD("GetClipBox: scaling main win coordinates (%d,%d)-(%d,%d)\n",
- lprc->left, lprc->top, lprc->right, lprc->bottom);
- // current implementation is NOT accurate, since it always returns the whole
- // virtual desktop area as the current clipbox...!!!
- *lprc=dxw.GetScreenRect();
- }
- OutTraceD("GetClipBox: ret=%x(%s)\n", ret, sRetCodes[ret]);
- return ret;
-}
-
-BOOL WINAPI extPolyline(HDC hdc, const POINT *lppt, int cPoints)
-{
- BOOL ret;
- if(IsTraceD){
- int i;
- OutTrace("Polyline: hdc=%x cPoints=%d pt=", hdc, cPoints);
- for(i=0; ibmiHeader);
- OutTraceD("SetDIBitsToDevice: BitmapInfo dim=(%dx%d) Planes=%d BPP=%d Compression=%x SizeImage=%x\n",
- bmi->biWidth, bmi->biHeight, bmi->biPlanes, bmi->biBitCount, bmi->biCompression, bmi->biSizeImage);
-
- if (dxw.IsFullScreen() && dxw.IsVirtual(hdc)){
- int X, Y;
- X=XDest+dxw.VirtualOffsetX;
- Y=YDest+dxw.VirtualOffsetY;
- OutTraceD("SetDIBitsToDevice: virtual pos=(%d,%d)+(%d+%d)=(%d,%d)\n",
- XDest, YDest, dxw.VirtualOffsetX, dxw.VirtualOffsetY, X, Y);
- ret=(*pSetDIBitsToDevice)(hdc, X, Y, dwWidth, dwHeight, XSrc, YSrc, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse);
- if(!ret || (ret==GDI_ERROR)) OutTraceE("SetDIBitsToDevice: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
- }
- //else
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- DWORD OrigWidth, OrigHeight;
- int OrigXDest, OrigYDest;
- OrigWidth=dwWidth;
- OrigHeight=dwHeight;
- OrigXDest=XDest;
- OrigYDest=YDest;
- dxw.MapClient(&XDest, &YDest, (int *)&dwWidth, (int *)&dwHeight);
- OutTraceD("SetDIBitsToDevice: fixed dest=(%d,%d)-(%d,%d)\n", XDest, YDest, dwWidth, dwHeight);
- HDC hTempDc;
- HBITMAP hbmPic;
- if(!(hTempDc=CreateCompatibleDC(hdc)))
- OutTraceE("CreateCompatibleDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- // tricky part: CreateCompatibleBitmap is needed to set the dc size, but it has to be performed
- // against hdc to set for color depth, then selected (through SelectObject) against the temporary
- // dc to assign the needed size and color space to the temporary dc.
- if(!(hbmPic=CreateCompatibleBitmap(hdc, OrigWidth, OrigHeight)))
- OutTraceE("CreateCompatibleBitmap: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- if(!SelectObject(hTempDc, hbmPic))
- OutTraceE("SelectObject: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- if(!(*pSetDIBitsToDevice)(hTempDc, 0, 0, OrigWidth, OrigHeight, XSrc, YSrc, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse))
- OutTraceE("SetDIBitsToDevice: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- if(!(ret=(*pGDIStretchBlt)(hdc, XDest, YDest, dwWidth, dwHeight, hTempDc, 0, 0, OrigWidth, OrigHeight, SRCCOPY)))
- OutTraceE("StretchBlt: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- if(!(DeleteObject(hbmPic))) // v2.02.32 - avoid resource leakage
- OutTraceE("DeleteObject: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- if(!(DeleteDC(hTempDc)))
- OutTraceE("DeleteDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- }
- else{
- ret=(*pSetDIBitsToDevice)(hdc, XDest, YDest, dwWidth, dwHeight, XSrc, YSrc, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse);
- }
- if(!ret || (ret==GDI_ERROR)) OutTraceE("SetDIBitsToDevice: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-//HBITMAP WINAPI extCreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)
-//{
-// HBITMAP ret;
-// OutTraceD("CreateCompatibleBitmap: hdc=%x size=(%d,%d)\n",
-// hdc, nWidth, nHeight);
-//
-// if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
-// dxw.MapClient(&nWidth, &nHeight);
-// OutTraceD("CreateCompatibleBitmap: fixed size=(%d,%d)\n", nWidth, nHeight);
-// }
-//
-// ret=(*pCreateCompatibleBitmap)(hdc, nWidth, nHeight);
-// if(!ret) OutTraceE("CreateCompatibleBitmap: ERROR ret=%x err=%d\n", ret, GetLastError());
-// return ret;
-//}
-
-COLORREF WINAPI extSetPixel(HDC hdc, int X, int Y, COLORREF crColor)
-{
- COLORREF ret;
- OutTraceD("SetPixel: hdc=%x color=%x point=(%d,%d)\n", hdc, crColor, X, Y);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&X, &Y);
- OutTraceD("SetPixel: fixed pos=(%d,%d)\n", X, Y);
- }
-
- ret=(*pSetPixel)(hdc, X, Y, crColor);
- // both 0x00000000 and 0xFFFFFFFF are legitimate colors and therefore valid return codes...
- //if(ret==GDI_ERROR) OutTraceE("SetPixel: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extEllipse(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
-{
- int ret;
- OutTraceD("Ellipse: hdc=%x rect=(%d,%d)-(%d,%d)\n", hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&nLeftRect, &nTopRect, &nRightRect, &nBottomRect);
- OutTraceD("Ellipse: fixed dest=(%d,%d)-(%d,%d)\n", nLeftRect, nTopRect, nRightRect, nBottomRect);
- }
-
- ret=(*pEllipse)(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
- if(!ret) OutTraceE("Ellipse: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extPolygon(HDC hdc, const POINT *lpPoints, int cCount)
-{
- BOOL ret;
- if(IsTraceD){
- int i;
- OutTrace("Polygon: hdc=%x cCount=%d pt=", hdc, cCount);
- for(i=0; ileft, lprc->top, lprc->right, lprc->bottom);
-
- if (dxw.IsFullScreen()){
- dxw.MapClient((RECT *)lprc);
- OutTraceD("CreateEllipticRgnIndirect: fixed rect=(%d,%d)-(%d,%d)\n", lprc->left, lprc->top, lprc->right, lprc->bottom);
- }
-
- ret=(*pCreateEllipticRgnIndirect)(lprc);
- if(!ret) OutTraceE("CreateEllipticRgnIndirect: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-HRGN WINAPI extCreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
-{
- HRGN ret;
- OutTraceD("CreateRectRgn: rect=(%d,%d)-(%d,%d)\n", nLeftRect, nTopRect, nRightRect, nBottomRect);
-
- if (dxw.IsFullScreen()){
- dxw.MapClient(&nLeftRect, &nTopRect, &nRightRect, &nBottomRect);
- OutTraceD("CreateRectRgn: fixed rect=(%d,%d)-(%d,%d)\n", nLeftRect, nTopRect, nRightRect, nBottomRect);
- }
-
- ret=(*pCreateRectRgn)(nLeftRect, nTopRect, nRightRect, nBottomRect);
- if(!ret) OutTraceE("CreateRectRgn: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-HRGN WINAPI extCreateRectRgnIndirect(const RECT *lprc)
-{
- HRGN ret;
- OutTraceD("CreateRectRgnIndirect: rect=(%d,%d)-(%d,%d)\n", lprc->left, lprc->top, lprc->right, lprc->bottom);
-
- if (dxw.IsFullScreen()){
- dxw.MapClient((RECT *)lprc);
- OutTraceD("CreateRectRgnIndirect: fixed rect=(%d,%d)-(%d,%d)\n", lprc->left, lprc->top, lprc->right, lprc->bottom);
- }
-
- ret=(*pCreateRectRgnIndirect)(lprc);
- if(!ret) OutTraceE("CreateRectRgnIndirect: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-HRGN WINAPI extCreatePolygonRgn(const POINT *lpPoints, int cPoints, int fnPolyFillMode)
-{
- HRGN ret;
- if(IsTraceD){
- int i;
- OutTrace("CreatePolygonRgn: PolyFillMode=%x cCount=%d pt=", fnPolyFillMode, cPoints);
- for(i=0; ileft, lpRect->top, lpRect->right, lpRect->bottom, uFormat, nCount, lpchText);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient((RECT *)lpRect);
- OutTraceD("DrawText: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
- }
-
- ret=(*pDrawText)(hdc, lpchText, nCount, lpRect, uFormat);
- if(!ret) OutTraceE("DrawText: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-int WINAPI extDrawTextEx(HDC hdc, LPTSTR lpchText, int nCount, LPRECT lpRect, UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams)
-{
- int ret;
- OutTraceD("DrawTextEx: hdc=%x rect=(%d,%d)-(%d,%d) DTFormat=%x Text=(%d)\"%s\"\n",
- hdc, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, dwDTFormat, nCount, lpchText);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient((RECT *)lpRect);
- OutTraceD("DrawTextEx: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
- }
-
- ret=(*pDrawTextEx)(hdc, lpchText, nCount, lpRect, dwDTFormat, lpDTParams);
- if(!ret) OutTraceE("DrawTextEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc,
- int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, DWORD dwRop)
-{
- BOOL ret;
- OutTraceD("MaskBlt: hdcDest=%x pos=(%d,%d) size=(%dx%d) hdcSrc=%x pos=(%d,%d) hbmMask=%x Mask=(%d,%d) dwRop=%x\n",
- hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, hbmMask, xMask, yMask, dwRop);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdcDest))){
- dxw.MapClient(&nXDest, &nYDest, &nWidth, &nHeight);
- OutTraceD("MaskBlt: fixed pos=(%d,%d) size=(%dx%d)\n", nXDest, nYDest, nWidth, nHeight);
- }
-
- ret=(*pMaskBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, hbmMask, xMask, yMask, dwRop);
- if(!ret) OutTraceE("MaskBlt: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extSetViewportOrgEx(HDC hdc, int X, int Y, LPPOINT lpPoint)
-{
- BOOL ret;
- OutTraceD("SetViewportOrgEx: hdc=%x pos=(%d,%d)\n", hdc, X, Y);
-
- if(dxw.IsVirtual(hdc)) {
- OutTraceD("SetViewportOrgEx: virtual hdc\n");
- dxw.VirtualOffsetX = X;
- dxw.VirtualOffsetY = Y;
- return TRUE;
- }
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&X, &Y);
- OutTraceD("SetViewportOrgEx: fixed pos=(%d,%d)\n", X, Y);
- }
-
- ret=(*pSetViewportOrgEx)(hdc, X, Y, lpPoint);
- if(ret && lpPoint) {
- OutTraceD("SetViewportOrgEx: previous ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.UnmapClient(lpPoint);
- OutTraceD("SetViewportOrgEx: fixed previous ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- }
- }
- if(!ret) OutTraceE("SetViewportOrgEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extSetViewportExtEx(HDC hdc, int nXExtent, int nYExtent, LPSIZE lpSize)
-{
- BOOL ret;
- OutTraceD("SetViewportExtEx: hdc=%x ext=(%d,%d)\n", hdc, nXExtent, nYExtent);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&nXExtent, &nYExtent);
- OutTraceD("SetViewportExtEx: fixed ext=(%d,%d)\n", nXExtent, nYExtent);
- }
-
- ret=(*pSetViewportExtEx)(hdc, nXExtent, nYExtent, lpSize);
- if(ret && lpSize) {
- OutTraceD("SetViewportExtEx: previous ext=(%d,%d)\n", lpSize->cx, lpSize->cy);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.UnmapClient((LPPOINT)lpSize);
- OutTraceD("SetViewportExtEx: fixed previous ext=(%d,%d)\n", lpSize->cx, lpSize->cy);
- }
- }
-
- if(!ret) OutTraceE("SetViewportExtEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extGetViewportOrgEx(HDC hdc, LPPOINT lpPoint)
-{
- BOOL ret;
- OutTraceD("GetViewportOrgEx: hdc=%x\n", hdc);
-
- if(dxw.IsVirtual(hdc)) {
- lpPoint->x = dxw.VirtualOffsetX;
- lpPoint->y = dxw.VirtualOffsetY;
- return TRUE;
- }
-
- ret=(*pGetViewportOrgEx)(hdc, lpPoint);
- if(ret) {
- OutTraceD("GetViewportOrgEx: ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.UnmapClient(lpPoint);
- OutTraceD("GetViewportOrgEx: fixed ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- }
- }
-
- if(!ret) OutTraceE("GetViewportOrgEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extGetWindowOrgEx(HDC hdc, LPPOINT lpPoint)
-{
- BOOL ret;
- OutTraceD("GetWindowOrgEx: hdc=%x\n", hdc);
-
- ret=(*pGetWindowOrgEx)(hdc, lpPoint);
- if(ret) {
- OutTraceD("GetWindowOrgEx: ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.UnmapClient(lpPoint);
- OutTraceD("GetWindowOrgEx: fixed ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- }
- }
-
- if(!ret) OutTraceE("GetWindowOrgEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extSetWindowOrgEx(HDC hdc, int X, int Y, LPPOINT lpPoint)
-{
- BOOL ret;
- OutTraceD("SetWindowOrgEx: hdc=%x pos=(%d,%d)\n", hdc, X, Y);
-
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.MapClient(&X, &Y);
- OutTraceD("SetWindowOrgEx: fixed pos=(%d,%d)\n", X, Y);
- }
-
- ret=(*pSetWindowOrgEx)(hdc, X, Y, lpPoint);
- if(ret && lpPoint) {
- OutTraceD("SetWindowOrgEx: previous ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.UnmapClient(lpPoint);
- OutTraceD("SetWindowOrgEx: fixed previous ViewPort=(%d,%d)\n", lpPoint->x, lpPoint->y);
- }
- }
- if(!ret) OutTraceE("SetWindowOrgEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extGetCurrentPositionEx(HDC hdc, LPPOINT lpPoint)
-{
- BOOL ret;
- OutTraceD("GetCurrentPositionEx: hdc=%x\n", hdc);
-
- ret=(*pGetCurrentPositionEx)(hdc, lpPoint);
- if(ret) {
- OutTraceD("GetCurrentPositionEx: pos=(%d,%d)\n", lpPoint->x, lpPoint->y);
- if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){
- dxw.UnmapClient(lpPoint);
- OutTraceD("GetCurrentPositionEx: fixed pos=(%d,%d)\n", lpPoint->x, lpPoint->y);
- }
- }
- if(!ret) OutTraceE("GetCurrentPositionEx: ERROR ret=%x err=%d\n", ret, GetLastError());
- return ret;
-}
-
-BOOL WINAPI extCreateScalableFontResourceA(DWORD fdwHidden, LPCTSTR lpszFontRes, LPCTSTR lpszFontFile, LPCTSTR lpszCurrentPath)
-{
- BOOL res;
- OutTraceD("CreateScalableFontResource: hidden=%d FontRes=\"%s\" FontFile=\"%s\" CurrentPath=\"%s\"\n",
- fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath);
- if (1) return TRUE;
- res=(*pCreateScalableFontResourceA)(fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath);
- if(!res) OutTraceE("CreateScalableFontResource: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
-}
-
-BOOL WINAPI extCreateScalableFontResourceW(DWORD fdwHidden, LPCWSTR lpszFontRes, LPCWSTR lpszFontFile, LPCWSTR lpszCurrentPath)
-{
- BOOL res;
- OutTraceD("CreateScalableFontResource: hidden=%d FontRes=\"%ls\" FontFile=\"%ls\" CurrentPath=\"%ls\"\n",
- fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath);
- if (1) return TRUE;
- res=(*pCreateScalableFontResourceW)(fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath);
- if(!res) OutTraceE("CreateScalableFontResource: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
-}
-
-int WINAPI extAddFontResourceA(LPCTSTR lpszFontFile)
-{
- BOOL res;
- OutTraceD("AddFontResource: FontFile=\"%s\"\n", lpszFontFile);
- if(1) return TRUE;
- res=(*pAddFontResourceA)(lpszFontFile);
- if(!res) OutTraceE("AddFontResource: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
-}
-
-int WINAPI extAddFontResourceW(LPCWSTR lpszFontFile)
-{
- BOOL res;
- OutTraceD("AddFontResource: FontFile=\"%ls\"\n", lpszFontFile);
- if(1) return TRUE;
- res=(*pAddFontResourceW)(lpszFontFile);
- if(!res) OutTraceE("AddFontResource: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
-}
-
-#if 0
-// to map:
-// GetCurrentPositionEx
-// GetViewportExtEx
-// DPtoLP
-// GetWindowOrgEx
-// LPtoDP
-// OffsetViewportOrgEx
-// OffsetWindowOrgEx
-// TransparentBlt
-// to do: eliminate FIXTEXTOUT handling
-// GetDCEx
-
-BOOL SetTextJustification(
- _In_ HDC hdc,
- _In_ int nBreakExtra, <----
- _In_ int nBreakCount
-);
-#endif
\ No newline at end of file
diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp
index dcad491..e3f22bf 100644
--- a/dll/kernel32.cpp
+++ b/dll/kernel32.cpp
@@ -39,6 +39,7 @@ static HookEntry_Type TimeHooks[]={
{"Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep},
{"SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx},
{"SetTimer", (FARPROC)SetTimer, (FARPROC *)&pSetTimer, (FARPROC)extSetTimer},
+ {"QueryPerformanceCounter", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter},
{0, NULL, 0, 0} // terminator
};
@@ -53,6 +54,11 @@ static HookEntry_Type SuppressChildHooks[]={
{0, NULL, 0, 0} // terminator
};
+//static HookEntry_Type SuppressPerfCountersHooks[]={
+// //{"QueryPerformanceFrequency", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)QueryPerformanceFrequency},
+// {0, NULL, 0, 0} // terminator
+//};
+
static char *libname = "kernel32.dll";
void HookKernel32(HMODULE module)
@@ -63,6 +69,7 @@ void HookKernel32(HMODULE module)
if(dxw.dwFlags2 & TIMESTRETCH) HookLibrary(module, TimeHooks, libname);
if(dxw.dwFlags2 & FAKEVERSION) HookLibrary(module, VersionHooks, libname);
if(dxw.dwFlags4 & SUPPRESSCHILD) HookLibrary(module, SuppressChildHooks, libname);
+ //if (1) HookLibrary(module, SuppressPerfCountersHooks, libname);
}
void HookKernel32Init()
@@ -94,6 +101,8 @@ FARPROC Remap_kernel32_ProcAddress(LPCSTR proc, HMODULE hModule)
if(dxw.dwFlags4 & SUPPRESSCHILD)
if (addr=RemapLibrary(proc, hModule, SuppressChildHooks)) return addr;
+ //if (addr=RemapLibrary(proc, hModule, SuppressPerfCountersHooks)) return addr;
+
return NULL;
}
@@ -701,3 +710,22 @@ BOOL WINAPI extCreateProcessA(
OutTraceD("CreateProcess: SUPPRESS ApplicationName=%s CommandLine=\"%s\"\n", lpApplicationName, lpCommandLine);
return TRUE;
}
+
+BOOL WINAPI extQueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)
+{
+ // just proxy, but currently unhooked.....
+ BOOL ret;
+ ret=(*pQueryPerformanceFrequency)(lpFrequency);
+ return ret;
+}
+
+BOOL WINAPI extQueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
+{
+ BOOL ret;
+ LARGE_INTEGER myPerfCount;
+ ret=(*pQueryPerformanceCounter)(&myPerfCount);
+ myPerfCount.HighPart = dxw.StretchCounter(myPerfCount.HighPart);
+ myPerfCount.LowPart = dxw.StretchCounter(myPerfCount.LowPart);
+ *lpPerformanceCount = myPerfCount;
+ return ret;
+}
diff --git a/dll/syslibs.h b/dll/syslibs.h
index 7a71749..92e540a 100644
--- a/dll/syslibs.h
+++ b/dll/syslibs.h
@@ -118,6 +118,8 @@ typedef int (WINAPI *AddFontResourceW_Type)(LPCWSTR);
typedef HANDLE (WINAPI *CreateFile_Type)(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
typedef DWORD (WINAPI *SetFilePointer_Type)(HANDLE, LONG, PLONG, DWORD);
typedef BOOL (WINAPI *CloseHandle_Type)(HANDLE);
+typedef BOOL (WINAPI *QueryPerformanceFrequency_Type)(LARGE_INTEGER *);
+typedef BOOL (WINAPI *QueryPerformanceCounter_Type)(LARGE_INTEGER *);
// ole32.dll:
typedef HRESULT (STDAPICALLTYPE *CoCreateInstance_Type)(REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID FAR*);
@@ -298,6 +300,8 @@ DXWEXTERN SleepEx_Type pSleepEx DXWINITIALIZED;
DXWEXTERN CreateFile_Type pCreateFile DXWINITIALIZED;
DXWEXTERN SetFilePointer_Type pSetFilePointer DXWINITIALIZED;
DXWEXTERN CloseHandle_Type pCloseHandle DXWINITIALIZED;
+DXWEXTERN QueryPerformanceFrequency_Type pQueryPerformanceFrequency DXWINITIALIZED;
+DXWEXTERN QueryPerformanceCounter_Type pQueryPerformanceCounter DXWINITIALIZED;
// ole32.dll:
DXWEXTERN CoCreateInstance_Type pCoCreateInstance DXWINITIALIZED;
@@ -474,6 +478,8 @@ extern HANDLE WINAPI extCreateFile(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,
extern DWORD WINAPI extSetFilePointer(HANDLE, LONG, PLONG, DWORD);
extern BOOL WINAPI extCloseHandle(HANDLE);
extern BOOL WINAPI extCreateProcessA(LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION);
+extern BOOL WINAPI extQueryPerformanceFrequency(LARGE_INTEGER *);
+extern BOOL WINAPI extQueryPerformanceCounter(LARGE_INTEGER *);
// ole32.dll:
extern HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID FAR*);
diff --git a/dll/winmm.cpp b/dll/winmm.cpp
index 90e19e7..989dfe8 100644
--- a/dll/winmm.cpp
+++ b/dll/winmm.cpp
@@ -49,7 +49,7 @@ DWORD WINAPI exttimeGetTime(void)
MMRESULT WINAPI exttimeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
{
MMRESULT res;
- uDelay = uDelay * 8;
+ //uDelay = uDelay * 8;
OutTraceD("timeSetEvent: Delay=%d Resolution=%d Event=%x\n", uDelay, uResolution, fuEvent);
res=(*ptimeSetEvent)(uDelay, uResolution, lpTimeProc, dwUser, fuEvent);
OutTraceD("timeSetEvent: ret=%x\n", res);
diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo
index 6b8a214..d21ab00 100644
Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ
diff --git a/host/dxwndhost.vs2008.vcproj b/host/dxwndhost.vs2008.vcproj
index e74f59a..70fff2c 100644
--- a/host/dxwndhost.vs2008.vcproj
+++ b/host/dxwndhost.vs2008.vcproj
@@ -1,7 +1,7 @@
path, MAX_PATH, InitPath);
if(!TargetMap->path[0]) return FALSE;
@@ -556,6 +557,14 @@ static int LoadConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitPa
TargetMap->MaxFPS = GetPrivateProfileInt("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "initts%i", i);
TargetMap->InitTS = GetPrivateProfileInt("target", key, 0, InitPath);
+
+ if (!gbDebug){
+ // clear debug flags
+ TargetMap->flags &= ~(0);
+ TargetMap->flags2 &= ~(FULLRECTBLT);
+ TargetMap->flags3 &= ~(YUV2RGB|RGB2YUV|SURFACEWARN|ANALYTICMODE|NODDRAWBLT|NODDRAWFLIP|NOGDIBLT);
+ TargetMap->flags4 &= ~(0);
+ }
return TRUE;
}