rename clowndoom to dp_doom, add skeleton code, fix issues

This commit is contained in:
oxmox 2023-02-19 02:17:52 +01:00
parent c9c334ae57
commit 777d766035
4 changed files with 145 additions and 18 deletions

View file

@ -56,4 +56,9 @@ add_executable(doomsim doomsim.cc)
target_compile_features(doomsim PRIVATE cxx_std_17) target_compile_features(doomsim PRIVATE cxx_std_17)
target_link_libraries(doomsim target_link_libraries(doomsim
PRIVATE dp_common PRIVATE dp_common
) )
unset(CMAKE_C_CLANG_TIDY)
unset(CMAKE_CXX_CLANG_TIDY)
add_subdirectory(dp_doom)

View file

@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.19) cmake_minimum_required(VERSION 3.19)
project(clowndoom LANGUAGES C) project(dp_doom LANGUAGES C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(BACKEND "SDL2" CACHE STRING "Which backend to use: Xlib, SDL1, or SDL2") set(BACKEND "nng" CACHE STRING "Which backend to use: Xlib, SDL1, SDL2 or nng")
option(WILDMIDI "Render MIDI using the WildMIDI library" ON) 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.c"
"linuxdoom-1.10/am_map.h" "linuxdoom-1.10/am_map.h"
"linuxdoom-1.10/d_englsh.h" "linuxdoom-1.10/d_englsh.h"
@ -135,11 +135,11 @@ add_executable(clowndoom WIN32
"linuxdoom-1.10/z_zone.c" "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 # Handling linking/building WildMIDI
if(WILDMIDI) if(WILDMIDI)
target_compile_definitions(clowndoom PRIVATE WILDMIDI) target_compile_definitions(dp_doom PRIVATE WILDMIDI)
# TODO - Add support for system library # TODO - Add support for system library
#find_package(WildMidi) #find_package(WildMidi)
@ -157,12 +157,12 @@ if(WILDMIDI)
add_subdirectory("external/wildmidi-0.4.5" EXCLUDE_FROM_ALL) add_subdirectory("external/wildmidi-0.4.5" EXCLUDE_FROM_ALL)
#endif() #endif()
target_link_libraries(clowndoom PRIVATE libwildmidi-static m) target_link_libraries(dp_doom PRIVATE libwildmidi-static m)
endif() endif()
# Handle backends # Handle backends
if(BACKEND STREQUAL "Xlib") 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.c"
"linuxdoom-1.10/ib_sound/miniaudio.h" "linuxdoom-1.10/ib_sound/miniaudio.h"
"linuxdoom-1.10/ib_system/posix.c" "linuxdoom-1.10/ib_system/posix.c"
@ -170,12 +170,12 @@ if(BACKEND STREQUAL "Xlib")
) )
# These are for the X11 stuff. # 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. # 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") elseif(BACKEND STREQUAL "SDL1")
target_sources(clowndoom PRIVATE target_sources(dp_doom PRIVATE
"linuxdoom-1.10/ib_sound/sdl.c" "linuxdoom-1.10/ib_sound/sdl.c"
"linuxdoom-1.10/ib_system/sdl.c" "linuxdoom-1.10/ib_system/sdl.c"
"linuxdoom-1.10/ib_video/sdl.c" "linuxdoom-1.10/ib_video/sdl.c"
@ -189,9 +189,9 @@ elseif(BACKEND STREQUAL "SDL1")
# add_subdirectory("external/sdl1" EXCLUDE_FROM_ALL) # add_subdirectory("external/sdl1" EXCLUDE_FROM_ALL)
#endif() #endif()
target_link_libraries(clowndoom PRIVATE SDL::SDL) target_link_libraries(dp_doom PRIVATE SDL::SDL)
elseif(BACKEND STREQUAL "SDL2") elseif(BACKEND STREQUAL "SDL2")
target_sources(clowndoom PRIVATE target_sources(dp_doom PRIVATE
"linuxdoom-1.10/ib_sound/sdl.c" "linuxdoom-1.10/ib_sound/sdl.c"
"linuxdoom-1.10/ib_system/sdl.c" "linuxdoom-1.10/ib_system/sdl.c"
"linuxdoom-1.10/ib_video/sdl.c" "linuxdoom-1.10/ib_video/sdl.c"
@ -202,15 +202,24 @@ elseif(BACKEND STREQUAL "SDL2")
if(NOT SDL2_FOUND) if(NOT SDL2_FOUND)
add_subdirectory("external/SDL" EXCLUDE_FROM_ALL) add_subdirectory("external/SDL" EXCLUDE_FROM_ALL)
if(SDL_STATIC) 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() else()
target_link_libraries(clowndoom PRIVATE SDL2::SDL2main SDL2::SDL2) target_link_libraries(dp_doom PRIVATE SDL2::SDL2main SDL2::SDL2)
endif() endif()
else() else()
target_link_libraries(clowndoom PRIVATE SDL2::SDL2main SDL2::SDL2) target_link_libraries(dp_doom PRIVATE SDL2::SDL2main SDL2::SDL2)
endif() 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() else()
message(FATAL_ERROR "Invalid BACKEND") message(FATAL_ERROR "Invalid BACKEND")
endif() endif()

View file

@ -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);
}

View file

@ -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 <stddef.h>
#include <stdlib.h>
#include <string.h>
#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)
{
}