now compiles under msvc 4.2

This commit is contained in:
Jeff Harris 2025-07-04 14:32:54 +12:00
parent a1f8e8db2a
commit 10a9a8bded
7 changed files with 210 additions and 193 deletions

View File

@ -42,6 +42,26 @@ option(DETHRACE_FIX_BUGS "Fix Dethrace bugs" ON)
option(DETHRACE_3DFX_PATCH "Include changes from VOODOO2C.EXE" ON)
option(DETHRACE_SOUND_ENABLED "Include audio support" ON)
option(DETHRACE_NET_ENABLED "Include net support" ON)
option(DETHRACE_PLATFORM_SDL1 "Support SDL 1.2 platform driver" OFF)
option(DETHRACE_PLATFORM_SDL2 "Support SDL 2 platform driver" ON)
option(MSVC_42_FOR_RECCMP "Build with MSVC 4.2 to match assembly" OFF)
if (MSVC_42_FOR_RECCMP)
set(DETHRACE_FIX_BUGS OFF)
set(DETHRACE_3DFX_PATCH OFF)
set(DETHRACE_SOUND_ENABLED OFF)
set(DETHRACE_NET_ENABLED OFF)
set(DETHRACE_PLATFORM_SDL1 OFF)
set(DETHRACE_PLATFORM_SDL2 OFF)
set(BRENDER_BUILD_DRIVERS OFF)
set(CMAKE_C_FLAGS_DEBUG "/Zi /Od /MTd")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
include("reccmp")
endif()
function(add_compile_flag_if_supported TARGET FLAG)
cmake_parse_arguments(ARGS "" "" "LANGUAGES" ${ARGN})
@ -68,8 +88,7 @@ endfunction()
test_big_endian(IS_BIGENDIAN)
option(DETHRACE_PLATFORM_SDL1 "Support SDL 1.2 platform driver" OFF)
option(DETHRACE_PLATFORM_SDL2 "Support SDL 2 platform driver" ON)
set(count_sdl_platforms 0)
set(DETHRACE_PLATFORMS)
@ -102,9 +121,10 @@ endif()
cmake_dependent_option(DETHRACE_PLATFORM_SDL_DYNAMIC "Load SDL dynamically" FALSE "count_sdl_platforms EQUAL 1" "${dynamic_sdl_force}")
# if(NOT DETHRACE_PLATFORMS)
# message(FATAL_ERROR "No platform drivers enabled")
# endif()
if(NOT DETHRACE_PLATFORMS AND NOT MSVC_42_FOR_RECCMP)
message(FATAL_ERROR "No platform drivers enabled")
endif()
add_subdirectory(lib/BRender-v1.3.2)
add_subdirectory(lib/libsmacker)
@ -114,6 +134,10 @@ if(DETHRACE_SOUND_ENABLED)
endif()
add_library(compile_with_werror INTERFACE)
add_subdirectory(src/harness)
add_subdirectory(src/S3)
add_subdirectory(src/smackw32)
add_subdirectory(src/DETHRACE)
if(DETHRACE_WERROR)
if(MSVC)
@ -123,11 +147,6 @@ if(DETHRACE_WERROR)
endif()
endif()
add_subdirectory(src/harness)
add_subdirectory(src/S3)
add_subdirectory(src/smackw32)
add_subdirectory(src/DETHRACE)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(test)

View File

@ -185,24 +185,29 @@ else()
endif()
# Create our main game binary.
add_executable(dethrace
# WIN32
# ${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
# ${CMAKE_SOURCE_DIR}/packaging/windows/dethrace.rc
)
if (MSVC_42_FOR_RECCMP)
add_executable(dethrace WIN32)
target_link_options(dethrace PRIVATE /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup)
reccmp_add_target(dethrace ID CARM95)
reccmp_configure()
else()
add_executable(dethrace
WIN32
${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
${CMAKE_SOURCE_DIR}/packaging/windows/dethrace.rc
)
get_property(build_rpaths GLOBAL PROPERTY DETHRACE_BUILD_RPATHS)
set_property(TARGET dethrace APPEND PROPERTY BUILD_RPATH "${build_rpaths}")
#get_property(build_rpaths GLOBAL PROPERTY DETHRACE_BUILD_RPATHS)
#set_property(TARGET dethrace APPEND PROPERTY BUILD_RPATH "${build_rpaths}")
if(MSVC)
target_link_libraries(dethrace PRIVATE dbghelp)
target_compile_definitions(dethrace PRIVATE -D_CRT_SECURE_NO_WARNINGS -DSDL_MAIN_HANDLED -DWIN32_LEAN_AND_MEAN)
endif()
endif()
target_link_libraries(dethrace PRIVATE dethrace_obj compile_with_werror)
target_sources(dethrace PRIVATE main.c)
if(MSVC)
#target_link_libraries(dethrace PRIVATE dbghelp)
target_link_options(dethrace PRIVATE /subsystem:windows /ENTRY:mainCRTStartup)
target_compile_definitions(dethrace PRIVATE -D_CRT_SECURE_NO_WARNINGS -DSDL_MAIN_HANDLED -DWIN32_LEAN_AND_MEAN)
endif()
if(DETHRACE_IDE_ROOT_DIR)
set_target_properties(dethrace PROPERTIES
VS_DEBUGGER_ENVIRONMENT "DETHRACE_ROOT_DIR=${DETHRACE_IDE_ROOT_DIR}"

View File

@ -135,8 +135,7 @@ void GameMain(int pArgc, char** pArgv) {
UsePathFileToDetermineIfFullInstallation();
if (!gCD_fully_installed && GetCDPathFromPathsTxtFile(CD_dir) && !PDCheckDriveExists(CD_dir)) {
PDInitialiseSystem();
fprintf(stderr, "Can't find the Carmageddon CD\n");
exit(1);
PDFatalError("Can't find the Carmageddon CD\n");
}
InitialiseDeathRace(pArgc, pArgv);
DoProgram();

View File

@ -1246,7 +1246,7 @@ void AdvanceChunkPtr(tPipe_chunk** pChunk, tChunk_subject_index pType) {
/* Fail-safe to avoid reading junk data from the session after */
if (*(tU8**)pChunk == gEnd_of_session) {
*pChunk = old_chunk;
} else if (*(tU8**)pChunk > gEnd_of_session) {
} else if ((int)(*(int**)pChunk) > (int)gEnd_of_session) {
*pChunk = old_chunk;
}
}

View File

@ -10,10 +10,13 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
typedef unsigned int uintptr_t;
typedef int intptr_t;
#pragma intrinsic(memcpy, memset, memcmp, strlen, strcpy, strcmp, strcat)
// required for platform-specific network structs
// if needed for a different platform, make this conditional
//#include "pc-all/net_types.h"

View File

@ -54,14 +54,24 @@ target_sources(harness PRIVATE
)
if(DETHRACE_SOUND_ENABLED)
target_sources(harness PRIVATE
audio/miniaudio.c
)
target_sources(harness PRIVATE audio/miniaudio.c)
target_link_libraries(harness PRIVATE miniaudio stb)
else()
target_sources(harness PRIVATE
audio/null.c
)
target_sources(harness PRIVATE audio/null.c)
endif()
if(MSVC_42_FOR_RECCMP)
# we don't currently care about running it, just get it compiled!
target_sources(harness PRIVATE os/null.c)
elseif(WIN32)
target_sources(harness PRIVATE os/windows.c)
target_link_libraries(harness PRIVATE dbghelp ws2_32)
elseif(APPLE)
target_sources(harness PRIVATE os/macos.c)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(harness PRIVATE os/linux.c)
else()
message(FATAL_ERROR "Unsupported or unknown platform: ${CMAKE_SYSTEM_NAME}")
endif()
if(DETHRACE_PLATFORM_SDL1)
@ -103,23 +113,4 @@ if(DETHRACE_PLATFORM_SDL_DYNAMIC)
target_link_libraries(harness PRIVATE ${CMAKE_DL_LIBS})
endif()
if(NOT DETHRACE_NET_ENABLED)
target_sources(harness PRIVATE
os/null.c
)
else()
if(WIN32)
target_sources(harness PRIVATE
os/windows.c
)
target_link_libraries(harness PRIVATE dbghelp ws2_32)
elseif(APPLE)
target_sources(harness PRIVATE
os/macos.c
)
else()
target_sources(harness PRIVATE
os/linux.c
)
endif()
endif()

View File

@ -1,422 +1,422 @@
// LIBRARY: CARM95 0x00455730
// _iswxdigit
// iswxdigit
// LIBRARY: CARM95 0x004a61ca
// _WinMain@16
// WinMain@16
// LIBRARY: CARM95 0x004ea660
// _strtok
// strtok
// LIBRARY: CARM95 0x004ea8a0
// _asin
// asin
// LIBRARY: CARM95 0x004ea8aa
// _acos
// acos
// LIBRARY: CARM95 0x004ea8b1
// _atan
// atan
// LIBRARY: CARM95 0x004ea8b8
// _atan2
// atan2
// LIBRARY: CARM95 0x004ea8f0
// _sprintf
// sprintf
// LIBRARY: CARM95 0x004eaa10
// _memcpy
// memcpy
// LIBRARY: CARM95 0x004eab60
// _pow
// pow
// LIBRARY: CARM95 0x004eab6a
// _log
// log
// LIBRARY: CARM95 0x004eab74
// _log10
// log10
// LIBRARY: CARM95 0x004eab7b
// _exp
// exp
// LIBRARY: CARM95 0x004eabe0
// _fclose
// fclose
// LIBRARY: CARM95 0x004eacd0
// _fprintf
// fprintf
// LIBRARY: CARM95 0x004ead80
// _qsort
// qsort
// LIBRARY: CARM95 0x004eafe0
// _shortsort
// shortsort
// LIBRARY: CARM95 0x004eb070
// _swap
// swap
// LIBRARY: CARM95 0x004eb0d0
// _ldexp
// ldexp
// LIBRARY: CARM95 0x004eb3e0
// _rand
// rand
// LIBRARY: CARM95 0x004eb430
// _floor
// floor
// LIBRARY: CARM95 0x004eb5a0
// _ceil
// ceil
// LIBRARY: CARM95 0x004eb710
// _fread
// fread
// LIBRARY: CARM95 0x004eb8e0
// _fwrite
// fwrite
// LIBRARY: CARM95 0x004ebb00
// _fseek
// fseek
// LIBRARY: CARM95 0x004ebc30
// _sscanf
// sscanf
// LIBRARY: CARM95 0x004ebd00
// _fgets
// fgets
// LIBRARY: CARM95 0x004ebf40
// _fopen
// fopen
// LIBRARY: CARM95 0x004ebf70
// _strrchr
// strrchr
// LIBRARY: CARM95 0x004ebfa0
// _fscanf
// fscanf
// LIBRARY: CARM95 0x004ec030
// _ungetc
// ungetc
// LIBRARY: CARM95 0x004ec350
// _strchr
// strchr
// LIBRARY: CARM95 0x004ec410
// _strstr
// strstr
// LIBRARY: CARM95 0x004ec490
// _fgetc
// fgetc
// LIBRARY: CARM95 0x004ec510
// _fmod
// fmod
// LIBRARY: CARM95 0x004ec550
// _fputs
// fputs
// LIBRARY: CARM95 0x004ec6e0
// _strncmp
// strncmp
// LIBRARY: CARM95 0x004ec720
// _strpbrk
// strpbrk
// LIBRARY: CARM95 0x004ec760
// _strncpy
// strncpy
// LIBRARY: CARM95 0x004ec860
// _rewind
// rewind
// LIBRARY: CARM95 0x004ec920
// _ctime
// ctime
// LIBRARY: CARM95 0x004ec970
// _time
// time
// LIBRARY: CARM95 0x004ecb00
// _malloc
// malloc
// LIBRARY: CARM95 0x004ecfc0
// _realloc_help
// realloc_help
// LIBRARY: CARM95 0x004ed9a0
// _CheckBytes
// CheckBytes
// LIBRARY: CARM95 0x004ee4a0
// _memchr
// memchr
// LIBRARY: CARM95 0x004ee550
// _printf
// printf
// LIBRARY: CARM95 0x004ee5e0
// _fputc
// fputc
// LIBRARY: CARM95 0x004ee680
// _strtol
// strtol
// LIBRARY: CARM95 0x004ee6b0
// _strtoxl
// strtoxl
// LIBRARY: CARM95 0x004eea40
// _strtoul
// strtoul
// LIBRARY: CARM95 0x004eee80
// _CrtMessageWindow
// CrtMessageWindow
// LIBRARY: CARM95 0x004ef1b0
// _ftell
// ftell
// LIBRARY: CARM95 0x004ef4b0
// _exit
// exit
// LIBRARY: CARM95 0x004ef4f0
// _doexit
// doexit
// LIBRARY: CARM95 0x004ef630
// _rename
// rename
// LIBRARY: CARM95 0x004ef690
// _remove
// remove
// LIBRARY: CARM95 0x004ef6f0
// _tolower
// tolower
// LIBRARY: CARM95 0x004efac0
// _abort
// abort
// LIBRARY: CARM95 0x004efaf0
// _getenv
// getenv
// LIBRARY: CARM95 0x004efbe0
// _strtod
// strtod
// LIBRARY: CARM95 0x004efd40
// _vsprintf
// vsprintf
// LIBRARY: CARM95 0x004f0717
// _rtforsqrtinf
// rtforsqrtinf
// LIBRARY: CARM95 0x004f071c
// _rtforsqrtzero
// rtforsqrtzero
// LIBRARY: CARM95 0x004f09f5
// _rtforatn20
// rtforatn20
// LIBRARY: CARM95 0x004f0a11
// _rtforatn200
// rtforatn200
// LIBRARY: CARM95 0x004f0a18
// _rtforatnby0
// rtforatnby0
// LIBRARY: CARM95 0x004f0a1e
// _rtsignpiby2
// rtsignpiby2
// LIBRARY: CARM95 0x004f1a60
// _write_char
// write_char
// LIBRARY: CARM95 0x004f1ae0
// _write_multi_char
// write_multi_char
// LIBRARY: CARM95 0x004f1b30
// _write_string
// write_string
// LIBRARY: CARM95 0x004f1b90
// _get_int_arg
// get_int_arg
// LIBRARY: CARM95 0x004f1bb0
// _get_int64_arg
// get_int64_arg
// LIBRARY: CARM95 0x004f1be0
// _get_short_arg
// get_short_arg
// LIBRARY: CARM95 0x004f1c6e
// _rtfor0to0
// rtfor0to0
// LIBRARY: CARM95 0x004f1ca4
// _rtforln0
// rtforln0
// LIBRARY: CARM95 0x004f1cb4
// _rtforloginf
// rtforloginf
// LIBRARY: CARM95 0x004f1cc8
// _rtforyto0
// rtforyto0
// LIBRARY: CARM95 0x004f1ccd
// _rtfor0tox
// rtfor0tox
// LIBRARY: CARM95 0x004f1ce8
// _rtfor0toneg
// rtfor0toneg
// LIBRARY: CARM95 0x004f1d32
// _expbigret
// expbigret
// LIBRARY: CARM95 0x004f1d51
// _rtforexpinf
// rtforexpinf
// LIBRARY: CARM95 0x004f1da1
// _isintTOS
// isintTOS
// LIBRARY: CARM95 0x004f1dc6
// _isintTOSret
// isintTOSret
// LIBRARY: CARM95 0x004f1dd5
// _usepowhlp
// usepowhlp
// LIBRARY: CARM95 0x004f1fe0
// _fflush
// fflush
// LIBRARY: CARM95 0x004f2140
// _flsall
// flsall
// LIBRARY: CARM95 0x004f3b90
// _memcpy_0
// memcpy_0
// LIBRARY: CARM95 0x004f55f0
// _strlen
// strlen
// LIBRARY: CARM95 0x004f606f
// _tossnan1
// tossnan1
// LIBRARY: CARM95 0x004f609d
// _tossnan2
// tossnan2
// LIBRARY: CARM95 0x004f60a4
// _tosnan2ret
// tosnan2ret
// LIBRARY: CARM95 0x004f60dc
// _snan2
// snan2
// LIBRARY: CARM95 0x004f60e3
// _nan2ret
// nan2ret
// LIBRARY: CARM95 0x004f7040
// _asctime
// asctime
// LIBRARY: CARM95 0x004f71a0
// _store_dt
// store_dt
// LIBRARY: CARM95 0x004f71e0
// _localtime
// localtime
// LIBRARY: CARM95 0x004f75a0
// _memset
// memset
// LIBRARY: CARM95 0x004f8e80
// _toupper
// toupper
// LIBRARY: CARM95 0x004f9020
// _xtoa
// xtoa
// LIBRARY: CARM95 0x004f90e0
// _strcpy
// strcpy
// LIBRARY: CARM95 0x004f90f0
// _strcat
// strcat
// LIBRARY: CARM95 0x004f93b0
// _raise
// raise
// LIBRARY: CARM95 0x004f95d0
// _siglookup
// siglookup
// LIBRARY: CARM95 0x004f9b00
// _strncnt
// strncnt
// LIBRARY: CARM95 0x004f9b7c
// _gu_return
// gu_return
// LIBRARY: CARM95 0x004f9ba5
// _uh_return
// uh_return
// LIBRARY: CARM95 0x004f9bc3
// _lu_top
// lu_top
// LIBRARY: CARM95 0x004f9c00
// _lu_done
// lu_done
// LIBRARY: CARM95 0x004f9c30
// _at_done
// at_done
// LIBRARY: CARM95 0x004f9e60
// _xcptlookup
// xcptlookup
// LIBRARY: CARM95 0x004f9ef0
// _x_ismbbtype
// x_ismbbtype
// LIBRARY: CARM95 0x004fa170
// _parse_cmdline
// parse_cmdline
// LIBRARY: CARM95 0x004faac0
// _getSystemCP
// getSystemCP
// LIBRARY: CARM95 0x004fab50
// _CPtoLCID
// CPtoLCID
// LIBRARY: CARM95 0x004fabf0
// _setSBCS
// setSBCS
// LIBRARY: CARM95 0x004facc3
// _lh_top
// lh_top
// LIBRARY: CARM95 0x004fad17
// _lh_continue
// lh_continue
// LIBRARY: CARM95 0x004fad22
// _lh_dismiss
// lh_dismiss
// LIBRARY: CARM95 0x004fad29
// _lh_bagit
// lh_bagit
// LIBRARY: CARM95 0x004fad30
// _lh_unwinding
// lh_unwinding
// LIBRARY: CARM95 0x004fad45
// _lh_return
// lh_return
// LIBRARY: CARM95 0x004fc210
// _wctomb
// wctomb
// LIBRARY: CARM95 0x004fcc00
// _mbtowc
// mbtowc
// LIBRARY: CARM95 0x004fcda0
// _isspace
// isspace
// LIBRARY: CARM95 0x004fdae0
// _cvtdate
// cvtdate
// LIBRARY: CARM95 0x004fdcf0
// _gmtime
// gmtime
// LIBRARY: CARM95 0x004fdfa0
// _wcslen
// wcslen
// LIBRARY: CARM95 0x004fe450
// _strncnt_0
// strncnt_0
// LIBRARY: CARM95 0x004fe830
// _findenv
// findenv
// LIBRARY: CARM95 0x004fe8d0
// _copy_environ
// copy_environ
// LIBRARY: CARM95 0x004ff930
// _$I10_OUTPUT
// $I10_OUTPUT
// LIBRARY: CARM95 0x00500120
// _atol
// atol
// LIBRARY: CARM95 0x00500240
// _strcmp
// strcmp
// LIBRARY: CARM95 0x005002d0
// _wcstombs
// wcstombs
// LIBRARY: CARM95 0x00500630
// _wcsncnt
// wcsncnt
// LIBRARY: CARM95 0x00502f60
// _feof
// feof
// LIBRARY: CARM95 0x00503140
// _longjmp
// longjmp
// LIBRARY: CARM95 0x0050315b
// _lj_local_unwind
// lj_local_unwind
// LIBRARY: CARM95 0x00503183
// _lj_old_unwind
// lj_old_unwind
// LIBRARY: CARM95 0x00503190
// _lj_no_unwind
// lj_no_unwind