FunkyFr3sh / cnc-ddraw

GDI, OpenGL and Direct3D 9 re-implementation of the DirectDraw API for classic 2D games for better compatibility with Windows 2000, XP, Vista, 7, 8, 10, 11, Wine (Linux/macOS/Android) and Virtual Machines
https://discord.gg/afWXJNDDF5
MIT License
2.21k stars 142 forks source link

Blade and Sword (in Chinese: 刀剑封魔录 ) game display tear #89

Closed cartman-kai closed 3 years ago

cartman-kai commented 3 years ago

I'm trying to play (in Chinese: 刀剑封魔录 )

The game can be started normally without crash.

ddraw.ini configuration:

windowed=true
maxfps=60
vsync=true
renderer=auto
maxgameticks=-1
hook=4

At the first moment of entering the game, the game screen is normal. When the player starts to move, the game screen will be torn in the form of lines.

normal tear

I have tried setting maxgameticks to -1,0,15,25,30,60 value, the results are the same, the game screen display is torn

This game has a built-in debug mode, which can display the fps of the game in the upper left corner of the game window. Only when maxgameticks in ddraw.ini is set to 1-1000, the fps value in debug mode will be the same as maxgameticks. The maxfps and vsync configuration items seem to have no effect on the fps value in debug mode.

Because the size of ddraw.log is too large, when recording the log, I did not try to turn on the debug mode. If necessary, I can do it.

cnc-ddraw-log.zip

cartman-kai commented 3 years ago

In addition, if I use the dgvoodoo project (also ddraw wrapper), the game screen is normal without setting the resolution.

But the window setting of dgvoodoo is invalid.

I want to use cnc-draw because fps is controllable and there are window modes available.

FunkyFr3sh commented 3 years ago

Could you maybe try to Alt+F4 to close the game quickly once the bug happens (The log is too big, makes it difficult to find the bug)? I meanwhile try to find the game somewhere so I can test it

cartman-kai commented 3 years ago

I tried setting maxgameticks=5 to trigger a bug, and then used ALT + F4 to exit the game. The total game time is about 20 seconds, and the log file size is 2MB.

In addition, this game may no longer have a formal acquisition channel. It was only sold as a CD in 2003, and there was no digital version later. However, it can be found on some Chinese game websites, but there may be legal risks.

cnc-ddraw-log.zip

Could you maybe try to Alt+F4 to close the game quickly once the bug happens (The log is too big, makes it difficult to find the bug)? I meanwhile try to find the game somewhere so I can test it

cartman-kai commented 3 years ago

The main computers I am using: OS: Windows 10 Pro edition CPU: intel Core i5 6500 GPU: Nvidia GTX1070

Just now, I found a very old laptop OS: Windows 7 x86 home edition CPU: intel Pentium SU4100 GPU: Intel GS45 shared Graphic

Unfortunately, running this game on these two computers and using cnc-ddraw have the problems described above.

If you can't get the copy of this game, you can describe the method of problem analysis. Maybe I can try it. For example: Use the disassembly tool ( like: IDA Free ) method to find out the API that the game displays and draws calls?

FunkyFr3sh commented 3 years ago

Log didn't help too much, looks like the game should be working fine. It's probably easy to fix, just have to find out what's wrong with it.... Didn't manage to get a copy of the game :(

There are a few things you can try, set your windows 7 laptop to 16bit color depth in windows and then check if it might be working like this.

Also try windowed=false with hook=0 and you can also try windowed=false with hook=2 + renderer=gdi.

If nothing of those helps then I would remove some parts of the ddraw functions to find out which one is breaking, the game is using blt, bltfast, getdc and lock. I could give you some test builds for that so we can check which function is doing what. Then once we found out which of the functions is causing the issue I would use ollydbg and set a breakpoint on it to check the values, but this might be a bit difficult to explain how to do that :(

cartman-kai commented 3 years ago

Report some test cases:

OS: Windows 7 laptop + setting display 16bit color depth cnc-ddraw: 1.4.0.0

ddraw.ini: default setting

windowed=false
renderer=auto
hook=4

ddraw.ini:

windowed=false
renderer=auto
hook=0

ddraw.ini:

windowed=false
renderer=gdi
hook=2

use Windows 7 laptop and setting display 32bit color depth, Verify the above case again, the same problem occurs.


Next, use Windows 10 and cnc-ddraw 1.4.0.0

ddraw.ini

windowed=false
renderer=auto
hook=0

ddraw.ini

windowed=false
renderer=gdi
hook=2

change ddraw.dll to with logging version, log file content:

[8756] 23:31:21.593 Windows 10 Enterprise (19041.vb_release.191206-1406) [8756] 23:31:21.593 cnc-ddraw = 74690000 [8756] 23:31:21.673 -> DirectDrawCreateEx(lpGUID=00000000, lplpDD=0019F8A4, riid=0052AABC, pUnkOuter=00000000) [8756] 23:31:21.673 GUID = 15E65EC0 (IID_IDirectDrawX), ddraw = 007421E8 [8756] 23:31:21.673 -> IDirectDrawAddRef(This=007421E8) [8756] 23:31:21.673 <- IDirectDrawAddRef(This ref=1, global ref=1) [8756] 23:31:21.679 Using gdi renderer [8756] 23:31:21.679 <- DirectDrawCreateEx [8756] 23:31:21.679 -> IDirectDraw__QueryInterface(This=007421E8, riid=0052AABC, obj=0056D858) [8756] 23:31:21.679 GUID = 15E65EC0 (IID_IDirectDrawX), ddraw = 00742208 [8756] 23:31:21.679 -> IDirectDrawAddRef(This=00742208) [8756] 23:31:21.680 <- IDirectDrawAddRef(This ref=1, global ref=2) [8756] 23:31:21.680 <- IDirectDrawQueryInterface [8756] 23:31:21.680 -> IDirectDrawGetCaps(This=00742208, lpDDDriverCaps=0019F8AC, lpDDEmulCaps=00000000) [8756] 23:31:21.680 <- IDirectDrawGetCaps [8756] 23:31:21.680 -> IDirectDrawSetCooperativeLevel(This=00742208, hwnd=0x0003061A, dwFlags=0x00000011)


There may be many problems with direct exchange of emails in public discussions.

Publishing game resource links may also be detected by web crawlers. Using symmetric encryption for magnet links may be a solution.

Encryption result:

bWFnbmV0Oj94dD11cm46YnRpaDoxRUVCRTJGMzQ5NDRBRkI2RkRDNTRBMEM2MzAwM0QyQjgyRTZBODJD

As a software engineer, you should quickly know the encryption method used.

Encryption method name tips:

  1. MCV in Red Alert 2 Role: ___ construction. (completion)
  2. The number is 2^6 =?

When you have finished downloading and decompression is complete, you should execute ComeOn.exe or Game.exe in the game directory. Other exe files may be trap software.

cartman-kai commented 3 years ago

Regarding ollydbg, I learned how to use it a long time ago, but I have forgotten almost.

A few days ago, I tried to use ollydbg to run this game, maybe because there was no breakpoint, after I clicked the run button, the game running process became unresponsive.

If there is a textbook or tutorial on game dynamic analysis, you can share it with me. Maybe I can try to help you solve some problems.

FunkyFr3sh commented 3 years ago

Had no luck getting the game yet... It's also difficult to explain how to debug it, but I'll to make some test builds tomorrow and upload them here

cartman-kai commented 3 years ago

Sorry, when I was search some information about this game at the weekend, I found that the English translation of this game was wrong by me, it should be .

In addition, I found the download link of this game on an English website.

FunkyFr3sh commented 3 years ago

Ah nice! Got it working now:

ddraw.zip

cartman-kai commented 3 years ago

After running some basic operation tests, the game images are loaded normally, and the sharders are also loaded normally.

ok

This is very cool.

Thank you very much!

cartman-kai commented 3 years ago

Blade & Sword game, when using the test version, the game screen will be displayed normally, However, a text display problem was found in one place.

Choose New Game or Load Game to enter the game. In the lower right corner of the game screen, there is a button like a book to open the log menu in the game (shortcut key: press n). For Chinese, the detailed description is in the box on the right, and the font style becomes italic.

log button font-style italic

when remove/rename ddraw.dll file to other name, re-open game. log detail font-style is normally. font-style normal

Both cnc-ddraw 1.4 release version and test build have problems.

FunkyFr3sh commented 3 years ago

Fixed.

I have to fix such bugs manually right now one by one, if you find another place where it happens then let me know

ddraw.zip