diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22be6cc..800e3fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,4 +56,9 @@ add_executable(doomsim doomsim.cc) target_compile_features(doomsim PRIVATE cxx_std_17) target_link_libraries(doomsim PRIVATE dp_common -) \ No newline at end of file +) + +unset(CMAKE_C_CLANG_TIDY) +unset(CMAKE_CXX_CLANG_TIDY) + +add_subdirectory(dp_doom) diff --git a/src/dp_doom/CMakeLists.txt b/src/dp_doom/CMakeLists.txt index 3502e5f..5272018 100644 --- a/src/dp_doom/CMakeLists.txt +++ b/src/dp_doom/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.19) -project(clowndoom LANGUAGES C) +project(dp_doom LANGUAGES C) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(BACKEND "SDL2" CACHE STRING "Which backend to use: Xlib, SDL1, or SDL2") -option(WILDMIDI "Render MIDI using the WildMIDI library" ON) +set(BACKEND "nng" CACHE STRING "Which backend to use: Xlib, SDL1, SDL2 or nng") +option(WILDMIDI "Render MIDI using the WildMIDI library" OFF) -add_executable(clowndoom WIN32 +add_executable(dp_doom WIN32 "linuxdoom-1.10/am_map.c" "linuxdoom-1.10/am_map.h" "linuxdoom-1.10/d_englsh.h" @@ -135,11 +135,11 @@ add_executable(clowndoom WIN32 "linuxdoom-1.10/z_zone.c" ) -set_target_properties(clowndoom PROPERTIES C_STANDARD 99) +set_target_properties(dp_doom PROPERTIES C_STANDARD 99) # Handling linking/building WildMIDI if(WILDMIDI) - target_compile_definitions(clowndoom PRIVATE WILDMIDI) + target_compile_definitions(dp_doom PRIVATE WILDMIDI) # TODO - Add support for system library #find_package(WildMidi) @@ -157,12 +157,12 @@ if(WILDMIDI) add_subdirectory("external/wildmidi-0.4.5" EXCLUDE_FROM_ALL) #endif() - target_link_libraries(clowndoom PRIVATE libwildmidi-static m) + target_link_libraries(dp_doom PRIVATE libwildmidi-static m) endif() # Handle backends if(BACKEND STREQUAL "Xlib") - target_sources(clowndoom PRIVATE + target_sources(dp_doom PRIVATE "linuxdoom-1.10/ib_sound/miniaudio.c" "linuxdoom-1.10/ib_sound/miniaudio.h" "linuxdoom-1.10/ib_system/posix.c" @@ -170,12 +170,12 @@ if(BACKEND STREQUAL "Xlib") ) # These are for the X11 stuff. - target_link_libraries(clowndoom PRIVATE Xext X11) + target_link_libraries(dp_doom PRIVATE Xext X11) # These are for miniaudio. - target_link_libraries(clowndoom PRIVATE m ${CMAKE_DL_LIBS} pthread) + target_link_libraries(dp_doom PRIVATE m ${CMAKE_DL_LIBS} pthread) elseif(BACKEND STREQUAL "SDL1") - target_sources(clowndoom PRIVATE + target_sources(dp_doom PRIVATE "linuxdoom-1.10/ib_sound/sdl.c" "linuxdoom-1.10/ib_system/sdl.c" "linuxdoom-1.10/ib_video/sdl.c" @@ -189,9 +189,9 @@ elseif(BACKEND STREQUAL "SDL1") # add_subdirectory("external/sdl1" EXCLUDE_FROM_ALL) #endif() - target_link_libraries(clowndoom PRIVATE SDL::SDL) + target_link_libraries(dp_doom PRIVATE SDL::SDL) elseif(BACKEND STREQUAL "SDL2") - target_sources(clowndoom PRIVATE + target_sources(dp_doom PRIVATE "linuxdoom-1.10/ib_sound/sdl.c" "linuxdoom-1.10/ib_system/sdl.c" "linuxdoom-1.10/ib_video/sdl.c" @@ -202,15 +202,24 @@ elseif(BACKEND STREQUAL "SDL2") if(NOT SDL2_FOUND) add_subdirectory("external/SDL" EXCLUDE_FROM_ALL) if(SDL_STATIC) - target_link_libraries(clowndoom PRIVATE SDL2::SDL2main SDL2::SDL2-static) + target_link_libraries(dp_doom PRIVATE SDL2::SDL2main SDL2::SDL2-static) else() - target_link_libraries(clowndoom PRIVATE SDL2::SDL2main SDL2::SDL2) + target_link_libraries(dp_doom PRIVATE SDL2::SDL2main SDL2::SDL2) endif() else() - target_link_libraries(clowndoom PRIVATE SDL2::SDL2main SDL2::SDL2) + target_link_libraries(dp_doom PRIVATE SDL2::SDL2main SDL2::SDL2) endif() - target_compile_definitions(clowndoom PRIVATE INCLUDE_SDL2_MAIN) + target_compile_definitions(dp_doom PRIVATE INCLUDE_SDL2_MAIN) +elseif(BACKEND STREQUAL "nng") + target_sources(dp_doom PRIVATE + "linuxdoom-1.10/ib_sound/sdl.c" + "linuxdoom-1.10/ib_system/nng.c" + "linuxdoom-1.10/ib_video/nng.c" + ) + + find_package(SDL2 REQUIRED) + target_link_libraries(dp_doom PRIVATE SDL2::SDL2 m) else() message(FATAL_ERROR "Invalid BACKEND") endif() diff --git a/src/dp_doom/linuxdoom-1.10/ib_system/nng.c b/src/dp_doom/linuxdoom-1.10/ib_system/nng.c new file mode 100644 index 0000000..5b18297 --- /dev/null +++ b/src/dp_doom/linuxdoom-1.10/ib_system/nng.c @@ -0,0 +1,45 @@ +#include "SDL.h" + +#include "../doomdef.h" + +#include "../ib_system.h" + + +// +// IB_GetTime +// returns time in 1/70th second tics +// +int IB_GetTime (void) +{ + return SDL_GetTicks() * TICRATE / 1000; +} + + +// +// IB_Init +// +void IB_Init (void) +{ + SDL_Init(0); +} + + +// +// IB_Quit +// +void IB_Quit (void) +{ + SDL_Quit(); +} + + +void IB_WaitVBL(int count) +{ + SDL_Delay(count * 1000 / 70); +} + + +void IB_Sleep(void) +{ + SDL_Delay(1); +} diff --git a/src/dp_doom/linuxdoom-1.10/ib_video/nng.c b/src/dp_doom/linuxdoom-1.10/ib_video/nng.c new file mode 100644 index 0000000..8ebb53f --- /dev/null +++ b/src/dp_doom/linuxdoom-1.10/ib_video/nng.c @@ -0,0 +1,68 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// $Log:$ +// +// DESCRIPTION: +// DOOM graphics stuff for X11, UNIX. +// +//----------------------------------------------------------------------------- + +#include +#include +#include + +#include "../doomstat.h" +#include "../i_system.h" +#include "../v_video.h" +#include "../m_argv.h" +#include "../d_main.h" + +#include "../doomdef.h" + +#include "../ib_video.h" + +// +// IB_StartTic +// +void IB_StartTic (void) +{ +} + +void IB_GetFramebuffer(unsigned char **pixels, size_t *pitch) +{ +} + +void IB_FinishUpdate (void) +{ +} + +void IB_GetColor(unsigned char *bytes, unsigned char red, unsigned char green, unsigned char blue) +{ +} + +void IB_InitGraphics(const char *title, size_t screen_width, size_t screen_height, size_t *bytes_per_pixel) +{ +} + +void IB_ShutdownGraphics(void) +{ +} + +void IB_GrabMouse(boolean grab) +{ +}