diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ed50b00..34c8dce 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,7 +4,6 @@ on:
push:
branches:
- 'master'
- - 'develop'
- 'github-action'
jobs:
@@ -152,4 +151,4 @@ jobs:
tag_name: experimental
files: cnc-ddraw-experimental/*
fail_on_unmatched_files: true
- draft: true
\ No newline at end of file
+ draft: true
diff --git a/Makefile b/Makefile
index 52c5804..c2f547b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,22 +1,37 @@
-include config.mk
-TARGET = ddraw.dll
-LDFLAGS = -Wl,--enable-stdcall-fixup -s -static -shared
-CFLAGS = -Iinc -O2 -march=i486 -Wall
-LIBS = -lgdi32 -lwinmm -ldbghelp -lole32
+TARGET ?= ddraw.dll
-COMMIT := $(shell git describe --match=NeVeRmAtCh --always --dirty || echo "UNKNOWN")
-BRANCH := $(shell git rev-parse --abbrev-ref HEAD || echo "UNKNOWN")
-ECOMMIT := $(shell echo "#define GIT_COMMIT" \"$(COMMIT)\" > inc/git.h)
-EBRANCH := $(shell echo "#define GIT_BRANCH" \"$(BRANCH)\" >> inc/git.h)
+LDFLAGS ?= -Wl,--enable-stdcall-fixup -s -static -shared
+CFLAGS ?= -Iinc -O2 -Wall -std=c99
+LIBS = -lgdi32 -lwinmm -lole32 -lmsimg32 -lavifil32 -luuid
-CC = i686-w64-mingw32-gcc
-WINDRES ?= i686-w64-mingw32-windres
+COMMIT := $(shell git describe --match=NeVeRmAtCh --always --dirty || echo UNKNOWN)
+BRANCH := $(shell git rev-parse --abbrev-ref HEAD || echo UNKNOWN)
+
+HASH := \#
+ECHOTEST := $(shell echo \"\")
+ifeq ($(ECHOTEST),\"\")
+ # Windows
+ ECOMMIT := $(shell echo $(HASH)define GIT_COMMIT "$(COMMIT)" > inc/git.h)
+ EBRANCH := $(shell echo $(HASH)define GIT_BRANCH "$(BRANCH)" >> inc/git.h)
+else
+ # Either *nix or Windows with BusyBox (e.g. w64devkit)
+ ECOMMIT := $(shell echo "$(HASH)define GIT_COMMIT" \"$(COMMIT)\" > inc/git.h)
+ EBRANCH := $(shell echo "$(HASH)define GIT_BRANCH" \"$(BRANCH)\" >> inc/git.h)
+endif
ifdef DEBUG
CFLAGS += -D _DEBUG -D _DEBUG_X
endif
+ifdef _WIN32_WINNT
+ CFLAGS += -march=i486 -D _WIN32_WINNT=$(_WIN32_WINNT)
+endif
+
+CC = i686-w64-mingw32-gcc
+WINDRES ?= i686-w64-mingw32-windres
+
SRCS := $(wildcard src/*.c) $(wildcard src/*/*.c) res.rc
OBJS := $(addsuffix .o, $(basename $(SRCS)))
@@ -24,10 +39,10 @@ OBJS := $(addsuffix .o, $(basename $(SRCS)))
all: $(TARGET)
%.o: %.rc
- $(WINDRES) -J rc $< $@
+ $(WINDRES) -J rc $< $@ || windres -J rc $< $@
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ exports.def $(LIBS)
clean:
- $(RM) $(TARGET) $(OBJS)
+ $(RM) $(TARGET) $(OBJS) || del $(TARGET) $(subst /,\\,$(OBJS))
diff --git a/README.md b/README.md
index cc6f69c..7485601 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
# cnc-ddraw
-cnc-ddraw can fix compatibility issues in older 2D games, such as black screen, bad performance, crashes or defective Alt+Tab.
+cnc-ddraw can fix compatibility issues in older 2D games, such as black screen, bad performance, crashes or defective Alt+Tab. It does also add new features such as borderless mode, windowed mode and upscaling via shaders.
### Features
- - Supports Windows 2000, XP, Vista, 7, 8, 10, 11, Wine (Linux/macOS/Android) and Virtual Machines
+ - Supports Windows ME, 2000, XP, Vista, 7, 8, 10, 11, Wine (Linux/macOS/Android) and Virtual Machines
- GDI / OpenGL / Direct3D 9 renderer (With automatic renderer selection)
- Upscaling via glsl shaders - https://imgur.com/a/kxsM1oY | https://imgur.com/a/wjrhpFV
- Windowed Mode / Fullscreen Exclusive Mode / Borderless Mode
@@ -24,31 +24,16 @@ cnc-ddraw can fix compatibility issues in older 2D games, such as black screen,
1. Download [cnc-ddraw.zip](https://github.com/FunkyFr3sh/cnc-ddraw/releases/latest/download/cnc-ddraw.zip) and extract it into your game folder
2. Start the game
-Wine (Linux/macOS/Android) only: override `ddraw` in [winecfg](https://wiki.winehq.org/Winecfg#Libraries) manually or run cnc-ddraw config.exe once.
+Wine (Linux/macOS/Android) only: override `ddraw` in [winecfg](https://wiki.winehq.org/Winecfg#Libraries) manually or run `cnc-ddraw config.exe` once.
-If you use cnc-ddraw with a game that got its own windowed mode built in then **make sure you disable the games own windowed mode** first. You can enable windowed mode via cnc-ddraw config.exe instead.
+**Important**
-
-
-**If the game starts but it doesn't work perfectly** then open the config program and check the **Compatibility settings**.
-
-
-
-**cnc-ddraw does not support Direct3D/Glide**, it will only work with games that use a **DirectDraw (Software)** renderer. Usually you can tell by the look of the game if it's a 3D game or not, but you can also let cnc-ddraw generate a debug log and search for "IDirect3D" - Link: https://github.com/FunkyFr3sh/cnc-ddraw/issues/44
-
-
-
-Some games may require additional steps before they can be used with cnc-ddraw, please check the [wiki](https://github.com/FunkyFr3sh/cnc-ddraw/wiki) for more details.
-
-
-
-**If the game doesn't start at all or it's crashing**, [then please generate a debug log file and upload it.](https://github.com/FunkyFr3sh/cnc-ddraw/issues/44)
-
-
-
-Need help and don't have a github account? Ask your questions on [Discord](https://discord.gg/afWXJNDDF5) (No registration required)
+- **The game must be set to fullscreen**. To enable windowed mode, use `cnc-ddraw config.exe` instead
+- **cnc-ddraw does not support Direct3D games**, the game must have a **DirectDraw (Software)** renderer
+- **If the game doesn't start at all or it's crashing**, [then please generate a debug log file and upload it.](https://github.com/FunkyFr3sh/cnc-ddraw/issues/44)
+- Some games require additional steps before they can be used with cnc-ddraw, check the [wiki](https://github.com/FunkyFr3sh/cnc-ddraw/wiki) for details
@@ -61,6 +46,9 @@ Need help and don't have a github account? Ask your questions on [Discord](https
### Supported Games
+- 101: The Airborne Invasion of Normandy
+- 7th Legion
+- Abomination - The Nemesis Project
- Addiction Pinball
- Age of Empires
- Age of Empires II
@@ -69,14 +57,24 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Age of Wonders
- Age of Wonders 2
- Age of Wonders: Shadow Magic
+- Agharta the Hollow Earth
+- Airline 69: Return to Casablanca
- Airline Tycoon Deluxe
- Alien Nations
- American Conquest (Steam+GOG)
- American Girls Dress Designer
- Amerzone
+- Ancient Conquest
+- Ancient Evil
- Anno 1602: Creation of a New World
+- Another War
- Anstoss 3
- Arcanum: Of Steamworks and Magick Obscura
+- Arcatera the Dark Brotherhood
+- Army Men 2
+- Army Men: Air Tactics
+- Army Men: Toys in Space
+- Army Men: World War / Army Men: Operation Meltdown
- Arthur's Pet Chase
- Arthur's Sand Castle Contest
- Arthur's Wilderness Rescue
@@ -88,24 +86,31 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Baldr Force EXE
- Baldur's Gate
- Baldur's Gate 2
-- Barbie(tm) Beach Vacation(tm)
+- Balls of Steel v1.2
- Barbie(R) Photo Designer
+- Barbie(tm) Beach Vacation(tm)
- Batman: Justice Unbalanced
- Batman: Toxic Chill
+- Bejeweled 2 Deluxe
+- Birthright: The Gorgons Alliance
- Blade & Sword
- Blood II - The Chosen
- Blue's 123 Time Activities
- Blue's Treasure Hunt
+- Broken Sword
+- Broken Sword 2: The Smoking Mirror
- Caesar III (Sierra - 1998)
-- Callus 95 - CPS-1 (Capcom Play System 1) emulator
- Call To Power 2
+- Callus 95 - CPS-1 (Capcom Play System 1) emulator
- Capitalism II
- Capitalism Lab
- Captain Claw
- Carmageddon
- Carmageddon 2
- Casino Empire (AKA Hoyle Casino)
+- Championship Manager 99-00
- Chaos Gate
+- Clans
- Close Combat 2: A Bridge Too Far
- Close Combat 3: The Russian Front
- Close Combat 4: The Battle of the Bulge
@@ -129,25 +134,41 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Commandos
- Commandos - Beyond The Call Of Duty
- Commandos 2
+- Commando 2004 (only with /ddraw command line parameter)
- Constructor
- Corsairs Gold
- Cossacks (Steam+GOG)
- Cultures - The Discovery of Vinland
- Cultures 2
+- Cyber Gladiators (needs CyberGladiators_Patch_Win_EN_WinXP.zip)
- Cyberchase Carnival Chaos
- Cyberchase Castleblanca Quest
+- Cydonia Mars - The First Manned Mission
+- Cloud Kingdom 3 (only with /ddraw command line parameter)
+- Dark Earth
- Dark Reign: The Future of War
+- Dark Secret of Africa
+- Day Of The Tentacle
+- Daytona
- Daytona USA (Sega - 1996)
- Deadlock 2
+- Deadly Tide
+- Delta Force
- Desperados: Wanted Dead or Alive
- Diablo
- Diablo 2
- Diablo 2: Lord of Destruction
- Diablo: Hellfire
+- Die by the Sword
- Disciples
- Disciples 2 - Rise of the Elves
+- Discoworld Noir
- Divine Divinity
+- Dominion - Storm Over Gift 3
+- Doom 95
+- Dracula
- Dragon Throne: Battle of Red Cliffs
+- Dreams to Realty
- DuelSavior
- DuelSavior: Justice
- Dune 2000
@@ -158,13 +179,19 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Emperor: Rise of the Middle Kingdom
- Enemy Infestation
- Escape Velocity Nova
+- Excalibur 2555AD
+- F-16 Agressor
- F-16 Multirole Fighter
- F-22 Raptor
+- Fable
- Fairy Tale About Father Frost, Ivan and Nastya
+- Falcon 4.0 (Microprose version)
- Fallout
- Fallout 2
+- Fallout Tactics: Brotherhood of Steel
- Final fantasy VII
- Final fantasy VIII
+- Final Liberation: Warhammer Epic 40000 (GOG)
- Freddi Fish
- Freddi Fish 4
- Freddi Fish's One-Stop Fun Shop
@@ -173,24 +200,41 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Freddi Fish: The Case of the Haunted Schoolhouse
- Freddi Fish: The Case of the Hogfish Rustlers of Briny Gulch
- Freddi Water Worries
+- Full Throttle
- Future Cop L.A.P.D
- G-Police
+- Gateway (Remake)
+- Geneforge
+- Gilbert Goodmate And The Mushroom Of Phungoria
+- Gorasul: The Legacy of the Dragon
- Grand Theft Auto
- Grand Theft Auto: London 1961
- Grand Theft Auto: London 1969
+- Gromada Revenge
- Gruntz
-- Gorasul: The Legacy of the Dragon
- Hamtaro: Wake Up Snoozer!
+- Handkerchief
- Hard Truck: Road to Victory
+- Heart of Darkness
- Hearts of Iron 2
+- Heroes Chronicles: Clash of the Dragons
+- Heroes Chronicles: Conquest of the Underworld
+- Heroes Chronicles: Masters of the Elements
+- Heroes Chronicles: Warlords of the Wasteland
+- Heroes of Might and Magic
- Heroes of Might and Magic II
- Heroes of Might and Magic III
- Heroes of Might and Magic IV
+- Hexen 95
- Hooligans: Storm over Europe
- Hugo Gold
- Hugo Wild River
- Icewind Dale
- Icewind Dale 2
+- Ignition
+- Imperialism 2: The Age of Exploration
+- Indiana Jones and the Fate of Atlantis
+- Indiana Jones and the Last Crusade
- Infantry Online
- Interstate 76
- Invictus: In the Shadow of Olympus
@@ -198,6 +242,8 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Jagged Alliance 2: Unfinished Business
- Jagged Alliance 2: Wildfire
- Jazz Jackrabbit 2
+- Jeff Wayne's The War of the Worlds
+- Karma Immortal Wrath
- Killing Time
- Kings Quest 8: Mask of Eternity
- KKND Xtreme
@@ -207,7 +253,10 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Kohan: Immortal Sovereigns
- Konung
- Konung 2
+- Lands of Lore 2 Guardian of Destiny (Software mode only)
- Lapis (lapis.mgame.com)
+- Last Bronx
+- Links Extreme
- Lionheart - Legacy of the Crusader
- Little Bear Kindergarten Thinking Adventures
- Little Bear Preschool Thinking Adventures
@@ -215,18 +264,27 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Little Bear Toddler Discovery Adventures
- Locomotion
- Lode Runner 2
+- Lost Vikings 2
+- M.A.X. 2 Mechanized Assault & Exploration
- Madeline 1st Grade Math
- Madeline 2nd Grade Math
+- Mageslayer
- Majesty Gold
- Majesty Gold HD
-- M.A.X. 2 Mechanized Assault & Exploration
+- Mario Sorb 3
+- Meat Puppet
- Mech Warrior 3
- Megaman X4
- Metal Gear Solid
+- Metal Knight
- Mob Rule (AKA Constructor: Street Wars / Street Wars: Constructor Underworld)
- Moorhuhn
- Moorhuhn 2
+- Moorhuhn Adventure: Fluch des Goldes
+- Moorhuhn Adventure: Schatz des Pharao and Fluch des Goldes)
- Moorhuhn Winter Editon
+- MiG-29 Fulcrum
+- Mission Deliver Kindness
- Moto Racer
- Moto Racer 2
- Nancy Drew: Danger on Deception Island
@@ -236,27 +294,37 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Nancy Drew: Stay Tuned For Danger
- Nancy Drew: The Secret of Shadow Ranch
- Nancy Drew: Treasure in the Royal Tower
+- NBA Action '98
+- NBA Full Court Press
- Need For Speed III: Hot Pursuit
- Need For Speed: High Stakes
+- Neo Sonic Universe
- New Robinson
- NexusTk
+- Nightmare Creatures
+- Ninja Jonder Deluxe
- Nox (Westwood - 2000)
- Oddworld: Abe's Exoddus
- Oddworld: Abe's Oddysee
+- Original War
- Outlaws
- Outlive
+- Outwars (software mode)
- Pacific General
- Pajama Sam
- Pajama Sam 3
+- Pajama Sam 3: You Are What You Eat From Your Head To Your Feet
- Pajama Sam's Games to Play on Any Day
- Pajama Sam's One-Stop Fun Shop
- Pajama Sam(r): Life is Rough When You Lose Your Stuff(tm)
- Pajama Sam: No Need to Hide When It's Dark Outside
-- Pajama Sam 3: You Are What You Eat From Your Head To Your Feet
+- Pandora's Box Puzzle Game
+- Panzer Dragoon
- Patrician 3
- Pax Imperia
- Pharaoh (Sierra - 1999)
- Pizza Syndicate (AKA Fast Food Tycoon)
+- Platypus
- Populous: The Beginning
- Poseidon: Master of Atlantis
- Pro Pinball - Big Race USA
@@ -269,6 +337,7 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Putt-Putt: Pep's Birthday Surprise
- Putt-Putt: Travels Through Time
- Quest for Glory 5
+- Rage of Mages
- Rage of Mages 2
- Railroad Tycoon II
- Reader Rabbit 1st Grade
@@ -286,14 +355,19 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Reader Rabbit's(R) Math Ages 6 - 9 (2002)
- Real War
- Red Baron 3D
-- Reksio and the Pirate Treasure (Reksio i Skarb Piratów)
-- Reksio and the UFO (Reksio i Ufo)
-- Reksio and the Wizards (Reksio i Czarodzieje)
-- Reksio and the Time Machine (Reksio i Wehikuł Czasu)
- Reksio and Captain Nemo (Reksio i Kapitan Nemo)
- Reksio and Kretes in Action (Reksio i Kretes w Akcji!)
+- Reksio and the Pirate Treasure (Reksio i Skarb Piratów)
+- Reksio and the Time Machine (Reksio i Wehikuł Czasu)
+- Reksio and the UFO (Reksio i Ufo)
+- Reksio and the Wizards (Reksio i Czarodzieje)
+- Rent-A-Hero
+- Resurrection - The Return of the Black Dragon (software mode)
+- Return to Krondor
+- Rising Lands (patched)
- Road Rash
- Robin Hood - The Legend of Sherwood
+- Roland Garros 98 (software mode)
- RollerCoaster Tycoon
- Sanitarium
- Scooby-Doo(TM), Case File #2 The Scary Stone Dragon
@@ -303,23 +377,39 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Sega Touring Car
- Septerra Core
- Settlers 3
+- Seven Kingdoms II
- Shadow Flare
- Shadow Watch
- Shogo - Mobile Armor Division
+- Silver (needs "SilverUK GeForce2 And Radeon Patch")
- Sim City 3000
- Sim Copter
+- SimTunes
- Sim Theme Park (aka Theme Park World)
- SimCoaster / Theme Park Inc
+- Simon the Sorcerer 1/2 (windows 95 version)
- Sonic 3D Blast
+- Soldiers At War
- Space Rangers
+- Spec Ops - Ranger Assault (software mode)
- SpongeBob SquarePants: Typing
- SPY Fox : Some Assembly Required
- SPY Fox in Dry Cereal
- SPY Fox: Hold the Mustard
- SPY Fox: Operation Ozone
+- Squad Leader
+- Star Trek Away Team
+- Star Trek Generations
+- Star Wars Anakin's Speedway
+- Star Wars Early Learning Activity Center
+- Star Wars Episode I: The Gungan Frontier
- Star Wars Jedi Knight: Dark Forces II
+- Star Wars Rebellion
+- Star Wars Yoda's Challenge
+- Star Wars: Droid Works
- Star Wars: Galactic Battlegrounds
- Star Wars: Galactic Battlegrounds: Clone Campaigns
+- Star Wars: Pit Droids
- StarCraft
- StarCraft: Broodwars
- StarFlyers Alien Space Chase
@@ -332,41 +422,68 @@ Need help and don't have a github account? Ask your questions on [Discord](https
- Stronghold Crusader HD
- Stronghold HD
- Sudden Strike 2
+- Superbike 2000
+- Swarog
+- The Jungle Book Groove Party
+- The Curse Of Monkey Island
+- The Dig
+- The Last Express
- The Missing on Lost Island
+- The Neverhood
+- The Next Worlds
- The Powerpuff Girls - Princess Snorebucks
- The Powerpuff Girls(TM) Mojo Jojo's Clone Zone
+- The Rocky Interactive Horror Show
+- The Sex Files
- The X-Files DVD
- Theme Hospital
- Three Kingdoms: Fate of the Dragon
- Throne of Darkness
+- Thunder Brigade
+- TianLong BaBu
+- Tone Rebellion
- Total Annihilation
- Total Annihilation (Unofficial Beta Patch v3.9.02)
- Total Annihilation: Kingdoms
+- Toy Story
+- Tridonis
- Twisted Metal
- Twisted Metal 2
- Tzar: The Burden of the Crown
+- Unreal
- Uprising 2: Lead and Destroy
- Uprising: Join or Die
- Vermeer
+- Virtua Cop
+- Virtua Cop 2
+- Virtua Fighter 2
- Virtua Fighter PC
+- Virtual Springfield
+- Virtual On: Cyber Troopers
+- WarGames
- War Wind
- War Wind II - Human Onslaught
-- WarCraft 2000: Nuclear Epidemic
- Warcraft 2
+- WarCraft 2000: Nuclear Epidemic
- Warlords 3: Darklords Rising
- Warlords Battlecry
- Warlords Battlecry 2
- Warlords Battlecry 3
+- Weird War
+- Wheel Of Fortune
+- Wing Commander - The Kilrathi Saga
- Wizardry 8
- Wizards and Warriors
- Worms 2
- Worms Armageddon
+- Z & Z Expansion Kit
- Zeus: Master of Olympus
- Zoombinis Island Odyssey
- Zoombinis Logical Journey
- Zoombinis Mountain Rescue
+- Zork Nemesis
- Zuma Deluxe
- - ...
+- ...
There are a lot more games supported but I don't usually update the list, just give it a try and if it doesn't work then check the [wiki](https://github.com/FunkyFr3sh/cnc-ddraw/wiki) and the instructions above.
diff --git a/action.yml b/action.yml
index ca39872..f2a0b38 100644
--- a/action.yml
+++ b/action.yml
@@ -11,7 +11,7 @@
# uses: phobos2077/sfall@develop
# with:
# release-xp: true
-#
+#
# - name: Copy sfall to mod directory
# run: copy "${{ steps.sfall.outputs.release-xp }}" "my/mod/directory/ddraw.dll"
#
diff --git a/build.cmd b/build.cmd
index 34bb56c..801abe4 100644
--- a/build.cmd
+++ b/build.cmd
@@ -10,6 +10,6 @@ set GIT6=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\
set PATH=C:\w64devkit\bin;%GIT1%;%GIT2%;%GIT3%;%GIT4%;%GIT5%;%GIT6%;%PATH%
make clean
-make
+make _WIN32_WINNT=0x0400
pause
diff --git a/build_debug.cmd b/build_debug.cmd
index 755ec1f..4e43145 100644
--- a/build_debug.cmd
+++ b/build_debug.cmd
@@ -10,6 +10,6 @@ set GIT6=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\
set PATH=C:\w64devkit\bin;%GIT1%;%GIT2%;%GIT3%;%GIT4%;%GIT5%;%GIT6%;%PATH%
make clean
-make DEBUG=1
+make DEBUG=1 _WIN32_WINNT=0x0400
pause
diff --git a/cnc-ddraw.vcxproj b/cnc-ddraw.vcxproj
index 992cb3e..3f5d12d 100644
--- a/cnc-ddraw.vcxproj
+++ b/cnc-ddraw.vcxproj
@@ -27,6 +27,7 @@
+
@@ -77,8 +78,10 @@
+
+
@@ -89,6 +92,7 @@
+
@@ -222,7 +226,7 @@
Windows
- dbghelp.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -264,7 +268,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -306,7 +310,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -348,7 +352,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- dbghelp.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -390,7 +394,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- dbghelp.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
diff --git a/cnc-ddraw.vcxproj.filters b/cnc-ddraw.vcxproj.filters
index e1e9a15..b15230e 100644
--- a/cnc-ddraw.vcxproj.filters
+++ b/cnc-ddraw.vcxproj.filters
@@ -168,6 +168,9 @@
Source Files
+
+ Source Files
+
@@ -293,6 +296,15 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp
index 4a0f97d..7d40a88 100644
--- a/config/ConfigFormUnit.cpp
+++ b/config/ConfigFormUnit.cpp
@@ -9,7 +9,6 @@
#include
#include
#include
-#include
#include "ConfigFormUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
@@ -132,31 +131,31 @@ void TConfigForm::ApplyTranslation(TIniFile *ini)
ConfigForm->Caption = L"cnc-ddraw 配置";
DisplayBtn->Caption = L"显示设置";
AdvancedBtn->Caption = L"高级设置";
- HotkeyBtn->Caption = L"热键设置";
+ HotkeyBtn->Caption = L"快捷键设置";
CompatibilityBtn->Caption = L"兼容性设置";
RestoreDefaultsBtn->Caption = L"恢复默认设置";
PresentationLbl->Caption = L"显示方式";
- MaintasLbl->Caption = L"保持纵横比";
- VsyncLbl->Caption = L"打开垂直同步";
+ MaintasLbl->Caption = L"保持宽高比";
+ VsyncLbl->Caption = L"启用垂直同步";
AdjmouseLbl->Caption = L"调整鼠标灵敏度";
- DevmodeLbl->Caption = L"锁定光标到窗口/屏幕";
+ DevmodeLbl->Caption = L"将光标锁定到窗口/屏幕";
RendererLbl->Caption = L"渲染器";
BorderLbl->Caption = L"在窗口模式下显示窗口边框";
SavesettingsLbl->Caption = L"记住窗口位置和大小";
- ShaderLbl->Caption = L"OpenGL着色器";
- MaxfpsLbl->Caption = L"限制帧率";
- BoxingLbl->Caption = L"打开窗盒显示/整数缩放";
+ ShaderLbl->Caption = L"OpenGL 着色器";
+ MaxfpsLbl->Caption = L"限制帧速率";
+ BoxingLbl->Caption = L"启用整数缩放";
ToggleWindowedLbl->Caption = L"切换窗口模式";
MaximizeWindowLbl->Caption = L"最大化窗口";
UnlockCursor1Lbl->Caption = L"解锁光标 1";
UnlockCursor2Lbl->Caption = L"解锁光标 2";
- ScreenshotLbl->Caption = L"截屏";
- MaxgameticksLbl->Caption = L"限制游戏速率";
+ ScreenshotLbl->Caption = L"截图";
+ MaxgameticksLbl->Caption = L"限制游戏速度";
NoactivateappLbl->Caption = L"修复损坏的Alt+Tab功能";
- ResolutionsLbl->Caption = L"解锁其他屏幕分辨率";
- MinfpsLbl->Caption = L"强制高FPS / 修复使用Freesync/G-Sync的卡顿问题";
- SinglecpuLbl->Caption = L"修复性能不佳和声音问题";
- NonexclusiveLbl->Caption = L"修复不显示的视频/UI元素";
+ ResolutionsLbl->Caption = L"解锁额外的屏幕分辨率";
+ MinfpsLbl->Caption = L"强制高 FPS / 修复 Freesync/G-Sync 卡顿";
+ SinglecpuLbl->Caption = L"修复低性能和声音问题";
+ NonexclusiveLbl->Caption = L"修复不显示的视频/UI 元素";
RendererCbx->Items->Clear();
RendererCbx->AddItem(L"自动", NULL);
@@ -173,25 +172,26 @@ void TConfigForm::ApplyTranslation(TIniFile *ini)
MaxgameticksCbx->Items->Clear();
MaxgameticksCbx->AddItem(L"无限制", NULL);
MaxgameticksCbx->AddItem(L"与显示器刷新率同步", NULL);
- MaxgameticksCbx->AddItem(L"模拟60hz刷新率显示器", NULL);
- MaxgameticksCbx->AddItem(L"1000tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"500tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"250tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"125tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"60tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"30tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"25tick每秒", NULL);
- MaxgameticksCbx->AddItem(L"15tick每秒", NULL);
+ MaxgameticksCbx->AddItem(L"模拟 60hz 刷新率显示器", NULL);
+ MaxgameticksCbx->AddItem(L"1000 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"500 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"250 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"125 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"60 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"30 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"25 次每秒", NULL);
+ MaxgameticksCbx->AddItem(L"15 次每秒", NULL);
System::UnicodeString shaderHint =
- L"某些着色器仅在打开放大功能时生效。\n\n";
+ L"一些着色器只有在启用放大时才有效。\n\n";
System::UnicodeString upscaleHint =
- L"必须打开放大功能才能使此设置生效。\n\n";
+ L"必须启用放大才能使此设置生效。\n\n";
System::UnicodeString enableUpscaleHint =
- L"要打开放大功能,请将显示方式设置为‘无边框’或‘拉伸至全屏’。\n"
- "对于‘窗口化’显示方式,您必须调整窗口大小或最大化窗口。";
+ L"要启用放大,请将显示方式设置为“无边框” \n"
+ "或“拉伸至全屏”。对于“窗口化”, \n"
+ "你必须调整窗口大小或将窗口开启最大化。";
ShaderLbl->Hint = shaderHint + enableUpscaleHint;
ShaderD3DCbx->Hint = shaderHint + enableUpscaleHint;
@@ -773,6 +773,87 @@ void TConfigForm::ApplyTranslation(TIniFile *ini)
BoxingLbl->Hint = upscaleHint + enableUpscaleHint;
BoxingChk->Hint = upscaleHint + enableUpscaleHint;
}
+ else if (lang == "polish" || (lang == "auto" && priID == LANG_POLISH)) {
+ LanguageImg->Visible = true;
+
+ /* -polish - made by WaRzillA @ github */
+
+ ConfigForm->Caption = L"Konfiguracja cnc-ddraw";
+ DisplayBtn->Caption = L"Ustawienia wyświetlania";
+ AdvancedBtn->Caption = L"Ustawienia zaawansowane";
+ HotkeyBtn->Caption = L"Skróty klawiaturowe";
+ CompatibilityBtn->Caption = L"Ustawienia kompatybilności";
+ RestoreDefaultsBtn->Caption = L"Przywróć ustawienia domyślne";
+ PresentationLbl->Caption = L"Tryb wyświetlania";
+ MaintasLbl->Caption = L"Zachowaj proporcje obrazu";
+ VsyncLbl->Caption = L"Włącz VSync";
+ AdjmouseLbl->Caption = L"Dostosuj czułość myszy";
+ DevmodeLbl->Caption = L"Zablokuj kursor w oknie/na ekranie";
+ RendererLbl->Caption = L"Silnik renderowania";
+ BorderLbl->Caption = L"Pokaż ramki okna w trybie okienkowym";
+ SavesettingsLbl->Caption = L"Zapamiętaj pozycję i rozmiar okna";
+ ShaderLbl->Caption = L"Shader OpenGL";
+ MaxfpsLbl->Caption = L"Ogranicz liczbę klatek na sekundę";
+ BoxingLbl->Caption = L"Włącz windowboxing / integer scaling ";
+ ToggleWindowedLbl->Caption = L"Przełącz na tryb okienkowy";
+ MaximizeWindowLbl->Caption = L"Maksymalizuj okno";
+ UnlockCursor1Lbl->Caption = L"Odblokuj kursor 1";
+ UnlockCursor2Lbl->Caption = L"Odblokuj kursor 2";
+ ScreenshotLbl->Caption = L"Zrzut ekranu";
+ MaxgameticksLbl->Caption = L"Ogranicz prędkość gry";
+ NoactivateappLbl->Caption = L"Napraw nieprawidłowe działanie Alt+Tab";
+ ResolutionsLbl->Caption = L"Odblokuj dodatkowe rozdzielczości ekranu";
+ MinfpsLbl->Caption = L"Wymuś wysokie FPS / Napraw zacinanie Freesync/G-Sync";
+ SinglecpuLbl->Caption = L"Napraw problemy z wydajnością i dźwiękiem";
+ NonexclusiveLbl->Caption = L"Napraw niewidoczne filmy / elementy interfejsu";
+
+ RendererCbx->Items->Clear();
+ RendererCbx->AddItem(L"Automatyczny", NULL);
+ RendererCbx->AddItem(L"Direct3D 9", NULL);
+ RendererCbx->AddItem(L"OpenGL", NULL);
+ RendererCbx->AddItem(L"GDI", NULL);
+
+ PresentationCbx->Items->Clear();
+ PresentationCbx->AddItem(L"Pełny ekran", NULL);
+ PresentationCbx->AddItem(L"Pełny ekran z upscalingiem", NULL);
+ PresentationCbx->AddItem(L"Tryb bezramkowy", NULL);
+ PresentationCbx->AddItem(L"Tryb okienkowy", NULL);
+
+ MaxgameticksCbx->Items->Clear();
+ MaxgameticksCbx->AddItem(L"Bez limitu", NULL);
+ MaxgameticksCbx->AddItem(L"Synchronizacja z odświeżaniem monitora", NULL);
+ MaxgameticksCbx->AddItem(L"Symulacja monitora 60 Hz", NULL);
+ MaxgameticksCbx->AddItem(L"1000 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"500 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"250 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"125 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"60 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"30 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"25 tików na sekundę", NULL);
+ MaxgameticksCbx->AddItem(L"15 tików na sekundę", NULL);
+
+ System::UnicodeString shaderHint =
+ L"Niektóre shadery działają tylko wtedy, gdy włączone jest skalowanie. \n\n";
+
+ System::UnicodeString upscaleHint =
+ L"Skalowanie musi być włączone, aby ta opcja działała. \n\n";
+
+ System::UnicodeString enableUpscaleHint =
+ L"Aby włączyć skalowanie, ustaw tryb wyświetlania na 'Tryb bezramkowy' \n"
+ "lub 'Pełny ekran z upscalingiem'. Dla 'Tryb okienkowy' \n"
+ "musisz zmienić rozmiar lub zmaksymalizować okno.";
+
+ ShaderLbl->Hint = shaderHint + enableUpscaleHint;
+ ShaderD3DCbx->Hint = shaderHint + enableUpscaleHint;
+ ShaderCbx->Hint = shaderHint + enableUpscaleHint;
+
+ MaintasLbl->Hint = upscaleHint + enableUpscaleHint;
+ MaintasChk->Hint = upscaleHint + enableUpscaleHint;
+ AdjmouseLbl->Hint = upscaleHint + enableUpscaleHint;
+ AdjmouseChk->Hint = upscaleHint + enableUpscaleHint;
+ BoxingLbl->Hint = upscaleHint + enableUpscaleHint;
+ BoxingChk->Hint = upscaleHint + enableUpscaleHint;
+ }
else {
IsEnglish = true;
@@ -825,6 +906,12 @@ void TConfigForm::ApplyTranslation(TIniFile *ini)
LanguageImg->Picture->Graphic = png;
LanguageImg->Visible = true;
}
+ else if (priID == LANG_POLISH) {
+ TPngImage *png = new TPngImage();
+ png->LoadFromResourceName((int)HInstance, "PngImage_PL");
+ LanguageImg->Picture->Graphic = png;
+ LanguageImg->Visible = true;
+ }
} catch (...) {
}
@@ -1187,7 +1274,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
MinfpsChk->State = Minfps != 0 ? tssOn : tssOff;
SinglecpuChk->State = GetBool(ini, "singlecpu", true) ? tssOff : tssOn;
- NonexclusiveChk->State = GetBool(ini, "nonexclusive", false) ? tssOn : tssOff;
+ NonexclusiveChk->State = GetBool(ini, "nonexclusive", true) ? tssOn : tssOff;
CompatibilityBtn->Visible = !GetBool(ini, "hide_compat_tab", false);
@@ -1198,11 +1285,6 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
delete ini;
- VsyncChk->Enabled = VsyncAllowed();
- if (!VsyncChk->Enabled) {
- VsyncChk->State = tssOff;
- }
-
Initialized = true;
}
@@ -1624,31 +1706,8 @@ bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValu
return s == "true" || s == "yes" || s == "1";
}
-bool TConfigForm::VsyncAllowed()
-{
- if (GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) {
- return true;
- }
-
- if (!IsWindows8OrGreater()) {
- return true;
- }
-
- if (NonexclusiveChk->State == tssOff &&
- (PresentationCbx->ItemIndex == 0 || PresentationCbx->ItemIndex == 1)) {
- return true;
- }
-
- return false;
-}
-
void __fastcall TConfigForm::PresentationCbxChange(TObject *Sender)
{
- VsyncChk->Enabled = VsyncAllowed();
- if (!VsyncChk->Enabled) {
- VsyncChk->State = tssOff;
- }
-
SaveSettings();
}
@@ -1757,11 +1816,6 @@ void __fastcall TConfigForm::SinglecpuChkClick(TObject *Sender)
void __fastcall TConfigForm::NonexclusiveChkClick(TObject *Sender)
{
- VsyncChk->Enabled = VsyncAllowed();
- if (!VsyncChk->Enabled) {
- VsyncChk->State = tssOff;
- }
-
SaveSettings();
}
diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm
index a34dc9f..4f108df 100644
--- a/config/ConfigFormUnit.dfm
+++ b/config/ConfigFormUnit.dfm
@@ -2677,7 +2677,7 @@ object ConfigForm: TConfigForm
61C0650530766087F0B9DE67A1EF3B173173597F3B695CC608E0B202F8FC22D7
BBBF4CD8CBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCB
B88CB18EFF1FA2974C1C31AF16A40000000049454E44AE426082}
- Position = poDesktopCenter
+ Position = poScreenCenter
OnActivate = FormActivate
OnCreate = FormCreate
DesignSize = (
diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h
index 8a46bf8..8a8a14c 100644
--- a/config/ConfigFormUnit.h
+++ b/config/ConfigFormUnit.h
@@ -118,7 +118,6 @@ private: // Benutzer-Deklarationen
virtual void __fastcall CreateParams(TCreateParams & Params);
void SaveSettings();
bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue);
- bool VsyncAllowed();
void ApplyTranslation(TIniFile *ini);
System::UnicodeString GetKeyText(WORD key);
WORD GetKeyCode(System::UnicodeString text);
diff --git a/config/Resources/pl.png b/config/Resources/pl.png
new file mode 100644
index 0000000..d413d01
Binary files /dev/null and b/config/Resources/pl.png differ
diff --git a/config/cnc-ddraw config.cbproj b/config/cnc-ddraw config.cbproj
index b2de346..7792b8b 100644
--- a/config/cnc-ddraw config.cbproj
+++ b/config/cnc-ddraw config.cbproj
@@ -227,6 +227,10 @@
RCDATA
PngImage_IT
+
+ RCDATA
+ PngImage_PL
+
RCDATA
PngImage_RU
@@ -364,7 +368,7 @@
- cnc-ddraw_config.exe
+ cnc-ddraw config.exe
true
@@ -430,6 +434,12 @@
true
+
+
+ .\
+ true
+
+
1
diff --git a/config/cnc-ddraw config.cpp b/config/cnc-ddraw config.cpp
index a69e541..cef38b4 100644
--- a/config/cnc-ddraw config.cpp
+++ b/config/cnc-ddraw config.cpp
@@ -67,4 +67,15 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
}
return 0;
}
+
+// dummy functions to avoid Wtsapi32.dll imports
+EXTERN_C BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags)
+{
+ return TRUE;
+}
+
+EXTERN_C BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd)
+{
+ return TRUE;
+}
//---------------------------------------------------------------------------
diff --git a/config/cnc-ddraw config_resources.rc b/config/cnc-ddraw config_resources.rc
index 9d29fa1..b077d3a 100644
--- a/config/cnc-ddraw config_resources.rc
+++ b/config/cnc-ddraw config_resources.rc
@@ -4,6 +4,7 @@ PngImage_ES RCDATA "Resources\\ES.png"
PngImage_FR RCDATA "Resources\\fr.png"
PngImage_HU RCDATA "Resources\\hu.png"
PngImage_IT RCDATA "Resources\\IT.png"
+PngImage_PL RCDATA "Resources\\pl.png"
PngImage_RU RCDATA "Resources\\RU.png"
PngImage_US RCDATA "Resources\\US.png"
PngImage_VN RCDATA "Resources\\VN.png"
diff --git a/inc/IDirect3D.h b/inc/IDirect3D.h
index dd03465..aed4b3d 100644
--- a/inc/IDirect3D.h
+++ b/inc/IDirect3D.h
@@ -3,6 +3,7 @@
#define WIN32_LEAN_AND_MEAN
#include
+#include "d3dcaps.h"
DEFINE_GUID(IID_IDirect3D, 0x3BBA0080, 0x2421, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56);
@@ -10,6 +11,9 @@ DEFINE_GUID(IID_IDirect3D2, 0x6aae1ec1, 0x662a, 0x11d0, 0x88, 0x9d, 0x00, 0xaa,
DEFINE_GUID(IID_IDirect3D3, 0xbb223240, 0xe72b, 0x11d0, 0xa9, 0xb4, 0x00, 0xaa, 0x00, 0xc0, 0x99, 0x3e);
DEFINE_GUID(IID_IDirect3D7, 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8);
+DEFINE_GUID(IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8);
+
+
#define DECLARE_D3D_INTERFACE(iface) typedef struct iface { \
struct iface##Vtbl FAR* lpVtbl; \
ULONG ref; \
@@ -17,7 +21,6 @@ DEFINE_GUID(IID_IDirect3D7, 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0x
typedef struct iface##Vtbl iface##Vtbl; \
struct iface##Vtbl
-
/* IID_IDirect3D */
DECLARE_D3D_INTERFACE(IDirect3DImpl)
@@ -27,7 +30,7 @@ DECLARE_D3D_INTERFACE(IDirect3DImpl)
ULONG(__stdcall * Release) (IDirect3DImpl*);
HRESULT(__stdcall * Initialize)(IDirect3DImpl*, int);
- HRESULT(__stdcall * EnumDevices)(IDirect3DImpl*, int, int);
+ HRESULT(__stdcall * EnumDevices)(IDirect3DImpl*, LPD3DENUMDEVICESCALLBACK, LPVOID);
HRESULT(__stdcall * CreateLight)(IDirect3DImpl*, int, int);
HRESULT(__stdcall * CreateMaterial)(IDirect3DImpl*, int, int);
HRESULT(__stdcall * CreateViewport)(IDirect3DImpl*, int, int);
@@ -44,7 +47,7 @@ DECLARE_D3D_INTERFACE(IDirect3D2Impl)
ULONG(__stdcall * AddRef) (IDirect3D2Impl*);
ULONG(__stdcall * Release) (IDirect3D2Impl*);
- HRESULT(__stdcall * EnumDevices)(IDirect3D2Impl*, int, int);
+ HRESULT(__stdcall * EnumDevices)(IDirect3D2Impl*, LPD3DENUMDEVICESCALLBACK, LPVOID);
HRESULT(__stdcall * CreateLight)(IDirect3D2Impl*, int, int);
HRESULT(__stdcall * CreateMaterial)(IDirect3D2Impl*, int, int);
HRESULT(__stdcall * CreateViewport)(IDirect3D2Impl*, int, int);
@@ -62,7 +65,7 @@ DECLARE_D3D_INTERFACE(IDirect3D3Impl)
ULONG(__stdcall * AddRef) (IDirect3D3Impl*);
ULONG(__stdcall * Release) (IDirect3D3Impl*);
- HRESULT(__stdcall * EnumDevices)(IDirect3D3Impl*, int, int);
+ HRESULT(__stdcall * EnumDevices)(IDirect3D3Impl*, LPD3DENUMDEVICESCALLBACK, LPVOID);
HRESULT(__stdcall * CreateLight)(IDirect3D3Impl*, int, int);
HRESULT(__stdcall * CreateMaterial)(IDirect3D3Impl*, int, int);
HRESULT(__stdcall * CreateViewport)(IDirect3D3Impl*, int, int);
@@ -83,7 +86,7 @@ DECLARE_D3D_INTERFACE(IDirect3D7Impl)
ULONG(__stdcall * AddRef) (IDirect3D7Impl*);
ULONG(__stdcall * Release) (IDirect3D7Impl*);
- HRESULT(__stdcall * EnumDevices)(IDirect3D7Impl*, int, int);
+ HRESULT(__stdcall * EnumDevices)(IDirect3D7Impl*, LPD3DENUMDEVICESCALLBACK7, LPVOID);
HRESULT(__stdcall * CreateDevice)(IDirect3D7Impl*, int, int, int);
HRESULT(__stdcall * CreateVertexBuffer)(IDirect3D7Impl*, int, int, int);
HRESULT(__stdcall * EnumZBufferFormats)(IDirect3D7Impl*, int, int, int);
diff --git a/inc/IDirectDrawSurface.h b/inc/IDirectDrawSurface.h
index f04e03a..b96314a 100644
--- a/inc/IDirectDrawSurface.h
+++ b/inc/IDirectDrawSurface.h
@@ -9,6 +9,11 @@
#include "IDirectDraw.h"
+typedef struct DDBITMAPINFO{
+ BITMAPINFOHEADER bmiHeader;
+ RGBQUAD bmiColors[256];
+} DDBITMAPINFO;
+
struct IDirectDrawSurfaceImpl;
struct IDirectDrawSurfaceImplVtbl;
@@ -18,9 +23,9 @@ typedef struct IDirectDrawSurfaceImpl
ULONG ref;
+ DWORD bpp;
DWORD width;
DWORD height;
- DWORD bpp;
DWORD size;
DWORD flags;
DWORD caps;
@@ -28,6 +33,8 @@ typedef struct IDirectDrawSurfaceImpl
CRITICAL_SECTION cs;
IDirectDrawPaletteImpl* palette;
+ PALETTEENTRY selected_pal[256];
+ UINT selected_pal_count;
void* surface;
HANDLE mapping;
diff --git a/inc/config.h b/inc/config.h
index 7dd8a23..e15bece 100644
--- a/inc/config.h
+++ b/inc/config.h
@@ -22,7 +22,7 @@ typedef struct CNCDDRAWCONFIG
INIFILE ini;
BOOL d3d9on12;
BOOL opengl_core;
-
+
/* Optional settings */
BOOL fullscreen;
@@ -42,6 +42,8 @@ typedef struct CNCDDRAWCONFIG
int d3d9_filter;
int anti_aliased_fonts_min_size;
int min_font_size;
+ int center_window;
+ char inject_resolution[128];
BOOL vhack;
char screenshot_dir[MAX_PATH];
BOOL toggle_borderless;
@@ -57,36 +59,37 @@ typedef struct CNCDDRAWCONFIG
BOOL singlecpu;
int resolutions;
int fixchilds;
+ BOOL hook_peekmessage;
/* Undocumented settings */
- BOOL releasealt;
- BOOL fixnotresponding;
- int hook;
+ BOOL fix_alt_key_stuck;
+ BOOL fix_not_responding;
+ BOOL no_compat_warning;
int guard_lines;
int max_resolutions;
BOOL lock_surfaces;
BOOL flipclear;
- BOOL fixmousehook;
BOOL rgb555;
BOOL no_dinput_hook;
- int refresh_rate;
- char inject_resolution[128];
- BOOL direct3d_passthrough;
BOOL center_cursor_fix;
char fake_mode[128];
- BOOL wine_allow_resize;
BOOL lock_mouse_top_left;
- BOOL no_compat_warning;
- BOOL remove_menu;
char win_version[32];
+ int hook;
+ BOOL limit_gdi_handles;
+ BOOL remove_menu;
+ int refresh_rate;
+ int terminate_process;
/* Hotkeys */
struct
{
int toggle_fullscreen;
+ int toggle_fullscreen2;
int toggle_maximize;
+ int toggle_maximize2;
int unlock_cursor1;
int unlock_cursor2;
int screenshot;
@@ -100,8 +103,10 @@ typedef struct CNCDDRAWCONFIG
BOOL stronghold_hack;
BOOL mgs_hack;
BOOL tlc_hack;
- BOOL homm_hack;
BOOL carma95_hack;
+ BOOL sirtech_hack;
+ BOOL flightsim98_hack;
+ BOOL darkcolony_hack;
} CNCDDRAWCONFIG;
diff --git a/inc/crc32.h b/inc/crc32.h
index d842810..9b0728d 100644
--- a/inc/crc32.h
+++ b/inc/crc32.h
@@ -6,5 +6,6 @@
unsigned long Crc32_ComputeBuf(unsigned long inCrc32, const void* buf, size_t bufLen);
+unsigned long Crc32_FromFile(unsigned long crc32, char* filename);
#endif
diff --git a/inc/d3dcaps.h b/inc/d3dcaps.h
new file mode 100644
index 0000000..4f86f61
--- /dev/null
+++ b/inc/d3dcaps.h
@@ -0,0 +1,607 @@
+/*==========================================================================;
+ *
+ * Copyright (C) Microsoft Corporation. All Rights Reserved.
+ *
+ * File: d3dcaps.h
+ * Content: Direct3D capabilities include file
+ *
+ ***************************************************************************/
+
+
+
+#ifndef _D3DCAPS_H
+#define _D3DCAPS_H
+
+/*
+ * Pull in DirectDraw include file automatically:
+ */
+#include "ddraw.h"
+
+#ifndef DIRECT3D_VERSION
+#define DIRECT3D_VERSION 0x0700
+#endif
+
+#if defined(_X86_) || defined(_IA64_)
+#pragma pack(4)
+#endif
+
+/* Description of capabilities of transform */
+
+typedef struct _D3DTRANSFORMCAPS {
+ DWORD dwSize;
+ DWORD dwCaps;
+} D3DTRANSFORMCAPS, *LPD3DTRANSFORMCAPS;
+
+#define D3DTRANSFORMCAPS_CLIP 0x00000001L /* Will clip whilst transforming */
+
+/* Description of capabilities of lighting */
+
+typedef struct _D3DLIGHTINGCAPS {
+ DWORD dwSize;
+ DWORD dwCaps; /* Lighting caps */
+ DWORD dwLightingModel; /* Lighting model - RGB or mono */
+ DWORD dwNumLights; /* Number of lights that can be handled */
+} D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS;
+
+#define D3DLIGHTINGMODEL_RGB 0x00000001L
+#define D3DLIGHTINGMODEL_MONO 0x00000002L
+
+#define D3DLIGHTCAPS_POINT 0x00000001L /* Point lights supported */
+#define D3DLIGHTCAPS_SPOT 0x00000002L /* Spot lights supported */
+#define D3DLIGHTCAPS_DIRECTIONAL 0x00000004L /* Directional lights supported */
+#if(DIRECT3D_VERSION < 0x700)
+#define D3DLIGHTCAPS_PARALLELPOINT 0x00000008L /* Parallel point lights supported */
+#endif
+#if(DIRECT3D_VERSION < 0x500)
+#define D3DLIGHTCAPS_GLSPOT 0x00000010L /* GL syle spot lights supported */
+#endif
+
+/* Description of capabilities for each primitive type */
+
+typedef struct _D3DPrimCaps {
+ DWORD dwSize;
+ DWORD dwMiscCaps; /* Capability flags */
+ DWORD dwRasterCaps;
+ DWORD dwZCmpCaps;
+ DWORD dwSrcBlendCaps;
+ DWORD dwDestBlendCaps;
+ DWORD dwAlphaCmpCaps;
+ DWORD dwShadeCaps;
+ DWORD dwTextureCaps;
+ DWORD dwTextureFilterCaps;
+ DWORD dwTextureBlendCaps;
+ DWORD dwTextureAddressCaps;
+ DWORD dwStippleWidth; /* maximum width and height of */
+ DWORD dwStippleHeight; /* of supported stipple (up to 32x32) */
+} D3DPRIMCAPS, *LPD3DPRIMCAPS;
+
+/* D3DPRIMCAPS dwMiscCaps */
+
+#define D3DPMISCCAPS_MASKPLANES 0x00000001L
+#define D3DPMISCCAPS_MASKZ 0x00000002L
+#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L
+#define D3DPMISCCAPS_CONFORMANT 0x00000008L
+#define D3DPMISCCAPS_CULLNONE 0x00000010L
+#define D3DPMISCCAPS_CULLCW 0x00000020L
+#define D3DPMISCCAPS_CULLCCW 0x00000040L
+
+/* D3DPRIMCAPS dwRasterCaps */
+
+#define D3DPRASTERCAPS_DITHER 0x00000001L
+#define D3DPRASTERCAPS_ROP2 0x00000002L
+#define D3DPRASTERCAPS_XOR 0x00000004L
+#define D3DPRASTERCAPS_PAT 0x00000008L
+#define D3DPRASTERCAPS_ZTEST 0x00000010L
+#define D3DPRASTERCAPS_SUBPIXEL 0x00000020L
+#define D3DPRASTERCAPS_SUBPIXELX 0x00000040L
+#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L
+#define D3DPRASTERCAPS_FOGTABLE 0x00000100L
+#define D3DPRASTERCAPS_STIPPLE 0x00000200L
+#if(DIRECT3D_VERSION >= 0x0500)
+#define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400L
+#define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800L
+#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L
+#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L
+#define D3DPRASTERCAPS_ZBIAS 0x00004000L
+#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L
+#define D3DPRASTERCAPS_FOGRANGE 0x00010000L
+#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L
+#endif /* DIRECT3D_VERSION >= 0x0500 */
+#if(DIRECT3D_VERSION >= 0x0600)
+#define D3DPRASTERCAPS_WBUFFER 0x00040000L
+#define D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000L
+#define D3DPRASTERCAPS_WFOG 0x00100000L
+#define D3DPRASTERCAPS_ZFOG 0x00200000L
+#endif /* DIRECT3D_VERSION >= 0x0600 */
+
+/* D3DPRIMCAPS dwZCmpCaps, dwAlphaCmpCaps */
+
+#define D3DPCMPCAPS_NEVER 0x00000001L
+#define D3DPCMPCAPS_LESS 0x00000002L
+#define D3DPCMPCAPS_EQUAL 0x00000004L
+#define D3DPCMPCAPS_LESSEQUAL 0x00000008L
+#define D3DPCMPCAPS_GREATER 0x00000010L
+#define D3DPCMPCAPS_NOTEQUAL 0x00000020L
+#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L
+#define D3DPCMPCAPS_ALWAYS 0x00000080L
+
+/* D3DPRIMCAPS dwSourceBlendCaps, dwDestBlendCaps */
+
+#define D3DPBLENDCAPS_ZERO 0x00000001L
+#define D3DPBLENDCAPS_ONE 0x00000002L
+#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L
+#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L
+#define D3DPBLENDCAPS_SRCALPHA 0x00000010L
+#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L
+#define D3DPBLENDCAPS_DESTALPHA 0x00000040L
+#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L
+#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L
+#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L
+#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L
+#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L
+#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L
+
+/* D3DPRIMCAPS dwShadeCaps */
+
+#define D3DPSHADECAPS_COLORFLATMONO 0x00000001L
+#define D3DPSHADECAPS_COLORFLATRGB 0x00000002L
+#define D3DPSHADECAPS_COLORGOURAUDMONO 0x00000004L
+#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L
+#define D3DPSHADECAPS_COLORPHONGMONO 0x00000010L
+#define D3DPSHADECAPS_COLORPHONGRGB 0x00000020L
+
+#define D3DPSHADECAPS_SPECULARFLATMONO 0x00000040L
+#define D3DPSHADECAPS_SPECULARFLATRGB 0x00000080L
+#define D3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100L
+#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L
+#define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400L
+#define D3DPSHADECAPS_SPECULARPHONGRGB 0x00000800L
+
+#define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000L
+#define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000L
+#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L
+#define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000L
+#define D3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000L
+#define D3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000L
+
+#define D3DPSHADECAPS_FOGFLAT 0x00040000L
+#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L
+#define D3DPSHADECAPS_FOGPHONG 0x00100000L
+
+/* D3DPRIMCAPS dwTextureCaps */
+
+/*
+ * Perspective-correct texturing is supported
+ */
+#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L
+
+/*
+ * Power-of-2 texture dimensions are required
+ */
+#define D3DPTEXTURECAPS_POW2 0x00000002L
+
+/*
+ * Alpha in texture pixels is supported
+ */
+#define D3DPTEXTURECAPS_ALPHA 0x00000004L
+
+/*
+ * Color-keyed textures are supported
+ */
+#define D3DPTEXTURECAPS_TRANSPARENCY 0x00000008L
+
+/*
+ * obsolete, see D3DPTADDRESSCAPS_BORDER
+ */
+#define D3DPTEXTURECAPS_BORDER 0x00000010L
+
+/*
+ * Only square textures are supported
+ */
+#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L
+
+#if(DIRECT3D_VERSION >= 0x0600)
+/*
+ * Texture indices are not scaled by the texture size prior
+ * to interpolation.
+ */
+#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L
+
+/*
+ * Device can draw alpha from texture palettes
+ */
+#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L
+
+/*
+ * Device can use non-POW2 textures if:
+ * 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage
+ * 2) D3DRS_WRAP(N) is zero for this texture's coordinates
+ * 3) mip mapping is not enabled (use magnification filter only)
+ */
+#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L
+
+#endif /* DIRECT3D_VERSION >= 0x0600 */
+#if(DIRECT3D_VERSION >= 0x0700)
+
+// 0x00000200L unused
+
+/*
+ * Device can divide transformed texture coordinates by the
+ * COUNTth texture coordinate (can do D3DTTFF_PROJECTED)
+ */
+#define D3DPTEXTURECAPS_PROJECTED 0x00000400L
+
+/*
+ * Device can do cubemap textures
+ */
+#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L
+
+#define D3DPTEXTURECAPS_COLORKEYBLEND 0x00001000L
+#endif /* DIRECT3D_VERSION >= 0x0700 */
+
+/* D3DPRIMCAPS dwTextureFilterCaps */
+
+#define D3DPTFILTERCAPS_NEAREST 0x00000001L
+#define D3DPTFILTERCAPS_LINEAR 0x00000002L
+#define D3DPTFILTERCAPS_MIPNEAREST 0x00000004L
+#define D3DPTFILTERCAPS_MIPLINEAR 0x00000008L
+#define D3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010L
+#define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020L
+
+#if(DIRECT3D_VERSION >= 0x0600)
+/* Device3 Min Filter */
+#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L
+#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L
+#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L
+
+/* Device3 Mip Filter */
+#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L
+#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L
+
+/* Device3 Mag Filter */
+#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L
+#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L
+#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L
+#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L
+#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L
+#endif /* DIRECT3D_VERSION >= 0x0600 */
+
+/* D3DPRIMCAPS dwTextureBlendCaps */
+
+#define D3DPTBLENDCAPS_DECAL 0x00000001L
+#define D3DPTBLENDCAPS_MODULATE 0x00000002L
+#define D3DPTBLENDCAPS_DECALALPHA 0x00000004L
+#define D3DPTBLENDCAPS_MODULATEALPHA 0x00000008L
+#define D3DPTBLENDCAPS_DECALMASK 0x00000010L
+#define D3DPTBLENDCAPS_MODULATEMASK 0x00000020L
+#define D3DPTBLENDCAPS_COPY 0x00000040L
+#if(DIRECT3D_VERSION >= 0x0500)
+#define D3DPTBLENDCAPS_ADD 0x00000080L
+#endif /* DIRECT3D_VERSION >= 0x0500 */
+
+/* D3DPRIMCAPS dwTextureAddressCaps */
+#define D3DPTADDRESSCAPS_WRAP 0x00000001L
+#define D3DPTADDRESSCAPS_MIRROR 0x00000002L
+#define D3DPTADDRESSCAPS_CLAMP 0x00000004L
+#if(DIRECT3D_VERSION >= 0x0500)
+#define D3DPTADDRESSCAPS_BORDER 0x00000008L
+#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L
+#endif /* DIRECT3D_VERSION >= 0x0500 */
+
+#if(DIRECT3D_VERSION >= 0x0600)
+
+/* D3DDEVICEDESC dwStencilCaps */
+
+#define D3DSTENCILCAPS_KEEP 0x00000001L
+#define D3DSTENCILCAPS_ZERO 0x00000002L
+#define D3DSTENCILCAPS_REPLACE 0x00000004L
+#define D3DSTENCILCAPS_INCRSAT 0x00000008L
+#define D3DSTENCILCAPS_DECRSAT 0x00000010L
+#define D3DSTENCILCAPS_INVERT 0x00000020L
+#define D3DSTENCILCAPS_INCR 0x00000040L
+#define D3DSTENCILCAPS_DECR 0x00000080L
+
+/* D3DDEVICEDESC dwTextureOpCaps */
+
+#define D3DTEXOPCAPS_DISABLE 0x00000001L
+#define D3DTEXOPCAPS_SELECTARG1 0x00000002L
+#define D3DTEXOPCAPS_SELECTARG2 0x00000004L
+#define D3DTEXOPCAPS_MODULATE 0x00000008L
+#define D3DTEXOPCAPS_MODULATE2X 0x00000010L
+#define D3DTEXOPCAPS_MODULATE4X 0x00000020L
+#define D3DTEXOPCAPS_ADD 0x00000040L
+#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L
+#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L
+#define D3DTEXOPCAPS_SUBTRACT 0x00000200L
+#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L
+#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L
+#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L
+#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L
+#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L
+#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L
+#define D3DTEXOPCAPS_PREMODULATE 0x00010000L
+#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L
+#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L
+#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L
+#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L
+#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L
+#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L
+#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L
+
+/* D3DDEVICEDESC dwFVFCaps flags */
+
+#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */
+#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */
+
+#endif /* DIRECT3D_VERSION >= 0x0600 */
+
+typedef float D3DVALUE, *LPD3DVALUE;
+typedef DWORD D3DCOLORMODEL;
+
+/*
+ * Description for a device.
+ * This is used to describe a device that is to be created or to query
+ * the current device.
+ */
+typedef struct _D3DDeviceDesc {
+ DWORD dwSize; /* Size of D3DDEVICEDESC structure */
+ DWORD dwFlags; /* Indicates which fields have valid data */
+ D3DCOLORMODEL dcmColorModel; /* Color model of device */
+ DWORD dwDevCaps; /* Capabilities of device */
+ D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */
+ BOOL bClipping; /* Device can do 3D clipping */
+ D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */
+ D3DPRIMCAPS dpcLineCaps;
+ D3DPRIMCAPS dpcTriCaps;
+ DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */
+ DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
+ DWORD dwMaxBufferSize; /* Maximum execute buffer size */
+ DWORD dwMaxVertexCount; /* Maximum vertex count */
+//#if(DIRECT3D_VERSION >= 0x0500)
+ // *** New fields for DX5 *** //
+
+ // Width and height caps are 0 for legacy HALs.
+ DWORD dwMinTextureWidth, dwMinTextureHeight;
+ DWORD dwMaxTextureWidth, dwMaxTextureHeight;
+ DWORD dwMinStippleWidth, dwMaxStippleWidth;
+ DWORD dwMinStippleHeight, dwMaxStippleHeight;
+//#endif /* DIRECT3D_VERSION >= 0x0500 */
+
+//#if(DIRECT3D_VERSION >= 0x0600)
+ // New fields for DX6
+ DWORD dwMaxTextureRepeat;
+ DWORD dwMaxTextureAspectRatio;
+ DWORD dwMaxAnisotropy;
+
+ // Guard band that the rasterizer can accommodate
+ // Screen-space vertices inside this space but outside the viewport
+ // will get clipped properly.
+ D3DVALUE dvGuardBandLeft;
+ D3DVALUE dvGuardBandTop;
+ D3DVALUE dvGuardBandRight;
+ D3DVALUE dvGuardBandBottom;
+
+ D3DVALUE dvExtentsAdjust;
+ DWORD dwStencilCaps;
+
+ DWORD dwFVFCaps;
+ DWORD dwTextureOpCaps;
+ WORD wMaxTextureBlendStages;
+ WORD wMaxSimultaneousTextures;
+//#endif /* DIRECT3D_VERSION >= 0x0600 */
+} D3DDEVICEDESC, *LPD3DDEVICEDESC;
+
+#if(DIRECT3D_VERSION >= 0x0700)
+typedef struct _D3DDeviceDesc7 {
+ DWORD dwDevCaps; /* Capabilities of device */
+ D3DPRIMCAPS dpcLineCaps;
+ D3DPRIMCAPS dpcTriCaps;
+ DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */
+ DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
+
+ DWORD dwMinTextureWidth, dwMinTextureHeight;
+ DWORD dwMaxTextureWidth, dwMaxTextureHeight;
+
+ DWORD dwMaxTextureRepeat;
+ DWORD dwMaxTextureAspectRatio;
+ DWORD dwMaxAnisotropy;
+
+ D3DVALUE dvGuardBandLeft;
+ D3DVALUE dvGuardBandTop;
+ D3DVALUE dvGuardBandRight;
+ D3DVALUE dvGuardBandBottom;
+
+ D3DVALUE dvExtentsAdjust;
+ DWORD dwStencilCaps;
+
+ DWORD dwFVFCaps;
+ DWORD dwTextureOpCaps;
+ WORD wMaxTextureBlendStages;
+ WORD wMaxSimultaneousTextures;
+
+ DWORD dwMaxActiveLights;
+ D3DVALUE dvMaxVertexW;
+ GUID deviceGUID;
+
+ WORD wMaxUserClipPlanes;
+ WORD wMaxVertexBlendMatrices;
+
+ DWORD dwVertexProcessingCaps;
+
+ DWORD dwReserved1;
+ DWORD dwReserved2;
+ DWORD dwReserved3;
+ DWORD dwReserved4;
+} D3DDEVICEDESC7, *LPD3DDEVICEDESC7;
+#endif /* DIRECT3D_VERSION >= 0x0700 */
+
+#define D3DDEVICEDESCSIZE (sizeof(D3DDEVICEDESC))
+#define D3DDEVICEDESC7SIZE (sizeof(D3DDEVICEDESC7))
+
+typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK)(GUID FAR *lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC, LPD3DDEVICEDESC, LPVOID);
+
+//#if(DIRECT3D_VERSION >= 0x0700)
+typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK7)(LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC7, LPVOID);
+//#endif /* DIRECT3D_VERSION >= 0x0700 */
+
+/* D3DDEVICEDESC dwFlags indicating valid fields */
+
+#define D3DDD_COLORMODEL 0x00000001L /* dcmColorModel is valid */
+#define D3DDD_DEVCAPS 0x00000002L /* dwDevCaps is valid */
+#define D3DDD_TRANSFORMCAPS 0x00000004L /* dtcTransformCaps is valid */
+#define D3DDD_LIGHTINGCAPS 0x00000008L /* dlcLightingCaps is valid */
+#define D3DDD_BCLIPPING 0x00000010L /* bClipping is valid */
+#define D3DDD_LINECAPS 0x00000020L /* dpcLineCaps is valid */
+#define D3DDD_TRICAPS 0x00000040L /* dpcTriCaps is valid */
+#define D3DDD_DEVICERENDERBITDEPTH 0x00000080L /* dwDeviceRenderBitDepth is valid */
+#define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000100L /* dwDeviceZBufferBitDepth is valid */
+#define D3DDD_MAXBUFFERSIZE 0x00000200L /* dwMaxBufferSize is valid */
+#define D3DDD_MAXVERTEXCOUNT 0x00000400L /* dwMaxVertexCount is valid */
+
+/* D3DDEVICEDESC dwDevCaps flags */
+
+#define D3DDEVCAPS_FLOATTLVERTEX 0x00000001L /* Device accepts floating point */
+ /* for post-transform vertex data */
+#define D3DDEVCAPS_SORTINCREASINGZ 0x00000002L /* Device needs data sorted for increasing Z */
+#define D3DDEVCAPS_SORTDECREASINGZ 0X00000004L /* Device needs data sorted for decreasing Z */
+#define D3DDEVCAPS_SORTEXACT 0x00000008L /* Device needs data sorted exactly */
+
+#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */
+#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */
+#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */
+#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080L /* Device can use TL buffers from video memory */
+#define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100L /* Device can texture from system memory */
+#define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200L /* Device can texture from device memory */
+#if(DIRECT3D_VERSION >= 0x0500)
+#define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400L /* Device can draw TLVERTEX primitives */
+#define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800L /* Device can render without waiting for flip to complete */
+#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000L /* Device can texture from nonlocal video memory */
+#endif /* DIRECT3D_VERSION >= 0x0500 */
+#if(DIRECT3D_VERSION >= 0x0600)
+#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */
+#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */
+#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/
+#endif /* DIRECT3D_VERSION >= 0x0600 */
+#if(DIRECT3D_VERSION >= 0x0700)
+#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */
+#define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000L /* Device supports a Tex Blt from system memory to non-local vidmem */
+#define D3DDEVCAPS_HWRASTERIZATION 0x00080000L /* Device has HW acceleration for rasterization */
+
+/*
+ * These are the flags in the D3DDEVICEDESC7.dwVertexProcessingCaps field
+ */
+
+/* device can do texgen */
+#define D3DVTXPCAPS_TEXGEN 0x00000001L
+/* device can do IDirect3DDevice7 colormaterialsource ops */
+#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L
+/* device can do vertex fog */
+#define D3DVTXPCAPS_VERTEXFOG 0x00000004L
+/* device can do directional lights */
+#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L
+/* device can do positional lights (includes point and spot) */
+#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L
+/* device can do local viewer */
+#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L
+
+#endif /* DIRECT3D_VERSION >= 0x0700 */
+
+#define D3DFDS_COLORMODEL 0x00000001L /* Match color model */
+#define D3DFDS_GUID 0x00000002L /* Match guid */
+#define D3DFDS_HARDWARE 0x00000004L /* Match hardware/software */
+#define D3DFDS_TRIANGLES 0x00000008L /* Match in triCaps */
+#define D3DFDS_LINES 0x00000010L /* Match in lineCaps */
+#define D3DFDS_MISCCAPS 0x00000020L /* Match primCaps.dwMiscCaps */
+#define D3DFDS_RASTERCAPS 0x00000040L /* Match primCaps.dwRasterCaps */
+#define D3DFDS_ZCMPCAPS 0x00000080L /* Match primCaps.dwZCmpCaps */
+#define D3DFDS_ALPHACMPCAPS 0x00000100L /* Match primCaps.dwAlphaCmpCaps */
+#define D3DFDS_SRCBLENDCAPS 0x00000200L /* Match primCaps.dwSourceBlendCaps */
+#define D3DFDS_DSTBLENDCAPS 0x00000400L /* Match primCaps.dwDestBlendCaps */
+#define D3DFDS_SHADECAPS 0x00000800L /* Match primCaps.dwShadeCaps */
+#define D3DFDS_TEXTURECAPS 0x00001000L /* Match primCaps.dwTextureCaps */
+#define D3DFDS_TEXTUREFILTERCAPS 0x00002000L /* Match primCaps.dwTextureFilterCaps */
+#define D3DFDS_TEXTUREBLENDCAPS 0x00004000L /* Match primCaps.dwTextureBlendCaps */
+#define D3DFDS_TEXTUREADDRESSCAPS 0x00008000L /* Match primCaps.dwTextureBlendCaps */
+
+/*
+ * FindDevice arguments
+ */
+typedef struct _D3DFINDDEVICESEARCH {
+ DWORD dwSize;
+ DWORD dwFlags;
+ BOOL bHardware;
+ D3DCOLORMODEL dcmColorModel;
+ GUID guid;
+ DWORD dwCaps;
+ D3DPRIMCAPS dpcPrimCaps;
+} D3DFINDDEVICESEARCH, *LPD3DFINDDEVICESEARCH;
+
+typedef struct _D3DFINDDEVICERESULT {
+ DWORD dwSize;
+ GUID guid; /* guid which matched */
+ D3DDEVICEDESC ddHwDesc; /* hardware D3DDEVICEDESC */
+ D3DDEVICEDESC ddSwDesc; /* software D3DDEVICEDESC */
+} D3DFINDDEVICERESULT, *LPD3DFINDDEVICERESULT;
+
+/*
+ * Description of execute buffer.
+ */
+typedef struct _D3DExecuteBufferDesc {
+ DWORD dwSize; /* size of this structure */
+ DWORD dwFlags; /* flags indicating which fields are valid */
+ DWORD dwCaps; /* capabilities of execute buffer */
+ DWORD dwBufferSize; /* size of execute buffer data */
+ LPVOID lpData; /* pointer to actual data */
+} D3DEXECUTEBUFFERDESC, *LPD3DEXECUTEBUFFERDESC;
+
+/* D3DEXECUTEBUFFER dwFlags indicating valid fields */
+
+#define D3DDEB_BUFSIZE 0x00000001l /* buffer size valid */
+#define D3DDEB_CAPS 0x00000002l /* caps valid */
+#define D3DDEB_LPDATA 0x00000004l /* lpData valid */
+
+/* D3DEXECUTEBUFFER dwCaps */
+
+#define D3DDEBCAPS_SYSTEMMEMORY 0x00000001l /* buffer in system memory */
+#define D3DDEBCAPS_VIDEOMEMORY 0x00000002l /* buffer in device memory */
+#define D3DDEBCAPS_MEM (D3DDEBCAPS_SYSTEMMEMORY|D3DDEBCAPS_VIDEOMEMORY)
+
+#if(DIRECT3D_VERSION < 0x0800)
+
+#if(DIRECT3D_VERSION >= 0x0700)
+typedef struct _D3DDEVINFO_TEXTUREMANAGER {
+ BOOL bThrashing; /* indicates if thrashing */
+ DWORD dwApproxBytesDownloaded; /* Approximate number of bytes downloaded by texture manager */
+ DWORD dwNumEvicts; /* number of textures evicted */
+ DWORD dwNumVidCreates; /* number of textures created in video memory */
+ DWORD dwNumTexturesUsed; /* number of textures used */
+ DWORD dwNumUsedTexInVid; /* number of used textures present in video memory */
+ DWORD dwWorkingSet; /* number of textures in video memory */
+ DWORD dwWorkingSetBytes; /* number of bytes in video memory */
+ DWORD dwTotalManaged; /* total number of managed textures */
+ DWORD dwTotalBytes; /* total number of bytes of managed textures */
+ DWORD dwLastPri; /* priority of last texture evicted */
+} D3DDEVINFO_TEXTUREMANAGER, *LPD3DDEVINFO_TEXTUREMANAGER;
+
+typedef struct _D3DDEVINFO_TEXTURING {
+ DWORD dwNumLoads; /* counts Load() API calls */
+ DWORD dwApproxBytesLoaded; /* Approximate number bytes loaded via Load() */
+ DWORD dwNumPreLoads; /* counts PreLoad() API calls */
+ DWORD dwNumSet; /* counts SetTexture() API calls */
+ DWORD dwNumCreates; /* counts texture creates */
+ DWORD dwNumDestroys; /* counts texture destroys */
+ DWORD dwNumSetPriorities; /* counts SetPriority() API calls */
+ DWORD dwNumSetLODs; /* counts SetLOD() API calls */
+ DWORD dwNumLocks; /* counts number of texture locks */
+ DWORD dwNumGetDCs; /* counts number of GetDCs to textures */
+} D3DDEVINFO_TEXTURING, *LPD3DDEVINFO_TEXTURING;
+#endif /* DIRECT3D_VERSION >= 0x0700 */
+
+#endif //(DIRECT3D_VERSION < 0x0800)
+
+#pragma pack()
+
+
+#endif /* _D3DCAPS_H_ */
+
+
diff --git a/inc/dd.h b/inc/dd.h
index e5904bb..fe175f7 100644
--- a/inc/dd.h
+++ b/inc/dd.h
@@ -51,6 +51,11 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
#define LIMIT_TESTCOOP 1
#define LIMIT_BLTFAST 2
#define LIMIT_UNLOCK 3
+#define LIMIT_PEEKMESSAGE 4
+
+#define CENTER_WINDOW_NEVER 0
+#define CENTER_WINDOW_AUTO 1
+#define CENTER_WINDOW_ALWAYS 2
#ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x00000002
@@ -60,6 +65,18 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
#define CREATE_WAITABLE_TIMER_MANUAL_RESET 0x00000001
#endif
+#ifndef GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
+#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 0x00000002
+#endif
+
+#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
+#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
+#endif
+
+#if (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
+#define GdiTransparentBlt TransparentBlt
+#endif
+
typedef struct SPEEDLIMITER
{
DWORD tick_length;
@@ -110,6 +127,7 @@ typedef struct CNCDDRAW
LONG palette_updated;
LONG surface_updated;
LONG clear_screen;
+ LONG screen_updated;
float scale_w;
float scale_h;
diff --git a/inc/ddpalette.h b/inc/ddpalette.h
index 7d264db..cfd46ff 100644
--- a/inc/ddpalette.h
+++ b/inc/ddpalette.h
@@ -7,6 +7,8 @@
#include "IDirectDrawPalette.h"
#include "dd.h"
+#define DDPCAPS_REFRESH_CHANGED_ONLY (1 << 31)
+
HRESULT ddp_GetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
HRESULT ddp_SetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
HRESULT dd_CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, IDirectDrawPaletteImpl** lpDDPalette, IUnknown FAR* unkOuter);
diff --git a/inc/debug.h b/inc/debug.h
index 6ac7f7b..fa70c85 100644
--- a/inc/debug.h
+++ b/inc/debug.h
@@ -6,6 +6,7 @@
#include
LONG WINAPI dbg_exception_handler(EXCEPTION_POINTERS* exception);
+LONG WINAPI dbg_vectored_exception_handler(EXCEPTION_POINTERS* exception);
void dbg_counter_start();
double dbg_counter_stop();
void dbg_debug_string(const char* format, ...);
@@ -26,19 +27,16 @@ void dbg_dump_dds_caps(DWORD caps);
void dbg_dump_dds_flags(DWORD flags);
void dbg_dump_dds_blt_fast_flags(DWORD flags);
void dbg_dump_dds_lock_flags(DWORD flags);
+void dbg_dump_di_scm_flags(DWORD flags);
+void dbg_dump_hook_type(int idHook);
char* dbg_d3d9_hr_to_str(HRESULT hr);
char* dbg_mes_to_str(int id);
-
-void __cdecl dbg_invoke_watson(
- _In_opt_z_ wchar_t const*,
- _In_opt_z_ wchar_t const*,
- _In_opt_z_ wchar_t const*,
- _In_ unsigned int,
- _In_ uintptr_t);
+void __cdecl dbg_invoke_watson(wchar_t const*, wchar_t const*, wchar_t const*, unsigned int, uintptr_t);
extern double g_dbg_frame_time;
extern DWORD g_dbg_frame_count;
extern LPTOP_LEVEL_EXCEPTION_FILTER g_dbg_exception_filter;
+extern PVOID g_dbg_exception_handle;
#if defined(__GNUC__) /* wrap msvc intrinsics onto gcc builtins */
#undef _ReturnAddress
diff --git a/inc/delay_imports.h b/inc/delay_imports.h
new file mode 100644
index 0000000..ba654ed
--- /dev/null
+++ b/inc/delay_imports.h
@@ -0,0 +1,25 @@
+#ifndef DELAY_IMPORTS_H
+#define DELAY_IMPORTS_H
+
+#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
+#define ThreadQuerySetWin32StartAddress 9
+
+typedef NTSTATUS(WINAPI* RTLVERIFYVERSIONINFOPROC)(PRTL_OSVERSIONINFOEXW, ULONG, ULONGLONG);
+typedef const char* (CDECL* WINE_GET_VERSIONPROC)();
+typedef void (CDECL* WINE_GET_HOST_VERSIONPROC)(const char** sysname, const char** release);
+typedef NTSTATUS(WINAPI* NTQUERYINFORMATIONTHREADPROC)(HANDLE, LONG, PVOID, ULONG, PULONG);
+
+typedef ULONGLONG(WINAPI* VERSETCONDITIONMASKPROC)(ULONGLONG, DWORD, BYTE);
+typedef BOOL(WINAPI* GETMODULEHANDLEEXAPROC)(DWORD, LPCSTR, HMODULE*);
+
+extern NTQUERYINFORMATIONTHREADPROC delay_NtQueryInformationThread;
+extern RTLVERIFYVERSIONINFOPROC delay_RtlVerifyVersionInfo;
+extern WINE_GET_VERSIONPROC delay_wine_get_version;
+extern WINE_GET_HOST_VERSIONPROC delay_wine_get_host_version;
+
+extern VERSETCONDITIONMASKPROC delay_VerSetConditionMask;
+extern GETMODULEHANDLEEXAPROC delay_GetModuleHandleExA;
+
+void delay_imports_init();
+
+#endif
diff --git a/inc/dllmain.h b/inc/dllmain.h
index 176d72a..f7e028b 100644
--- a/inc/dllmain.h
+++ b/inc/dllmain.h
@@ -29,4 +29,8 @@ typedef HRESULT(__stdcall* SETPROCESSDPIAWERENESSPROC)(PROCESS_DPI_AWARENESS);
typedef BOOL(__stdcall* SETPROCESSDPIAWAREPROC)();
typedef BOOL(__stdcall* SETPROCESSDPIAWARENESSCONTEXTPROC)(DPI_AWARENESS_CONTEXT);
+#if (_WIN32_WINNT < _WIN32_WINNT_WINXP)
+#define SetThreadExecutionState(a)
+#endif
+
#endif
diff --git a/inc/hook.h b/inc/hook.h
index 92301d4..23de636 100644
--- a/inc/hook.h
+++ b/inc/hook.h
@@ -2,10 +2,12 @@
#define HOOK_H
#include
+#include
#define HOOK_SKIP_2 0x00000001l
#define HOOK_LOCAL_ONLY 0x00000002l
+#define HOOK_SYSTEM_ONLY 0x00000004l
typedef struct HOOKLISTDATA {
char function_name[32];
@@ -16,7 +18,7 @@ typedef struct HOOKLISTDATA {
HMODULE mod;
} HOOKLISTDATA;
-typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[34]; } HOOKLIST;
+typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[39]; } HOOKLIST;
typedef BOOL(WINAPI* GETCURSORPOSPROC)(LPPOINT);
typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*);
@@ -35,6 +37,7 @@ typedef BOOL(WINAPI* SETWINDOWPOSPROC)(HWND, HWND, int, int, int, int, UINT);
typedef BOOL(WINAPI* MOVEWINDOWPROC)(HWND, int, int, int, int, BOOL);
typedef LRESULT(WINAPI* SENDMESSAGEAPROC)(HWND, UINT, WPARAM, LPARAM);
typedef LONG(WINAPI* SETWINDOWLONGAPROC)(HWND, int, LONG);
+typedef LONG(WINAPI* SETWINDOWLONGWPROC)(HWND, int, LONG);
typedef LONG(WINAPI* GETWINDOWLONGAPROC)(HWND, int);
typedef BOOL(WINAPI* ENABLEWINDOWPROC)(HWND, BOOL);
typedef HWND(WINAPI* CREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
@@ -57,13 +60,21 @@ typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
typedef BOOL(WINAPI* PEEKMESSAGEAPROC)(LPMSG, HWND, UINT, UINT, UINT);
typedef BOOL(WINAPI* GETMESSAGEAPROC)(LPMSG, HWND, UINT, UINT);
typedef BOOL(WINAPI* GETWINDOWPLACEMENTPROC)(HWND, WINDOWPLACEMENT*);
+typedef BOOL(WINAPI* SETWINDOWPLACEMENTPROC)(HWND, const WINDOWPLACEMENT*);
typedef BOOL(WINAPI* ENUMDISPLAYSETTINGSAPROC)(LPCSTR, DWORD, DEVMODEA*);
+typedef LRESULT(WINAPI* DEFWINDOWPROCAPROC)(HWND, UINT, WPARAM, LPARAM);
+typedef HWND(WINAPI* SETPARENTPROC)(HWND, HWND);
+typedef HDC (WINAPI* BEGINPAINTPROC)(HWND, LPPAINTSTRUCT);
typedef SHORT(WINAPI* GETKEYSTATEPROC)(int);
typedef SHORT(WINAPI* GETASYNCKEYSTATEPROC)(int);
typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int);
typedef HFONT(WINAPI* CREATEFONTINDIRECTAPROC)(CONST LOGFONT*);
typedef HFONT(WINAPI* CREATEFONTAPROC)(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR);
+typedef UINT(WINAPI* GETSYSTEMPALETTEENTRIESPROC)(HDC, UINT, UINT, LPPALETTEENTRY);
+typedef HPALETTE(WINAPI* SELECTPALETTEPROC)(HDC, HPALETTE, BOOL);
+typedef UINT (WINAPI* REALIZEPALETTEPROC)(HDC);
+
typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR);
typedef HMODULE(WINAPI* LOADLIBRARYWPROC)(LPCWSTR);
typedef HMODULE(WINAPI* LOADLIBRARYEXAPROC)(LPCSTR, HANDLE, DWORD);
@@ -76,6 +87,8 @@ typedef HRESULT(WINAPI* COCREATEINSTANCEPROC)(REFCLSID, LPUNKNOWN, DWORD, REFIID
typedef MCIERROR(WINAPI* MCISENDCOMMANDAPROC)(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR);
typedef LPTOP_LEVEL_EXCEPTION_FILTER(WINAPI* SETUNHANDLEDEXCEPTIONFILTERPROC)(LPTOP_LEVEL_EXCEPTION_FILTER);
+typedef PGETFRAME (WINAPI* AVISTREAMGETFRAMEOPENPROC)(PAVISTREAM, LPBITMAPINFOHEADER);
+
extern GETCURSORPOSPROC real_GetCursorPos;
extern CLIPCURSORPROC real_ClipCursor;
extern SHOWCURSORPROC real_ShowCursor;
@@ -93,6 +106,7 @@ extern SETWINDOWPOSPROC real_SetWindowPos;
extern MOVEWINDOWPROC real_MoveWindow;
extern SENDMESSAGEAPROC real_SendMessageA;
extern SETWINDOWLONGAPROC real_SetWindowLongA;
+extern SETWINDOWLONGWPROC real_SetWindowLongW;
extern GETWINDOWLONGAPROC real_GetWindowLongA;
extern ENABLEWINDOWPROC real_EnableWindow;
extern CREATEWINDOWEXAPROC real_CreateWindowExA;
@@ -110,12 +124,19 @@ extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
extern PEEKMESSAGEAPROC real_PeekMessageA;
extern GETMESSAGEAPROC real_GetMessageA;
extern GETWINDOWPLACEMENTPROC real_GetWindowPlacement;
+extern SETWINDOWPLACEMENTPROC real_SetWindowPlacement;
extern ENUMDISPLAYSETTINGSAPROC real_EnumDisplaySettingsA;
+extern DEFWINDOWPROCAPROC real_DefWindowProcA;
+extern SETPARENTPROC real_SetParent;
+extern BEGINPAINTPROC real_BeginPaint;
extern GETKEYSTATEPROC real_GetKeyState;
extern GETASYNCKEYSTATEPROC real_GetAsyncKeyState;
extern GETDEVICECAPSPROC real_GetDeviceCaps;
extern CREATEFONTINDIRECTAPROC real_CreateFontIndirectA;
extern CREATEFONTAPROC real_CreateFontA;
+extern GETSYSTEMPALETTEENTRIESPROC real_GetSystemPaletteEntries;
+extern SELECTPALETTEPROC real_SelectPalette;
+extern REALIZEPALETTEPROC real_RealizePalette;
extern LOADLIBRARYAPROC real_LoadLibraryA;
extern LOADLIBRARYWPROC real_LoadLibraryW;
extern LOADLIBRARYEXAPROC real_LoadLibraryExA;
@@ -127,6 +148,7 @@ extern GETVERSIONEXAPROC real_GetVersionExA;
extern COCREATEINSTANCEPROC real_CoCreateInstance;
extern MCISENDCOMMANDAPROC real_mciSendCommandA;
extern SETUNHANDLEDEXCEPTIONFILTERPROC real_SetUnhandledExceptionFilter;
+extern AVISTREAMGETFRAMEOPENPROC real_AVIStreamGetFrameOpen;
extern BOOL g_hook_active;
extern HOOKLIST g_hook_hooklist[];
diff --git a/inc/mouse.h b/inc/mouse.h
index 65ef0da..1181ac2 100644
--- a/inc/mouse.h
+++ b/inc/mouse.h
@@ -1,12 +1,9 @@
#ifndef MOUSE_H
#define MOUSE_H
-void mouse_hook_init();
-void mouse_hook_exit();
void mouse_lock();
void mouse_unlock();
-LRESULT CALLBACK mouse_gm_hook_proc(int code, WPARAM wParam, LPARAM lParam);
-LRESULT CALLBACK mouse_hook_proc(int code, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK mouse_hook_proc(int Code, WPARAM wParam, LPARAM lParam);
extern BOOL g_mouse_locked;
extern HHOOK g_mouse_hook;
diff --git a/inc/opengl_utils.h b/inc/opengl_utils.h
index 4449951..d84dd20 100644
--- a/inc/opengl_utils.h
+++ b/inc/opengl_utils.h
@@ -115,5 +115,6 @@ extern HMODULE g_oglu_hmodule;
extern BOOL g_oglu_got_version2;
extern BOOL g_oglu_got_version3;
extern char g_oglu_version[];
+extern char g_oglu_version_long[];
#endif
diff --git a/inc/palette.h b/inc/palette.h
new file mode 100644
index 0000000..8e38ec4
--- /dev/null
+++ b/inc/palette.h
@@ -0,0 +1,265 @@
+#ifndef PALETTE_H
+#define PALETTE_H
+
+// Original palette copied from Windows ME
+static PALETTEENTRY g_ddp_default_palette[] =
+{
+ { 0, 0, 0, 0 },
+ { 128, 0, 0, 0 },
+ { 0, 128, 0, 0 },
+ { 128, 128, 0, 0 },
+ { 0, 0, 128, 0 },
+ { 128, 0, 128, 0 },
+ { 0, 128, 128, 0 },
+ { 192, 192, 192, 0 },
+ { 192, 220, 192, 0 },
+ { 166, 202, 240, 0 },
+ { 95, 63, 63, 0 },
+ { 127, 63, 63, 0 },
+ { 159, 63, 63, 0 },
+ { 191, 63, 63, 0 },
+ { 223, 63, 63, 0 },
+ { 255, 63, 63, 0 },
+ { 63, 95, 63, 0 },
+ { 95, 95, 63, 0 },
+ { 127, 95, 63, 0 },
+ { 159, 95, 63, 0 },
+ { 191, 95, 63, 0 },
+ { 223, 95, 63, 0 },
+ { 255, 95, 63, 0 },
+ { 63, 127, 63, 0 },
+ { 95, 127, 63, 0 },
+ { 127, 127, 63, 0 },
+ { 159, 127, 63, 0 },
+ { 191, 127, 63, 0 },
+ { 223, 127, 63, 0 },
+ { 255, 127, 63, 0 },
+ { 63, 159, 63, 0 },
+ { 95, 159, 63, 0 },
+ { 127, 159, 63, 0 },
+ { 159, 159, 63, 0 },
+ { 191, 159, 63, 0 },
+ { 223, 159, 63, 0 },
+ { 255, 159, 63, 0 },
+ { 63, 191, 63, 0 },
+ { 95, 191, 63, 0 },
+ { 127, 191, 63, 0 },
+ { 159, 191, 63, 0 },
+ { 191, 191, 63, 0 },
+ { 223, 191, 63, 0 },
+ { 255, 191, 63, 0 },
+ { 63, 223, 63, 0 },
+ { 95, 223, 63, 0 },
+ { 127, 223, 63, 0 },
+ { 159, 223, 63, 0 },
+ { 191, 223, 63, 0 },
+ { 223, 223, 63, 0 },
+ { 255, 223, 63, 0 },
+ { 63, 255, 63, 0 },
+ { 95, 255, 63, 0 },
+ { 127, 255, 63, 0 },
+ { 159, 255, 63, 0 },
+ { 191, 255, 63, 0 },
+ { 223, 255, 63, 0 },
+ { 255, 255, 63, 0 },
+ { 63, 63, 95, 0 },
+ { 95, 63, 95, 0 },
+ { 127, 63, 95, 0 },
+ { 159, 63, 95, 0 },
+ { 191, 63, 95, 0 },
+ { 223, 63, 95, 0 },
+ { 255, 63, 95, 0 },
+ { 63, 95, 95, 0 },
+ { 95, 95, 95, 0 },
+ { 127, 95, 95, 0 },
+ { 159, 95, 95, 0 },
+ { 191, 95, 95, 0 },
+ { 223, 95, 95, 0 },
+ { 255, 95, 95, 0 },
+ { 63, 127, 95, 0 },
+ { 95, 127, 95, 0 },
+ { 127, 127, 95, 0 },
+ { 159, 127, 95, 0 },
+ { 191, 127, 95, 0 },
+ { 223, 127, 95, 0 },
+ { 255, 127, 95, 0 },
+ { 63, 159, 95, 0 },
+ { 95, 159, 95, 0 },
+ { 127, 159, 95, 0 },
+ { 159, 159, 95, 0 },
+ { 191, 159, 95, 0 },
+ { 223, 159, 95, 0 },
+ { 255, 159, 95, 0 },
+ { 63, 191, 95, 0 },
+ { 95, 191, 95, 0 },
+ { 127, 191, 95, 0 },
+ { 159, 191, 95, 0 },
+ { 191, 191, 95, 0 },
+ { 223, 191, 95, 0 },
+ { 255, 191, 95, 0 },
+ { 63, 223, 95, 0 },
+ { 95, 223, 95, 0 },
+ { 127, 223, 95, 0 },
+ { 159, 223, 95, 0 },
+ { 191, 223, 95, 0 },
+ { 223, 223, 95, 0 },
+ { 255, 223, 95, 0 },
+ { 63, 255, 95, 0 },
+ { 95, 255, 95, 0 },
+ { 127, 255, 95, 0 },
+ { 159, 255, 95, 0 },
+ { 191, 255, 95, 0 },
+ { 223, 255, 95, 0 },
+ { 255, 255, 95, 0 },
+ { 63, 63, 127, 0 },
+ { 95, 63, 127, 0 },
+ { 127, 63, 127, 0 },
+ { 159, 63, 127, 0 },
+ { 191, 63, 127, 0 },
+ { 223, 63, 127, 0 },
+ { 255, 63, 127, 0 },
+ { 63, 95, 127, 0 },
+ { 95, 95, 127, 0 },
+ { 127, 95, 127, 0 },
+ { 159, 95, 127, 0 },
+ { 191, 95, 127, 0 },
+ { 223, 95, 127, 0 },
+ { 255, 95, 127, 0 },
+ { 63, 127, 127, 0 },
+ { 95, 127, 127, 0 },
+ { 127, 127, 127, 0 },
+ { 159, 127, 127, 0 },
+ { 191, 127, 127, 0 },
+ { 223, 127, 127, 0 },
+ { 255, 127, 127, 0 },
+ { 63, 159, 127, 0 },
+ { 95, 159, 127, 0 },
+ { 127, 159, 127, 0 },
+ { 159, 159, 127, 0 },
+ { 191, 159, 127, 0 },
+ { 223, 159, 127, 0 },
+ { 255, 159, 127, 0 },
+ { 63, 191, 127, 0 },
+ { 95, 191, 127, 0 },
+ { 127, 191, 127, 0 },
+ { 159, 191, 127, 0 },
+ { 191, 191, 127, 0 },
+ { 223, 191, 127, 0 },
+ { 255, 191, 127, 0 },
+ { 63, 223, 127, 0 },
+ { 95, 223, 127, 0 },
+ { 127, 223, 127, 0 },
+ { 159, 223, 127, 0 },
+ { 191, 223, 127, 0 },
+ { 223, 223, 127, 0 },
+ { 255, 223, 127, 0 },
+ { 63, 255, 127, 0 },
+ { 95, 255, 127, 0 },
+ { 127, 255, 127, 0 },
+ { 159, 255, 127, 0 },
+ { 191, 255, 127, 0 },
+ { 223, 255, 127, 0 },
+ { 255, 255, 127, 0 },
+ { 63, 63, 159, 0 },
+ { 95, 63, 159, 0 },
+ { 127, 63, 159, 0 },
+ { 159, 63, 159, 0 },
+ { 191, 63, 159, 0 },
+ { 223, 63, 159, 0 },
+ { 255, 63, 159, 0 },
+ { 63, 95, 159, 0 },
+ { 95, 95, 159, 0 },
+ { 127, 95, 159, 0 },
+ { 159, 95, 159, 0 },
+ { 191, 95, 159, 0 },
+ { 223, 95, 159, 0 },
+ { 255, 95, 159, 0 },
+ { 63, 127, 159, 0 },
+ { 95, 127, 159, 0 },
+ { 127, 127, 159, 0 },
+ { 159, 127, 159, 0 },
+ { 191, 127, 159, 0 },
+ { 223, 127, 159, 0 },
+ { 255, 127, 159, 0 },
+ { 63, 159, 159, 0 },
+ { 95, 159, 159, 0 },
+ { 127, 159, 159, 0 },
+ { 159, 159, 159, 0 },
+ { 191, 159, 159, 0 },
+ { 223, 159, 159, 0 },
+ { 255, 159, 159, 0 },
+ { 63, 191, 159, 0 },
+ { 95, 191, 159, 0 },
+ { 127, 191, 159, 0 },
+ { 159, 191, 159, 0 },
+ { 191, 191, 159, 0 },
+ { 223, 191, 159, 0 },
+ { 255, 191, 159, 0 },
+ { 63, 223, 159, 0 },
+ { 95, 223, 159, 0 },
+ { 127, 223, 159, 0 },
+ { 159, 223, 159, 0 },
+ { 191, 223, 159, 0 },
+ { 223, 223, 159, 0 },
+ { 255, 223, 159, 0 },
+ { 63, 255, 159, 0 },
+ { 95, 255, 159, 0 },
+ { 127, 255, 159, 0 },
+ { 159, 255, 159, 0 },
+ { 191, 255, 159, 0 },
+ { 223, 255, 159, 0 },
+ { 255, 255, 159, 0 },
+ { 63, 63, 191, 0 },
+ { 95, 63, 191, 0 },
+ { 127, 63, 191, 0 },
+ { 159, 63, 191, 0 },
+ { 191, 63, 191, 0 },
+ { 223, 63, 191, 0 },
+ { 255, 63, 191, 0 },
+ { 63, 95, 191, 0 },
+ { 95, 95, 191, 0 },
+ { 127, 95, 191, 0 },
+ { 159, 95, 191, 0 },
+ { 191, 95, 191, 0 },
+ { 223, 95, 191, 0 },
+ { 255, 95, 191, 0 },
+ { 63, 127, 191, 0 },
+ { 95, 127, 191, 0 },
+ { 127, 127, 191, 0 },
+ { 159, 127, 191, 0 },
+ { 191, 127, 191, 0 },
+ { 223, 127, 191, 0 },
+ { 255, 127, 191, 0 },
+ { 63, 159, 191, 0 },
+ { 95, 159, 191, 0 },
+ { 127, 159, 191, 0 },
+ { 159, 159, 191, 0 },
+ { 191, 159, 191, 0 },
+ { 223, 159, 191, 0 },
+ { 255, 159, 191, 0 },
+ { 63, 191, 191, 0 },
+ { 95, 191, 191, 0 },
+ { 127, 191, 191, 0 },
+ { 159, 191, 191, 0 },
+ { 191, 191, 191, 0 },
+ { 223, 191, 191, 0 },
+ { 255, 191, 191, 0 },
+ { 63, 223, 191, 0 },
+ { 95, 223, 191, 0 },
+ { 127, 223, 191, 0 },
+ { 159, 223, 191, 0 },
+ { 191, 223, 191, 0 },
+ { 223, 223, 191, 0 },
+ { 255, 251, 240, 0 },
+ { 58, 109, 165, 0 },
+ { 128, 128, 128, 0 },
+ { 255, 0, 0, 0 },
+ { 0, 255, 0, 0 },
+ { 255, 255, 0, 0 },
+ { 0, 0, 255, 0 },
+ { 255, 0, 255, 0 },
+ { 0, 255, 255, 0 },
+ { 255, 255, 255, 0 }
+};
+
+#endif
diff --git a/inc/utils.h b/inc/utils.h
index beb1c57..3833ede 100644
--- a/inc/utils.h
+++ b/inc/utils.h
@@ -6,6 +6,10 @@
HMODULE WINAPI util_enumerate_modules(_In_opt_ HMODULE hModuleLast);
+void util_set_process_affinity();
+void util_set_thread_affinity(DWORD tid);
+void util_pull_messages();
+DWORD util_get_timestamp(HMODULE mod);
FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name);
BOOL util_caller_is_ddraw_wrapper(void* return_address);
BOOL util_is_bad_read_ptr(void* p);
diff --git a/inc/version.h b/inc/version.h
index 9fef507..29e19fa 100644
--- a/inc/version.h
+++ b/inc/version.h
@@ -3,12 +3,11 @@
#define str(s) #s
#define ver_str(a,b,c,d) str(a) "." str(b) "." str(c) "." str(d)
-#define git_str(a) str(a)
-#define VERSION_MAJOR 6
-#define VERSION_MINOR 8
+#define VERSION_MAJOR 7
+#define VERSION_MINOR 1
#define VERSION_BUILD 0
-#define VERSION_REVISION 3
+#define VERSION_REVISION 1
#define VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION
#define VERSION_STRING ver_str(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION)
diff --git a/inc/versionhelpers.h b/inc/versionhelpers.h
index 8a59f74..36f2dd6 100644
--- a/inc/versionhelpers.h
+++ b/inc/versionhelpers.h
@@ -28,9 +28,13 @@
#define _WIN32_WINNT_WIN11 0x0A00
#endif
+#if (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
+#define VerifyVersionInfoW(a,b,c) 0
+#define VerSetConditionMask verhelp_set_mask
+#endif
-void verhelp_init();
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask);
+ULONGLONG verhelp_set_mask(ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition);
const char* verhelp_wine_get_version();
void verhelp_wine_get_host_version(const char** sysname, const char** release);
@@ -56,6 +60,17 @@ VERSIONHELPERAPI IsWindowsVersion(DWORD major, DWORD minor, DWORD build, WORD se
VER_SERVICEPACKMAJOR, VER_EQUAL));
}
+VERSIONHELPERAPI IsWindowsVersionExcactBuild(DWORD major, DWORD minor, DWORD build, WORD servpack)
+{
+ RTL_OSVERSIONINFOEXW vi = { sizeof(vi),major,minor,build,0,{0},servpack };
+ return verhelp_verify_version(&vi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER | VER_SERVICEPACKMAJOR,
+ VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
+ VER_MAJORVERSION, VER_EQUAL),
+ VER_MINORVERSION, VER_EQUAL),
+ VER_BUILDNUMBER, VER_EQUAL),
+ VER_SERVICEPACKMAJOR, VER_EQUAL));
+}
+
VERSIONHELPERAPI IsWindowsVersionAnySP(DWORD major, DWORD minor, DWORD build)
{
RTL_OSVERSIONINFOEXW vi = { sizeof(vi),major,minor,build,0,{0},0 };
@@ -67,6 +82,10 @@ VERSIONHELPERAPI IsWindowsVersionAnySP(DWORD major, DWORD minor, DWORD build)
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
}
+VERSIONHELPERAPI IsWindows2000OrGreater(void) {
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN2K), LOBYTE(_WIN32_WINNT_WIN2K), 0, 0);
+}
+
VERSIONHELPERAPI IsWindowsXPOrGreater(void) {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 0);
}
@@ -127,11 +146,19 @@ VERSIONHELPERAPI IsWindows11OrGreater(void) {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN11), LOBYTE(_WIN32_WINNT_WIN11), 22000, 0);
}
+VERSIONHELPERAPI IsWindows11Version24H2OrGreater(void) {
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN11), LOBYTE(_WIN32_WINNT_WIN11), 26100, 0);
+}
+
VERSIONHELPERAPI IsWindowsServer(void) {
OSVERSIONINFOEXW vi = {sizeof(vi),0,0,0,0,{0},0,0,0,VER_NT_WORKSTATION};
return !verhelp_verify_version(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
}
+VERSIONHELPERAPI IsWindows2000(void) {
+ return IsWindowsVersionAnySP(HIBYTE(_WIN32_WINNT_WIN2K), LOBYTE(_WIN32_WINNT_WIN2K), 0);
+}
+
VERSIONHELPERAPI IsWindowsXP(void) {
return IsWindowsVersionAnySP(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
}
@@ -200,6 +227,10 @@ VERSIONHELPERAPI IsWindows11(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WIN11), LOBYTE(_WIN32_WINNT_WIN11), 22000, 0);
}
+VERSIONHELPERAPI IsWindows11Version24H2(void) {
+ return IsWindowsVersionExcactBuild(HIBYTE(_WIN32_WINNT_WIN11), LOBYTE(_WIN32_WINNT_WIN11), 26100, 0);
+}
+
VERSIONHELPERAPI IsWine(void) {
return verhelp_wine_get_version() != NULL;
}
diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h
index fa5c635..ad44c7e 100644
--- a/inc/winapi_hooks.h
+++ b/inc/winapi_hooks.h
@@ -2,6 +2,7 @@
#define WINAPI_HOOKS_H
#include
+#include
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint);
@@ -21,6 +22,7 @@ BOOL WINAPI fake_SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int
BOOL WINAPI fake_MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint);
LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong);
+LONG WINAPI fake_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong);
LONG WINAPI fake_GetWindowLongA(HWND hWnd, int nIndex);
BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable);
BOOL WINAPI fake_DestroyWindow(HWND hWnd);
@@ -33,10 +35,15 @@ HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, D
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
BOOL WINAPI fake_GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT* lpwndpl);
+BOOL WINAPI fake_SetWindowPlacement(HWND hWnd, const WINDOWPLACEMENT* lpwndpl);
BOOL WINAPI fake_EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, DEVMODEA* lpDevMode);
+LRESULT WINAPI fake_DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
+HWND WINAPI fake_SetParent(HWND hWndChild, HWND hWndNewParent);
+HDC WINAPI fake_BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
SHORT WINAPI fake_GetKeyState(int nVirtKey);
SHORT WINAPI fake_GetAsyncKeyState(int vKey);
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
+int WINAPI fake_GetDeviceCaps_system(HDC hdc, int index);
BOOL WINAPI fake_StretchBlt(
HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);
@@ -58,6 +65,9 @@ int WINAPI fake_StretchDIBits(
HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA*);
HFONT WINAPI fake_CreateFontA(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR);
+UINT WINAPI fake_GetSystemPaletteEntries(HDC, UINT, UINT, LPPALETTEENTRY);
+HPALETTE WINAPI fake_SelectPalette(HDC, HPALETTE, BOOL);
+UINT WINAPI fake_RealizePalette(HDC);
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);
@@ -87,4 +97,6 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI fake_SetUnhandledExceptionFilter(
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
+PGETFRAME WINAPI fake_AVIStreamGetFrameOpen(PAVISTREAM pavi, LPBITMAPINFOHEADER lpbiWanted);
+
#endif
diff --git a/inc/wndproc.h b/inc/wndproc.h
index 43a1e8e..4af4f7e 100644
--- a/inc/wndproc.h
+++ b/inc/wndproc.h
@@ -12,10 +12,15 @@
#define WM_RESTORE_STYLE WM_APP+119
#define IDT_TIMER_LEAVE_BNET 541287654
+#define IDT_TIMER_LINUX_FIX_WINDOW_SIZE 345267753
#define CNC_DDRAW_SET_FULLSCREEN 1
#define CNC_DDRAW_SET_WINDOWED 2
+#ifndef WM_UNICHAR
+#define WM_UNICHAR 0x0109
+#endif
+
LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#endif
diff --git a/src/IDirect3D/IDirect3D.c b/src/IDirect3D/IDirect3D.c
index 0aaa1e8..e4b0ee5 100644
--- a/src/IDirect3D/IDirect3D.c
+++ b/src/IDirect3D/IDirect3D.c
@@ -14,6 +14,11 @@ HRESULT __stdcall IDirect3D__QueryInterface(IDirect3DImpl* This, REFIID riid, vo
HRESULT ret = E_FAIL;
+ if (riid)
+ {
+ TRACE("NOT_IMPLEMENTED GUID = %08X\n", ((GUID*)riid)->Data1);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
@@ -51,10 +56,20 @@ HRESULT __stdcall IDirect3D__Initialize(IDirect3DImpl* This, int a)
return ret;
}
-HRESULT __stdcall IDirect3D__EnumDevices(IDirect3DImpl* This, int a, int b)
+HRESULT __stdcall IDirect3D__EnumDevices(
+ IDirect3DImpl* This,
+ LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
+ LPVOID lpUserArg)
{
TRACE("NOT_IMPLEMENTED -> %s(This=%p) [%p]\n", __FUNCTION__, This, _ReturnAddress());
- HRESULT ret = E_FAIL;
+ HRESULT ret = S_OK;
+
+ if (lpEnumDevicesCallback)
+ {
+ D3DDEVICEDESC desc = { 0 };
+ lpEnumDevicesCallback((GUID FAR*)&GUID_NULL, "NULL", "NULL", &desc, &desc, lpUserArg);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
diff --git a/src/IDirect3D/IDirect3D2.c b/src/IDirect3D/IDirect3D2.c
index 50ae5ec..c4f93ab 100644
--- a/src/IDirect3D/IDirect3D2.c
+++ b/src/IDirect3D/IDirect3D2.c
@@ -14,6 +14,11 @@ HRESULT __stdcall IDirect3D2__QueryInterface(IDirect3D2Impl* This, REFIID riid,
HRESULT ret = E_FAIL;
+ if (riid)
+ {
+ TRACE("NOT_IMPLEMENTED GUID = %08X\n", ((GUID*)riid)->Data1);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
@@ -43,10 +48,20 @@ ULONG __stdcall IDirect3D2__Release(IDirect3D2Impl* This)
return ret;
}
-HRESULT __stdcall IDirect3D2__EnumDevices(IDirect3D2Impl* This, int a, int b)
+HRESULT __stdcall IDirect3D2__EnumDevices(
+ IDirect3D2Impl* This,
+ LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
+ LPVOID lpUserArg)
{
TRACE("NOT_IMPLEMENTED -> %s(This=%p) [%p]\n", __FUNCTION__, This, _ReturnAddress());
- HRESULT ret = E_FAIL;
+ HRESULT ret = S_OK;
+
+ if (lpEnumDevicesCallback)
+ {
+ //D3DDEVICEDESC desc = { 0 };
+ //lpEnumDevicesCallback((GUID FAR*)&GUID_NULL, "NULL", "NULL", &desc, &desc, lpUserArg);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
diff --git a/src/IDirect3D/IDirect3D3.c b/src/IDirect3D/IDirect3D3.c
index 9cc65bd..8b6ff43 100644
--- a/src/IDirect3D/IDirect3D3.c
+++ b/src/IDirect3D/IDirect3D3.c
@@ -14,6 +14,11 @@ HRESULT __stdcall IDirect3D3__QueryInterface(IDirect3D3Impl* This, REFIID riid,
HRESULT ret = E_FAIL;
+ if (riid)
+ {
+ TRACE("NOT_IMPLEMENTED GUID = %08X\n", ((GUID*)riid)->Data1);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
@@ -43,10 +48,20 @@ ULONG __stdcall IDirect3D3__Release(IDirect3D3Impl* This)
return ret;
}
-HRESULT __stdcall IDirect3D3__EnumDevices(IDirect3D3Impl* This, int a, int b)
+HRESULT __stdcall IDirect3D3__EnumDevices(
+ IDirect3D3Impl* This,
+ LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
+ LPVOID lpUserArg)
{
TRACE("NOT_IMPLEMENTED -> %s(This=%p) [%p]\n", __FUNCTION__, This, _ReturnAddress());
- HRESULT ret = E_FAIL;
+ HRESULT ret = S_OK;
+
+ if (lpEnumDevicesCallback)
+ {
+ //D3DDEVICEDESC desc = { 0 };
+ //lpEnumDevicesCallback((GUID FAR*)&GUID_NULL, "NULL", "NULL", &desc, &desc, lpUserArg);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
diff --git a/src/IDirect3D/IDirect3D7.c b/src/IDirect3D/IDirect3D7.c
index 5d64fc6..0102923 100644
--- a/src/IDirect3D/IDirect3D7.c
+++ b/src/IDirect3D/IDirect3D7.c
@@ -14,6 +14,11 @@ HRESULT __stdcall IDirect3D7__QueryInterface(IDirect3D7Impl* This, REFIID riid,
HRESULT ret = E_FAIL;
+ if (riid)
+ {
+ TRACE("NOT_IMPLEMENTED GUID = %08X\n", ((GUID*)riid)->Data1);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
@@ -43,10 +48,20 @@ ULONG __stdcall IDirect3D7__Release(IDirect3D7Impl* This)
return ret;
}
-HRESULT __stdcall IDirect3D7__EnumDevices(IDirect3D7Impl* This, int a, int b)
+HRESULT __stdcall IDirect3D7__EnumDevices(
+ IDirect3D7Impl* This,
+ LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback,
+ LPVOID lpUserArg)
{
TRACE("NOT_IMPLEMENTED -> %s(This=%p) [%p]\n", __FUNCTION__, This, _ReturnAddress());
- HRESULT ret = E_FAIL;
+ HRESULT ret = S_OK;
+
+ if (lpEnumDevicesCallback)
+ {
+ //D3DDEVICEDESC7 desc = { 0 };
+ //lpEnumDevicesCallback("NULL", "NULL", &desc, lpUserArg);
+ }
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
diff --git a/src/IDirectDraw/IDirectDraw.c b/src/IDirectDraw/IDirectDraw.c
index 7bff5f0..9384714 100644
--- a/src/IDirectDraw/IDirectDraw.c
+++ b/src/IDirectDraw/IDirectDraw.c
@@ -56,7 +56,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid
ret = S_OK;
}
- else if (IsEqualGUID(&IID_IDirect3D, riid) && !g_config.direct3d_passthrough)
+ else if (IsEqualGUID(&IID_IDirect3D, riid))
{
IDirect3DImpl* d3d =
(IDirect3DImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DImpl));
@@ -70,7 +70,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid
ret = S_OK;
}
- else if (IsEqualGUID(&IID_IDirect3D2, riid) && !g_config.direct3d_passthrough)
+ else if (IsEqualGUID(&IID_IDirect3D2, riid))
{
IDirect3D2Impl* d3d =
(IDirect3D2Impl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D2Impl));
@@ -84,7 +84,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid
ret = S_OK;
}
- else if (IsEqualGUID(&IID_IDirect3D3, riid) && !g_config.direct3d_passthrough)
+ else if (IsEqualGUID(&IID_IDirect3D3, riid))
{
IDirect3D3Impl* d3d =
(IDirect3D3Impl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D3Impl));
@@ -98,7 +98,7 @@ HRESULT __stdcall IDirectDraw__QueryInterface(IDirectDrawImpl* This, REFIID riid
ret = S_OK;
}
- else if (IsEqualGUID(&IID_IDirect3D7, riid) && !g_config.direct3d_passthrough)
+ else if (IsEqualGUID(&IID_IDirect3D7, riid))
{
IDirect3D7Impl* d3d =
(IDirect3D7Impl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D7Impl));
@@ -328,8 +328,18 @@ HRESULT __stdcall IDirectDraw__EnumSurfaces(
LPVOID lpContext,
LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback)
{
- TRACE("NOT_IMPLEMENTED -> %s(This=%p) [%p]\n", __FUNCTION__, This, _ReturnAddress());
+ TRACE(
+ "NOT_IMPLEMENTED -> %s(This=%p, dwFlags=%08X, lpDDSurfaceDesc=%p, lpContext=%p, lpEnumSurfacesCallback=%p) [%p]\n",
+ __FUNCTION__,
+ This,
+ dwFlags,
+ lpDDSurfaceDesc,
+ lpContext,
+ lpEnumSurfacesCallback,
+ _ReturnAddress());
+
HRESULT ret = DD_OK;
+
TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__);
return ret;
}
diff --git a/src/IDirectDraw/IDirectDrawSurface.c b/src/IDirectDraw/IDirectDrawSurface.c
index 3eec3e6..7916405 100644
--- a/src/IDirectDraw/IDirectDrawSurface.c
+++ b/src/IDirectDraw/IDirectDrawSurface.c
@@ -340,7 +340,7 @@ HRESULT __stdcall IDirectDrawSurface__GetDC(IDirectDrawSurfaceImpl* This, HDC FA
HRESULT __stdcall IDirectDrawSurface__GetFlipStatus(IDirectDrawSurfaceImpl* This, DWORD dwFlags)
{
- TRACE_EXT("-> %s(This=%p) [%p]\n", __FUNCTION__, This, _ReturnAddress());
+ TRACE_EXT("-> %s(This=%p, dwFlags=%08X) [%p]\n", __FUNCTION__, This, dwFlags, _ReturnAddress());
HRESULT ret = DD_OK;
TRACE_EXT("<- %s\n", __FUNCTION__);
return ret;
diff --git a/src/blt.c b/src/blt.c
index 0c212aa..166e3dd 100644
--- a/src/blt.c
+++ b/src/blt.c
@@ -518,7 +518,7 @@ void blt_colorfill(
if (bpp == 8 ||
(bpp == 16 &&
(color & 0xFF) == ((color >> 8) & 0xFF)) ||
- (bpp == 32 &&
+ ((bpp == 32 || bpp == 24) &&
(color & 0xFF) == ((color >> 8) & 0xFF) &&
(color & 0xFF) == ((color >> 16) & 0xFF) &&
(color & 0xFF) == ((color >> 24) & 0xFF)))
diff --git a/src/config.c b/src/config.c
index a5e5d3a..36b756a 100644
--- a/src/config.c
+++ b/src/config.c
@@ -52,6 +52,10 @@ void cfg_load()
GET_INT(g_config.save_settings, "savesettings", 1);
GET_BOOL(g_config.resizable, "resizable", TRUE);
GET_INT(g_config.d3d9_filter, "d3d9_filter", FILTER_CUBIC);
+ GET_INT(g_config.anti_aliased_fonts_min_size, "anti_aliased_fonts_min_size", 13);
+ GET_INT(g_config.min_font_size, "min_font_size", 0);
+ GET_INT(g_config.center_window, "center_window", CENTER_WINDOW_AUTO);
+ GET_STRING("inject_resolution", "", g_config.inject_resolution, sizeof(g_config.inject_resolution));
GET_BOOL(g_config.vhack, "vhack", FALSE);
GET_STRING("screenshotdir", ".\\Screenshots\\", g_config.screenshot_dir, sizeof(g_config.screenshot_dir));
GET_BOOL(g_config.toggle_borderless, "toggle_borderless", FALSE);
@@ -67,37 +71,36 @@ void cfg_load()
GET_BOOL(g_config.singlecpu, "singlecpu", TRUE);
GET_INT(g_config.resolutions, "resolutions", RESLIST_NORMAL);
GET_INT(g_config.fixchilds, "fixchilds", FIX_CHILDS_DETECT_PAINT);
- GET_STRING("win_version", "", g_config.win_version, sizeof(g_config.win_version));
+ GET_BOOL(g_config.hook_peekmessage, "hook_peekmessage", FALSE);
/* Undocumented settings */
- GET_BOOL(g_config.releasealt, "releasealt", FALSE);
+ GET_BOOL(g_config.fix_alt_key_stuck, "fix_alt_key_stuck", FALSE);
GET_BOOL(GameHandlesClose, "game_handles_close", FALSE);
- GET_BOOL(g_config.fixnotresponding, "fixnotresponding", FALSE);
- GET_INT(g_config.hook, "hook", 4);
+ GET_BOOL(g_config.fix_not_responding, "fix_not_responding", FALSE);
+ GET_BOOL(g_config.no_compat_warning, "no_compat_warning", FALSE);
GET_INT(g_config.guard_lines, "guard_lines", 200);
GET_INT(g_config.max_resolutions, "max_resolutions", 0);
GET_BOOL(g_config.lock_surfaces, "lock_surfaces", FALSE);
GET_BOOL(g_config.flipclear, "flipclear", FALSE);
- GET_BOOL(g_config.fixmousehook, "fixmousehook", FALSE);
GET_BOOL(g_config.rgb555, "rgb555", FALSE);
GET_BOOL(g_config.no_dinput_hook, "no_dinput_hook", FALSE);
- GET_INT(g_config.refresh_rate, "refresh_rate", 0);
- GET_INT(g_config.anti_aliased_fonts_min_size, "anti_aliased_fonts_min_size", 13);
- GET_STRING("inject_resolution", "", g_config.inject_resolution, sizeof(g_config.inject_resolution));
- GET_INT(g_config.min_font_size, "min_font_size", 0);
- GET_BOOL(g_config.direct3d_passthrough, "direct3d_passthrough", FALSE);
GET_BOOL(g_config.center_cursor_fix, "center_cursor_fix", FALSE);
GET_STRING("fake_mode", "", g_config.fake_mode, sizeof(g_config.fake_mode));
- GET_BOOL(g_config.wine_allow_resize, "wine_allow_resize", FALSE);
GET_BOOL(g_config.lock_mouse_top_left, "lock_mouse_top_left", FALSE);
- GET_BOOL(g_config.no_compat_warning, "no_compat_warning", FALSE);
+ GET_STRING("win_version", "", g_config.win_version, sizeof(g_config.win_version));
+ GET_INT(g_config.hook, "hook", 4);
+ GET_BOOL(g_config.limit_gdi_handles, "limit_gdi_handles", FALSE);
GET_BOOL(g_config.remove_menu, "remove_menu", FALSE);
+ GET_INT(g_config.refresh_rate, "refresh_rate", 0);
+ GET_BOOL(g_config.terminate_process, "terminate_process", FALSE);
/* Hotkeys */
GET_INT(g_config.hotkeys.toggle_fullscreen, "keytogglefullscreen", VK_RETURN);
+ GET_INT(g_config.hotkeys.toggle_fullscreen2, "keytogglefullscreen2", 0);
GET_INT(g_config.hotkeys.toggle_maximize, "keytogglemaximize", VK_NEXT);
+ GET_INT(g_config.hotkeys.toggle_maximize2, "keytogglemaximize2", 0);
GET_INT(g_config.hotkeys.unlock_cursor1, "keyunlockcursor1", VK_TAB);
GET_INT(g_config.hotkeys.unlock_cursor2, "keyunlockcursor2", VK_RCONTROL);
GET_INT(g_config.hotkeys.screenshot, "keyscreenshot", VK_SNAPSHOT);
@@ -110,9 +113,11 @@ void cfg_load()
GET_BOOL(g_config.stronghold_hack, "stronghold_hack", FALSE);
GET_BOOL(g_config.mgs_hack, "mgs_hack", FALSE);
GET_BOOL(g_config.tlc_hack, "tlc_hack", FALSE);
- GET_BOOL(g_config.homm_hack, "homm_hack", FALSE);
GET_BOOL(g_config.carma95_hack, "carma95_hack", FALSE);
-
+ GET_BOOL(g_config.sirtech_hack, "sirtech_hack", FALSE);
+ GET_BOOL(g_config.flightsim98_hack, "flightsim98_hack", FALSE);
+ GET_BOOL(g_config.darkcolony_hack, "darkcolony_hack", FALSE);
+
GameHandlesClose = GameHandlesClose || g_config.infantryhack;
if (g_config.lock_mouse_top_left)
@@ -129,6 +134,10 @@ void cfg_save()
if (!g_config.save_settings)
return;
+ /* Do not save settings while macOS maximize is active */
+ if (IsMacOS() && !g_config.window_rect.left && !g_config.window_rect.top)
+ return;
+
char buf[16];
char* section = g_config.save_settings == 1 ? "ddraw" : g_config.process_file_name;
@@ -248,6 +257,14 @@ static void cfg_create_ini()
"; Raise the size of small fonts to X\n"
"min_font_size=0\n"
"\n"
+ "; Center window to screen when game changes the display resolution\n"
+ "; Possible values: 0 = never center, 1 = automatic, 2 = always center\n"
+ "center_window=1\n"
+ "\n"
+ "; Inject a custom display resolution into the in-game resolution list - Example values: 960x540, 3840x2160\n"
+ "; Note: This setting can used for downscaling as well, you can insert resolutions higher than your monitor supports\n"
+ "inject_resolution=\n"
+ "\n"
"; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1, Worms 2 and KKND Xtreme)\n"
"vhack=false\n"
"\n"
@@ -274,7 +291,7 @@ static void cfg_create_ini()
"; Note: Usually one of the following values will work: 60 / 30 / 25 / 20 / 15 (lower value = slower game speed)\n"
"maxgameticks=0\n"
"\n"
- "; Method that should be used to limit game ticks (maxgameticks=): 0 = Automatic, 1 = TestCooperativeLevel, 2 = BltFast, 3 = Unlock\n"
+ "; Method that should be used to limit game ticks (maxgameticks=): 0 = Automatic, 1 = TestCooperativeLevel, 2 = BltFast, 3 = Unlock, 4 = PeekMessage\n"
"limiter_type=0\n"
"\n"
"; Force minimum FPS, possible values: 0 = disabled, -1 = use 'maxfps=' value, -2 = same as -1 but force full redraw, 1-1000 = custom FPS\n"
@@ -289,7 +306,7 @@ static void cfg_create_ini()
"; Note: Disable this if the game is not running smooth or there are sound issues\n"
"singlecpu=true\n"
"\n"
- "; Available resolutions, possible values: 0 = Small list, 1 = Very small list, 2 = Full list\n"
+ "; Available display resolutions, possible values: 0 = Small list, 1 = Very small list, 2 = Full list\n"
"; Note: Set this to 2 if your chosen resolution is not working or does not show up in the list\n"
"; Note: Set this to 1 if the game is crashing on startup\n"
"resolutions=0\n"
@@ -298,29 +315,30 @@ static void cfg_create_ini()
"; Note: Disables upscaling if a child window was detected (to ensure the game is fully playable, may look weird though)\n"
"fixchilds=2\n"
"\n"
+ "; Enable the following setting if your cursor doesn't lock to the window or it doesn't work properly when upscaling is enabled\n"
+ "hook_peekmessage=false\n"
"\n"
- "; Undocumented settings - You may or may not change these (You should rather focus on the settings above)\n"
- "releasealt=false\n"
+ "\n"
+ "; Undocumented compatibility settings - These will probably not solve your problem, you should rather focus on the settings above\n"
+ "fix_alt_key_stuck=false\n"
"game_handles_close=false\n"
- "fixnotresponding=false\n"
- "hook=4\n"
+ "fix_not_responding=false\n"
+ "no_compat_warning=false\n"
"guard_lines=200\n"
"max_resolutions=0\n"
"lock_surfaces=false\n"
"flipclear=false\n"
- "fixmousehook=false\n"
"rgb555=false\n"
"no_dinput_hook=false\n"
- "refresh_rate=0\n"
- ";inject_resolution=960x540\n"
- "direct3d_passthrough=false\n"
"center_cursor_fix=false\n"
";fake_mode=640x480x32\n"
- "wine_allow_resize=false\n"
"lock_mouse_top_left=false\n"
- "no_compat_warning=false\n"
- "remove_menu=false\n"
";win_version=95\n"
+ "hook=4\n"
+ "limit_gdi_handles=false\n"
+ "remove_menu=false\n"
+ "refresh_rate=0\n"
+ "terminate_process=false\n"
"\n"
"\n"
"\n"
@@ -332,9 +350,15 @@ static void cfg_create_ini()
"; Switch between windowed and fullscreen mode = [Alt] + ???\n"
"keytogglefullscreen=0x0D\n"
"\n"
+ "; Switch between windowed and fullscreen mode (single key) = ???\n"
+ "keytogglefullscreen2=0x00\n"
+ "\n"
"; Maximize window = [Alt] + ???\n"
"keytogglemaximize=0x22\n"
"\n"
+ "; Maximize window (single key) = ???\n"
+ "keytogglemaximize2=0x00\n"
+ "\n"
"; Unlock cursor 1 = [Ctrl] + ???\n"
"keyunlockcursor1=0x09\n"
"\n"
@@ -350,7 +374,7 @@ static void cfg_create_ini()
"; The following settings are for cnc-ddraw config.exe\n"
"\n"
"\n"
- "; cnc-ddraw config program language, possible values: auto, english, chinese, german, spanish, russian, hungarian, french, italian, vietnamese\n"
+ "; cnc-ddraw config program language, possible values: auto, english, chinese, german, spanish, russian, hungarian, french, italian, vietnamese, polish\n"
"configlang=auto\n"
"\n"
"; cnc-ddraw config program theme, possible values: Windows10, Cobalt XEMedia\n"
@@ -368,10 +392,24 @@ static void cfg_create_ini()
"; The following settings override all settings shown above, section name = executable name\n"
"\n"
"\n"
+ "; 101: The Airborne Invasion of Normandy\n"
+ "[101]\n"
+ "terminate_process=true\n"
+ "\n"
+ "; 7th Legion\n"
+ "[legion]\n"
+ "maxgameticks=25\n"
+ "\n"
"; Atrox\n"
"[Atrox]\n"
"nonexclusive=true\n"
"\n"
+ "; Arcatera the Dark Brotherhood\n"
+ "[darksun]\n"
+ "maxgameticks=60\n"
+ "maxfps=60\n"
+ "minfps=-1\n"
+ "\n"
"; Atomic Bomberman\n"
"[BM]\n"
"maxgameticks=60\n"
@@ -415,6 +453,22 @@ static void cfg_create_ini()
"fake_mode=640x480x32\n"
"nonexclusive=true\n"
"\n"
+ "; Age of Wonders\n"
+ "[AoW]\n"
+ "resolutions=2\n"
+ "nonexclusive=false\n"
+ "singlecpu=false\n"
+ "\n"
+ "; Age of Wonders\n"
+ "[AoWCompat]\n"
+ "resolutions=2\n"
+ "nonexclusive=false\n"
+ "singlecpu=false\n"
+ "\n"
+ "; Age of Wonders Config Tool\n"
+ "[AoWSetup]\n"
+ "resolutions=2\n"
+ "\n"
"; Age of Wonders 2\n"
"[AoW2]\n"
"resolutions=2\n"
@@ -456,6 +510,30 @@ static void cfg_create_ini()
"[1602]\n"
"adjmouse=true\n"
"\n"
+ "; Army Men: World War / Army Men: Operation Meltdown\n"
+ "[amww]\n"
+ "maxfps=60\n"
+ "maxgameticks=120\n"
+ "minfps=-1\n"
+ "\n"
+ "; Army Men: Air Tactics\n"
+ "[Amat]\n"
+ "maxfps=60\n"
+ "maxgameticks=120\n"
+ "minfps=-1\n"
+ "\n"
+ "; Army Men: Toys in Space\n"
+ "[ARMYMENTIS]\n"
+ "maxfps=60\n"
+ "maxgameticks=120\n"
+ "minfps=-1\n"
+ "\n"
+ "; Army Men 2\n"
+ "[ArmyMen2]\n"
+ "maxfps=60\n"
+ "maxgameticks=120\n"
+ "minfps=-1\n"
+ "\n"
"; Alien Nations\n"
"[AN]\n"
"adjmouse=true\n"
@@ -463,7 +541,7 @@ static void cfg_create_ini()
"; Atlantis\n"
"[ATLANTIS]\n"
"renderer=opengl\n"
- "maxgameticks=60\n"
+ "maxgameticks=30\n"
"center_cursor_fix=true\n"
"\n"
"; Airline Tycoon Deluxe\n"
@@ -477,8 +555,13 @@ static void cfg_create_ini()
"\n"
"; Axis & Allies\n"
"[AxisAllies]\n"
+ "hook_peekmessage=true\n"
"maxgameticks=60\n"
"\n"
+ "; A Bug's Life Action Game\n"
+ "[bugs]\n"
+ "fix_not_responding=true\n"
+ "\n"
"; Barney - Secret of the Rainbow\n"
"[Barney]\n"
"adjmouse=false\n"
@@ -493,6 +576,11 @@ static void cfg_create_ini()
"[BGMain]\n"
"resolutions=2\n"
"\n"
+ "; Balls of Steel v1.2\n"
+ "[bos]\n"
+ "checkfile=.\\barbarin.ddp\n"
+ "win_version=95\n"
+ "\n"
"; BALDR FORCE EXE\n"
"[BaldrForce]\n"
"noactivateapp=true\n"
@@ -716,6 +804,14 @@ static void cfg_create_ini()
"nonexclusive=true\n"
"adjmouse=true\n"
"\n"
+ "; Cloud Kingdom 3 (only with /ddraw command line parameter)\n"
+ "[Clouds Kingdom 3]\n"
+ "fake_mode=320x240x32\n"
+ "\n"
+ "; Commando 2004 (only with /ddraw command line parameter)\n"
+ "[commando]\n"
+ "fake_mode=320x240x32\n"
+ "\n"
"; Chris Sawyer's Locomotion\n"
"[LOCO/2]\n"
"checkfile=.\\LOCO.EXE\n"
@@ -731,21 +827,30 @@ static void cfg_create_ini()
"\n"
"; Close Combat 2: A Bridge Too Far\n"
"[cc2]\n"
+ "maxgameticks=20\n"
+ "limiter_type=4\n"
+ "minfps=15\n"
"adjmouse=true\n"
"nonexclusive=true\n"
"\n"
"; Close Combat 3: The Russian Front\n"
"[cc3]\n"
+ "maxgameticks=30\n"
+ "limiter_type=2\n"
"adjmouse=true\n"
"nonexclusive=true\n"
"\n"
"; Close Combat 4: The Battle of the Bulge\n"
"[cc4]\n"
+ "maxgameticks=30\n"
+ "limiter_type=2\n"
"adjmouse=true\n"
"nonexclusive=true\n"
"\n"
"; Close Combat 5: Invasion: Normandy\n"
"[cc5]\n"
+ "maxgameticks=30\n"
+ "limiter_type=2\n"
"adjmouse=true\n"
"nonexclusive=true\n"
"\n"
@@ -776,17 +881,33 @@ static void cfg_create_ini()
"[corsairs]\n"
"adjmouse=true\n"
"\n"
+ "; Dark Colony\n"
+ "[dc16]\n"
+ "maxgameticks=30\n"
+ "darkcolony_hack=true\n"
+ "hook_peekmessage=true\n"
+ "\n"
"; Divine Divinity\n"
"[div]\n"
"resolutions=2\n"
"singlecpu=false\n"
"\n"
+ "; Die by the Sword\n"
+ "[windie]\n"
+ "maxgameticks=30\n"
+ "\n"
"; Dragon Throne: Battle of Red Cliffs\n"
"[AdSanguo]\n"
"maxgameticks=60\n"
"noactivateapp=true\n"
"limiter_type=2\n"
"\n"
+ "; Dark Secret of Africa\n"
+ "[Game/5]\n"
+ "checkfile=.\\CONFIG.CFG\n"
+ "maxfps=60\n"
+ "minfps=-1\n"
+ "\n"
"; Dark Reign: The Future of War\n"
"[DKReign]\n"
"maxgameticks=60\n"
@@ -796,6 +917,10 @@ static void cfg_create_ini()
"maxgameticks=60\n"
"noactivateapp=true\n"
"\n"
+ "; Dreams to Realty\n"
+ "[windream]\n"
+ "maxgameticks=60\n"
+ "\n"
"; Deadlock 2\n"
"[DEADLOCK]\n"
"fixchilds=0\n"
@@ -817,9 +942,18 @@ static void cfg_create_ini()
"lock_mouse_top_left=true\n"
"renderer=gdi\n"
"\n"
+ "; Discoworld Noir\n"
+ "[dn]\n"
+ "fake_mode=640x480x16\n"
+ "\n"
+ "; Dominion - Storm Over Gift 3\n"
+ "[dominion]\n"
+ "flipclear=true\n"
+ "\n"
"; Escape Velocity Nova\n"
"[EV Nova]\n"
"nonexclusive=true\n"
+ "hook_peekmessage=true\n"
"rgb555=true\n"
"keytogglefullscreen=0x46\n"
"adjmouse=true\n"
@@ -827,17 +961,56 @@ static void cfg_create_ini()
"; Economic War\n"
"[EcoW]\n"
"maxgameticks=60\n"
- "fixnotresponding=true\n"
+ "fix_not_responding=true\n"
"\n"
"; Emperor: Rise of the Middle Kingdom\n"
"[Emperor]\n"
"nonexclusive=true\n"
"adjmouse=true\n"
"\n"
+ "; Enemy Infestation\n"
+ "[EI]\n"
+ "hook_peekmessage=true\n"
+ "\n"
+ "; F-16 Agressor\n"
+ "[f-16]\n"
+ "resolutions=1\n"
+ "\n"
+ "; Fallout Tactics: Brotherhood of Steel\n"
+ "[BOS/2]\n"
+ "checkfile=.\\binkw32.dll\n"
+ "hook_peekmessage=true\n"
+ "\n"
+ "; Fallout Tactics: Brotherhood of Steel\n"
+ "[BOS_HR]\n"
+ "hook_peekmessage=true\n"
+ "\n"
+ "; Fallout Tactics: Brotherhood of Steel\n"
+ "[FT Tools]\n"
+ "hook_peekmessage=true\n"
+ "\n"
+ "; Flight Simulator 98\n"
+ "[FLTSIM95]\n"
+ "flightsim98_hack=true\n"
+ "\n"
+ "; Flight Simulator 98\n"
+ "[FLTSIM98]\n"
+ "flightsim98_hack=true\n"
+ "\n"
"; Fairy Tale About Father Frost, Ivan and Nastya\n"
"[mrazik]\n"
"guard_lines=0\n"
"\n"
+ "; Fable\n"
+ "[Fable]\n"
+ "maxgameticks=59\n"
+ "limiter_type=4\n"
+ "\n"
+ "; Final Liberation: Warhammer Epic 40000\n"
+ "[Epic40k]\n"
+ "hook_peekmessage=true\n"
+ "maxgameticks=125\n"
+ "\n"
"; Future Cop - L.A.P.D.\n"
"[FCopLAPD]\n"
"nonexclusive=true\n"
@@ -882,7 +1055,7 @@ static void cfg_create_ini()
"\n"
"; Glover\n"
"[glover]\n"
- "fixnotresponding=true\n"
+ "fix_not_responding=true\n"
"\n"
"; G-Police\n"
"[GPOLICE]\n"
@@ -892,6 +1065,8 @@ static void cfg_create_ini()
"[gangsters]\n"
"adjmouse=true\n"
"nonexclusive=true\n"
+ "fixchilds=0\n"
+ "fake_mode=640x480x8\n"
"\n"
"; Grand Theft Auto\n"
"[Grand Theft Auto]\n"
@@ -914,20 +1089,20 @@ static void cfg_create_ini()
"; Girl Talk\n"
"[GirlTalk]\n"
"resolutions=2\n"
+ "game_handles_close=true\n"
"\n"
"; Jazz Jackrabbit 2 plus\n"
"[Jazz2]\n"
- "keytogglefullscreen=0x08\n"
"inject_resolution=800x450\n"
"\n"
"; Jazz Jackrabbit 2\n"
"[Jazz2_NonPlus]\n"
- "keytogglefullscreen=0x08\n"
"inject_resolution=800x450\n"
"\n"
"; Jungle Storm\n"
"[Jstorm]\n"
"no_compat_warning=true\n"
+ "win_version=98\n"
"\n"
"; Hades Challenge\n"
"[HADESCH]\n"
@@ -936,28 +1111,30 @@ static void cfg_create_ini()
"; Heroes of Might and Magic II: The Succession Wars\n"
"[HEROES2W]\n"
"adjmouse=true\n"
+ "game_handles_close=true\n"
+ "keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic III\n"
"[Heroes3]\n"
"renderer=opengl\n"
"game_handles_close=true\n"
- "homm_hack=true\n"
+ "keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic III HD Mod\n"
"[Heroes3 HD]\n"
"renderer=opengl\n"
"game_handles_close=true\n"
- "homm_hack=true\n"
+ "keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic III - Master of Puppets mod\n"
"[MoP]\n"
"game_handles_close=true\n"
- "homm_hack=true\n"
+ "keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic IV\n"
"[heroes4]\n"
"remove_menu=true\n"
- "homm_hack=true\n"
+ "keytogglefullscreen2=0x73\n"
"\n"
"; Hard Truck: Road to Victory\n"
"[htruck]\n"
@@ -965,6 +1142,19 @@ static void cfg_create_ini()
"renderer=opengl\n"
"noactivateapp=true\n"
"\n"
+ "; Hooligans: Storm over Europe\n"
+ "[hooligans]\n"
+ "limit_gdi_handles=true\n"
+ "\n"
+ "; Imperialism 2: The Age of Exploration\n"
+ "[Imperialism II]\n"
+ "adjmouse=false\n"
+ "width=0\n"
+ "height=0\n"
+ "resizable=false\n"
+ "maintas=false\n"
+ "boxing=false\n"
+ "\n"
"; Icewind Dale 2\n"
"; Note: 'Full Screen' must be enabled in Config.exe\n"
"; Note: 1070x602 is the lowest possible 16:9 resolution for the Widescreen patch (600/601 height will crash)\n"
@@ -996,44 +1186,48 @@ static void cfg_create_ini()
"; Jagged Alliance 2\n"
"[ja2]\n"
"singlecpu=false\n"
- "fixmousehook=true\n"
- "releasealt=true\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
"; Jagged Alliance 2: Unfinished Business\n"
"[JA2UB]\n"
"singlecpu=false\n"
- "fixmousehook=true\n"
- "releasealt=true\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
"; Jagged Alliance 2: Wildfire\n"
"[WF6]\n"
"singlecpu=false\n"
- "fixmousehook=true\n"
- "releasealt=true\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
"; Jagged Alliance 2 - UC mod\n"
"[JA2_UC]\n"
"singlecpu=false\n"
- "fixmousehook=true\n"
- "releasealt=true\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
"; Jagged Alliance 2 - Vengeance Reloaded mod\n"
"[JA2_Vengeance]\n"
"singlecpu=false\n"
- "fixmousehook=true\n"
- "releasealt=true\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
- "; Jedi Knight Dark Forces 2\n"
- "[JK]\n"
- "direct3d_passthrough=true\n"
+ "; Jagged Alliance 2 - Vengeance Reloaded mod German exe\n"
+ "[JA2_Vengeance_DE]\n"
+ "singlecpu=false\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
"; Jeopardy! - NOT WORKING YET\n"
"[jeoppc]\n"
"singlecpu=false\n"
"\n"
- "; Kings Quest 8\n"
- "[Mask]\n"
- "renderer=opengl\n"
+ "; Karma Immortal Wrath\n"
+ "[karma]\n"
+ "fix_not_responding=true\n"
+ "maxgameticks=60\n"
+ "limiter_type=4\n"
"\n"
"; Konung\n"
"[konung]\n"
@@ -1061,6 +1255,15 @@ static void cfg_create_ini()
"limiter_type=2\n"
"maxgameticks=60\n"
"\n"
+ "; Lode Runner 2\n"
+ "[LR2]\n"
+ "no_dinput_hook=true\n"
+ "fake_mode=640x480x16\n"
+ "\n"
+ "; Last Bronx\n"
+ "[LB]\n"
+ "maxgameticks=30\n"
+ "\n"
"; Lapis (lapis.mgame.com)\n"
"[Lapis]\n"
"fixchilds=3\n"
@@ -1102,6 +1305,22 @@ static void cfg_create_ini()
"maintas=false\n"
"boxing=false\n"
"\n"
+ "; Lionheart\n"
+ "[Lionheart]\n"
+ "hook_peekmessage=true\n"
+ "\n"
+ "; Lost Vikings 2\n"
+ "[LOSTV95]\n"
+ "fake_mode=320x240x16\n"
+ "\n"
+ "; Nightmare Creatures\n"
+ "[NC]\n"
+ "maxgameticks=30\n"
+ "\n"
+ "; Moto Racer (software mode)\n"
+ "[moto]\n"
+ "maxgameticks=59\n"
+ "\n"
"; Madeline 1st Grade Math\n"
"[madmath1]\n"
"nonexclusive=true\n"
@@ -1112,6 +1331,9 @@ static void cfg_create_ini()
"resizable=false\n"
"maintas=false\n"
"boxing=false\n"
+ "renderer=gdi\n"
+ "hook=2\n"
+ "win_version=nt4\n"
"\n"
"; Madeline 1st Grade Math: Progress Report\n"
"[madpr]\n"
@@ -1123,6 +1345,9 @@ static void cfg_create_ini()
"resizable=false\n"
"maintas=false\n"
"boxing=false\n"
+ "renderer=gdi\n"
+ "hook=2\n"
+ "win_version=nt4\n"
"\n"
"; Madeline 2nd Grade Math\n"
"[madmath2]\n"
@@ -1134,6 +1359,9 @@ static void cfg_create_ini()
"resizable=false\n"
"maintas=false\n"
"boxing=false\n"
+ "renderer=gdi\n"
+ "hook=2\n"
+ "win_version=nt4\n"
"\n"
"; Majesty Gold\n"
"[Majesty]\n"
@@ -1147,17 +1375,39 @@ static void cfg_create_ini()
"[MajestyHD - Old]\n"
"adjmouse=true\n"
"\n"
+ "; Meat Puppet\n"
+ "[meat]\n"
+ "hook_peekmessage=true\n"
+ "\n"
"; Mech Warrior 3\n"
"[Mech3]\n"
"nonexclusive=true\n"
"\n"
+ "; Men In Black - NOT WORKING YET\n"
+ "[MIB]\n"
+ "hook=2\n"
+ "\n"
"; Moorhuhn 2\n"
"[Moorhuhn2]\n"
- "releasealt=true\n"
+ "fix_alt_key_stuck=true\n"
+ "\n"
+ "; Metal Knight\n"
+ "[mk]\n"
+ "maxgameticks=60\n"
+ "limiter_type=4\n"
"\n"
"; New Robinson\n"
"[ROBY]\n"
"adjmouse=true\n"
+ "hook_peekmessage=true\n"
+ "\n"
+ "; Neo Sonic Universe\n"
+ "[nsu]\n"
+ "fake_mode=320x240x32\n"
+ "\n"
+ "; Neo Sonic Universe - battle mode\n"
+ "[nsu_battle]\n"
+ "fake_mode=320x240x32\n"
"\n"
"; Nancy Drew (All games)\n"
"[Game/3]\n"
@@ -1165,6 +1415,10 @@ static void cfg_create_ini()
"limiter_type=1\n"
"maxgameticks=120\n"
"\n"
+ "; NBA Full Court Press\n"
+ "[NBA_FCP]\n"
+ "fake_mode=640x480x8\n"
+ "\n"
"; Nox\n"
"[NOX]\n"
"checkfile=.\\NOX.ICD\n"
@@ -1189,6 +1443,10 @@ static void cfg_create_ini()
"adjmouse=true\n"
"renderer=gdi\n"
"\n"
+ "; Pandora's Box Puzzle Game\n"
+ "[Pandora]\n"
+ "fixchilds=0\n"
+ "\n"
"; Paddle Bash Hotshot\n"
"[SPAGHSPaddle]\n"
"no_compat_warning=true\n"
@@ -1209,10 +1467,6 @@ static void cfg_create_ini()
"[Pajama3]\n"
"renderer=gdi\n"
"\n"
- "; Pajama Sam(r): Life is Rough When You Lose Your Stuff(tm)\n"
- "[PajamaLRS]\n"
- "keytogglefullscreen=0x08\n"
- "\n"
"; Pajama Sam's One-Stop Fun Shop\n"
"[SamsFunShop]\n"
"renderer=gdi\n"
@@ -1266,10 +1520,6 @@ static void cfg_create_ini()
"[puttputtjtc]\n"
"renderer=gdi\n"
"\n"
- "; Putt-Putt: Pep's Birthday Surprise\n"
- "[PuttsFunShop]\n"
- "keytogglefullscreen=0x08\n"
- "\n"
"; Pizza Syndicate\n"
"[Pizza2]\n"
"renderer=opengl\n"
@@ -1286,8 +1536,19 @@ static void cfg_create_ini()
"[PlayWTT]\n"
"hook=3\n"
"\n"
+ "; Populous - The Beginning\n"
+ "[popTB]\n"
+ "singlecpu=false\n"
+ "\n"
+ "; Rage of Mages\n"
+ "[rom]\n"
+ "maxgameticks=60\n"
+ "limiter_type=4\n"
+ "singlecpu=true\n"
+ "\n"
"; Railroad Tycoon II\n"
"[RT2]\n"
+ "maxgameticks=60"
"adjmouse=true\n"
"\n"
"; Reader Rabbit Thinking Ages 4-6 (US)\n"
@@ -1324,6 +1585,15 @@ static void cfg_create_ini()
"maxgameticks=60\n"
"limiter_type=3\n"
"\n"
+ "; Return to Krondor\n"
+ "[RtK]\n"
+ "fixchilds=3\n"
+ "lock_mouse_top_left=true\n"
+ "limiter_type=2\n"
+ "game_handles_close=true\n"
+ "maxgameticks=59\n"
+ "anti_aliased_fonts_min_size=99\n"
+ "\n"
"; ROAD RASH\n"
"[RoadRash]\n"
"adjmouse=true\n"
@@ -1333,14 +1603,22 @@ static void cfg_create_ini()
"[Game/4]\n"
"checkfile=.\\Robin Hood.exe\n"
"singlecpu=false\n"
+ "fix_not_responding=true\n"
"\n"
"; Robin Hood - The Legend of Sherwood (Steam)\n"
"[_rh]\n"
"singlecpu=false\n"
+ "fix_not_responding=true\n"
"\n"
"; Robin Hood - The Legend of Sherwood\n"
"[Robin Hood]\n"
"singlecpu=false\n"
+ "fix_not_responding=true\n"
+ "\n"
+ "; Rising Lands\n"
+ "[Rising]\n"
+ "maxgameticks=30\n"
+ "limiter_type=4\n"
"\n"
"; Scooby-Doo(TM), Case File #1 The Glowing Bug Man - NOT WORKING YET\n"
"[Case File #1]\n"
@@ -1348,6 +1626,21 @@ static void cfg_create_ini()
"nonexclusive=true\n"
"fake_mode=640x480x32\n"
"\n"
+ "; Seven Kingdoms II\n"
+ "[7k2]\n"
+ "fake_mode=352x240x32\n"
+ "fix_not_responding=true\n"
+ "\n"
+ "; Seven Games of the Soul\n"
+ "[faust]\n"
+ "maxgameticks=25\n"
+ "\n"
+ "; Swarog\n"
+ "[Swarog]\n"
+ "maxfps=60\n"
+ "maxgameticks=60\n"
+ "minfps=-1\n"
+ "\n"
"; Sim Copter\n"
"[SimCopter]\n"
"nonexclusive=true\n"
@@ -1364,6 +1657,15 @@ static void cfg_create_ini()
"maintas=false\n"
"boxing=false\n"
"\n"
+ "; Star Wars Rebellion\n"
+ "[REBEXE]\n"
+ "adjmouse=false\n"
+ "width=0\n"
+ "height=0\n"
+ "resizable=false\n"
+ "maintas=false\n"
+ "boxing=false\n"
+ "\n"
"; Star Wars: Galactic Battlegrounds\n"
"[battlegrounds]\n"
"nonexclusive=true\n"
@@ -1378,6 +1680,10 @@ static void cfg_create_ini()
"[StarCraft]\n"
"game_handles_close=true\n"
"\n"
+ "; Space Rangers\n"
+ "[Rangers]\n"
+ "hook_peekmessage=true\n"
+ "\n"
"; SPYFox: Hold the Mustard\n"
"[mustard]\n"
"renderer=gdi\n"
@@ -1427,16 +1733,45 @@ static void cfg_create_ini()
"; Sim City 3000\n"
"[SC3]\n"
"minfps=-2\n"
+ "maxgameticks=60\n"
+ "\n"
+ "; SimTunes\n"
+ "[SIMTUNES]\n"
+ "terminate_process=true\n"
+ "hook=3\n"
+ "\n"
+ "; Street Wars: Constructor Underworld\n"
+ "[Sw]\n"
+ "checkfile=.\\smackw32.dll\n"
+ "maxgameticks=30\n"
+ "limiter_type=4\n"
"\n"
"; Shadow Watch\n"
- "[sw]\n"
+ "[sw/2]\n"
+ "checkfile=.\\Dx.dll\n"
"adjmouse=true\n"
+ "maxgameticks=30\n"
+ "hook_peekmessage=true\n"
"\n"
"; Shadow Flare\n"
"[ShadowFlare]\n"
"nonexclusive=true\n"
"adjmouse=true\n"
"\n"
+ "; Squad Leader\n"
+ "[SquadLeader]\n"
+ "maxgameticks=30\n"
+ "limiter_type=4\n"
+ "\n"
+ "; Soldiers At War\n"
+ "[SAW_Game]\n"
+ "maxgameticks=30\n"
+ "limiter_type=4\n"
+ "\n"
+ "; The Tone Rebellion\n"
+ "[Float]\n"
+ "hook_peekmessage=true\n"
+ "\n"
"; Total Annihilation (Unofficial Beta Patch v3.9.02)\n"
"[TotalA]\n"
"max_resolutions=32\n"
@@ -1449,6 +1784,10 @@ static void cfg_create_ini()
"lock_surfaces=true\n"
"singlecpu=false\n"
"\n"
+ "; Virtual Springfield\n"
+ "[VIRTUAL]\n"
+ "game_handles_close=true\n"
+ "\n"
"; Total Annihilation: Kingdoms\n"
"[Kingdoms]\n"
"game_handles_close=true\n"
@@ -1477,7 +1816,7 @@ static void cfg_create_ini()
"\n"
"; The Jungle Book Groove Party\n"
"[Jungle_vr]\n"
- "fixnotresponding=true\n"
+ "fix_not_responding=true\n"
"\n"
"; Three Kingdoms: Fate of the Dragon\n"
"[sanguo]\n"
@@ -1517,6 +1856,13 @@ static void cfg_create_ini()
"[Tzar]\n"
"adjmouse=true\n"
"\n"
+ "; Unreal\n"
+ "[Unreal]\n"
+ "adjmouse=false\n"
+ "lock_mouse_top_left=true\n"
+ "center_cursor_fix=true\n"
+ "noactivateapp=true\n"
+ "\n"
"; Uprising\n"
"[uprising]\n"
"adjmouse=true\n"
@@ -1531,16 +1877,36 @@ static void cfg_create_ini()
"adjmouse=true\n"
"fake_mode=640x480x32\n"
"\n"
+ "; Virtua Fighter 2\n"
+ "[VF2]\n"
+ "fake_mode=640x480x8\n"
+ "\n"
+ "; Virtual On: Cyber Troopers\n"
+ "[V_ON]\n"
+ "devmode=true\n"
+ "windowed=true\n"
+ "fullscreen=true\n"
+ "toggle_borderless=true\n"
+ "\n"
+ "; Wall Street Trader 2000 - NOT WORKING YET\n"
+ "[WSTrader]\n"
+ "nonexclusive=false\n"
+ "windowed=false\n"
+ "\n"
"; WarCraft 2000: Nuclear Epidemic\n"
"[war2000]\n"
"resolutions=2\n"
"guard_lines=600\n"
"minfps=-2\n"
"\n"
+ "; Warhammer 40000: Chaos Gate\n"
+ "[WH40K]\n"
+ "maxgameticks=250\n"
+ "\n"
"; Wizardry 8\n"
"[Wiz8]\n"
- "fixmousehook=true\n"
- "releasealt=true\n"
+ "sirtech_hack=true\n"
+ "fix_alt_key_stuck=true\n"
"\n"
"; Worms 2\n"
"[worms2]\n"
@@ -1551,19 +1917,30 @@ static void cfg_create_ini()
"\n"
"; Worms Armageddon\n"
"[WA]\n"
- "adjmouse=true\n"
- "width=0\n"
- "height=0\n"
- "resizable=false\n"
+ "lock_mouse_top_left=true\n"
+ "\n"
+ "; Wheel Of Fortune\n"
+ "[WHEEL]\n"
+ "singlecpu=false\n"
"\n"
"; War Wind\n"
"[WW]\n"
"minfps=-1\n"
"\n"
+ "; Jeff Wayne's 'The War Of The Worlds'\n"
+ "[WoW]\n"
+ "minfps=-1\n"
+ "\n"
"; Zeus and Poseidon\n"
"[Zeus]\n"
"adjmouse=true\n"
"\n"
+ "; Zork Nemesis\n"
+ "[znemesis]\n"
+ "fix_not_responding=true\n"
+ "maxgameticks=60\n"
+ "limiter_type=4\n"
+ "\n"
, fh);
fclose(fh);
diff --git a/src/crc32.c b/src/crc32.c
index 826842f..e7ff75d 100644
--- a/src/crc32.c
+++ b/src/crc32.c
@@ -77,6 +77,29 @@ unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
return( crc32 ^ 0xFFFFFFFF );
}
+unsigned long Crc32_FromFile(unsigned long crc32, char* filename)
+{
+ if (!filename)
+ return 0;
+
+ FILE* fp = fopen(filename, "rb");
+ if (!fp)
+ return 0;
+
+ char buf[1024];
+ for (size_t s = 0; (s = fread(buf, 1, sizeof(buf), fp)) && !ferror(fp);)
+ {
+ crc32 = Crc32_ComputeBuf(crc32, buf, s);
+ }
+
+ if (ferror(fp))
+ crc32 = 0;
+
+ fclose(fp);
+
+ return crc32;
+}
+
/*----------------------------------------------------------------------------*\
* END OF MODULE: crc32.c
\*----------------------------------------------------------------------------*/
diff --git a/src/dd.c b/src/dd.c
index 1ec2bef..b9e5b12 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -518,6 +518,7 @@ HRESULT dd_GetCaps(LPDDCAPS_DX1 lpDDDriverCaps, LPDDCAPS_DX1 lpDDEmulCaps)
memset(lpDDEmulCaps, 0, size);
lpDDEmulCaps->dwSize = size;
+ lpDDEmulCaps->dwCaps = DDCAPS_BLTSTRETCH;
}
return DD_OK;
@@ -559,7 +560,7 @@ HRESULT dd_GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc)
lpDDSurfaceDesc->dwWidth = width;
lpDDSurfaceDesc->dwHeight = height;
- if (bpp == 32)
+ if (bpp == 32 || bpp == 24)
{
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB;
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0xFF0000;
@@ -612,6 +613,8 @@ HRESULT dd_GetVerticalBlankStatus(LPBOOL lpbIsInVB)
*lpbIsInVB = TRUE;
}
+ TRACE(" lpbIsInVB = %s\n", *lpbIsInVB ? "TRUE" : "FALSE");
+
return DD_OK;
}
@@ -708,9 +711,14 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
g_ddraw.render.height = g_config.window_rect.bottom;
/* temporary fix: center window for games that keep changing their resolution */
- if ((g_ddraw.width || g_config.infantryhack) &&
+ if (g_config.center_window &&
+ (g_ddraw.width || g_config.infantryhack || g_config.center_window == CENTER_WINDOW_ALWAYS) &&
(g_ddraw.width != dwWidth || g_ddraw.height != dwHeight) &&
- (dwWidth > g_config.window_rect.right || dwHeight > g_config.window_rect.bottom))
+ (
+ dwWidth > g_config.window_rect.right ||
+ dwHeight > g_config.window_rect.bottom ||
+ g_config.center_window == CENTER_WINDOW_ALWAYS)
+ )
{
g_config.window_rect.left = -32000;
g_config.window_rect.top = -32000;
@@ -882,6 +890,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
g_config.windowed = TRUE;
g_config.fullscreen = TRUE;
+ g_config.toggle_borderless = TRUE;
border = FALSE;
/* prevent OpenGL from going automatically into fullscreen exclusive mode */
@@ -919,15 +928,12 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
if (g_config.boxing)
{
- g_ddraw.render.viewport.width = g_ddraw.width;
- g_ddraw.render.viewport.height = g_ddraw.height;
-
for (int i = 20; i-- > 1;)
{
if (g_ddraw.width * i <= g_ddraw.render.width && g_ddraw.height * i <= g_ddraw.render.height)
{
- g_ddraw.render.viewport.width *= i;
- g_ddraw.render.viewport.height *= i;
+ g_ddraw.render.viewport.width = i * g_ddraw.width;
+ g_ddraw.render.viewport.height = i * g_ddraw.height;
break;
}
}
@@ -1029,7 +1035,8 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
if (g_config.remove_menu && GetMenu(g_ddraw.hwnd))
SetMenu(g_ddraw.hwnd, NULL);
- if (g_ddraw.last_msg_pull_tick &&
+ if (!g_config.fix_not_responding &&
+ g_ddraw.last_msg_pull_tick &&
g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
GetCurrentThreadId() == g_ddraw.gui_thread_id &&
!IsWine())
@@ -1055,6 +1062,12 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
g_ddraw.hwnd,
GWL_STYLE,
(real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW) & ~(WS_MAXIMIZE));
+
+ DWORD class_sytle = GetClassLongA(g_ddraw.hwnd, GCL_STYLE);
+ if (class_sytle & CS_NOCLOSE)
+ {
+ SetClassLongA(g_ddraw.hwnd, GCL_STYLE, class_sytle & ~CS_NOCLOSE);
+ }
}
LONG exstyle = real_GetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE);
@@ -1071,12 +1084,14 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
real_SetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE, exstyle & ~(WS_EX_CLIENTEDGE));
}
- if (!g_config.wine_allow_resize && IsWine())
+ if (IsWine())
{
+ LONG remove_flags = !g_config.resizable ? (WS_MAXIMIZEBOX | WS_THICKFRAME) : 0;
+
real_SetWindowLongA(
g_ddraw.hwnd,
GWL_STYLE,
- (real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE) | WS_MINIMIZEBOX) & ~(WS_MAXIMIZEBOX | WS_THICKFRAME));
+ (real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE) | WS_MINIMIZEBOX) & ~(remove_flags));
}
/* center the window with correct dimensions */
@@ -1239,6 +1254,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
g_ddraw.render.run = FALSE;
g_config.windowed = TRUE;
g_config.fullscreen = TRUE;
+ g_config.toggle_borderless = TRUE;
return dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, dwFlags);
}
@@ -1255,6 +1271,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
g_ddraw.render.run = FALSE;
g_config.windowed = TRUE;
g_config.fullscreen = TRUE;
+ g_config.toggle_borderless = TRUE;
return dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, dwFlags);
}
}
@@ -1324,7 +1341,8 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
- g_ddraw.render.thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)g_ddraw.renderer, NULL, 0, NULL);
+ DWORD tid;
+ g_ddraw.render.thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)g_ddraw.renderer, NULL, 0, &tid);
SetThreadPriority(g_ddraw.render.thread, THREAD_PRIORITY_ABOVE_NORMAL);
}
@@ -1334,6 +1352,21 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
real_SendMessageA(g_ddraw.hwnd, WM_DISPLAYCHANGE_DDRAW, g_ddraw.bpp, MAKELPARAM(g_ddraw.width, g_ddraw.height));
}
+ TRACE(
+ " render res=%ux%u (viewport res=%ux%u, x=%d, y=%d)\n",
+ g_ddraw.render.width,
+ g_ddraw.render.height,
+ g_ddraw.render.viewport.width,
+ g_ddraw.render.viewport.height,
+ g_ddraw.render.viewport.x,
+ g_ddraw.render.viewport.y);
+
+ TRACE(
+ " windowed=%s, fullscreen=%s, adjmouse=%s\n",
+ g_config.windowed ? "true" : "false",
+ g_config.fullscreen ? "true" : "false",
+ g_config.adjmouse ? "true" : "false");
+
return DD_OK;
}
@@ -1370,7 +1403,6 @@ HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags)
g_ddraw.gui_thread_id = GetWindowThreadProcessId(g_ddraw.hwnd, NULL);
keyboard_hook_init();
- mouse_hook_init();
if (!g_ddraw.render.hdc)
{
@@ -1512,12 +1544,18 @@ HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags)
}
else if (!g_ddraw.width)
{
- g_ddraw.windowed_hack = TRUE;
-
RECT rc = { 0 };
real_GetClientRect(hwnd, &rc);
- dd_SetDisplayMode(rc.right, rc.bottom, 16, 0);
+ BOOL popup = real_GetWindowLongA(hwnd, GWL_STYLE) & WS_POPUP;
+
+ if ((rc.right < real_GetSystemMetrics(SM_CXSCREEN) && rc.bottom < real_GetSystemMetrics(SM_CYSCREEN)) || !popup)
+ {
+ TRACE(" client rect=%dx%d\n", rc.right, rc.bottom);
+
+ g_ddraw.windowed_hack = TRUE;
+ dd_SetDisplayMode(rc.right, rc.bottom, 16, 0);
+ }
}
}
else
@@ -1532,17 +1570,8 @@ HRESULT dd_WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
{
if (g_config.maxgameticks == -2)
{
- /* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
- if (g_ddraw.renderer == ogl_render_main && !IsWine() && !IsWindows8OrGreater())
- {
- if (fpsl_wait_for_vblank())
- return DD_OK;
- }
- else
- {
- if (fpsl_dwm_flush() || fpsl_wait_for_vblank())
- return DD_OK;
- }
+ if (fpsl_wait_for_vblank())
+ return DD_OK;
}
if (!g_ddraw.flip_limiter.tick_length)
@@ -1677,26 +1706,6 @@ ULONG dd_Release()
if (g_ddraw.hwnd && IsWindow(g_ddraw.hwnd))
{
- /* restore old window size, required for games that can switch between windowed and fullscreen during runtime */
- if (g_ddraw.width)
- {
- RECT rc = { 0, 0, g_ddraw.width, g_ddraw.height };
-
- LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
- LONG exstyle = real_GetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE);
-
- AdjustWindowRectEx(&rc, style, GetMenu(g_ddraw.hwnd) != NULL, exstyle);
-
- real_SetWindowPos(
- g_ddraw.hwnd,
- 0,
- 0,
- 0,
- (rc.right - rc.left),
- (rc.bottom - rc.top),
- SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
- }
-
/* restore old wndproc, subsequent ddraw creation will otherwise fail */
real_SetWindowLongA(g_ddraw.hwnd, GWL_WNDPROC, (LONG)g_ddraw.wndproc);
}
@@ -1819,7 +1828,17 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
if (g_config.singlecpu)
{
- SetProcessAffinityMask(proc, 1);
+ if (!IsWine() && IsWindows11Version24H2OrGreater())
+ {
+ if (GetProcessAffinityMask(proc, &proc_affinity, &system_affinity))
+ SetProcessAffinityMask(proc, system_affinity);
+
+ util_set_process_affinity();
+ }
+ else
+ {
+ SetProcessAffinityMask(proc, 1);
+ }
}
else if (GetProcessAffinityMask(proc, &proc_affinity, &system_affinity))
{
diff --git a/src/ddpalette.c b/src/ddpalette.c
index ed2b858..e51df8e 100644
--- a/src/ddpalette.c
+++ b/src/ddpalette.c
@@ -14,11 +14,15 @@ HRESULT ddp_GetEntries(
DWORD dwNumEntries,
LPPALETTEENTRY lpEntries)
{
- for (int i = dwBase, x = 0; i < dwBase + dwNumEntries; i++, x++)
+ if (!lpEntries)
+ return DDERR_INVALIDPARAMS;
+
+ for (int i = dwBase, x = 0; i < dwBase + dwNumEntries && i < 256; i++, x++)
{
lpEntries[x].peRed = This->data_rgb[i].rgbRed;
lpEntries[x].peGreen = This->data_rgb[i].rgbGreen;
lpEntries[x].peBlue = This->data_rgb[i].rgbBlue;
+ lpEntries[x].peFlags = 0;
}
return DD_OK;
@@ -31,7 +35,17 @@ HRESULT ddp_SetEntries(
DWORD dwCount,
LPPALETTEENTRY lpEntries)
{
- for (int i = dwStartingEntry, x = 0; i < dwStartingEntry + dwCount; i++, x++)
+ if (!lpEntries)
+ return DDERR_INVALIDPARAMS;
+
+ RGBQUAD data_rgb[256];
+
+ if ((dwFlags & DDPCAPS_REFRESH_CHANGED_ONLY))
+ {
+ memcpy(data_rgb, This->data_rgb, sizeof(This->data_rgb));
+ }
+
+ for (int i = dwStartingEntry, x = 0; i < dwStartingEntry + dwCount && i < 256; i++, x++)
{
This->data_bgr[i] = (lpEntries[x].peBlue << 16) | (lpEntries[x].peGreen << 8) | lpEntries[x].peRed;
@@ -57,6 +71,17 @@ HRESULT ddp_SetEntries(
This->data_rgb[255].rgbReserved = 0;
}
+ if ((dwFlags & DDPCAPS_REFRESH_CHANGED_ONLY))
+ {
+ if (memcmp(data_rgb, This->data_rgb, sizeof(This->data_rgb)) == 0)
+ {
+ // do not set palette_updated BOOL if nothing changed
+ return DD_OK;
+ }
+
+ TRACE_EXT(" Palette changed\n");
+ }
+
if (g_ddraw.ref && g_ddraw.primary && g_ddraw.primary->palette == This && g_ddraw.render.run)
{
InterlockedExchange(&g_ddraw.render.palette_updated, TRUE);
diff --git a/src/ddsurface.c b/src/ddsurface.c
index 121f8fb..96d69de 100644
--- a/src/ddsurface.c
+++ b/src/ddsurface.c
@@ -12,7 +12,10 @@
#include "blt.h"
#include "config.h"
#include "ddclipper.h"
+#include "utils.h"
#include "versionhelpers.h"
+#include "ddpalette.h"
+#include "palette.h"
LONG g_dds_gdi_handles;
@@ -47,20 +50,19 @@ HRESULT dds_Blt(
DWORD dwFlags,
LPDDBLTFX lpDDBltFx)
{
+ if (lpDDSrcSurface &&
+ lpDDSrcSurface->bpp != 8 &&
+ lpDDSrcSurface->bpp != 16 &&
+ lpDDSrcSurface->bpp != 24 &&
+ lpDDSrcSurface->bpp != 32)
+ {
+ return DDERR_INVALIDPARAMS;
+ }
+
dbg_dump_dds_blt_flags(dwFlags);
dbg_dump_dds_blt_fx_flags((dwFlags & DDBLT_DDFX) && lpDDBltFx ? lpDDBltFx->dwDDFX : 0);
- if (g_config.fixnotresponding &&
- g_ddraw.hwnd &&
- g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
- GetCurrentThreadId() == g_ddraw.gui_thread_id &&
- !IsWine())
- {
- /* workaround for "Not Responding" window problem */
- g_ddraw.last_msg_pull_tick = timeGetTime();
- MSG msg;
- real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT);
- }
+ util_pull_messages();
if (g_ddraw.ref &&
g_ddraw.iskkndx &&
@@ -83,10 +85,16 @@ HRESULT dds_Blt(
RECT dst_rect = { 0, 0, This->width, This->height };
if (lpSrcRect && src_surface)
- memcpy(&src_rect, lpSrcRect, sizeof(src_rect));
+ {
+ //dbg_print_rect("lpSrcRect", lpSrcRect);
+ src_rect = *lpSrcRect;
+ }
if (lpDestRect)
- memcpy(&dst_rect, lpDestRect, sizeof(dst_rect));
+ {
+ //dbg_print_rect("lpDestRect", lpDestRect);
+ dst_rect = *lpDestRect;
+ }
int src_w = src_rect.right - src_rect.left;
int src_h = src_rect.bottom - src_rect.top;
@@ -228,6 +236,11 @@ HRESULT dds_Blt(
if (dst_buf && (dwFlags & DDBLT_COLORFILL) && lpDDBltFx && dst_w > 0 && dst_h > 0)
{
+ if (This->bpp == 24)
+ {
+ TRACE_EXT(" NOT_IMPLEMENTED This->bpp=%u, dwFillColor=%08X\n", This->bpp, lpDDBltFx->dwFillColor);
+ }
+
blt_colorfill(
dst_buf,
dst_x,
@@ -251,7 +264,10 @@ HRESULT dds_Blt(
BOOL mirror_left_right = got_fx && (lpDDBltFx->dwDDFX & DDBLTFX_MIRRORLEFTRIGHT);
BOOL mirror_up_down = got_fx && (lpDDBltFx->dwDDFX & DDBLTFX_MIRRORUPDOWN);
- if (This->bpp != src_surface->bpp || (is_stretch_blt && This == src_surface))
+ if (This->bpp != src_surface->bpp ||
+ This->bpp == 24 ||
+ src_surface->bpp == 24 ||
+ (is_stretch_blt && This == src_surface))
{
TRACE_EXT(" NOT_IMPLEMENTED This->bpp=%u, src_surface->bpp=%u\n", This->bpp, src_surface->bpp);
@@ -261,13 +277,13 @@ HRESULT dds_Blt(
HDC src_dc;
dds_GetDC(src_surface, &src_dc);
- if ((dwFlags & DDBLT_KEYSRC) || (dwFlags & DDBLT_KEYSRCOVERRIDE))
+ if (((dwFlags & DDBLT_KEYSRC) && (src_surface->flags & DDSD_CKSRCBLT)) || (dwFlags & DDBLT_KEYSRCOVERRIDE))
{
UINT color =
(dwFlags & DDBLT_KEYSRCOVERRIDE) ?
lpDDBltFx->ddckSrcColorkey.dwColorSpaceLowValue : src_surface->color_key.dwColorSpaceLowValue;
- if (src_surface->bpp == 32)
+ if (src_surface->bpp == 32 || src_surface->bpp == 24)
{
color = color & 0xFFFFFF;
}
@@ -319,7 +335,7 @@ HRESULT dds_Blt(
*/
}
else if (
- (dwFlags & DDBLT_KEYSRC) ||
+ ((dwFlags & DDBLT_KEYSRC) && (src_surface->flags & DDSD_CKSRCBLT)) ||
(dwFlags & DDBLT_KEYSRCOVERRIDE) ||
mirror_left_right ||
mirror_up_down)
@@ -431,6 +447,7 @@ HRESULT dds_Blt(
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
{
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
if (!(This->flags & DDSD_BACKBUFFERCOUNT) || This->last_flip_tick + FLIP_REDRAW_TIMEOUT < timeGetTime())
{
@@ -439,7 +456,7 @@ HRESULT dds_Blt(
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
SwitchToThread();
- if (g_ddraw.ticks_limiter.tick_length > 0)
+ if (g_ddraw.ticks_limiter.tick_length > 0 && g_config.limiter_type != LIMIT_PEEKMESSAGE)
{
g_ddraw.ticks_limiter.dds_unlock_limiter_disabled = TRUE;
util_limit_game_ticks();
@@ -465,7 +482,10 @@ HRESULT dds_BltFast(
RECT src_rect = { 0, 0, src_surface ? src_surface->width : 0, src_surface ? src_surface->height : 0 };
if (lpSrcRect && src_surface)
- memcpy(&src_rect, lpSrcRect, sizeof(src_rect));
+ {
+ //dbg_print_rect("lpSrcRect", lpSrcRect);
+ src_rect = *lpSrcRect;
+ }
int dst_x = dwX;
int dst_y = dwY;
@@ -549,7 +569,9 @@ HRESULT dds_BltFast(
if (src_surface && dst_w > 0 && dst_h > 0)
{
- if (This->bpp != src_surface->bpp)
+ if (This->bpp != src_surface->bpp ||
+ This->bpp == 24 ||
+ src_surface->bpp == 24)
{
TRACE_EXT(" NOT_IMPLEMENTED This->bpp=%u, src_surface->bpp=%u\n", This->bpp, src_surface->bpp);
@@ -559,11 +581,11 @@ HRESULT dds_BltFast(
HDC src_dc;
dds_GetDC(src_surface, &src_dc);
- if (dwFlags & DDBLTFAST_SRCCOLORKEY)
+ if ((dwFlags & DDBLTFAST_SRCCOLORKEY) && (src_surface->flags & DDSD_CKSRCBLT))
{
UINT color = src_surface->color_key.dwColorSpaceLowValue;
- if (src_surface->bpp == 32)
+ if (src_surface->bpp == 32 || src_surface->bpp == 24)
{
color = color & 0xFFFFFF;
}
@@ -612,7 +634,7 @@ HRESULT dds_BltFast(
SRCCOPY);
*/
}
- else if (dwFlags & DDBLTFAST_SRCCOLORKEY)
+ else if ((dwFlags & DDBLTFAST_SRCCOLORKEY) && (src_surface->flags & DDSD_CKSRCBLT))
{
blt_colorkey(
dst_buf,
@@ -664,6 +686,7 @@ HRESULT dds_BltFast(
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
{
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
DWORD time = timeGetTime();
@@ -710,8 +733,7 @@ HRESULT dds_GetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC lpDDSur
DDSD_WIDTH |
DDSD_HEIGHT |
DDSD_PITCH |
- DDSD_PIXELFORMAT |
- DDSD_LPSURFACE;
+ DDSD_PIXELFORMAT;
lpDDSurfaceDesc->dwWidth = This->width;
lpDDSurfaceDesc->dwHeight = This->height;
@@ -745,7 +767,7 @@ HRESULT dds_GetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC lpDDSur
lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x07E0;
lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x001F;
}
- else if (This->bpp == 32)
+ else if (This->bpp == 32 || This->bpp == 24)
{
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0xFF0000;
lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x00FF00;
@@ -822,6 +844,7 @@ HRESULT dds_Flip(IDirectDrawSurfaceImpl* This, IDirectDrawSurfaceImpl* lpDDSurfa
This->last_flip_tick = timeGetTime();
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
SwitchToThread();
@@ -830,7 +853,7 @@ HRESULT dds_Flip(IDirectDrawSurfaceImpl* This, IDirectDrawSurfaceImpl* lpDDSurfa
dd_WaitForVerticalBlank(DDWAITVB_BLOCKEND, NULL);
}
- if (g_ddraw.ticks_limiter.tick_length > 0)
+ if (g_ddraw.ticks_limiter.tick_length > 0 && g_config.limiter_type != LIMIT_PEEKMESSAGE)
{
g_ddraw.ticks_limiter.dds_unlock_limiter_disabled = TRUE;
util_limit_game_ticks();
@@ -886,6 +909,11 @@ HRESULT dds_GetClipper(IDirectDrawSurfaceImpl* This, IDirectDrawClipperImpl** lp
HRESULT dds_GetColorKey(IDirectDrawSurfaceImpl* This, DWORD dwFlags, LPDDCOLORKEY lpColorKey)
{
+ if (!(This->flags & DDSD_CKSRCBLT))
+ {
+ return DDERR_NOCOLORKEY;
+ }
+
if (dwFlags != DDCKEY_SRCBLT || !lpColorKey)
{
TRACE(" NOT_IMPLEMENTED dwFlags=%08X, lpColorKey=%p\n", dwFlags, lpColorKey);
@@ -926,7 +954,8 @@ HRESULT dds_GetDC(IDirectDrawSurfaceImpl* This, HDC FAR* lpHDC)
if (lpHDC)
*lpHDC = dc;
- InterlockedExchange((LONG*)&This->dc_state, SaveDC(dc));
+ if (!(This->caps & DDSCAPS_OWNDC))
+ InterlockedExchange((LONG*)&This->dc_state, SaveDC(dc));
return DD_OK;
}
@@ -969,7 +998,7 @@ HRESULT dds_GetPixelFormat(IDirectDrawSurfaceImpl* This, LPDDPIXELFORMAT ddpfPix
ddpfPixelFormat->dwGBitMask = 0x07E0;
ddpfPixelFormat->dwBBitMask = 0x001F;
}
- else if (This->bpp == 32)
+ else if (This->bpp == 32 || This->bpp == 24)
{
ddpfPixelFormat->dwRBitMask = 0xFF0000;
ddpfPixelFormat->dwGBitMask = 0x00FF00;
@@ -994,17 +1023,7 @@ HRESULT dds_Lock(
dbg_dump_dds_lock_flags(dwFlags);
- if (g_config.fixnotresponding &&
- g_ddraw.hwnd &&
- g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
- GetCurrentThreadId() == g_ddraw.gui_thread_id &&
- !IsWine())
- {
- /* workaround for "Not Responding" window problem */
- g_ddraw.last_msg_pull_tick = timeGetTime();
- MSG msg;
- real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT);
- }
+ util_pull_messages();
HRESULT ret = dds_GetSurfaceDesc(This, lpDDSurfaceDesc);
@@ -1034,6 +1053,7 @@ HRESULT dds_ReleaseDC(IDirectDrawSurfaceImpl* This, HDC hDC)
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
{
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
DWORD time = timeGetTime();
@@ -1044,7 +1064,8 @@ HRESULT dds_ReleaseDC(IDirectDrawSurfaceImpl* This, HDC hDC)
}
}
- RestoreDC(hDC, InterlockedExchangeAdd((LONG*)&This->dc_state, 0));
+ if (!(This->caps & DDSCAPS_OWNDC))
+ RestoreDC(hDC, InterlockedExchangeAdd((LONG*)&This->dc_state, 0));
return DD_OK;
}
@@ -1098,11 +1119,13 @@ HRESULT dds_SetColorKey(IDirectDrawSurfaceImpl* This, DWORD dwFlags, LPDDCOLORKE
HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* lpDDPalette)
{
+ if (This->bpp != 8)
+ return DDERR_INVALIDPIXELFORMAT;
+
if (lpDDPalette)
IDirectDrawPalette_AddRef(lpDDPalette);
- if (This->palette)
- IDirectDrawPalette_Release(This->palette);
+ IDirectDrawPaletteImpl* old_palette = This->palette;
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref)
{
@@ -1121,6 +1144,9 @@ HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* lpD
This->palette = lpDDPalette;
}
+ if (old_palette)
+ IDirectDrawPalette_Release(old_palette);
+
return DD_OK;
}
@@ -1213,6 +1239,7 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect)
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref && g_ddraw.render.run)
{
InterlockedExchange(&g_ddraw.render.surface_updated, TRUE);
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
DWORD time = timeGetTime();
@@ -1222,6 +1249,7 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect)
ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
if (g_ddraw.ticks_limiter.tick_length > 0 &&
+ g_config.limiter_type != LIMIT_PEEKMESSAGE &&
(!g_ddraw.ticks_limiter.dds_unlock_limiter_disabled || g_config.limiter_type == LIMIT_UNLOCK))
{
util_limit_game_ticks();
@@ -1301,7 +1329,8 @@ HRESULT dds_SetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC2 lpDDSD
This->bpp = 16;
break;
case 24:
- TRACE(" NOT_IMPLEMENTED bpp=%u\n", lpDDSD->ddpfPixelFormat.dwRGBBitCount);
+ This->bpp = 24;
+ break;
case 32:
This->bpp = 32;
break;
@@ -1414,7 +1443,8 @@ HRESULT dd_CreateSurface(
dst_surface->bpp = 16;
break;
case 24:
- TRACE(" NOT_IMPLEMENTED bpp=%u\n", lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount);
+ dst_surface->bpp = 24;
+ break;
case 32:
dst_surface->bpp = 32;
break;
@@ -1468,21 +1498,24 @@ HRESULT dd_CreateSurface(
DWORD aligned_width = dst_surface->pitch / dst_surface->bytes_pp;
- DWORD bmi_size = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256;
DWORD bmp_size = dst_surface->pitch * (dst_surface->height + g_config.guard_lines);
- dst_surface->bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bmi_size);
+ dst_surface->bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDBITMAPINFO));
dst_surface->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
dst_surface->bmi->bmiHeader.biWidth = aligned_width;
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height + g_config.guard_lines);
dst_surface->bmi->bmiHeader.biPlanes = 1;
dst_surface->bmi->bmiHeader.biBitCount = dst_surface->bpp;
- dst_surface->bmi->bmiHeader.biCompression = dst_surface->bpp == 8 ? BI_RGB : BI_BITFIELDS;
+ dst_surface->bmi->bmiHeader.biCompression = dst_surface->bpp == 16 ? BI_BITFIELDS : BI_RGB;
WORD clr_bits = (WORD)(dst_surface->bmi->bmiHeader.biPlanes * dst_surface->bmi->bmiHeader.biBitCount);
- dst_surface->bmi->bmiHeader.biClrUsed =
- dst_surface->bmi->bmiHeader.biCompression == BI_BITFIELDS ? 3 : (1 << clr_bits);
+ dst_surface->bmi->bmiHeader.biClrUsed =
+ dst_surface->bpp == 8 ? 256 :
+ dst_surface->bpp == 16 ? 3 :
+ dst_surface->bpp == 24 ? 0 :
+ dst_surface->bpp == 32 ? 0 :
+ 0;
dst_surface->bmi->bmiHeader.biSizeImage =
((aligned_width * clr_bits + 63) & ~63) / 8 * dst_surface->height;
@@ -1509,15 +1542,9 @@ HRESULT dd_CreateSurface(
((DWORD*)dst_surface->bmi->bmiColors)[1] = 0x07E0;
((DWORD*)dst_surface->bmi->bmiColors)[2] = 0x001F;
}
- else if (dst_surface->bpp == 32)
- {
- ((DWORD*)dst_surface->bmi->bmiColors)[0] = 0xFF0000;
- ((DWORD*)dst_surface->bmi->bmiColors)[1] = 0x00FF00;
- ((DWORD*)dst_surface->bmi->bmiColors)[2] = 0x0000FF;
- }
/* Claw hack: 128x128 surfaces need a DC for custom levels to work properly */
- if (InterlockedExchangeAdd(&g_dds_gdi_handles, 0) < 4000 ||
+ if ((!g_config.limit_gdi_handles && InterlockedExchangeAdd(&g_dds_gdi_handles, 0) < 9000) ||
(dst_surface->width == g_ddraw.width && dst_surface->height == g_ddraw.height) ||
(dst_surface->width == 128 && dst_surface->height == 128))
{
@@ -1526,17 +1553,18 @@ HRESULT dd_CreateSurface(
if (dst_surface->hdc)
InterlockedIncrement(&g_dds_gdi_handles);
+ // CreateDIBSection cannot handle values higher than a WORD - 0xFF00 (guard lines);
+ DWORD map_offset = min(65280, dst_surface->pitch * g_config.guard_lines);
+
dst_surface->mapping =
CreateFileMappingA(
INVALID_HANDLE_VALUE,
NULL,
PAGE_READWRITE | SEC_COMMIT,
0,
- bmp_size + 256,
+ bmp_size + 256 + map_offset,
NULL);
- DWORD map_offset = 0;
-
if (dst_surface->mapping)
{
LPVOID data = MapViewOfFile(dst_surface->mapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
@@ -1582,6 +1610,16 @@ HRESULT dd_CreateSurface(
{
g_ddraw.primary = dst_surface;
FakePrimarySurface = dst_surface->surface;
+
+ if (dst_surface->bpp == 8)
+ {
+ IDirectDrawPaletteImpl* lpDDPalette;
+ dd_CreatePalette(DDPCAPS_ALLOW256, g_ddp_default_palette, &lpDDPalette, NULL);
+ dds_SetPalette(dst_surface, lpDDPalette);
+
+ // Make sure temp palette will be released once replaced
+ IDirectDrawPalette_Release(lpDDPalette);
+ }
}
}
diff --git a/src/debug.c b/src/debug.c
index c5f0507..b030114 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -2,6 +2,8 @@
#include
#include
#include
+#include
+#include "directinput.h"
#include "ddraw.h"
#include "dd.h"
#include "ddsurface.h"
@@ -11,11 +13,17 @@
#include "version.h"
#include "git.h"
#include "versionhelpers.h"
+#include "utils.h"
+#include "crc32.h"
+#include "dllmain.h"
+#include "config.h"
+#include "delay_imports.h"
double g_dbg_frame_time = 0;
DWORD g_dbg_frame_count = 0;
LPTOP_LEVEL_EXCEPTION_FILTER g_dbg_exception_filter;
+PVOID g_dbg_exception_handle;
static LONGLONG g_dbg_counter_start_time = 0;
static double g_dbg_counter_freq = 0.0;
@@ -34,33 +42,47 @@ LONG WINAPI dbg_exception_handler(EXCEPTION_POINTERS* exception)
{
g_dbg_crash_count++;
- HANDLE dmp =
- CreateFile(
- g_dbg_crash_count == 1 ? g_dbg_dmp_path1 : g_dbg_dmp_path2,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_WRITE | FILE_SHARE_READ,
- 0,
- CREATE_ALWAYS,
- 0,
- 0);
+ BOOL(WINAPI * MiniDumpWriteDumpProc)(
+ HANDLE,
+ DWORD,
+ HANDLE,
+ MINIDUMP_TYPE,
+ PMINIDUMP_EXCEPTION_INFORMATION,
+ PMINIDUMP_USER_STREAM_INFORMATION,
+ PMINIDUMP_CALLBACK_INFORMATION
+ );
- if (dmp != INVALID_HANDLE_VALUE)
+ MiniDumpWriteDumpProc = (void*)real_GetProcAddress(real_LoadLibraryA("Dbghelp.dll"), "MiniDumpWriteDump");
+ if (MiniDumpWriteDumpProc)
{
- MINIDUMP_EXCEPTION_INFORMATION info;
- info.ThreadId = GetCurrentThreadId();
- info.ExceptionPointers = exception;
- info.ClientPointers = TRUE;
+ HANDLE dmp =
+ CreateFile(
+ g_dbg_crash_count == 1 ? g_dbg_dmp_path1 : g_dbg_dmp_path2,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_WRITE | FILE_SHARE_READ,
+ 0,
+ CREATE_ALWAYS,
+ 0,
+ 0);
- MiniDumpWriteDump(
- GetCurrentProcess(),
- GetCurrentProcessId(),
- dmp,
- 0,
- &info,
- NULL,
- NULL);
+ if (dmp != INVALID_HANDLE_VALUE)
+ {
+ MINIDUMP_EXCEPTION_INFORMATION info;
+ info.ThreadId = GetCurrentThreadId();
+ info.ExceptionPointers = exception;
+ info.ClientPointers = TRUE;
- CloseHandle(dmp);
+ MiniDumpWriteDumpProc(
+ GetCurrentProcess(),
+ GetCurrentProcessId(),
+ dmp,
+ 0,
+ &info,
+ NULL,
+ NULL);
+
+ CloseHandle(dmp);
+ }
}
if (exception && exception->ExceptionRecord)
@@ -68,15 +90,13 @@ LONG WINAPI dbg_exception_handler(EXCEPTION_POINTERS* exception)
HMODULE mod = NULL;
char filename[MAX_PATH] = { 0 };
-#if defined(_MSC_VER) /* comment this out just to keep the mingw build win2000 compatible */
- if (GetModuleHandleExA(
+ if (delay_GetModuleHandleExA && delay_GetModuleHandleExA(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
exception->ExceptionRecord->ExceptionAddress,
&mod))
{
GetModuleFileNameA(mod, filename, sizeof(filename) - 1);
}
-#endif
TRACE(
"Exception at %p (%p+%p), Code=%08X - %s\n",
@@ -110,6 +130,48 @@ void __cdecl dbg_invoke_watson(
}
#endif
+LONG WINAPI dbg_vectored_exception_handler(EXCEPTION_POINTERS* exception)
+{
+ if (exception &&
+ exception->ContextRecord &&
+ exception->ExceptionRecord &&
+ exception->ExceptionRecord->ExceptionAddress &&
+ exception->ExceptionRecord->ExceptionCode == STATUS_PRIVILEGED_INSTRUCTION)
+ {
+ size_t size = 0;
+ BYTE* addr = exception->ExceptionRecord->ExceptionAddress;
+ switch (*addr)
+ {
+ case 0xE4: // IN ib
+ case 0xE5: // IN id
+ case 0xE6: // OUT ib
+ case 0xE7: // OUT ib
+ size = 2;
+ break;
+ case 0xF8: // CLC
+ case 0xF9: // STC
+ case 0xFA: // CLI
+ case 0xFB: // STI
+ case 0xFC: // CLD
+ case 0xFD: // STD
+ case 0xEC: // IN ib
+ case 0xED: // IN id
+ case 0xEE: // OUT
+ case 0xEF: // OUT
+ size = 1;
+ break;
+ }
+
+ if (size)
+ {
+ exception->ContextRecord->Eip += size;
+ return EXCEPTION_CONTINUE_EXECUTION;
+ }
+ }
+
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+
void dbg_init()
{
static BOOL once = 0;
@@ -151,37 +213,56 @@ void dbg_init()
}
TRACE(
- "cnc-ddraw version = %d.%d.%d.%d (git~%s, %s)\n",
- VERSION_MAJOR,
- VERSION_MINOR,
- VERSION_BUILD,
- VERSION_REVISION,
+ "cnc-ddraw version = %d.%d.%d.%d (git~%s, %s)\n",
+ VERSION_MAJOR,
+ VERSION_MINOR,
+ VERSION_BUILD,
+ VERSION_REVISION,
GIT_COMMIT,
GIT_BRANCH);
- HKEY hkey;
+ TRACE("cnc-ddraw = %p\n", g_ddraw_module);
+
+ HKEY hkey = NULL;
LONG status =
RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0L, KEY_READ, &hkey);
- if (status == ERROR_SUCCESS)
+ HKEY hkey9x = NULL;
+ LONG status9x =
+ RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", 0L, KEY_READ, &hkey9x);
+
+ char name[256] = { 0 };
+ DWORD name_size = sizeof(name);
+ if (status || RegQueryValueExA(hkey, "ProductName", NULL, NULL, (PVOID)&name, &name_size) != ERROR_SUCCESS)
{
- char name[256] = { 0 };
- DWORD name_size = sizeof(name);
- RegQueryValueExA(hkey, "ProductName", NULL, NULL, (PVOID)&name, &name_size);
-
- char dversion[256] = { 0 };
- DWORD dversion_size = sizeof(dversion);
- RegQueryValueExA(hkey, "DisplayVersion", NULL, NULL, (PVOID)&dversion, &dversion_size);
-
- char build[256] = { 0 };
- DWORD build_size = sizeof(build);
- RegQueryValueExA(hkey, "BuildLab", NULL, NULL, (PVOID)&build, &build_size);
-
- TRACE("%s %s (%s)\n", name, dversion, build);
-
- RegCloseKey(hkey);
+ if (status9x == ERROR_SUCCESS)
+ RegQueryValueExA(hkey9x, "ProductName", NULL, NULL, (PVOID)&name, &name_size);
}
+ char vers[256] = { 0 };
+ DWORD vers_size = sizeof(vers);
+ if (status || RegQueryValueExA(hkey, "DisplayVersion", NULL, NULL, (PVOID)&vers, &vers_size) != ERROR_SUCCESS)
+ {
+ if (status9x == ERROR_SUCCESS)
+ RegQueryValueExA(hkey9x, "VersionNumber", NULL, NULL, (PVOID)&vers, &vers_size);
+ }
+
+ char build[256] = { 0 };
+ DWORD build_size = sizeof(build);
+ if (status || RegQueryValueExA(hkey, "BuildLabEx", NULL, NULL, (PVOID)&build, &build_size) != ERROR_SUCCESS)
+ {
+ if (status == ERROR_SUCCESS)
+ RegQueryValueExA(hkey, "BuildLab", NULL, NULL, (PVOID)&build, &build_size);
+ }
+
+ TRACE("%s %s (%s)\n", name, vers, build);
+
+ if (status == ERROR_SUCCESS)
+ RegCloseKey(hkey);
+
+ if (status9x == ERROR_SUCCESS)
+ RegCloseKey(hkey9x);
+
if (IsWine())
{
TRACE("Wine version = %s\n", verhelp_wine_get_version());
@@ -192,6 +273,14 @@ void dbg_init()
TRACE("Wine sysname = %s, release = %s\n", sysname, release);
}
+
+ TRACE("crc32 = %08X\n", Crc32_FromFile(0, exe_path));
+
+ DWORD timestamp = util_get_timestamp(GetModuleHandleA(NULL));
+ if (timestamp)
+ {
+ TRACE("timestamp = %s", asctime(_gmtime32((const long*)×tamp)));
+ }
}
}
@@ -1002,6 +1091,78 @@ void dbg_dump_dds_lock_flags(DWORD flags)
#endif
}
+void dbg_dump_di_scm_flags(DWORD flags)
+{
+#ifdef _DEBUG
+ if (flags & DISCL_EXCLUSIVE) {
+ TRACE(" DISCL_EXCLUSIVE\n");
+ }
+ if (flags & DISCL_NONEXCLUSIVE) {
+ TRACE(" DISCL_NONEXCLUSIVE\n");
+ }
+ if (flags & DISCL_FOREGROUND) {
+ TRACE(" DISCL_FOREGROUND\n");
+ }
+ if (flags & DISCL_BACKGROUND) {
+ TRACE(" DISCL_BACKGROUND\n");
+ }
+ if (flags & DISCL_NOWINKEY) {
+ TRACE(" DISCL_NOWINKEY\n");
+ }
+#endif
+}
+
+void dbg_dump_hook_type(int idHook)
+{
+#ifdef _DEBUG
+ if (idHook == 0) {
+ TRACE(" WH_JOURNALRECORD\n");
+ }
+ if (idHook == 1) {
+ TRACE(" WH_JOURNALPLAYBACK\n");
+ }
+ if (idHook == 2) {
+ TRACE(" WH_KEYBOARD\n");
+ }
+ if (idHook == 3) {
+ TRACE(" WH_GETMESSAGE\n");
+ }
+ if (idHook == 4) {
+ TRACE(" WH_CALLWNDPROC\n");
+ }
+ if (idHook == 5) {
+ TRACE(" WH_CBT\n");
+ }
+ if (idHook == 6) {
+ TRACE(" WH_SYSMSGFILTER\n");
+ }
+ if (idHook == 7) {
+ TRACE(" WH_MOUSE\n");
+ }
+ if (idHook == 9) {
+ TRACE(" WH_DEBUG\n");
+ }
+ if (idHook == 10) {
+ TRACE(" WH_SHELL\n");
+ }
+ if (idHook == 11) {
+ TRACE(" WH_FOREGROUNDIDLE\n");
+ }
+ if (idHook == 12) {
+ TRACE(" WH_CALLWNDPROCRET\n");
+ }
+ if (idHook == 13) {
+ TRACE(" WH_KEYBOARD_LL\n");
+ }
+ if (idHook == 14) {
+ TRACE(" WH_MOUSE_LL\n");
+ }
+ if (idHook == -1) {
+ TRACE(" WH_MSGFILTER\n");
+ }
+#endif
+}
+
char* dbg_d3d9_hr_to_str(HRESULT hr)
{
#define HR_TO_STR(x) if (x == hr) return #x
diff --git a/src/delay_imports.c b/src/delay_imports.c
new file mode 100644
index 0000000..2b23dda
--- /dev/null
+++ b/src/delay_imports.c
@@ -0,0 +1,30 @@
+#include
+#include "versionhelpers.h"
+#include "delay_imports.h"
+
+NTQUERYINFORMATIONTHREADPROC delay_NtQueryInformationThread;
+RTLVERIFYVERSIONINFOPROC delay_RtlVerifyVersionInfo;
+WINE_GET_VERSIONPROC delay_wine_get_version;
+WINE_GET_HOST_VERSIONPROC delay_wine_get_host_version;
+
+VERSETCONDITIONMASKPROC delay_VerSetConditionMask;
+GETMODULEHANDLEEXAPROC delay_GetModuleHandleExA;
+
+void delay_imports_init()
+{
+ HMODULE mod = GetModuleHandleA("ntdll.dll");
+ if (mod)
+ {
+ delay_NtQueryInformationThread = (NTQUERYINFORMATIONTHREADPROC)GetProcAddress(mod, "NtQueryInformationThread");
+ delay_RtlVerifyVersionInfo = (RTLVERIFYVERSIONINFOPROC)GetProcAddress(mod, "RtlVerifyVersionInfo");
+ delay_wine_get_version = (WINE_GET_VERSIONPROC)GetProcAddress(mod, "wine_get_version");
+ delay_wine_get_host_version = (WINE_GET_HOST_VERSIONPROC)GetProcAddress(mod, "wine_get_host_version");
+ }
+
+ mod = GetModuleHandleA("Kernel32.dll");
+ if (mod)
+ {
+ delay_VerSetConditionMask = (VERSETCONDITIONMASKPROC)GetProcAddress(mod, "VerSetConditionMask");
+ delay_GetModuleHandleExA = (GETMODULEHANDLEEXAPROC)GetProcAddress(mod, "GetModuleHandleExA");
+ }
+}
diff --git a/src/directinput.c b/src/directinput.c
index 358374b..a0d077d 100644
--- a/src/directinput.c
+++ b/src/directinput.c
@@ -6,6 +6,7 @@
#include "dd.h"
#include "mouse.h"
#include "config.h"
+#include "utils.h"
#ifdef _MSC_VER
#include "detours.h"
@@ -54,10 +55,12 @@ static PROC hook_func(PROC* org_func, PROC new_func)
static HRESULT WINAPI fake_did_SetCooperativeLevel(IDirectInputDeviceA* This, HWND hwnd, DWORD dwFlags)
{
TRACE("DirectInput SetCooperativeLevel(This=%p, hwnd=%p, dwFlags=0x%08X) [%p]\n", This, hwnd, dwFlags, _ReturnAddress());
+ TRACE(" mouse_device = %s\n", This == g_mouse_device ? "TRUE" : "FALSE");
+ dbg_dump_di_scm_flags(dwFlags);
- if (This == g_mouse_device && g_ddraw.ref && (dwFlags & DISCL_EXCLUSIVE))
+ if (This == g_mouse_device && (dwFlags & DISCL_EXCLUSIVE))
{
- if (g_mouse_locked || g_config.devmode)
+ if (g_mouse_locked || g_config.devmode || !g_ddraw.ref)
{
while (real_ShowCursor(FALSE) >= 0);
}
@@ -84,13 +87,16 @@ static HRESULT WINAPI fake_did_GetDeviceData(
pdwInOut,
dwFlags,
_ReturnAddress());
- */
+ */
+
+ BOOL block_mouse = This == g_mouse_device && !g_mouse_locked && !g_config.devmode;
+ BOOL in_background = FALSE;//g_ddraw.ref && g_ddraw.hwnd && !util_in_foreground(g_ddraw.hwnd);
HRESULT result = real_did_GetDeviceData(This, cbObjectData, rgdod, pdwInOut, dwFlags);
- if (SUCCEEDED(result) && This == g_mouse_device && !g_mouse_locked && !g_config.devmode)
+ if (SUCCEEDED(result))
{
- if (pdwInOut)
+ if ((block_mouse || in_background) && pdwInOut)
{
if (rgdod && *pdwInOut > 0 && cbObjectData > 0)
{
@@ -108,11 +114,14 @@ static HRESULT WINAPI fake_did_GetDeviceState(IDirectInputDeviceA* This, DWORD c
{
//TRACE("DirectInput GetDeviceState(This=%p, cbData=%lu, lpvData=%p) [%p]\n", This, cbData, lpvData, _ReturnAddress());
+ BOOL block_mouse = This == g_mouse_device && !g_mouse_locked && !g_config.devmode;
+ BOOL in_background = g_ddraw.ref && g_ddraw.hwnd && !util_in_foreground(g_ddraw.hwnd);
+
HRESULT result = real_did_GetDeviceState(This, cbData, lpvData);
- if (SUCCEEDED(result) && This == g_mouse_device && !g_mouse_locked && !g_config.devmode)
+ if (SUCCEEDED(result))
{
- if (cbData > 0 && lpvData)
+ if ((block_mouse || in_background) && cbData > 0 && lpvData)
{
memset(lpvData, 0, cbData);
}
@@ -133,9 +142,14 @@ static HRESULT WINAPI fake_di_CreateDevice(
if (SUCCEEDED(result))
{
- if (rguid && IsEqualGUID(&GUID_SysMouse, rguid))
+ if (rguid)
{
- g_mouse_device = *lplpDIDevice;
+ TRACE(" GUID = %08X\n", ((GUID*)rguid)->Data1);
+
+ if (IsEqualGUID(&GUID_SysMouse, rguid))
+ {
+ g_mouse_device = *lplpDIDevice;
+ }
}
if (!real_did_SetCooperativeLevel)
@@ -173,9 +187,14 @@ static HRESULT WINAPI fake_di_CreateDeviceEx(
if (SUCCEEDED(result))
{
- if (rguid && IsEqualGUID(&GUID_SysMouse, rguid))
+ if (rguid)
{
- g_mouse_device = *lplpDIDevice;
+ TRACE(" GUID = %08X\n", ((GUID*)rguid)->Data1);
+
+ if (IsEqualGUID(&GUID_SysMouse, rguid))
+ {
+ g_mouse_device = *lplpDIDevice;
+ }
}
if (!real_did_SetCooperativeLevel)
diff --git a/src/dllmain.c b/src/dllmain.c
index fa8e2d1..8832177 100644
--- a/src/dllmain.c
+++ b/src/dllmain.c
@@ -12,8 +12,8 @@
#include "indeo.h"
#include "utils.h"
#include "versionhelpers.h"
+#include "delay_imports.h"
#include "keyboard.h"
-#include "mouse.h"
/* export for cncnet cnc games */
@@ -24,6 +24,7 @@ PVOID FakePrimarySurface;
HMODULE g_ddraw_module;
+static BOOL g_screensaver_disabled;
BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
{
@@ -33,9 +34,9 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
{
g_ddraw_module = hDll;
- verhelp_init();
+ delay_imports_init();
- if (GetEnvironmentVariableW(L"cnc_ddraw_config_init", NULL, 0))
+ if (GetEnvironmentVariable("cnc_ddraw_config_init", NULL, 0))
{
cfg_load();
return TRUE;
@@ -43,12 +44,19 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
#ifdef _DEBUG
dbg_init();
- TRACE("cnc-ddraw = %p\n", hDll);
g_dbg_exception_filter = real_SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)dbg_exception_handler);
#endif
cfg_load();
+ PVOID(WINAPI * add_handler)(ULONG, PVECTORED_EXCEPTION_HANDLER) =
+ (void*)real_GetProcAddress(GetModuleHandleA("Kernel32.dll"), "AddVectoredExceptionHandler");
+
+ if (add_handler)
+ {
+ g_dbg_exception_handle = add_handler(1, (PVECTORED_EXCEPTION_HANDLER)dbg_vectored_exception_handler);
+ }
+
char buf[1024];
if (GetEnvironmentVariable("__COMPAT_LAYER", buf, sizeof(buf)))
@@ -67,13 +75,14 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
if (_strcmpi(s, "WIN95") == 0 || _strcmpi(s, "WIN98") == 0 || _strcmpi(s, "NT4SP5") == 0)
{
- char mes[128] = { 0 };
+ char mes[280] = { 0 };
_snprintf(
mes,
sizeof(mes) - 1,
- "Please disable the '%s' compatibility mode for all game executables and "
- "then try to start the game again.",
+ "Warning: Compatibility modes detected. \n\nIf there are issues with the game then try to "
+ "disable the '%s' compatibility mode for all game executables.\n\n"
+ "Note: You can disable this warning via ddraw.ini -> 'no_compat_warning=true'",
s);
if (!g_config.no_compat_warning)
@@ -124,6 +133,19 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
set_aware();
}
+ /* Make sure screensaver will stay off and monitors will stay on */
+ SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
+
+ /* WINE does not support SetThreadExecutionState so we'll have to use SPI_SETSCREENSAVEACTIVE instead */
+ BOOL screensaver_enabled = FALSE;
+ SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &screensaver_enabled, 0);
+
+ if (screensaver_enabled)
+ {
+ SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
+ g_screensaver_disabled = TRUE;
+ }
+
indeo_enable();
timeBeginPeriod(1);
hook_init();
@@ -131,7 +153,7 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
}
case DLL_PROCESS_DETACH:
{
- if (GetEnvironmentVariableW(L"cnc_ddraw_config_init", NULL, 0))
+ if (GetEnvironmentVariable("cnc_ddraw_config_init", NULL, 0))
return TRUE;
TRACE("cnc-ddraw DLL_PROCESS_DETACH\n");
@@ -141,11 +163,34 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
indeo_disable();
timeEndPeriod(1);
keyboard_hook_exit();
- mouse_hook_exit();
dinput_hook_exit();
hook_exit();
+
+ SetThreadExecutionState(ES_CONTINUOUS);
+
+ if (g_screensaver_disabled)
+ {
+ SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);
+ }
+
+ ULONG(WINAPI* remove_handler)(PVOID) =
+ (void*)real_GetProcAddress(GetModuleHandleA("Kernel32.dll"), "RemoveVectoredExceptionHandler");
+
+ if (g_dbg_exception_handle && remove_handler)
+ remove_handler(g_dbg_exception_handle);
+
+ if (g_config.terminate_process == 2)
+ TerminateProcess(GetCurrentProcess(), 0);
+
break;
}
+ case DLL_THREAD_ATTACH:
+ {
+ if (g_config.singlecpu && !IsWine() && IsWindows11Version24H2OrGreater())
+ {
+ util_set_thread_affinity(GetCurrentThreadId());
+ }
+ }
}
return TRUE;
@@ -178,7 +223,7 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
HRESULT ret;
- if (util_caller_is_ddraw_wrapper(_ReturnAddress()))
+ if (util_caller_is_ddraw_wrapper(_ReturnAddress()) || g_config.flightsim98_hack)
{
if (lplpDD)
*lplpDD = NULL;
@@ -223,7 +268,7 @@ HRESULT WINAPI DirectDrawCreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnk
HRESULT ret;
- if (util_caller_is_ddraw_wrapper(_ReturnAddress()))
+ if (util_caller_is_ddraw_wrapper(_ReturnAddress()) || g_config.flightsim98_hack)
{
if (lplpDD)
*lplpDD = NULL;
diff --git a/src/fps_limiter.c b/src/fps_limiter.c
index 14c4394..0996784 100644
--- a/src/fps_limiter.c
+++ b/src/fps_limiter.c
@@ -120,16 +120,9 @@ BOOL fpsl_wait_for_vblank()
BOOL fpsl_dwm_flush()
{
- if (g_fpsl.initialized && fpsl_dwm_is_enabled() && g_fpsl.DwmFlush)
+ if (g_fpsl.initialized && fpsl_dwm_is_enabled() && g_fpsl.DwmFlush && !IsWine())
{
- HRESULT x = g_fpsl.DwmFlush();
-
- if (!SUCCEEDED(x))
- {
- //TRACE(" ERROR %s(result=%08X)\n", __FUNCTION__, x);
- }
-
- return SUCCEEDED(x);
+ return SUCCEEDED(g_fpsl.DwmFlush());
}
return FALSE;
diff --git a/src/hook.c b/src/hook.c
index d71bf72..29846c7 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -51,12 +51,19 @@ SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
PEEKMESSAGEAPROC real_PeekMessageA = PeekMessageA;
GETMESSAGEAPROC real_GetMessageA = GetMessageA;
GETWINDOWPLACEMENTPROC real_GetWindowPlacement = GetWindowPlacement;
+SETWINDOWPLACEMENTPROC real_SetWindowPlacement = SetWindowPlacement;
ENUMDISPLAYSETTINGSAPROC real_EnumDisplaySettingsA = EnumDisplaySettingsA;
+DEFWINDOWPROCAPROC real_DefWindowProcA = DefWindowProcA;
+SETPARENTPROC real_SetParent = SetParent;
+BEGINPAINTPROC real_BeginPaint = BeginPaint;
GETKEYSTATEPROC real_GetKeyState = GetKeyState;
GETASYNCKEYSTATEPROC real_GetAsyncKeyState = GetAsyncKeyState;
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA;
CREATEFONTAPROC real_CreateFontA = CreateFontA;
+GETSYSTEMPALETTEENTRIESPROC real_GetSystemPaletteEntries = GetSystemPaletteEntries;
+SELECTPALETTEPROC real_SelectPalette = SelectPalette;
+REALIZEPALETTEPROC real_RealizePalette = RealizePalette;
LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA;
LOADLIBRARYWPROC real_LoadLibraryW = LoadLibraryW;
LOADLIBRARYEXAPROC real_LoadLibraryExA = LoadLibraryExA;
@@ -68,6 +75,13 @@ GETVERSIONEXAPROC real_GetVersionExA = GetVersionExA;
COCREATEINSTANCEPROC real_CoCreateInstance = CoCreateInstance;
MCISENDCOMMANDAPROC real_mciSendCommandA = mciSendCommandA;
SETUNHANDLEDEXCEPTIONFILTERPROC real_SetUnhandledExceptionFilter = SetUnhandledExceptionFilter;
+AVISTREAMGETFRAMEOPENPROC real_AVIStreamGetFrameOpen = AVIStreamGetFrameOpen;
+
+#if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K)
+SETWINDOWLONGWPROC real_SetWindowLongW = SetWindowLongW;
+#else
+SETWINDOWLONGWPROC real_SetWindowLongW;
+#endif
HOOKLIST g_hook_hooklist[] =
{
@@ -102,11 +116,20 @@ HOOKLIST g_hook_hooklist[] =
{ "PeekMessageA", (PROC)fake_PeekMessageA, (PROC*)&real_PeekMessageA, 0 },
{ "GetMessageA", (PROC)fake_GetMessageA, (PROC*)&real_GetMessageA, 0 },
{ "GetWindowPlacement", (PROC)fake_GetWindowPlacement, (PROC*)&real_GetWindowPlacement, 0 },
+ { "SetWindowPlacement", (PROC)fake_SetWindowPlacement, (PROC*)&real_SetWindowPlacement, 0 },
{ "EnumDisplaySettingsA", (PROC)fake_EnumDisplaySettingsA, (PROC*)&real_EnumDisplaySettingsA, 0 },
+ { "DefWindowProcA", (PROC)fake_DefWindowProcA, (PROC*)&real_DefWindowProcA, 0 },
+ { "SetParent", (PROC)fake_SetParent, (PROC*)&real_SetParent, 0 },
+ { "BeginPaint", (PROC)fake_BeginPaint, (PROC*)&real_BeginPaint, 0 },
{ "GetKeyState", (PROC)fake_GetKeyState, (PROC*)&real_GetKeyState, 0 },
{ "GetAsyncKeyState", (PROC)fake_GetAsyncKeyState, (PROC*)&real_GetAsyncKeyState, 0 },
{ "SetForegroundWindow", (PROC)fake_SetForegroundWindow, (PROC*)&real_SetForegroundWindow, 0 },
{ "SetWindowsHookExA", (PROC)fake_SetWindowsHookExA, (PROC*)&real_SetWindowsHookExA, 0 },
+
+#if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K)
+ { "SetWindowLongW", (PROC)fake_SetWindowLongW, (PROC*)&real_SetWindowLongW, 0 },
+#endif
+
{ "", NULL, NULL, 0 }
}
},
@@ -124,6 +147,13 @@ HOOKLIST g_hook_hooklist[] =
{ "", NULL, NULL, 0 }
}
},
+ {
+ "Avifil32.dll",
+ {
+ { "AVIStreamGetFrameOpen", (PROC)fake_AVIStreamGetFrameOpen, (PROC*)&real_AVIStreamGetFrameOpen, 0 },
+ { "", NULL, NULL, 0 }
+ }
+ },
{
"dinput.dll",
{
@@ -148,7 +178,11 @@ HOOKLIST g_hook_hooklist[] =
{ "SetDIBitsToDevice", (PROC)fake_SetDIBitsToDevice, (PROC*)&real_SetDIBitsToDevice, HOOK_SKIP_2 },
{ "StretchDIBits", (PROC)fake_StretchDIBits, (PROC*)&real_StretchDIBits, HOOK_SKIP_2 },
{ "GetDeviceCaps", (PROC)fake_GetDeviceCaps, (PROC*)&real_GetDeviceCaps, HOOK_LOCAL_ONLY },
+ { "GetDeviceCaps", (PROC)fake_GetDeviceCaps_system, NULL, HOOK_SYSTEM_ONLY },
{ "CreateFontA", (PROC)fake_CreateFontA, (PROC*)&real_CreateFontA, 0 },
+ { "GetSystemPaletteEntries", (PROC)fake_GetSystemPaletteEntries, (PROC*)&real_GetSystemPaletteEntries, 0 },
+ { "SelectPalette", (PROC)fake_SelectPalette, (PROC*)&real_SelectPalette, 0 },
+ { "RealizePalette", (PROC)fake_RealizePalette, (PROC*)&real_RealizePalette, 0 },
{ "CreateFontIndirectA", (PROC)fake_CreateFontIndirectA, (PROC*)&real_CreateFontIndirectA, 0 },
{ "", NULL, NULL, 0 }
}
@@ -156,8 +190,8 @@ HOOKLIST g_hook_hooklist[] =
{
"WING32.DLL",
{
- { "WinGBitBlt", (PROC)fake_WinGBitBlt, NULL, HOOK_SKIP_2 },
- { "WinGStretchBlt", (PROC)fake_WinGStretchBlt, NULL, HOOK_SKIP_2 },
+ { "WinGBitBlt", (PROC)fake_WinGBitBlt, NULL, 0 },
+ { "WinGStretchBlt", (PROC)fake_WinGStretchBlt, NULL, 0 },
{ "", NULL, NULL, 0 }
}
},
@@ -169,9 +203,9 @@ HOOKLIST g_hook_hooklist[] =
{ "LoadLibraryExA", (PROC)fake_LoadLibraryExA, (PROC*)&real_LoadLibraryExA, HOOK_SKIP_2 },
{ "LoadLibraryExW", (PROC)fake_LoadLibraryExW, (PROC*)&real_LoadLibraryExW, HOOK_SKIP_2 },
{ "GetProcAddress", (PROC)fake_GetProcAddress, (PROC*)&real_GetProcAddress, HOOK_SKIP_2 },
- { "GetDiskFreeSpaceA", (PROC)fake_GetDiskFreeSpaceA, (PROC*)&real_GetDiskFreeSpaceA, HOOK_SKIP_2 },
- { "GetVersion", (PROC)fake_GetVersion, (PROC*)&real_GetVersion, HOOK_SKIP_2 },
- { "GetVersionExA", (PROC)fake_GetVersionExA, (PROC*)&real_GetVersionExA, HOOK_SKIP_2 },
+ { "GetDiskFreeSpaceA", (PROC)fake_GetDiskFreeSpaceA, (PROC*)&real_GetDiskFreeSpaceA, 0 },
+ { "GetVersion", (PROC)fake_GetVersion, (PROC*)&real_GetVersion, 0 },
+ { "GetVersionExA", (PROC)fake_GetVersionExA, (PROC*)&real_GetVersionExA, 0 },
#if defined(_DEBUG) && defined(__GNUC__)
{ "SetUnhandledExceptionFilter", (PROC)fake_SetUnhandledExceptionFilter, (PROC*)&real_SetUnhandledExceptionFilter, 0 },
#endif
@@ -210,17 +244,15 @@ void hook_patch_obfuscated_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks,
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
return;
- PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew);
+ PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)hmod + (DWORD)dos_header->e_lfanew);
if (nt_headers->Signature != IMAGE_NT_SIGNATURE)
return;
DWORD import_desc_rva = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
- DWORD import_desc_size = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size;
-
- if (import_desc_rva == 0 || import_desc_size == 0)
+ if (!import_desc_rva)
return;
- PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)dos_header + import_desc_rva);
+ PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)hmod + import_desc_rva);
while (import_desc->FirstThunk)
{
@@ -232,13 +264,13 @@ void hook_patch_obfuscated_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks,
for (int i = 0; hooks[i].module_name[0]; i++)
{
- char* imp_module_name = (char*)((DWORD)dos_header + import_desc->Name);
+ char* imp_module_name = (char*)((DWORD)hmod + import_desc->Name);
if (_stricmp(imp_module_name, hooks[i].module_name) == 0)
{
HMODULE cur_mod = GetModuleHandleA(hooks[i].module_name);
- PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)dos_header + import_desc->FirstThunk);
+ PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)hmod + import_desc->FirstThunk);
while (first_thunk->u1.Function)
{
@@ -262,6 +294,9 @@ void hook_patch_obfuscated_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks,
if (!is_local && (hooks[i].data[x].flags & HOOK_LOCAL_ONLY))
continue;
+ if (is_local && (hooks[i].data[x].flags & HOOK_SYSTEM_ONLY))
+ continue;
+
if (unhook)
{
if (first_thunk->u1.Function == (DWORD)hooks[i].data[x].new_function)
@@ -332,17 +367,15 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks, BOOL is_loc
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
return;
- PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew);
+ PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)hmod + (DWORD)dos_header->e_lfanew);
if (nt_headers->Signature != IMAGE_NT_SIGNATURE)
return;
DWORD import_desc_rva = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
- DWORD import_desc_size = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size;
-
- if (import_desc_rva == 0 || import_desc_size == 0)
+ if (!import_desc_rva)
return;
- PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)dos_header + import_desc_rva);
+ PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)hmod + import_desc_rva);
while (import_desc->FirstThunk)
{
@@ -354,12 +387,12 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks, BOOL is_loc
for (int i = 0; hooks[i].module_name[0]; i++)
{
- char* imp_module_name = (char*)((DWORD)dos_header + import_desc->Name);
+ char* imp_module_name = (char*)((DWORD)hmod + import_desc->Name);
if (_stricmp(imp_module_name, hooks[i].module_name) == 0)
{
- PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)dos_header + import_desc->FirstThunk);
- PIMAGE_THUNK_DATA o_first_thunk = (void*)((DWORD)dos_header + import_desc->OriginalFirstThunk);
+ PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)hmod + import_desc->FirstThunk);
+ PIMAGE_THUNK_DATA o_first_thunk = (void*)((DWORD)hmod + import_desc->OriginalFirstThunk);
while (first_thunk->u1.Function)
{
@@ -382,6 +415,9 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks, BOOL is_loc
if (!is_local && (hooks[i].data[x].flags & HOOK_LOCAL_ONLY))
continue;
+ if (is_local && (hooks[i].data[x].flags & HOOK_SYSTEM_ONLY))
+ continue;
+
#if defined(__GNUC__)
if (util_is_bad_read_ptr((void*)import->Name))
continue;
@@ -450,27 +486,25 @@ BOOL hook_got_ddraw_import(HMODULE mod, BOOL check_imported_dlls)
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
return FALSE;
- PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew);
+ PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)mod + (DWORD)dos_header->e_lfanew);
if (nt_headers->Signature != IMAGE_NT_SIGNATURE)
return FALSE;
DWORD import_desc_rva = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
- DWORD import_desc_size = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size;
-
- if (import_desc_rva == 0 || import_desc_size == 0)
+ if (!import_desc_rva)
return FALSE;
- PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)dos_header + import_desc_rva);
+ PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)mod + import_desc_rva);
while (import_desc->FirstThunk)
{
if (import_desc->Name)
{
- char* imp_module_name = (char*)((DWORD)dos_header + import_desc->Name);
+ char* imp_module_name = (char*)((DWORD)mod + import_desc->Name);
if (_stricmp(imp_module_name, "ddraw.dll") == 0)
{
- PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)dos_header + import_desc->FirstThunk);
+ PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)mod + import_desc->FirstThunk);
if (first_thunk->u1.Function)
return TRUE;
@@ -649,6 +683,8 @@ void hook_init()
{
/* Switch to 3 if we can be sure that ddraw.dll will not be unloaded from the process */
g_config.hook = 3;
+
+ TRACE("Switched to hook 3\n");
}
}
diff --git a/src/keyboard.c b/src/keyboard.c
index 109269b..f54ba63 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -62,6 +62,14 @@ LRESULT CALLBACK keyboard_hook_proc(int code, WPARAM wParam, LPARAM lParam)
return 1;
}
+ if (wParam == g_config.hotkeys.toggle_fullscreen2)
+ {
+ if (key_triggered)
+ util_toggle_fullscreen();
+
+ return 1;
+ }
+
if (wParam == g_config.hotkeys.toggle_maximize && alt_down && key_down)
{
if (key_triggered)
@@ -70,17 +78,30 @@ LRESULT CALLBACK keyboard_hook_proc(int code, WPARAM wParam, LPARAM lParam)
return 1;
}
- if (wParam == VK_F4 && g_config.homm_hack) /* Heroes of Might and Magic 3 and 4 */
+ if (wParam == g_config.hotkeys.toggle_maximize2)
{
if (key_triggered)
- util_toggle_fullscreen();
+ util_toggle_maximize();
return 1;
}
- if (wParam == g_config.hotkeys.screenshot && key_released)
+ if (wParam == g_config.hotkeys.screenshot)
{
- ss_take_screenshot(g_ddraw.primary);
+ // VK_SNAPSHOT does not have a KEYDOWN event...
+ if (g_config.hotkeys.screenshot == VK_SNAPSHOT)
+ {
+ if (key_released)
+ {
+ ss_take_screenshot(g_ddraw.primary);
+ return 1;
+ }
+ }
+ else if (key_triggered)
+ {
+ ss_take_screenshot(g_ddraw.primary);
+ return 1;
+ }
}
if (wParam == g_config.hotkeys.unlock_cursor1 || wParam == VK_CONTROL)
diff --git a/src/mouse.c b/src/mouse.c
index 3e0d0ac..46aca13 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1,45 +1,15 @@
#include
-#include
-#include
#include "debug.h"
#include "winapi_hooks.h"
#include "dd.h"
#include "hook.h"
#include "utils.h"
#include "config.h"
-#include "mouse.h"
BOOL g_mouse_locked;
HHOOK g_mouse_hook;
HOOKPROC g_mouse_proc;
-static HHOOK g_mouse_gm_hook;
-
-void mouse_hook_init()
-{
- if (g_mouse_gm_hook && UnhookWindowsHookEx(g_mouse_gm_hook))
- {
- g_mouse_gm_hook = NULL;
- }
-
- if (!g_ddraw.gui_thread_id)
- return;
-
- g_mouse_gm_hook =
- real_SetWindowsHookExA(
- WH_GETMESSAGE,
- mouse_gm_hook_proc,
- NULL,
- g_ddraw.gui_thread_id);
-}
-
-void mouse_hook_exit()
-{
- if (g_mouse_gm_hook)
- {
- UnhookWindowsHookEx(g_mouse_gm_hook);
- }
-}
void mouse_lock()
{
@@ -113,79 +83,15 @@ void mouse_unlock()
}
}
-LRESULT CALLBACK mouse_gm_hook_proc(int code, WPARAM wParam, LPARAM lParam)
-{
- MSG* msg = (MSG*)lParam;
-
- if (code < 0 || !g_ddraw.width || !msg || msg->hwnd != g_ddraw.hwnd)
- return CallNextHookEx(g_mouse_gm_hook, code, wParam, lParam);
-
- switch (LOWORD(msg->message))
- {
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- case WM_XBUTTONUP:
- case WM_MOUSEWHEEL:
- case WM_MOUSEHOVER:
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_MOUSEMOVE:
- {
- if (LOWORD(msg->message) == WM_MOUSEWHEEL)
- {
- POINT pt = { GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam) };
- real_ScreenToClient(g_ddraw.hwnd, &pt);
- msg->lParam = MAKELPARAM(pt.x, pt.y);
- }
-
- int x = max(GET_X_LPARAM(msg->lParam) - g_ddraw.mouse.x_adjust, 0);
- int y = max(GET_Y_LPARAM(msg->lParam) - g_ddraw.mouse.y_adjust, 0);
-
- if (g_config.adjmouse)
- {
- if (g_config.vhack && !g_config.devmode)
- {
- POINT pt = { 0, 0 };
- fake_GetCursorPos(&pt);
-
- x = pt.x;
- y = pt.y;
- }
- else
- {
- x = (DWORD)(roundf(x * g_ddraw.mouse.unscale_x));
- y = (DWORD)(roundf(y * g_ddraw.mouse.unscale_y));
- }
- }
-
- x = min(x, g_ddraw.width - 1);
- y = min(y, g_ddraw.height - 1);
-
- msg->lParam = MAKELPARAM(x, y);
-
- break;
- }
- }
-
- return CallNextHookEx(g_mouse_gm_hook, code, wParam, lParam);
-}
-
-LRESULT CALLBACK mouse_hook_proc(int code, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK mouse_hook_proc(int Code, WPARAM wParam, LPARAM lParam)
{
if (!g_ddraw.ref)
- return g_mouse_proc(code, wParam, lParam);
+ return g_mouse_proc(Code, wParam, lParam);
- if (code < 0 || (!g_config.devmode && !g_mouse_locked))
- return CallNextHookEx(g_mouse_hook, code, wParam, lParam);
+ if (Code < 0 || (!g_config.devmode && !g_mouse_locked))
+ return CallNextHookEx(g_mouse_hook, Code, wParam, lParam);
fake_GetCursorPos(&((MOUSEHOOKSTRUCT*)lParam)->pt);
- return g_mouse_proc(code, wParam, lParam);
+ return g_mouse_proc(Code, wParam, lParam);
}
diff --git a/src/opengl_utils.c b/src/opengl_utils.c
index 8222f10..e315b15 100644
--- a/src/opengl_utils.c
+++ b/src/opengl_utils.c
@@ -95,6 +95,7 @@ HMODULE g_oglu_hmodule;
BOOL g_oglu_got_version2;
BOOL g_oglu_got_version3;
char g_oglu_version[128];
+char g_oglu_version_long[128];
BOOL oglu_load_dll()
{
@@ -201,6 +202,7 @@ void oglu_init()
if (glversion)
{
strncpy(g_oglu_version, glversion, sizeof(g_oglu_version) - 1);
+ strncpy(g_oglu_version_long, glversion, sizeof(g_oglu_version_long) - 1);
g_oglu_version[sizeof(g_oglu_version) - 1] = '\0'; /* strncpy fix */
strtok(g_oglu_version, " ");
}
@@ -231,20 +233,28 @@ void oglu_init()
BOOL oglu_ext_exists(char* ext, HDC hdc)
{
+ BOOL got_num_extensions = FALSE;
+
if (glGetIntegerv && glGetStringi)
{
GLint n = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
- for (GLint i = 0; i < n; i++)
+ if (glGetError() == GL_NO_ERROR)
{
- char* glext = (char*)glGetStringi(GL_EXTENSIONS, i);
+ got_num_extensions = TRUE;
- if (glext && strcmp(glext, ext) == 0)
- return TRUE;
+ for (GLint i = 0; i < n; i++)
+ {
+ char* glext = (char*)glGetStringi(GL_EXTENSIONS, i);
+
+ if (glext && strcmp(glext, ext) == 0)
+ return TRUE;
+ }
}
}
- else
+
+ if (!got_num_extensions)
{
char* glext = (char*)glGetString(GL_EXTENSIONS);
diff --git a/src/render_gdi.c b/src/render_gdi.c
index 5ad3586..c7292ed 100644
--- a/src/render_gdi.c
+++ b/src/render_gdi.c
@@ -99,14 +99,17 @@ DWORD WINAPI gdi_render_main(void)
FillRect(g_ddraw.render.hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
}
+ int lines_copied = 0;
+
if (g_ddraw.bnet_active)
{
RECT rc = { 0, 0, g_ddraw.render.width, g_ddraw.render.height };
FillRect(g_ddraw.render.hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
+ lines_copied = 1;
}
else if (upscale_hack)
{
- real_StretchDIBits(
+ lines_copied = real_StretchDIBits(
g_ddraw.render.hdc,
g_ddraw.render.viewport.x,
g_ddraw.render.viewport.y,
@@ -124,7 +127,7 @@ DWORD WINAPI gdi_render_main(void)
else if (!g_ddraw.child_window_exists &&
(g_ddraw.render.width != g_ddraw.width || g_ddraw.render.height != g_ddraw.height))
{
- real_StretchDIBits(
+ lines_copied = real_StretchDIBits(
g_ddraw.render.hdc,
g_ddraw.render.viewport.x,
g_ddraw.render.viewport.y,
@@ -139,7 +142,8 @@ DWORD WINAPI gdi_render_main(void)
DIB_RGB_COLORS,
SRCCOPY);
}
- else
+
+ if (lines_copied == 0 || lines_copied == GDI_ERROR)
{
real_SetDIBitsToDevice(
g_ddraw.render.hdc,
diff --git a/src/render_ogl.c b/src/render_ogl.c
index be0793e..aae1d34 100644
--- a/src/render_ogl.c
+++ b/src/render_ogl.c
@@ -111,6 +111,8 @@ DWORD WINAPI ogl_render_main(void)
{
GL_CHECK(oglu_init());
+ g_ogl.got_error = g_ogl.got_error || (err = glGetError()) != GL_NO_ERROR;
+
BOOL got_swap_ctrl;
GL_CHECK(got_swap_ctrl = oglu_ext_exists("WGL_EXT_swap_control", g_ogl.hdc));
@@ -246,6 +248,15 @@ static void ogl_build_programs()
_snprintf(shader_path, sizeof(shader_path) - 1, "%s%s", g_config.dll_path, g_config.shader);
}
+ /* Hack for Intel HD 4000 driver bug - force default shader */
+
+ if (_stricmp(g_oglu_version_long, "4.0.0 - Build 10.18.10.4252") == 0 ||
+ _stricmp(g_oglu_version_long, "4.0.0 - Build 10.18.10.5161") == 0)
+ {
+ //shader_path[0] = 0;
+ //g_config.shader[0] = 0;
+ }
+
/* detect common upscaling shaders and disable them if no upscaling is required */
BOOL is_upscaler =
@@ -594,8 +605,10 @@ static void ogl_init_shader1_program()
glUseProgram(g_ogl.shader1_program);
GLint vertex_coord_attr_loc = glGetAttribLocation(g_ogl.shader1_program, "VertexCoord");
+ if (vertex_coord_attr_loc == -1) // dosbox staging
+ vertex_coord_attr_loc = glGetAttribLocation(g_ogl.shader1_program, "a_position");
+
g_ogl.shader1_tex_coord_attr_loc = glGetAttribLocation(g_ogl.shader1_program, "TexCoord");
- g_ogl.shader1_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader1_program, "FrameCount");
glGenBuffers(3, g_ogl.shader1_vbos);
@@ -652,10 +665,13 @@ static void ogl_init_shader1_program()
glEnableVertexAttribArray(vertex_coord_attr_loc);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ARRAY_BUFFER, g_ogl.shader1_vbos[1]);
- glVertexAttribPointer(g_ogl.shader1_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
- glEnableVertexAttribArray(g_ogl.shader1_tex_coord_attr_loc);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+ if (g_ogl.shader1_tex_coord_attr_loc != -1)
+ {
+ glBindBuffer(GL_ARRAY_BUFFER, g_ogl.shader1_vbos[1]);
+ glVertexAttribPointer(g_ogl.shader1_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(g_ogl.shader1_tex_coord_attr_loc);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ogl.shader1_vbos[2]);
static const GLushort indices[] =
@@ -677,24 +693,44 @@ static void ogl_init_shader1_program()
output_size[1] = (float)g_ddraw.render.viewport.height;
GLint loc = glGetUniformLocation(g_ogl.shader1_program, "OutputSize");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader1_program, "rubyOutputSize");
+
if (loc != -1)
glUniform2fv(loc, 1, output_size);
+
loc = glGetUniformLocation(g_ogl.shader1_program, "TextureSize");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader1_program, "rubyTextureSize");
+
if (loc != -1)
glUniform2fv(loc, 1, texture_size);
+
loc = glGetUniformLocation(g_ogl.shader1_program, "InputSize");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader1_program, "rubyInputSize");
+
if (loc != -1)
glUniform2fv(loc, 1, input_size);
+
+ loc = glGetUniformLocation(g_ogl.shader1_program, "Texture");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader1_program, "rubyTexture");
+
+ if (loc != -1)
+ glUniform1i(loc, 0);
+
+
loc = glGetUniformLocation(g_ogl.shader1_program, "FrameDirection");
if (loc != -1)
glUniform1i(loc, 1);
- loc = glGetUniformLocation(g_ogl.shader1_program, "Texture");
- if (loc != -1)
- glUniform1i(loc, 0);
+ g_ogl.shader1_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader1_program, "FrameCount");
+ if (g_ogl.shader1_frame_count_uni_loc == -1)
+ g_ogl.shader1_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader1_program, "rubyFrameCount");
const float mvp_matrix[16] = {
1,0,0,0,
@@ -702,7 +738,10 @@ static void ogl_init_shader1_program()
0,0,1,0,
0,0,0,1,
};
- glUniformMatrix4fv(glGetUniformLocation(g_ogl.shader1_program, "MVPMatrix"), 1, GL_FALSE, mvp_matrix);
+
+ loc = glGetUniformLocation(g_ogl.shader1_program, "MVPMatrix");
+ if (loc != -1)
+ glUniformMatrix4fv(loc, 1, GL_FALSE, mvp_matrix);
glGenFramebuffers(FBO_COUNT, g_ogl.frame_buffer_id);
glGenTextures(FBO_COUNT, g_ogl.frame_buffer_tex_id);
@@ -808,8 +847,10 @@ static void ogl_init_shader2_program()
glUseProgram(g_ogl.shader2_program);
GLint vertex_coord_attr_loc = glGetAttribLocation(g_ogl.shader2_program, "VertexCoord");
+ if (vertex_coord_attr_loc == -1)
+ vertex_coord_attr_loc = glGetAttribLocation(g_ogl.shader2_program, "a_position");
+
g_ogl.shader2_tex_coord_attr_loc = glGetAttribLocation(g_ogl.shader2_program, "TexCoord");
- g_ogl.shader2_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader2_program, "FrameCount");
glGenBuffers(3, g_ogl.shader2_vbos);
@@ -844,10 +885,13 @@ static void ogl_init_shader2_program()
glEnableVertexAttribArray(vertex_coord_attr_loc);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ARRAY_BUFFER, g_ogl.shader2_vbos[1]);
- glVertexAttribPointer(g_ogl.shader2_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
- glEnableVertexAttribArray(g_ogl.shader2_tex_coord_attr_loc);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+ if (g_ogl.shader2_tex_coord_attr_loc != -1)
+ {
+ glBindBuffer(GL_ARRAY_BUFFER, g_ogl.shader2_vbos[1]);
+ glVertexAttribPointer(g_ogl.shader2_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(g_ogl.shader2_tex_coord_attr_loc);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ogl.shader2_vbos[2]);
static const GLushort indices[] =
@@ -869,25 +913,37 @@ static void ogl_init_shader2_program()
output_size[1] = (float)g_ddraw.render.viewport.height;
GLint loc = glGetUniformLocation(g_ogl.shader2_program, "OutputSize");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader2_program, "rubyOutputSize");
+
if (loc != -1)
glUniform2fv(loc, 1, output_size);
+
loc = glGetUniformLocation(g_ogl.shader2_program, "TextureSize");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader2_program, "rubyTextureSize");
+
if (loc != -1)
glUniform2fv(loc, 1, texture_size);
+
loc = glGetUniformLocation(g_ogl.shader2_program, "InputSize");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader2_program, "rubyInputSize");
+
if (loc != -1)
glUniform2fv(loc, 1, input_size);
- loc = glGetUniformLocation(g_ogl.shader2_program, "FrameDirection");
- if (loc != -1)
- glUniform1i(loc, 1);
loc = glGetUniformLocation(g_ogl.shader2_program, "Texture");
+ if (loc == -1)
+ loc = glGetUniformLocation(g_ogl.shader2_program, "rubyTexture");
+
if (loc != -1)
glUniform1i(loc, 0);
+
loc = glGetUniformLocation(g_ogl.shader2_program, "PassPrev2Texture");
if (loc != -1)
glUniform1i(loc, 1);
@@ -896,13 +952,24 @@ static void ogl_init_shader2_program()
if (loc != -1)
glUniform2fv(loc, 1, texture_size);
+ loc = glGetUniformLocation(g_ogl.shader2_program, "FrameDirection");
+ if (loc != -1)
+ glUniform1i(loc, 1);
+
+ g_ogl.shader2_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader2_program, "FrameCount");
+ if (g_ogl.shader2_frame_count_uni_loc == -1)
+ g_ogl.shader2_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader2_program, "rubyFrameCount");
+
const float mvp_matrix[16] = {
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1,
};
- glUniformMatrix4fv(glGetUniformLocation(g_ogl.shader2_program, "MVPMatrix"), 1, GL_FALSE, mvp_matrix);
+
+ loc = glGetUniformLocation(g_ogl.shader2_program, "MVPMatrix");
+ if (loc != -1)
+ glUniformMatrix4fv(loc, 1, GL_FALSE, mvp_matrix);
}
static void ogl_render()
@@ -923,6 +990,11 @@ static void ogl_render()
{
glEnable(GL_TEXTURE_2D);
}
+ else // 8 bpp only works with a shader (opengl 2.0 or above)
+ {
+ g_ogl.use_opengl = FALSE;
+ return;
+ }
DWORD timeout = g_config.minfps > 0 ? g_ddraw.minfps_tick_len : INFINITE;
@@ -1089,8 +1161,11 @@ static void ogl_render()
0.0f, g_ogl.scale_h,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord), tex_coord, GL_STATIC_DRAW);
- glVertexAttribPointer(g_ogl.shader2_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
- glEnableVertexAttribArray(g_ogl.shader2_tex_coord_attr_loc);
+ if (g_ogl.shader2_tex_coord_attr_loc != -1)
+ {
+ glVertexAttribPointer(g_ogl.shader2_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(g_ogl.shader2_tex_coord_attr_loc);
+ }
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
@@ -1105,8 +1180,11 @@ static void ogl_render()
g_ogl.scale_w, 0.0f,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord), tex_coord, GL_STATIC_DRAW);
- glVertexAttribPointer(g_ogl.shader1_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
- glEnableVertexAttribArray(g_ogl.shader1_tex_coord_attr_loc);
+ if (g_ogl.shader1_tex_coord_attr_loc != -1)
+ {
+ glVertexAttribPointer(g_ogl.shader1_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(g_ogl.shader1_tex_coord_attr_loc);
+ }
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
@@ -1121,8 +1199,11 @@ static void ogl_render()
0.0f, g_ogl.scale_h,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord), tex_coord, GL_STATIC_DRAW);
- glVertexAttribPointer(g_ogl.shader1_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
- glEnableVertexAttribArray(g_ogl.shader1_tex_coord_attr_loc);
+ if (g_ogl.shader1_tex_coord_attr_loc != -1)
+ {
+ glVertexAttribPointer(g_ogl.shader1_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(g_ogl.shader1_tex_coord_attr_loc);
+ }
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
@@ -1144,7 +1225,9 @@ static void ogl_render()
}
}
- glActiveTexture(GL_TEXTURE0);
+ if (glActiveTexture)
+ glActiveTexture(GL_TEXTURE0);
+
glBindTexture(GL_TEXTURE_2D, g_ogl.surface_tex_ids[tex_index]);
if (g_ddraw.bpp == 8)
diff --git a/src/utils.c b/src/utils.c
index ee7b8cd..fafd4ed 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,6 +1,8 @@
#include
#include
+#include
#include
+#include
#include "ddraw.h"
#include "debug.h"
#include "dd.h"
@@ -10,6 +12,8 @@
#include "render_d3d9.h"
#include "utils.h"
#include "config.h"
+#include "versionhelpers.h"
+#include "delay_imports.h"
/*
@@ -69,6 +73,123 @@ HMODULE WINAPI util_enumerate_modules(_In_opt_ HMODULE hModuleLast)
return NULL;
}
+void util_set_process_affinity()
+{
+#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
+ HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
+ if (snap == INVALID_HANDLE_VALUE)
+ return;
+
+ THREADENTRY32 entry = { 0 };
+ entry.dwSize = sizeof(THREADENTRY32);
+
+ if (!Thread32First(snap, &entry))
+ {
+ CloseHandle(snap);
+ return;
+ }
+
+ do
+ {
+ if (entry.th32OwnerProcessID == GetCurrentProcessId())
+ {
+ util_set_thread_affinity(entry.th32ThreadID);
+ }
+ } while (Thread32Next(snap, &entry));
+
+ CloseHandle(snap);
+#endif
+}
+
+void util_set_thread_affinity(DWORD tid)
+{
+#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
+ HANDLE thread = OpenThread(THREAD_QUERY_INFORMATION | THREAD_SET_INFORMATION, FALSE, tid);
+ if (thread)
+ {
+ void* start = NULL;
+ NTSTATUS status = STATUS_PENDING;
+
+ if (delay_NtQueryInformationThread)
+ {
+ status =
+ delay_NtQueryInformationThread(thread, ThreadQuerySetWin32StartAddress, &start, sizeof(start), NULL);
+ }
+
+ if (status == STATUS_SUCCESS && start && delay_GetModuleHandleExA)
+ {
+ char game_exe_path[MAX_PATH] = { 0 };
+ char game_dir[MAX_PATH] = { 0 };
+
+ if (GetModuleFileNameA(NULL, game_exe_path, sizeof(game_exe_path)))
+ {
+ _splitpath(game_exe_path, NULL, game_dir, NULL, NULL);
+
+ char mod_path[MAX_PATH] = { 0 };
+ char mod_dir[MAX_PATH] = { 0 };
+ char mod_filename[MAX_PATH] = { 0 };
+ HMODULE mod = NULL;
+
+ if (delay_GetModuleHandleExA(
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, start, &mod))
+ {
+ if (GetModuleFileNameA(mod, mod_path, sizeof(mod_path)))
+ {
+ _splitpath(mod_path, NULL, mod_dir, mod_filename, NULL);
+
+ if (_strnicmp(game_dir, mod_dir, strlen(game_dir)) == 0) // _strcmpi(mod_filename, "WINMM") == 0
+ {
+ SetThreadAffinityMask(thread, 1);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ SetThreadAffinityMask(thread, 1);
+ }
+
+ CloseHandle(thread);
+ }
+#endif
+}
+
+void util_pull_messages()
+{
+ if (g_config.fix_not_responding &&
+ g_ddraw.hwnd &&
+ g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
+ GetCurrentThreadId() == g_ddraw.gui_thread_id &&
+ !IsWine())
+ {
+ /* workaround for "Not Responding" window problem */
+ //g_ddraw.last_msg_pull_tick = timeGetTime();
+ MSG msg;
+ if (real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessageA(&msg);
+ }
+ }
+}
+
+DWORD util_get_timestamp(HMODULE mod)
+{
+ if (!mod || mod == INVALID_HANDLE_VALUE)
+ return 0;
+
+ PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)mod;
+ if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
+ return 0;
+
+ PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew);
+ if (nt_headers->Signature != IMAGE_NT_SIGNATURE)
+ return 0;
+
+ return nt_headers->FileHeader.TimeDateStamp;
+}
+
FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
{
if (!mod || mod == INVALID_HANDLE_VALUE)
@@ -80,17 +201,15 @@ FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
return NULL;
- PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew);
+ PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)mod + (DWORD)dos_header->e_lfanew);
if (nt_headers->Signature != IMAGE_NT_SIGNATURE)
return NULL;
DWORD import_desc_rva = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
- DWORD import_desc_size = nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size;
-
- if (import_desc_rva == 0 || import_desc_size == 0)
+ if (!import_desc_rva)
return NULL;
- PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)dos_header + import_desc_rva);
+ PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)mod + import_desc_rva);
while (import_desc->FirstThunk)
{
@@ -100,12 +219,12 @@ FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
continue;
}
- char* imp_module_name = (char*)((DWORD)dos_header + import_desc->Name);
+ char* imp_module_name = (char*)((DWORD)mod + import_desc->Name);
if (_stricmp(imp_module_name, module_name) == 0)
{
- PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)dos_header + import_desc->FirstThunk);
- PIMAGE_THUNK_DATA o_first_thunk = (void*)((DWORD)dos_header + import_desc->OriginalFirstThunk);
+ PIMAGE_THUNK_DATA first_thunk = (void*)((DWORD)mod + import_desc->FirstThunk);
+ PIMAGE_THUNK_DATA o_first_thunk = (void*)((DWORD)mod + import_desc->OriginalFirstThunk);
while (first_thunk->u1.Function)
{
@@ -116,7 +235,7 @@ FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
continue;
}
- PIMAGE_IMPORT_BY_NAME import = (void*)((DWORD)dos_header + o_first_thunk->u1.AddressOfData);
+ PIMAGE_IMPORT_BY_NAME import = (void*)((DWORD)mod + o_first_thunk->u1.AddressOfData);
if ((o_first_thunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) == 0)
{
@@ -148,10 +267,7 @@ FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
BOOL util_caller_is_ddraw_wrapper(void* return_address)
{
- BOOL (WINAPI *getModuleHandleExA)(DWORD, LPCSTR, HMODULE*) =
- (void*)real_GetProcAddress(real_LoadLibraryA("Kernel32.dll"), "GetModuleHandleExA");
-
- if (!getModuleHandleExA)
+ if (!delay_GetModuleHandleExA)
return FALSE;
void* directDrawCreate = (void*)util_get_iat_proc(GetModuleHandleA(NULL), "ddraw.dll", "DirectDrawCreate");
@@ -165,9 +281,9 @@ BOOL util_caller_is_ddraw_wrapper(void* return_address)
HMODULE D3dHook_dll = GetModuleHandleA("D3dHook.dll");
if (D3dHook_dll)
{
- if ((getModuleHandleExA(flags, return_address, &mod) && mod == D3dHook_dll) ||
- (getModuleHandleExA(flags, directDrawCreate, &mod) && mod == D3dHook_dll) ||
- (getModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == D3dHook_dll))
+ if ((delay_GetModuleHandleExA(flags, return_address, &mod) && mod == D3dHook_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreate, &mod) && mod == D3dHook_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == D3dHook_dll))
{
MessageBoxA(
NULL,
@@ -183,9 +299,9 @@ BOOL util_caller_is_ddraw_wrapper(void* return_address)
HMODULE wndmode_dll = GetModuleHandleA("wndmode.dll");
if (wndmode_dll)
{
- if ((getModuleHandleExA(flags, return_address, &mod) && mod == wndmode_dll) ||
- (getModuleHandleExA(flags, directDrawCreate, &mod) && mod == wndmode_dll) ||
- (getModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == wndmode_dll))
+ if ((delay_GetModuleHandleExA(flags, return_address, &mod) && mod == wndmode_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreate, &mod) && mod == wndmode_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == wndmode_dll))
{
MessageBoxA(
NULL,
@@ -201,9 +317,9 @@ BOOL util_caller_is_ddraw_wrapper(void* return_address)
HMODULE windmode_dll = GetModuleHandleA("windmode.dll");
if (windmode_dll)
{
- if ((getModuleHandleExA(flags, return_address, &mod) && mod == windmode_dll) ||
- (getModuleHandleExA(flags, directDrawCreate, &mod) && mod == windmode_dll) ||
- (getModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == windmode_dll))
+ if ((delay_GetModuleHandleExA(flags, return_address, &mod) && mod == windmode_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreate, &mod) && mod == windmode_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == windmode_dll))
{
MessageBoxA(
NULL,
@@ -219,9 +335,9 @@ BOOL util_caller_is_ddraw_wrapper(void* return_address)
HMODULE dxwnd_dll = GetModuleHandleA("dxwnd.dll");
if (dxwnd_dll)
{
- if ((getModuleHandleExA(flags, return_address, &mod) && mod == dxwnd_dll) ||
- (getModuleHandleExA(flags, directDrawCreate, &mod) && mod == dxwnd_dll) ||
- (getModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == dxwnd_dll))
+ if ((delay_GetModuleHandleExA(flags, return_address, &mod) && mod == dxwnd_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreate, &mod) && mod == dxwnd_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == dxwnd_dll))
{
MessageBoxA(
NULL,
@@ -237,9 +353,9 @@ BOOL util_caller_is_ddraw_wrapper(void* return_address)
HMODULE age_dll = GetModuleHandleA("age.dll");
if (age_dll)
{
- if ((getModuleHandleExA(flags, return_address, &mod) && mod == age_dll) ||
- (getModuleHandleExA(flags, directDrawCreate, &mod) && mod == age_dll) ||
- (getModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == age_dll))
+ if ((delay_GetModuleHandleExA(flags, return_address, &mod) && mod == age_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreate, &mod) && mod == age_dll) ||
+ (delay_GetModuleHandleExA(flags, directDrawCreateEx, &mod) && mod == age_dll))
{
HKEY hkey;
LONG status =
@@ -576,6 +692,10 @@ void util_toggle_maximize()
if (!g_config.resizable || !g_config.windowed || g_config.fullscreen || !g_ddraw.width)
return;
+ /* Do not allow cnc-ddraw maximize while macOS maximize is active */
+ if (IsMacOS() && !g_config.window_rect.left && !g_config.window_rect.top)
+ return;
+
RECT client_rc;
RECT dst_rc;
@@ -680,6 +800,10 @@ void util_toggle_fullscreen()
if (g_ddraw.bnet_active || !g_ddraw.width || (g_config.infantryhack && GetMenu(g_ddraw.hwnd)))
return;
+ /* Do not allow ALT+ENTER while macOS maximize is active */
+ if (IsMacOS() && !g_config.window_rect.left && !g_config.window_rect.top)
+ return;
+
if (g_config.toggle_borderless && g_config.windowed)
{
if (!g_config.fullscreen)
@@ -865,6 +989,7 @@ BOOL CALLBACK util_enum_child_proc(HWND hwnd, LPARAM lparam)
if (g_config.fixchilds == FIX_CHILDS_DETECT_HIDE ||
g_config.fixchilds == FIX_CHILDS_DETECT_HIDE_NOSCALE ||
+ strcmp(class_name, "Cc2EditClassTh") == 0 ||
strcmp(class_name, "msctls_statusbar32") == 0 ||
strcmp(class_name, "VideoRenderer") == 0 ||
strcmp(class_name, "MCIQTZ_Window") == 0 ||
diff --git a/src/versionhelpers.c b/src/versionhelpers.c
index e422e90..f9f35c2 100644
--- a/src/versionhelpers.c
+++ b/src/versionhelpers.c
@@ -1,43 +1,30 @@
#include
#include "versionhelpers.h"
+#include "delay_imports.h"
-typedef NTSTATUS(WINAPI* RTLVERIFYVERSIONINFOPROC)(PRTL_OSVERSIONINFOEXW, ULONG, ULONGLONG);
-typedef const char* (CDECL* WINE_GET_VERSIONPROC)();
-typedef void (CDECL* WINE_GET_HOST_VERSIONPROC)(const char** sysname, const char** release);
-
-static RTLVERIFYVERSIONINFOPROC RtlVerifyVersionInfo;
-static WINE_GET_VERSIONPROC wine_get_version;
-static WINE_GET_HOST_VERSIONPROC wine_get_host_version;
-
-/* GetProcAddress is rather slow so we use a function to initialize it once on startup */
-void verhelp_init()
-{
- HMODULE mod = GetModuleHandleA("ntdll.dll");
- if (mod)
- {
- RtlVerifyVersionInfo = (RTLVERIFYVERSIONINFOPROC)GetProcAddress(mod, "RtlVerifyVersionInfo");
- wine_get_version = (WINE_GET_VERSIONPROC)GetProcAddress(mod, "wine_get_version");
- wine_get_host_version = (WINE_GET_HOST_VERSIONPROC)GetProcAddress(mod, "wine_get_host_version");
- }
-}
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask)
{
- return RtlVerifyVersionInfo ?
- RtlVerifyVersionInfo(versionInfo, typeMask, conditionMask) == 0 :
+ return delay_RtlVerifyVersionInfo ?
+ delay_RtlVerifyVersionInfo(versionInfo, typeMask, conditionMask) == 0 :
VerifyVersionInfoW(versionInfo, typeMask, conditionMask);
}
+ULONGLONG verhelp_set_mask(ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition)
+{
+ return delay_VerSetConditionMask ? delay_VerSetConditionMask(ConditionMask, TypeMask, Condition) : 0;
+}
+
const char* verhelp_wine_get_version()
{
- return wine_get_version ? wine_get_version() : NULL;
+ return delay_wine_get_version ? delay_wine_get_version() : NULL;
}
void verhelp_wine_get_host_version(const char** sysname, const char** release)
{
- if (wine_get_host_version)
+ if (delay_wine_get_host_version)
{
- wine_get_host_version(sysname, release);
+ delay_wine_get_host_version(sysname, release);
return;
}
diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c
index 019f2da..33655c1 100644
--- a/src/winapi_hooks.c
+++ b/src/winapi_hooks.c
@@ -1,6 +1,7 @@
#include
#include
#include
+#include
#include "debug.h"
#include "config.h"
#include "dd.h"
@@ -20,6 +21,8 @@
#include "dllmain.h"
#include "hook.h"
#include "directinput.h"
+#include "ddpalette.h"
+#include "palette.h"
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
@@ -414,6 +417,20 @@ LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
if (!g_ddraw.ref || !g_ddraw.hwnd)
return real_SendMessageA(hWnd, Msg, wParam, lParam);
+ if (g_ddraw.hwnd == hWnd && Msg == WM_MOUSEMOVE)
+ {
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ if (g_config.adjmouse)
+ {
+ x = (int)(roundf(x * g_ddraw.mouse.scale_x));
+ y = (int)(roundf(y * g_ddraw.mouse.scale_y));
+ }
+
+ lParam = MAKELPARAM(x + g_ddraw.mouse.x_adjust, y + g_ddraw.mouse.y_adjust);
+ }
+
if (g_ddraw.hwnd == hWnd && Msg == WM_SIZE && g_config.hook != 2)
{
Msg = WM_SIZE_DDRAW;
@@ -433,7 +450,7 @@ LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong)
{
- if (g_ddraw.ref && g_ddraw.hwnd == hWnd)
+ if (g_ddraw.ref && g_ddraw.hwnd && g_ddraw.hwnd == hWnd)
{
if (nIndex == GWL_STYLE)
return 0;
@@ -450,6 +467,17 @@ LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong)
return real_SetWindowLongA(hWnd, nIndex, dwNewLong);
}
+LONG WINAPI fake_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
+{
+ if (g_ddraw.ref && g_ddraw.hwnd && g_ddraw.hwnd == hWnd)
+ {
+ if (nIndex == GWL_STYLE)
+ return 0;
+ }
+
+ return real_SetWindowLongW(hWnd, nIndex, dwNewLong);
+}
+
LONG WINAPI fake_GetWindowLongA(HWND hWnd, int nIndex)
{
if (g_ddraw.ref && g_ddraw.hwnd == hWnd)
@@ -577,12 +605,14 @@ HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, D
dwThreadId,
_ReturnAddress());
+ dbg_dump_hook_type(idHook);
+
if (idHook == WH_KEYBOARD_LL && hmod && GetModuleHandle("AcGenral") == hmod)
{
return NULL;
}
- if (idHook == WH_MOUSE && lpfn && !hmod && !g_mouse_hook && g_config.fixmousehook)
+ if (idHook == WH_MOUSE && lpfn && !hmod && !g_mouse_hook && g_config.sirtech_hack)
{
g_mouse_proc = lpfn;
return g_mouse_hook = real_SetWindowsHookExA(idHook, mouse_hook_proc, hmod, dwThreadId);
@@ -622,7 +652,7 @@ void HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMa
lpMsg->pt.y = InterlockedExchangeAdd((LONG*)&g_ddraw.cursor.y, 0);
}
- if (lpMsg->hwnd != g_ddraw.hwnd)
+ if (lpMsg->hwnd != g_ddraw.hwnd || !g_config.hook_peekmessage)
return;
switch (LOWORD(lpMsg->message))
@@ -633,22 +663,37 @@ void HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMa
{
if (!g_config.devmode && !g_mouse_locked && (wRemoveMsg & PM_REMOVE))
{
- InterlockedExchange((LONG*)&g_ddraw.cursor.x, GET_X_LPARAM(lpMsg->lParam));
- InterlockedExchange((LONG*)&g_ddraw.cursor.y, GET_Y_LPARAM(lpMsg->lParam));
+ int x = GET_X_LPARAM(lpMsg->lParam);
+ int y = GET_Y_LPARAM(lpMsg->lParam);
+
+ if (x > g_ddraw.render.viewport.x + g_ddraw.render.viewport.width ||
+ x < g_ddraw.render.viewport.x ||
+ y > g_ddraw.render.viewport.y + g_ddraw.render.viewport.height ||
+ y < g_ddraw.render.viewport.y)
+ {
+ x = g_ddraw.width / 2;
+ y = g_ddraw.height / 2;
+ }
+ else
+ {
+ x = (DWORD)((x - g_ddraw.render.viewport.x) * g_ddraw.mouse.unscale_x);
+ y = (DWORD)((y - g_ddraw.render.viewport.y) * g_ddraw.mouse.unscale_y);
+ }
+
+ InterlockedExchange((LONG*)&g_ddraw.cursor.x, x);
+ InterlockedExchange((LONG*)&g_ddraw.cursor.y, y);
mouse_lock();
- if (!wMsgFilterMin &&
- !wMsgFilterMax &&
+ if (!wMsgFilterMin &&
+ !wMsgFilterMax &&
!(wRemoveMsg & (PM_QS_INPUT | PM_QS_PAINT | PM_QS_POSTMESSAGE | PM_QS_SENDMESSAGE)))
{
- lpMsg->message = (UINT)MAKELONG(WM_NULL, HIWORD(lpMsg->message));
+ lpMsg->message = WM_NULL;
+ break;
}
-
- break;
}
-
- break;
+ /* fall through for lParam */
}
/* down messages are ignored if we have no cursor lock */
case WM_XBUTTONDBLCLK:
@@ -666,19 +711,53 @@ void HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMa
{
if (!g_config.devmode && !g_mouse_locked)
{
- // Does not work with 'New Robinson'
- if (!wMsgFilterMin &&
- !wMsgFilterMax &&
+ if (!wMsgFilterMin &&
+ !wMsgFilterMax &&
!(wRemoveMsg & (PM_QS_INPUT | PM_QS_PAINT | PM_QS_POSTMESSAGE | PM_QS_SENDMESSAGE)))
{
- lpMsg->message = (UINT)MAKELONG(WM_NULL, HIWORD(lpMsg->message));
+ lpMsg->message = WM_NULL;
+ break;
}
-
- break;
}
- InterlockedExchange((LONG*)&g_ddraw.cursor.x, GET_X_LPARAM(lpMsg->lParam));
- InterlockedExchange((LONG*)&g_ddraw.cursor.y, GET_Y_LPARAM(lpMsg->lParam));
+ if (LOWORD(lpMsg->message) == WM_MOUSEWHEEL)
+ {
+ POINT pt = { GET_X_LPARAM(lpMsg->lParam), GET_Y_LPARAM(lpMsg->lParam) };
+ real_ScreenToClient(g_ddraw.hwnd, &pt);
+ lpMsg->lParam = MAKELPARAM(pt.x, pt.y);
+ }
+
+ int x = max(GET_X_LPARAM(lpMsg->lParam) - g_ddraw.mouse.x_adjust, 0);
+ int y = max(GET_Y_LPARAM(lpMsg->lParam) - g_ddraw.mouse.y_adjust, 0);
+
+ if (g_config.adjmouse)
+ {
+ if (g_config.vhack && !g_config.devmode)
+ {
+ POINT pt = { 0, 0 };
+ fake_GetCursorPos(&pt);
+
+ x = pt.x;
+ y = pt.y;
+ }
+ else
+ {
+ x = (DWORD)(roundf(x * g_ddraw.mouse.unscale_x));
+ y = (DWORD)(roundf(y * g_ddraw.mouse.unscale_y));
+ }
+ }
+
+ x = min(x, g_ddraw.width - 1);
+ y = min(y, g_ddraw.height - 1);
+
+ InterlockedExchange((LONG*)&g_ddraw.cursor.x, x);
+ InterlockedExchange((LONG*)&g_ddraw.cursor.y, y);
+
+ lpMsg->lParam = MAKELPARAM(x, y);
+
+ lpMsg->pt.x = x;
+ lpMsg->pt.y = y;
+
break;
}
}
@@ -701,6 +780,21 @@ BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wM
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
{
+ if (g_config.darkcolony_hack && !hWnd)
+ {
+ hWnd = g_ddraw.hwnd;
+
+ MSG msg;
+ real_PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ }
+
+ if (g_config.limiter_type == LIMIT_PEEKMESSAGE &&
+ g_ddraw.ticks_limiter.tick_length > 0 &&
+ InterlockedExchange(&g_ddraw.render.screen_updated, FALSE))
+ {
+ util_limit_game_ticks();
+ }
+
if (g_ddraw.ref && (!hWnd || hWnd == g_ddraw.hwnd))
g_ddraw.last_msg_pull_tick = timeGetTime();
@@ -731,7 +825,7 @@ BOOL WINAPI fake_GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT* lpwndpl)
lpwndpl->rcNormalPosition.right = g_ddraw.width;
lpwndpl->rcNormalPosition.top = 0;
}
- else
+ else if (!IsChild(g_ddraw.hwnd, hWnd) && !(real_GetWindowLongA(hWnd, GWL_STYLE) & WS_CHILD))
{
real_MapWindowPoints(HWND_DESKTOP, g_ddraw.hwnd, (LPPOINT)&lpwndpl->rcNormalPosition, 2);
}
@@ -740,6 +834,17 @@ BOOL WINAPI fake_GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT* lpwndpl)
return result;
}
+BOOL WINAPI fake_SetWindowPlacement(HWND hWnd, const WINDOWPLACEMENT* lpwndpl)
+{
+ if (lpwndpl && g_ddraw.ref && g_ddraw.hwnd && hWnd == g_ddraw.hwnd)
+ {
+ if (lpwndpl->showCmd == SW_SHOWMAXIMIZED || lpwndpl->showCmd == SW_MAXIMIZE)
+ return TRUE;
+ }
+
+ return real_SetWindowPlacement(hWnd, lpwndpl);
+}
+
BOOL WINAPI fake_EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, DEVMODEA* lpDevMode)
{
BOOL result = real_EnumDisplaySettingsA(lpszDeviceName, iModeNum, lpDevMode);
@@ -778,6 +883,66 @@ BOOL WINAPI fake_EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, DEV
return result;
}
+LRESULT WINAPI fake_DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ if (g_ddraw.ref && g_ddraw.hwnd && g_ddraw.hwnd == hWnd)
+ {
+ if (Msg == WM_NCHITTEST)
+ return HTCLIENT;
+ }
+
+ return real_DefWindowProcA(hWnd, Msg, wParam, lParam);
+}
+
+HWND WINAPI fake_SetParent(HWND hWndChild, HWND hWndNewParent)
+{
+ if (g_ddraw.ref && g_ddraw.hwnd && g_ddraw.hwnd == hWndNewParent)
+ {
+ char class_name[MAX_PATH] = { 0 };
+ GetClassNameA(hWndChild, class_name, sizeof(class_name) - 1);
+
+ if (strcmp(class_name, "VideoRenderer") == 0)
+ {
+ RECT rc_org;
+ fake_GetWindowRect(hWndChild, &rc_org);
+
+ HWND result = real_SetParent(hWndChild, hWndNewParent);
+
+ real_MoveWindow(
+ hWndChild,
+ rc_org.left,
+ rc_org.top,
+ (rc_org.right - rc_org.left),
+ (rc_org.bottom - rc_org.top),
+ FALSE);
+
+ return result;
+ }
+ }
+
+ return real_SetParent(hWndChild, hWndNewParent);
+}
+
+HDC WINAPI fake_BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint)
+{
+ if (g_ddraw.ref && g_ddraw.width && g_ddraw.hwnd && g_ddraw.hwnd == hWnd && lpPaint)
+ {
+ HDC result = real_BeginPaint(hWnd, lpPaint);
+
+ if (result)
+ {
+ lpPaint->rcPaint.left = 0;
+ lpPaint->rcPaint.top = 0;
+ lpPaint->rcPaint.right = g_ddraw.width;
+ lpPaint->rcPaint.bottom = g_ddraw.height;
+ }
+
+ return result;
+ }
+
+ return real_BeginPaint(hWnd, lpPaint);
+}
+
SHORT WINAPI fake_GetKeyState(int nVirtKey)
{
if (g_config.windowed && g_ddraw.ref && g_ddraw.hwnd && !util_in_foreground())
@@ -801,36 +966,80 @@ SHORT WINAPI fake_GetAsyncKeyState(int vKey)
int WINAPI fake_GetDeviceCaps(HDC hdc, int index)
{
DWORD bpp = 0;
+ DWORD width = 0;
+ DWORD height = 0;
if (g_ddraw.ref && g_ddraw.bpp)
{
bpp = g_ddraw.bpp;
+ width = g_ddraw.width;
+ height = g_ddraw.height;
}
else if (g_config.fake_mode[0])
{
char* e = &g_config.fake_mode[0];
- strtoul(e, &e, 0);
- strtoul(e + 1, &e, 0);
+ width = strtoul(e, &e, 0);
+ height = strtoul(e + 1, &e, 0);
bpp = strtoul(e + 1, &e, 0);
}
- if (bpp && index == BITSPIXEL && (g_config.hook != 2 || g_ddraw.renderer == gdi_render_main))
+ if (bpp && index == BITSPIXEL)
{
return bpp;
}
- if (bpp == 8 && (g_config.hook != 2 || g_ddraw.renderer == gdi_render_main))
+ if (bpp == 8)
{
if (index == RASTERCAPS)
{
return RC_PALETTE | real_GetDeviceCaps(hdc, index);
}
- if (index == SIZEPALETTE || index == NUMCOLORS)
+ if (index == SIZEPALETTE)
{
return 256;
}
+
+ if (index == NUMCOLORS)
+ {
+ if (WindowFromDC(hdc) == GetDesktopWindow())
+ {
+ return 20;
+ }
+ else
+ {
+ return 256;
+ }
+ }
+ }
+
+ if (width && ((g_ddraw.hwnd && WindowFromDC(hdc) == g_ddraw.hwnd) || WindowFromDC(hdc) == GetDesktopWindow()))
+ {
+ if (index == HORZRES)
+ {
+ return width;
+ }
+
+ if (index == VERTRES)
+ {
+ return height;
+ }
+ }
+
+ return real_GetDeviceCaps(hdc, index);
+}
+
+int WINAPI fake_GetDeviceCaps_system(HDC hdc, int index)
+{
+ if (g_ddraw.ref &&
+ g_ddraw.bpp == 8 &&
+ ((g_ddraw.hwnd && WindowFromDC(hdc) == g_ddraw.hwnd) || WindowFromDC(hdc) == GetDesktopWindow()))
+ {
+ if (index == RASTERCAPS)
+ {
+ return RC_PALETTE | real_GetDeviceCaps(hdc, index);
+ }
}
return real_GetDeviceCaps(hdc, index);
@@ -851,6 +1060,11 @@ BOOL WINAPI fake_StretchBlt(
{
HWND hwnd = WindowFromDC(hdcDest);
+ if (g_ddraw.ref && g_ddraw.hwnd && hwnd == g_ddraw.hwnd && !g_ddraw.primary)
+ {
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
+ }
+
char class_name[MAX_PATH] = { 0 };
if (g_ddraw.ref && g_ddraw.hwnd && hwnd && hwnd != g_ddraw.hwnd)
@@ -904,12 +1118,39 @@ BOOL WINAPI fake_StretchBlt(
return result;
}
}
- else if (g_ddraw.width > 0 && g_ddraw.render.hdc)
+ else if (
+ g_ddraw.width > 0 &&
+ g_ddraw.render.hdc &&
+ (hwnd == g_ddraw.hwnd ||
+ (real_GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT) ||
+ strcmp(class_name, "AVIWnd32") == 0))
{
+ POINT pt = { 0 };
+ real_MapWindowPoints(hwnd, g_ddraw.hwnd, &pt, 1);
+
+ if (hwnd != g_ddraw.hwnd && strcmp(class_name, "AVIWnd32") == 0)
+ {
+ LONG exstyle = real_GetWindowLongA(hwnd, GWL_EXSTYLE);
+ if (!(exstyle & WS_EX_TRANSPARENT))
+ {
+ real_SetWindowLongA(hwnd, GWL_EXSTYLE, exstyle | WS_EX_TRANSPARENT);
+
+ real_SetWindowPos(
+ hwnd,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ SWP_ASYNCWINDOWPOS | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER
+ );
+ }
+ }
+
return real_StretchBlt(
hwnd == g_ddraw.hwnd ? hdcDest : g_ddraw.render.hdc,
- (int)(roundf(xDest * g_ddraw.render.scale_w)) + g_ddraw.render.viewport.x,
- (int)(roundf(yDest * g_ddraw.render.scale_h)) + g_ddraw.render.viewport.y,
+ (int)(roundf((xDest + pt.x) * g_ddraw.render.scale_w)) + g_ddraw.render.viewport.x,
+ (int)(roundf((yDest + pt.y) * g_ddraw.render.scale_h)) + g_ddraw.render.viewport.y,
(int)(roundf(wDest * g_ddraw.render.scale_w)),
(int)(roundf(hDest * g_ddraw.render.scale_h)),
hdcSrc,
@@ -956,6 +1197,11 @@ BOOL WINAPI fake_BitBlt(
{
HWND hwnd = WindowFromDC(hdc);
+ if (g_ddraw.ref && g_ddraw.hwnd && hwnd == g_ddraw.hwnd && !g_ddraw.primary)
+ {
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
+ }
+
char class_name[MAX_PATH] = { 0 };
if (g_ddraw.ref && g_ddraw.hwnd && hwnd && hwnd != g_ddraw.hwnd)
@@ -1000,7 +1246,10 @@ BOOL WINAPI fake_BitBlt(
return result;
}
}
- else if (g_ddraw.width > 0 && g_ddraw.render.hdc)
+ else if (
+ g_ddraw.width > 0 &&
+ g_ddraw.render.hdc &&
+ (hwnd == g_ddraw.hwnd || (real_GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
{
return real_StretchBlt(
hwnd == g_ddraw.hwnd ? hdc : g_ddraw.render.hdc,
@@ -1049,6 +1298,11 @@ int WINAPI fake_SetDIBitsToDevice(
{
HWND hwnd = WindowFromDC(hdc);
+ if (g_ddraw.ref && g_ddraw.hwnd && hwnd == g_ddraw.hwnd && !g_ddraw.primary)
+ {
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
+ }
+
char class_name[MAX_PATH] = { 0 };
if (g_ddraw.ref && g_ddraw.hwnd && hwnd && hwnd != g_ddraw.hwnd)
@@ -1096,7 +1350,10 @@ int WINAPI fake_SetDIBitsToDevice(
return result;
}
}
- else if (g_ddraw.width > 0 && g_ddraw.render.hdc)
+ else if (
+ g_ddraw.width > 0 &&
+ g_ddraw.render.hdc &&
+ (hwnd == g_ddraw.hwnd || (real_GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
{
return
real_StretchDIBits(
@@ -1136,6 +1393,11 @@ int WINAPI fake_StretchDIBits(
{
HWND hwnd = WindowFromDC(hdc);
+ if (g_ddraw.ref && g_ddraw.hwnd && hwnd == g_ddraw.hwnd && !g_ddraw.primary)
+ {
+ InterlockedExchange(&g_ddraw.render.screen_updated, TRUE);
+ }
+
char class_name[MAX_PATH] = { 0 };
if (g_ddraw.ref && g_ddraw.hwnd && hwnd && hwnd != g_ddraw.hwnd)
@@ -1184,7 +1446,10 @@ int WINAPI fake_StretchDIBits(
return result;
}
}
- else if (g_ddraw.width > 0 && g_ddraw.render.hdc)
+ else if (
+ g_ddraw.width > 0 &&
+ g_ddraw.render.hdc &&
+ (hwnd == g_ddraw.hwnd || (real_GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
{
return
real_StretchDIBits(
@@ -1283,6 +1548,97 @@ HFONT WINAPI fake_CreateFontA(
lpszFace);
}
+UINT WINAPI fake_GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries)
+{
+ TRACE(
+ "%s(hdc=%p, iStart=%u, cEntries=%u, pPalEntries=%p) [%p]\n",
+ __FUNCTION__,
+ hdc,
+ iStart,
+ cEntries,
+ pPalEntries,
+ _ReturnAddress());
+
+ if (g_ddraw.ref && g_ddraw.bpp == 8 && pPalEntries && GetObjectType(hdc) == OBJ_DC)
+ {
+ TRACE(" Display DC\n");
+
+ if (g_ddraw.primary && g_ddraw.primary->palette)
+ {
+ ddp_GetEntries(g_ddraw.primary->palette, 0, iStart, cEntries, pPalEntries);
+ }
+ else
+ {
+ for (int i = iStart, x = 0; i < iStart + cEntries && i < 256; i++, x++)
+ {
+ pPalEntries[x] = g_ddp_default_palette[i];
+ }
+ }
+
+ return cEntries;
+ }
+
+ return real_GetSystemPaletteEntries(hdc, iStart, cEntries, pPalEntries);
+}
+
+HPALETTE WINAPI fake_SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd)
+{
+ TRACE_EXT(
+ "%s(hdc=%p, hPal=%p, bForceBkgd=%d) [%p]\n",
+ __FUNCTION__,
+ hdc,
+ hPal,
+ bForceBkgd,
+ _ReturnAddress());
+
+ if (g_ddraw.ref &&
+ g_ddraw.bpp == 8 &&
+ ((g_ddraw.hwnd && WindowFromDC(hdc) == g_ddraw.hwnd) || WindowFromDC(hdc) == GetDesktopWindow()))
+ {
+ TRACE_EXT(" Display DC\n");
+
+ if (g_ddraw.primary && g_ddraw.primary->palette)
+ {
+ g_ddraw.primary->selected_pal_count = GetPaletteEntries(hPal, 0, 256, g_ddraw.primary->selected_pal);
+
+ return real_SelectPalette(g_ddraw.primary->hdc, hPal, bForceBkgd);;
+ }
+ }
+
+ return real_SelectPalette(hdc, hPal, bForceBkgd);
+}
+
+UINT WINAPI fake_RealizePalette(HDC hdc)
+{
+ TRACE_EXT("%s(hdc=%p) [%p]\n", __FUNCTION__, hdc, _ReturnAddress());
+
+ if (g_ddraw.ref &&
+ g_ddraw.bpp == 8 &&
+ ((g_ddraw.hwnd && WindowFromDC(hdc) == g_ddraw.hwnd) || WindowFromDC(hdc) == GetDesktopWindow()))
+ {
+ TRACE_EXT(" Display DC\n");
+
+ if (g_ddraw.primary && g_ddraw.primary->palette)
+ {
+ if (g_ddraw.primary->selected_pal_count != 256)
+ {
+ TRACE_EXT(" selected_pal_count = %u\n", g_ddraw.primary->selected_pal_count);
+ }
+
+ ddp_SetEntries(
+ g_ddraw.primary->palette,
+ DDPCAPS_REFRESH_CHANGED_ONLY,
+ 0,
+ g_ddraw.primary->selected_pal_count,
+ g_ddraw.primary->selected_pal);
+
+ return g_ddraw.primary->selected_pal_count;
+ }
+ }
+
+ return real_RealizePalette(hdc);
+}
+
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName)
{
HMODULE hmod_old = GetModuleHandleA(lpLibFileName);
@@ -1698,6 +2054,14 @@ HWND WINAPI fake_CreateWindowExA(
dwStyle &= ~WS_POPUP;
}
+ /* Dark Colony */
+ if (HIWORD(lpClassName) && _strcmpi(lpClassName, "Merc Direct Draw Driver") == 0 &&
+ lpWindowName && _strcmpi(lpWindowName, "Direct Draw Driver") == 0 &&
+ !dwExStyle)
+ {
+ dwExStyle |= WS_EX_APPWINDOW;
+ }
+
/* Fallout 1/2 */
if (HIWORD(lpClassName) && _strcmpi(lpClassName, "GNW95 Class") == 0 &&
lpWindowName && strstr(lpWindowName, "FALLOUT"))
@@ -1706,6 +2070,13 @@ HWND WINAPI fake_CreateWindowExA(
dwExStyle |= WS_EX_APPWINDOW;
}
+ /* Fallout Tactics */
+ if (HIWORD(lpClassName) && _strcmpi(lpClassName, "bosWin32Class") == 0 &&
+ lpWindowName && _strcmpi(lpWindowName, "Fallout: Tactics (TM)") == 0)
+ {
+ dwStyle |= WS_VISIBLE;
+ }
+
/* Center Claw DVD movies */
if (HIWORD(lpClassName) && _strcmpi(lpClassName, "Afx:400000:3") == 0 &&
g_ddraw.ref && g_ddraw.hwnd && hWndParent == g_ddraw.hwnd &&
@@ -1727,6 +2098,28 @@ HWND WINAPI fake_CreateWindowExA(
Y = pt.y + align_y;
}
+ /* Metal Knight Movies */
+ if (HIWORD(lpClassName) && _strcmpi(lpClassName, "Afx:400000:3:0:1900011:0") == 0 &&
+ lpWindowName && _strcmpi(lpWindowName, "AVI player") == 0 &&
+ dwStyle == WS_POPUP &&
+ dwExStyle == WS_EX_TOPMOST &&
+ g_ddraw.ref && g_ddraw.hwnd &&
+ g_ddraw.width)
+ {
+ dwExStyle = 0;
+
+ POINT pt = { 0, 0 };
+ real_ClientToScreen(g_ddraw.hwnd, &pt);
+
+ int added_height = g_ddraw.render.height - g_ddraw.height;
+ int added_width = g_ddraw.render.width - g_ddraw.width;
+ int align_y = added_height > 0 ? added_height / 2 : 0;
+ int align_x = added_width > 0 ? added_width / 2 : 0;
+
+ X += pt.x + align_x;
+ Y += pt.y + align_y;
+ }
+
/* Disney Trivia Challenge */
if (HIWORD(lpClassName) && _strcmpi(lpClassName, "Disney Trivia Challenge") == 0 &&
hWndParent && (dwStyle & WS_CHILD))
@@ -1763,6 +2156,13 @@ HWND WINAPI fake_CreateWindowExA(
hWndParent = g_ddraw.hwnd;
}
+ /* A Bug's Life Action Game */
+ //HIWORD(lpClassName) && _strcmpi(lpClassName, "Bugs") == 0 &&
+ if (dwExStyle == 0x01000008)
+ {
+ dwExStyle = WS_EX_TOPMOST;
+ }
+
/* Fix for SMACKW32.DLL creating another window that steals the focus */
if (HIWORD(lpClassName) && _strcmpi(lpClassName, "MouseTypeWind") == 0 && g_ddraw.ref && g_ddraw.hwnd)
{
@@ -1943,3 +2343,27 @@ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI fake_SetUnhandledExceptionFilter(
return old;
//return real_SetUnhandledExceptionFilter(lpTopLevelExceptionFilter);
}
+
+PGETFRAME WINAPI fake_AVIStreamGetFrameOpen(PAVISTREAM pavi, LPBITMAPINFOHEADER lpbiWanted)
+{
+ if (g_ddraw.ref && g_ddraw.primary && (DWORD)lpbiWanted == AVIGETFRAMEF_BESTDISPLAYFMT)
+ {
+ DDBITMAPINFO bmi;
+ memcpy(&bmi, g_ddraw.primary->bmi, sizeof(DDBITMAPINFO));
+
+ bmi.bmiHeader.biHeight = 0;
+ bmi.bmiHeader.biWidth = 0;
+
+ if (g_ddraw.bpp == 8 && g_ddraw.primary->palette)
+ {
+ memcpy(&bmi.bmiColors[0], g_ddraw.primary->palette->data_rgb, sizeof(bmi.bmiColors));
+ }
+
+ PGETFRAME result = real_AVIStreamGetFrameOpen(pavi, (LPBITMAPINFOHEADER)&bmi);
+
+ if (result)
+ return result;
+ }
+
+ return real_AVIStreamGetFrameOpen(pavi, lpbiWanted);
+}
diff --git a/src/wndproc.c b/src/wndproc.c
index c0993b1..3555058 100644
--- a/src/wndproc.c
+++ b/src/wndproc.c
@@ -49,8 +49,9 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WM_NCPAINT:
case WM_CANCELMODE:
case WM_DISPLAYCHANGE:
+ case WM_NCCALCSIZE:
{
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
case WM_GETMINMAXINFO:
{
@@ -88,20 +89,48 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
return 0;
}
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
+ case WM_KILLFOCUS:
case WM_NCACTIVATE:
{
if (g_config.noactivateapp)
{
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
break;
}
case WM_NCHITTEST:
{
- LRESULT result = DefWindowProc(hWnd, uMsg, wParam, lParam);
+ if (g_mouse_locked || g_config.devmode)
+ {
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+
+ if (!g_config.windowed || real_ScreenToClient(g_ddraw.hwnd, &pt))
+ {
+ int x = max(pt.x - g_ddraw.mouse.x_adjust, 0);
+ int y = max(pt.y - g_ddraw.mouse.y_adjust, 0);
+
+ if (g_config.adjmouse)
+ {
+ x = (DWORD)(roundf(x * g_ddraw.mouse.unscale_x));
+ y = (DWORD)(roundf(y * g_ddraw.mouse.unscale_y));
+ }
+
+ pt.x = min(x, g_ddraw.width - 1);
+ pt.y = min(y, g_ddraw.height - 1);
+ }
+ else
+ {
+ pt.x = InterlockedExchangeAdd((LONG*)&g_ddraw.cursor.x, 0);
+ pt.y = InterlockedExchangeAdd((LONG*)&g_ddraw.cursor.y, 0);
+ }
+
+ CallWindowProcA(g_ddraw.wndproc, hWnd, uMsg, wParam, MAKELPARAM(pt.x, pt.y));
+ }
+
+ LRESULT result = real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
if (!g_config.resizable)
{
@@ -146,7 +175,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case HTTOP:
case HTTOPLEFT:
case HTTOPRIGHT:
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
case HTCLIENT:
if (!g_mouse_locked && !g_config.devmode)
{
@@ -216,6 +245,12 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
return 0;
}
+ case IDT_TIMER_LINUX_FIX_WINDOW_SIZE:
+ {
+ KillTimer(g_ddraw.hwnd, IDT_TIMER_LINUX_FIX_WINDOW_SIZE);
+ util_set_window_rect(0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ return 0;
+ }
}
break;
}
@@ -441,20 +476,70 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
{
if (g_config.windowed)
{
+ WORD width = LOWORD(lParam);
+ WORD height = HIWORD(lParam);
+
if (wParam == SIZE_RESTORED)
{
+ /* macOS maximize hack */
+ if (in_size_move && g_ddraw.render.thread && IsMacOS())
+ {
+ EnterCriticalSection(&g_ddraw.cs);
+ g_ddraw.render.run = FALSE;
+ ReleaseSemaphore(g_ddraw.render.sem, 1, NULL);
+ LeaveCriticalSection(&g_ddraw.cs);
+
+ WaitForSingleObject(g_ddraw.render.thread, INFINITE);
+ g_ddraw.render.thread = NULL;
+ }
+
if (in_size_move && !g_ddraw.render.thread)
{
- g_config.window_rect.right = LOWORD(lParam);
- g_config.window_rect.bottom = HIWORD(lParam);
+ g_config.window_rect.right = width;
+ g_config.window_rect.bottom = height;
}
- else if (!in_size_move && g_ddraw.render.thread && !g_config.fullscreen && g_config.wine_allow_resize && IsLinux())
+ else if (!in_size_move && g_ddraw.render.thread && !g_config.fullscreen && IsLinux())
{
- g_config.window_rect.right = LOWORD(lParam);
- g_config.window_rect.bottom = HIWORD(lParam);
+ if (width != g_ddraw.render.width || height != g_ddraw.render.height)
+ {
+ KillTimer(g_ddraw.hwnd, IDT_TIMER_LINUX_FIX_WINDOW_SIZE);
+
+ g_config.window_rect.right = width;
+ g_config.window_rect.bottom = height;
- if (g_config.window_rect.right != g_ddraw.render.width || g_config.window_rect.bottom != g_ddraw.render.height)
dd_SetDisplayMode(0, 0, 0, 0);
+
+ if (width < g_ddraw.width || height < g_ddraw.height)
+ {
+ /* Can't enforce minimum window size in linux because there is no WM_SIZING and
+ WM_GETMINMAXINFO is ignored for whatever reasons */
+
+ SetTimer(g_ddraw.hwnd, IDT_TIMER_LINUX_FIX_WINDOW_SIZE, 1000, (TIMERPROC)NULL);
+ }
+ }
+ }
+ }
+ else if (wParam == SIZE_MAXIMIZED)
+ {
+ if (!in_size_move && g_ddraw.render.thread && !g_config.fullscreen && IsLinux())
+ {
+ if (width != g_ddraw.render.width || height != g_ddraw.render.height)
+ {
+ KillTimer(g_ddraw.hwnd, IDT_TIMER_LINUX_FIX_WINDOW_SIZE);
+
+ g_config.window_rect.right = width;
+ g_config.window_rect.bottom = height;
+
+ dd_SetDisplayMode(0, 0, 0, 0);
+
+ if (width < g_ddraw.width || height < g_ddraw.height)
+ {
+ /* Can't enforce minimum window size in linux because there is no WM_SIZING and
+ WM_GETMINMAXINFO is ignored for whatever reasons */
+
+ SetTimer(g_ddraw.hwnd, IDT_TIMER_LINUX_FIX_WINDOW_SIZE, 1000, (TIMERPROC)NULL);
+ }
+ }
}
}
}
@@ -465,7 +550,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
}
- return DefWindowProc(hWnd, uMsg, wParam, lParam); /* Carmageddon fix */
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam); /* Carmageddon fix */
}
case WM_MOVE:
{
@@ -479,7 +564,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
util_update_bnet_pos(x, y);
}
- if (in_size_move || (IsWine() && !g_config.fullscreen && g_ddraw.render.thread))
+ if (in_size_move || (IsLinux() && !g_config.fullscreen && g_ddraw.render.thread))
{
if (x != -32000)
g_config.window_rect.left = x; /* -32000 = Exit/Minimize */
@@ -492,7 +577,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
if (g_ddraw.got_child_windows)
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
- return DefWindowProc(hWnd, uMsg, wParam, lParam); /* Carmageddon fix */
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam); /* Carmageddon fix */
}
case WM_RESTORE_STYLE:
{
@@ -522,6 +607,9 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
if (wParam == SC_MAXIMIZE)
{
+ if (IsWine())
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
+
if (g_config.resizable)
{
util_toggle_maximize();
@@ -532,14 +620,18 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
if (wParam == SC_CLOSE && !GameHandlesClose)
{
- _exit(0);
+ if (g_config.terminate_process)
+ g_config.terminate_process = 2;
+
+ ExitProcess(0);
+ //_exit(0);
}
if (wParam == SC_KEYMENU && GetMenu(g_ddraw.hwnd) == NULL)
return 0;
if (!GameHandlesClose)
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
break;
}
@@ -675,7 +767,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
}
}
- if (wParam && g_config.releasealt)
+ if (wParam && g_config.fix_alt_key_stuck)
{
INPUT ip;
memset(&ip, 0, sizeof(ip));
@@ -707,7 +799,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
break;
}
- if (wParam && g_ddraw.alt_key_down && !g_config.releasealt)
+ if (wParam && g_ddraw.alt_key_down && !g_config.fix_alt_key_stuck)
{
PostMessageA(g_ddraw.hwnd, WM_SYSKEYUP, VK_MENU, 0);
g_ddraw.alt_key_down = FALSE;
@@ -762,13 +854,18 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
}
case WM_SYSKEYDOWN:
{
+ if (wParam == VK_F4)
+ {
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
+ }
+
break;
}
case WM_SYSKEYUP:
{
if (wParam == VK_TAB || (wParam && wParam == g_config.hotkeys.toggle_fullscreen))
{
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return real_DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
break;
@@ -788,14 +885,33 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
{
if (!g_config.devmode && !g_mouse_locked)
{
- InterlockedExchange((LONG*)&g_ddraw.cursor.x, GET_X_LPARAM(lParam));
- InterlockedExchange((LONG*)&g_ddraw.cursor.y, GET_Y_LPARAM(lParam));
+ int x = GET_X_LPARAM(lParam);
+ int y = GET_Y_LPARAM(lParam);
+
+ if (x > g_ddraw.render.viewport.x + g_ddraw.render.viewport.width ||
+ x < g_ddraw.render.viewport.x ||
+ y > g_ddraw.render.viewport.y + g_ddraw.render.viewport.height ||
+ y < g_ddraw.render.viewport.y)
+ {
+ x = g_ddraw.width / 2;
+ y = g_ddraw.height / 2;
+ }
+ else
+ {
+ x = (DWORD)((x - g_ddraw.render.viewport.x) * g_ddraw.mouse.unscale_x);
+ y = (DWORD)((y - g_ddraw.render.viewport.y) * g_ddraw.mouse.unscale_y);
+ }
+
+ x = min(x, g_ddraw.width - 1);
+ y = min(y, g_ddraw.height - 1);
+
+ InterlockedExchange((LONG*)&g_ddraw.cursor.x, x);
+ InterlockedExchange((LONG*)&g_ddraw.cursor.y, y);
mouse_lock();
return 0;
}
-
- break;
+ /* fall through for lParam */
}
/* down messages are ignored if we have no cursor lock */
case WM_XBUTTONDBLCLK:
@@ -816,8 +932,40 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
return 0;
}
- InterlockedExchange((LONG*)&g_ddraw.cursor.x, GET_X_LPARAM(lParam));
- InterlockedExchange((LONG*)&g_ddraw.cursor.y, GET_Y_LPARAM(lParam));
+ if (uMsg == WM_MOUSEWHEEL)
+ {
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+ real_ScreenToClient(g_ddraw.hwnd, &pt);
+ lParam = MAKELPARAM(pt.x, pt.y);
+ }
+
+ int x = max(GET_X_LPARAM(lParam) - g_ddraw.mouse.x_adjust, 0);
+ int y = max(GET_Y_LPARAM(lParam) - g_ddraw.mouse.y_adjust, 0);
+
+ if (g_config.adjmouse)
+ {
+ if (g_config.vhack && !g_config.devmode)
+ {
+ POINT pt = { 0, 0 };
+ fake_GetCursorPos(&pt);
+
+ x = pt.x;
+ y = pt.y;
+ }
+ else
+ {
+ x = (DWORD)(roundf(x * g_ddraw.mouse.unscale_x));
+ y = (DWORD)(roundf(y * g_ddraw.mouse.unscale_y));
+ }
+ }
+
+ x = min(x, g_ddraw.width - 1);
+ y = min(y, g_ddraw.height - 1);
+
+ InterlockedExchange((LONG*)&g_ddraw.cursor.x, x);
+ InterlockedExchange((LONG*)&g_ddraw.cursor.y, y);
+
+ lParam = MAKELPARAM(x, y);
break;
}