Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get DirectDraw backend to work with real hardware #842

Open
wants to merge 2 commits into
base: vanilla
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ option(MAP_EDITORTD "Include internal scenario editor in Tiberian Dawn build." O
option(MAP_EDITORRA "Include internal scenario editor in Red Alert build." OFF)
option(NETWORKING "Enable network play." ON)
option(WIN9X "Enable support for Windows 95/98/ME." OFF)
option(DSOUND "Enable DirectSound audio. (deprecated)" OFF)
option(DDRAW "Enable DirectDraw video backend. (deprecated)" OFF)
option(DSOUND "Enable DirectSound audio." OFF)
option(DDRAW "Enable DirectDraw video backend." OFF)
option(SDL1 "Enable SDL1 video backend." OFF)
option(SDL2 "Enable SDL2 video backend." ON)
option(OPENAL "Enable OpenAL audio backend." ON)
Expand All @@ -29,14 +29,14 @@ option(BUILD_WITH_ASAN "Build with address sanitizer" OFF)

if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(WIN9X "Enable support for Windows 95/98/ME." OFF)
option(DSOUND "Enable DirectSound audio. (deprecated)" OFF)
option(DDRAW "Enable DirectDraw video backend. (deprecated)" OFF)
option(DSOUND "Enable DirectSound audio." OFF)
option(DDRAW "Enable DirectDraw video backend." OFF)
option(SDL1 "Enable SDL1 video backend." OFF)
option(SDL2 "Enable SDL2 video backend." ON)
option(OPENAL "Enable OpenAL audio backend." ON)
add_feature_info(Windows9x WIN9X "Windows 95/98/ME support" OFF)
add_feature_info(DirectSound DSOUND "DirectSound audio backend (deprecated)")
add_feature_info(DirectDraw DDRAW "DirectDraw video backend (deprecated)")
add_feature_info(DirectSound DSOUND "DirectSound audio backend")
add_feature_info(DirectDraw DDRAW "DirectDraw video backend")
add_feature_info(SDL1 SDL1 "SDL1 video backend")
add_feature_info(SDL2 SDL2 "SDL2 video backend")
add_feature_info(OpenAL OPENAL "OpenAL audio backend")
Expand All @@ -46,8 +46,19 @@ else()
set(OPENAL TRUE)
endif()

if(WIN32 AND WIN9X)
if(SDL2)
message("note: Use DSOUND or SDL1 for video support in Windows 9x.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message("note: Use DSOUND or SDL1 for video support in Windows 9x.")
message("note: Use DDRAW or SDL1 for video support in Windows 9x.")

message(FATAL_ERROR "SDL2 is unsupported when targeting Windows 9x.")
endif()
if(OPENAL)
message("note: Use DSOUND for sound support in Windows 9x.")
message(FATAL_ERROR "OpenAL is unsupported when targeting Windows 9x.")
endif()
endif()

if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
add_feature_info(MakeBundle MAKE_BUNDLE "App bundles will be generated")
if(MAKE_BUNDLE)
set(MAKE_BUNDLE_OPTION MACOSX_BUNDLE)
Expand Down
16 changes: 15 additions & 1 deletion common/video_ddraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,21 @@ bool Set_Video_Mode(int w, int h, int bits_per_pixel)
//
// Set the required display mode with 8 bits per pixel
//
result = DirectDrawObject->SetDisplayMode(w, h, bits_per_pixel);
do {
result = DirectDrawObject->SetDisplayMode(w, h, bits_per_pixel);
if (result != DD_OK) {
/* giulianob: C&C runs by default in 640x400 resolution, which is
by some videocards even back then. In failure to set the
resulution, try to fallback into 640x480. */
Comment on lines +677 to +679
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* giulianob: C&C runs by default in 640x400 resolution, which is
by some videocards even back then. In failure to set the
resulution, try to fallback into 640x480. */
/* giulianob: C&C runs by default in 640x400 resolution, which isn't
supported by some video cards even back then. If it fails to set
the resolution, try to fall back to 640x480. */

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original code for 480 should be restored in InitDDraw, see original source repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (h == 400) {
h = 480;
} else {
/* Just give up. */
result = ~DD_OK;
}
}
} while (result != DD_OK);

if (result != DD_OK) {
DirectDrawObject->Release();
DirectDrawObject = NULL;
Expand Down