From e1af7e3f8c36432b2261323310f39584ad149e83 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 21:14:45 +0100 Subject: [PATCH 01/25] - Game-Music-Emu: reduce code delta with original source. This will help with the next Game-Music-Emu upgrades. --- game-music-emu/CMakeLists.txt | 7 +++++++ game-music-emu/gme/CMakeLists.txt | 23 ++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/game-music-emu/CMakeLists.txt b/game-music-emu/CMakeLists.txt index 8ceb1b4b7..fc6af33df 100644 --- a/game-music-emu/CMakeLists.txt +++ b/game-music-emu/CMakeLists.txt @@ -108,3 +108,10 @@ set( LIBGME_HAVE_GCC_VISIBILITY ${ENABLE_VISIBILITY} CACHE BOOL "GCC support for # Shared library defined here add_subdirectory(gme) + +# EXCLUDE_FROM_ALL adds build rules but keeps it out of default build +# [ZDoom] Not needed. +if( FALSE ) +add_subdirectory(player EXCLUDE_FROM_ALL) +add_subdirectory(demo EXCLUDE_FROM_ALL) +endif() diff --git a/game-music-emu/gme/CMakeLists.txt b/game-music-emu/gme/CMakeLists.txt index 10544d721..d10ed2920 100644 --- a/game-music-emu/gme/CMakeLists.txt +++ b/game-music-emu/gme/CMakeLists.txt @@ -131,6 +131,12 @@ set (EXPORTED_HEADERS gme.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gme_types.h.in ${CMAKE_CURRENT_BINARY_DIR}/gme_types.h) +# [ZDoom] Not needed. +if( FALSE ) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgme.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libgme.pc @ONLY) +endif() + # On some platforms we may need to change headers or whatnot based on whether # we're building the library or merely using the library. The following is # only defined when building the library to allow us to tell which is which. @@ -147,7 +153,18 @@ add_library(gme ${libgme_SRCS}) # to the API), the SOVERSION should be the same even when bumping up VERSION. # The way gme.h is designed, SOVERSION should very rarely be bumped, if ever. # Hopefully the API can stay compatible with old versions. -#set_target_properties(gme -# PROPERTIES VERSION ${GME_VERSION} -# SOVERSION 0) +# [ZDoom] Not needed. +if( FALSE ) +set_target_properties(gme + PROPERTIES VERSION ${GME_VERSION} + SOVERSION 0) + +install(TARGETS gme LIBRARY DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin # DLL platforms + ARCHIVE DESTINATION lib) # DLL platforms + +install(FILES ${EXPORTED_HEADERS} DESTINATION include/gme) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgme.pc DESTINATION lib/pkgconfig) +endif() + target_link_libraries(gme) From 8895716e273a5bcecaa00714ef95c99a2845b131 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 21:19:56 +0100 Subject: [PATCH 02/25] - Game-Music-Emu: Merge commit cf7bfd2. Commit title: 'added gme_tell_samples() and gme_seek_samples()' --- game-music-emu/gme/Music_Emu.cpp | 13 +++++++++++-- game-music-emu/gme/Music_Emu.h | 6 ++++++ game-music-emu/gme/gme.cpp | 2 ++ game-music-emu/gme/gme.h | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/game-music-emu/gme/Music_Emu.cpp b/game-music-emu/gme/Music_Emu.cpp index d0dbe77a8..b7fc4993b 100644 --- a/game-music-emu/gme/Music_Emu.cpp +++ b/game-music-emu/gme/Music_Emu.cpp @@ -178,6 +178,11 @@ blargg_long Music_Emu::msec_to_samples( blargg_long msec ) const return (sec * sample_rate() + msec * sample_rate() / 1000) * stereo; } +long Music_Emu::tell_samples() const +{ + return out_time; +} + long Music_Emu::tell() const { blargg_long rate = sample_rate() * stereo; @@ -185,14 +190,18 @@ long Music_Emu::tell() const return sec * 1000 + (out_time - sec * rate) * 1000 / rate; } -blargg_err_t Music_Emu::seek( long msec ) +blargg_err_t Music_Emu::seek_samples( long time ) { - blargg_long time = msec_to_samples( msec ); if ( time < out_time ) RETURN_ERR( start_track( current_track_ ) ); return skip( time - out_time ); } +blargg_err_t Music_Emu::seek( long msec ) +{ + return seek_samples( msec_to_samples( msec ) ); +} + blargg_err_t Music_Emu::skip( long count ) { require( current_track() >= 0 ); // start_track() must have been called already diff --git a/game-music-emu/gme/Music_Emu.h b/game-music-emu/gme/Music_Emu.h index b96f4b611..d98f7ce7e 100644 --- a/game-music-emu/gme/Music_Emu.h +++ b/game-music-emu/gme/Music_Emu.h @@ -41,9 +41,15 @@ public: // Number of milliseconds (1000 msec = 1 second) played since beginning of track long tell() const; + // Number of samples generated since beginning of track + long tell_samples() const; + // Seek to new time in track. Seeking backwards or far forward can take a while. blargg_err_t seek( long msec ); + // Equivalent to restarting track then skipping n samples + blargg_err_t seek_samples( long n ); + // Skip n samples blargg_err_t skip( long n ); diff --git a/game-music-emu/gme/gme.cpp b/game-music-emu/gme/gme.cpp index 990fee345..5247c1f1a 100644 --- a/game-music-emu/gme/gme.cpp +++ b/game-music-emu/gme/gme.cpp @@ -337,7 +337,9 @@ BLARGG_EXPORT gme_err_t gme_play ( Music_Emu* me, int n, short* p ) BLARGG_EXPORT void gme_set_fade ( Music_Emu* me, int start_msec ) { me->set_fade( start_msec ); } BLARGG_EXPORT int gme_track_ended ( Music_Emu const* me ) { return me->track_ended(); } BLARGG_EXPORT int gme_tell ( Music_Emu const* me ) { return me->tell(); } +BLARGG_EXPORT int gme_tell_samples ( Music_Emu const* me ) { return me->tell_samples(); } BLARGG_EXPORT gme_err_t gme_seek ( Music_Emu* me, int msec ) { return me->seek( msec ); } +BLARGG_EXPORT gme_err_t gme_seek_samples ( Music_Emu* me, int n ) { return me->seek_samples( n ); } BLARGG_EXPORT int gme_voice_count ( Music_Emu const* me ) { return me->voice_count(); } BLARGG_EXPORT void gme_ignore_silence ( Music_Emu* me, int disable ) { me->ignore_silence( disable != 0 ); } BLARGG_EXPORT void gme_set_tempo ( Music_Emu* me, double t ) { me->set_tempo( t ); } diff --git a/game-music-emu/gme/gme.h b/game-music-emu/gme/gme.h index 1f2a2d150..8eb952e23 100644 --- a/game-music-emu/gme/gme.h +++ b/game-music-emu/gme/gme.h @@ -47,9 +47,15 @@ int gme_track_ended( Music_Emu const* ); /* Number of milliseconds (1000 = one second) played since beginning of track */ int gme_tell( Music_Emu const* ); +/* Number of samples generated since beginning of track */ +int gme_tell_samples( Music_Emu const* ); + /* Seek to new time in track. Seeking backwards or far forward can take a while. */ gme_err_t gme_seek( Music_Emu*, int msec ); +/* Equivalent to restarting track then skipping n samples */ +gme_err_t gme_seek_samples( Music_Emu*, int n ); + /******** Informational ********/ From f239c0ea05d53be750d2dd1a91c78a9c6f0b26c3 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 21:27:34 +0100 Subject: [PATCH 03/25] - Game-Music-Emu: Merge commit 6e1544d. Commit title: 'Fix undefined left-shift of signed int.' --- game-music-emu/gme/Spc_Cpu.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/game-music-emu/gme/Spc_Cpu.cpp b/game-music-emu/gme/Spc_Cpu.cpp index a9746e015..db96ac390 100644 --- a/game-music-emu/gme/Spc_Cpu.cpp +++ b/game-music-emu/gme/Spc_Cpu.cpp @@ -433,9 +433,7 @@ void Snes_Spc::cpu_write( int data, int addr, rel_time_t time ) #endif // Registers other than $F2 and $F4-$F7 - //if ( reg != 2 && reg != 4 && reg != 5 && reg != 6 && reg != 7 ) - // TODO: this is a bit on the fragile side - if ( ((~0x2F00 << (bits_in_int - 16)) << reg) < 0 ) // 36% + if ( reg != 2 && (reg < 4 || reg > 7) ) // 36% cpu_write_smp_reg( data, time, reg ); } // High mem/address wrap-around From 05e77303bf103dd3319d74882090e0ca42c768b6 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 21:33:44 +0100 Subject: [PATCH 04/25] - Game-Music-Emu: Merge commit 12b50ee. Commit title: Honor LIB_SUFFIX with pkg-config metadata. --- game-music-emu/changes.txt | 6 ++++++ game-music-emu/gme/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/game-music-emu/changes.txt b/game-music-emu/changes.txt index 62391ebb5..dfab7a9c0 100644 --- a/game-music-emu/changes.txt +++ b/game-music-emu/changes.txt @@ -1,6 +1,12 @@ Game_Music_Emu Change Log ------------------------- +Game_Music_Emu 0.6.1 +-------------------- + +- Packaging improvements: + - Honor $LIB_SUFFIX for installed pkg-config metadata. + Game_Music_Emu 0.6.0 -------------------- diff --git a/game-music-emu/gme/CMakeLists.txt b/game-music-emu/gme/CMakeLists.txt index d10ed2920..8d710709f 100644 --- a/game-music-emu/gme/CMakeLists.txt +++ b/game-music-emu/gme/CMakeLists.txt @@ -164,7 +164,7 @@ install(TARGETS gme LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib) # DLL platforms install(FILES ${EXPORTED_HEADERS} DESTINATION include/gme) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgme.pc DESTINATION lib/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgme.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) endif() target_link_libraries(gme) From 287fc513a22a6abb319fb564c5ddd113badbbce6 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 21:39:08 +0100 Subject: [PATCH 05/25] - Game-Music-Emu: Merge and change commits 9bb5ad7, bc0a473 and 2018c1b. Commit titles: 9bb5ad7 - 'Add filename param to demo app.' bc0a473 - 'Allow building a static library (-DLIBTYPE=STATIC)' 2018c1b - 'Merged in lachs0r/game-music-emu (pull request #1)' Change: ZDoom doesn't need the shared library, so disable it always. --- game-music-emu/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/game-music-emu/CMakeLists.txt b/game-music-emu/CMakeLists.txt index fc6af33df..2e2299456 100644 --- a/game-music-emu/CMakeLists.txt +++ b/game-music-emu/CMakeLists.txt @@ -79,6 +79,9 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" ) SET(USE_GME_NSF 1 BOOL "Enable NES NSF music emulation") #endif() +# [ZDoom] Set always to OFF. +set(BUILD_SHARED_LIBS 0 BOOL "Build shared library (set to OFF for static library)") + # Check for GCC "visibility" support. if (CMAKE_COMPILER_IS_GNUCXX) check_cxx_compiler_flag (-fvisibility=hidden __LIBGME_TEST_VISIBILITY) From 3d3bc8e40e250387e456a672ce5e7a4915d021b4 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 21:51:53 +0100 Subject: [PATCH 06/25] - Game-Music-Emu: Merge commits b1948ac, 8af6ba4, eb5f592 and 56d43f4. Commit titles: b1948ac - 'Describe CMake addition for static libs in changelog.' 8af6ba4 - 'Bump version in CMakeLists as well.' eb5f592 - 'Update readme for repo move and next version.' 56d43f4 - 'Update readme as well now.' --- game-music-emu/CMakeLists.txt | 2 +- game-music-emu/changes.txt | 6 ++++++ game-music-emu/gme.txt | 13 +++++++------ game-music-emu/readme.txt | 30 +++++++++++++++++++++++------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/game-music-emu/CMakeLists.txt b/game-music-emu/CMakeLists.txt index 2e2299456..20973401b 100644 --- a/game-music-emu/CMakeLists.txt +++ b/game-music-emu/CMakeLists.txt @@ -4,7 +4,7 @@ project(libgme) include (CheckCXXCompilerFlag) # When version is changed, also change the one in gme/gme.h to match -set(GME_VERSION 0.6.0 CACHE INTERNAL "libgme Version") +set(GME_VERSION 0.6.1 CACHE INTERNAL "libgme Version") # 2.6+ always assumes FATAL_ERROR, but 2.4 and below don't. # Of course, 2.4 might work, in which case you're welcome to drop diff --git a/game-music-emu/changes.txt b/game-music-emu/changes.txt index dfab7a9c0..48986756a 100644 --- a/game-music-emu/changes.txt +++ b/game-music-emu/changes.txt @@ -4,8 +4,14 @@ Game_Music_Emu Change Log Game_Music_Emu 0.6.1 -------------------- +- Moved repository to Bitbucket since Google Code announced they would + shutdown this year. + - Packaging improvements: - Honor $LIB_SUFFIX for installed pkg-config metadata. + - Support setting BUILD_SHARED_LIBS to OFF to build libgme as a static + library. (Pass -DBUILD_SHARED_LIBS=OFF when running cmake). + Thanks to lachs0r. Game_Music_Emu 0.6.0 -------------------- diff --git a/game-music-emu/gme.txt b/game-music-emu/gme.txt index d9a2452c7..baec6f4dc 100644 --- a/game-music-emu/gme.txt +++ b/game-music-emu/gme.txt @@ -1,10 +1,11 @@ -Game_Music_Emu 0.6.0 +Game_Music_Emu 0.6.1 -------------------- -Author : Shay Green -Website: http://www.slack.net/~ant/libs/ -Forum : http://groups.google.com/group/blargg-sound-libs -Source : https://code.google.com/p/game-music-emu/ -License: GNU Lesser General Public License (LGPL) +Author : Shay Green +Maintainer : Michael Pyne +Website : http://www.slack.net/~ant/libs/ +Forum : http://groups.google.com/group/blargg-sound-libs +Source : https://bitbucket.org/mpyne/game-music-emu/ +License : GNU Lesser General Public License (LGPL), see LICENSE.txt Contents -------- diff --git a/game-music-emu/readme.txt b/game-music-emu/readme.txt index 82a501dbd..b29a00797 100644 --- a/game-music-emu/readme.txt +++ b/game-music-emu/readme.txt @@ -1,4 +1,4 @@ -Game_Music_Emu 0.6.0: Game Music Emulators +Game_Music_Emu 0.6.1: Game Music Emulators ------------------------------------------ Game_Music_Emu is a collection of video game music file emulators that support the following formats and systems: @@ -38,26 +38,42 @@ Website: http://www.slack.net/~ant/ Forum : http://groups.google.com/group/blargg-sound-libs License: GNU Lesser General Public License (LGPL) +Current Maintainer: Michael Pyne Getting Started --------------- Build a program consisting of demo/basics.c, demo/Wave_Writer.cpp, and -all source files in gme/. If you have CMake 2.6 or later, execute +all source files in gme/. - run cmake - cd demo - run make +Or, if you have CMake 2.6 or later, execute at a command prompt (from the +extracted source directory): -Be sure "test.nsf" is in the same directory as the program. Running it + mkdir build + cd build + cmake ../ # <-- Pass any needed CMake flags here + make # To build the library + cd demo + make # To build the demo itself + +Be sure "test.nsf" is in the same directory as the demo program. Running it should generate the recording "out.wav". +You can use "make install" to install the library. To choose where to install +the library to, use the CMake argument "-DCMAKE_INSTALL_PREFIX=/usr/local" +(and replace /usr/local with the base path you wish to use). Alternately, you +can specify the base path to install to when you run "make install" by passing +'DESTDIR=/usr/local' on the make install command line (again, replace +/usr/local as appropriate). + +To build a static library instead of shared (the default), pass +-DBUILD_SHARED_LIBS=OFF to the cmake command when running cmake. + A slightly more extensive demo application is available in the player/ directory. It requires SDL to build. Read gme.txt for more information. Post to the discussion forum for assistance. - Files ----- gme.txt General notes about the library From dd92587841ff9bb2d579b5ec7a1af5d2e3c8c9a4 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 22:01:06 +0100 Subject: [PATCH 07/25] - Game-Music-Emu: Merge commit bf60977. Commit title: 'Fix compile failures with zlib support enabled.' --- game-music-emu/gme/Data_Reader.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/game-music-emu/gme/Data_Reader.h b/game-music-emu/gme/Data_Reader.h index acf571f67..6c22b678e 100644 --- a/game-music-emu/gme/Data_Reader.h +++ b/game-music-emu/gme/Data_Reader.h @@ -129,6 +129,8 @@ private: }; #ifdef HAVE_ZLIB_H +#include + // Gzip compressed file reader class Gzip_File_Reader : public File_Reader { public: @@ -143,7 +145,7 @@ public: long tell() const; blargg_err_t seek( long ); private: - void* file_; + gzFile file_; long size_; }; #endif From b515a034f6614fd288b428d00c56c53ecee16daa Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 22:05:45 +0100 Subject: [PATCH 08/25] - Game-Music-Emu: Merge commits dfffd2b and 2cbb70f. Commit titles: dfffd2b - 'Hide the GCC visibility option to non-GCC compilers.' 2cbb70f - 'Merged in edward_san/game-music-emu (pull request #3)' --- game-music-emu/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/game-music-emu/CMakeLists.txt b/game-music-emu/CMakeLists.txt index 20973401b..c6472b690 100644 --- a/game-music-emu/CMakeLists.txt +++ b/game-music-emu/CMakeLists.txt @@ -104,10 +104,10 @@ if (CMAKE_COMPILER_IS_GNUCXX) endif() endif() endif() # test visibility -endif() -# Cache this result -set( LIBGME_HAVE_GCC_VISIBILITY ${ENABLE_VISIBILITY} CACHE BOOL "GCC support for hidden visibility") + # Cache this result + set( LIBGME_HAVE_GCC_VISIBILITY ${ENABLE_VISIBILITY} CACHE BOOL "GCC support for hidden visibility") +endif() # Shared library defined here add_subdirectory(gme) From 88942dcc688f8da616279d0516b0e8c24e9cfc4b Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 16 Dec 2016 22:13:18 +0100 Subject: [PATCH 09/25] - Game-Music-Emu: Merge commits 87b322b and d48c1c8. Commit titles: 87b322b - 'Properly clamp SPC CPU registers and temporaries.' d48c1c8 - 'Complete bumping version to 0.6.1.' This completes the code upgrade to GME 0.6.1. --- game-music-emu/gme/Spc_Cpu.h | 2 +- game-music-emu/gme/gme.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/game-music-emu/gme/Spc_Cpu.h b/game-music-emu/gme/Spc_Cpu.h index ba2ca7a81..8829e818b 100644 --- a/game-music-emu/gme/Spc_Cpu.h +++ b/game-music-emu/gme/Spc_Cpu.h @@ -77,7 +77,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define SPC_NO_SP_WRAPAROUND 0 #define SET_SP( v ) (sp = ram + 0x101 + ((uint8_t) v)) -#define GET_SP() (uint8_t) (sp - 0x101 - ram) +#define GET_SP() (uint8_t (sp - 0x101 - ram)) #if SPC_NO_SP_WRAPAROUND #define PUSH16( v ) (sp -= 2, SET_LE16( sp, v )) diff --git a/game-music-emu/gme/gme.h b/game-music-emu/gme/gme.h index 8eb952e23..cb07061b4 100644 --- a/game-music-emu/gme/gme.h +++ b/game-music-emu/gme/gme.h @@ -1,6 +1,6 @@ /* Game music emulator library C interface (also usable from C++) */ -/* Game_Music_Emu 0.6.0 */ +/* Game_Music_Emu 0.6.1 */ #ifndef GME_H #define GME_H @@ -8,7 +8,7 @@ extern "C" { #endif -#define GME_VERSION 0x000600 /* 1 byte major, 1 byte minor, 1 byte patch-level */ +#define GME_VERSION 0x000601 /* 1 byte major, 1 byte minor, 1 byte patch-level */ /* Error string returned by library functions, or NULL if no error (success) */ typedef const char* gme_err_t; From 9ac7a07be68419c20cfb8e97d50c253aa7a1bb6e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Dec 2016 22:34:36 +0100 Subject: [PATCH 10/25] - Set colormap light info using R_SetColorMapLight and R_SetDSColorMapLight rather than manually calculating it - Move texture and span management into R_DrawMaskedColumn --- src/r_draw.cpp | 10 +++++++ src/r_draw.h | 2 ++ src/r_main.h | 3 +++ src/r_plane.cpp | 40 ++++++++++++++++++++-------- src/r_segs.cpp | 40 ++++++++++++++-------------- src/r_things.cpp | 68 +++++++++++++++++++++++++----------------------- src/r_things.h | 2 +- src/v_draw.cpp | 30 +++------------------ 8 files changed, 104 insertions(+), 91 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a461e1877..25297f6c8 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -548,6 +548,11 @@ namespace swrenderer dc_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); } + void R_SetColorMapLight(FDynamicColormap *base_colormap, float light, int shade) + { + R_SetColorMapLight(base_colormap->Maps, light, shade); + } + void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade) { using namespace drawerargs; @@ -555,6 +560,11 @@ namespace swrenderer ds_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); } + void R_SetDSColorMapLight(FDynamicColormap *base_colormap, float light, int shade) + { + R_SetDSColorMapLight(base_colormap->Maps, light, shade); + } + void R_SetTranslationMap(lighttable_t *translation) { using namespace drawerargs; diff --git a/src/r_draw.h b/src/r_draw.h index 58934981b..ab430d2af 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -192,7 +192,9 @@ namespace swrenderer void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade); + void R_SetColorMapLight(FDynamicColormap *base_colormap, float light, int shade); void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade); + void R_SetDSColorMapLight(FDynamicColormap *base_colormap, float light, int shade); void R_SetTranslationMap(lighttable_t *translation); void R_SetupSpanBits(FTexture *tex); diff --git a/src/r_main.h b/src/r_main.h index 87b56163b..be1c36306 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -85,6 +85,9 @@ extern bool r_dontmaplines; // Change R_CalcTiltedLighting() when this changes. #define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) +// Converts fixedlightlev into a shade value +#define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS) + extern double GlobVis; void R_SetVisibility(double visibility); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index eafc9fa26..cd378aec1 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -240,8 +240,7 @@ void R_MapPlane (int y, int x1) if (plane_shade) { // Determine lighting based on the span's distance from the viewer. - ds_colormap = basecolormap->Maps + (GETPALOOKUP ( - GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT); + R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade); } ds_y = y; @@ -1043,7 +1042,7 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske R_SetupSpanBits(tex); double xscale = pl->xform.xScale * tex->Scale.X; double yscale = pl->xform.yScale * tex->Scale.Y; - ds_source = tex->GetPixels (); + R_SetSpanSource(tex); basecolormap = pl->colormap; planeshade = LIGHT2SHADE(pl->lightlevel); @@ -1405,12 +1404,13 @@ void R_DrawSkyPlane (visplane_t *pl) bool fakefixed = false; if (fixedcolormap) { - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); } else { fakefixed = true; - fixedcolormap = dc_colormap = NormalLight.Maps; + fixedcolormap = NormalLight.Maps; + R_SetColorMapLight(fixedcolormap, 0, 0); } R_DrawSky (pl); @@ -1484,12 +1484,21 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t planeheight = fabs(pl->height.Zat0() - ViewPos.Z); GlobVis = r_FloorVisibility / planeheight; + ds_light = 0; if (fixedlightlev >= 0) - ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; + { + R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + plane_shade = false; + } else if (fixedcolormap) - ds_colormap = fixedcolormap, plane_shade = false; + { + R_SetDSColorMapLight(fixedcolormap, 0, 0); + plane_shade = false; + } else + { plane_shade = true; + } if (spanfunc != R_FillSpan) { @@ -1645,11 +1654,20 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t planelightfloat = -planelightfloat; if (fixedlightlev >= 0) - ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; + { + R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + plane_shade = false; + } else if (fixedcolormap) - ds_colormap = fixedcolormap, plane_shade = false; + { + R_SetDSColorMapLight(fixedcolormap, 0, 0); + plane_shade = false; + } else - ds_colormap = basecolormap->Maps, plane_shade = true; + { + R_SetDSColorMapLight(basecolormap, 0, 0); + plane_shade = true; + } // Hack in support for 1 x Z and Z x 1 texture sizes if (ds_ybits == 0) @@ -1766,4 +1784,4 @@ bool R_PlaneInitData () return true; } -} \ No newline at end of file +} diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d6ab86aa0..38db1a6b2 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -44,6 +44,7 @@ #include "r_plane.h" #include "r_segs.h" #include "r_3dfloors.h" +#include "r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" @@ -53,8 +54,9 @@ CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); +EXTERN_CVAR(Bool, r_mipmap) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; @@ -156,7 +158,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // calculate lighting if (fixedcolormap == NULL && fixedlightlev < 0) { - dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(basecolormap, rw_light, wallshade); } dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); @@ -174,9 +176,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt) // when forming multipatched textures (see r_data.c). // draw the texture - const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); - R_DrawMaskedColumn(pixels, spans, useRt); + R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt); rw_light += rw_lightstep; spryscale += rw_scalestep; } @@ -292,9 +292,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); // find positioning texheight = tex->GetScaledHeightDouble(); @@ -440,7 +440,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) while (dc_x < stop) { - rt_initcols(); + rt_initcols(nullptr); BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++; @@ -609,9 +609,9 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; @@ -1061,9 +1061,9 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); // clip wall to the floor and ceiling for (x = x1; x < x2; ++x) @@ -2304,11 +2304,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -2359,7 +2359,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (false); dc_x++; @@ -2369,9 +2369,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { R_WallSpriteColumn (true); @@ -2384,7 +2384,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, wallshade); } R_WallSpriteColumn (false); dc_x++; @@ -2408,4 +2408,4 @@ done: WallC = savecoord; } -} \ No newline at end of file +} diff --git a/src/r_things.cpp b/src/r_things.cpp index 9e9b161cd..f03bfbae0 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -256,8 +256,23 @@ double sprtopscreen; bool sprflipvert; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool useRt) +void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked) { + const FTexture::Span *span; + const BYTE *column; + + column = tex->GetColumn(col >> FRACBITS, &span); + + FTexture::Span unmaskedSpan[2]; + if (unmasked) + { + span = unmaskedSpan; + unmaskedSpan[0].TopOffset = 0; + unmaskedSpan[0].Length = tex->GetHeight(); + unmaskedSpan[1].TopOffset = 0; + unmaskedSpan[1].Length = 0; + } + while (span->Length != 0) { const int length = span->Length; @@ -377,8 +392,6 @@ static inline bool R_ClipSpriteColumnWithPortals(vissprite_t* spr) // void R_DrawVisSprite (vissprite_t *vis) { - const BYTE *pixels; - const FTexture::Span *spans; fixed_t frac; FTexture *tex; int x2, stop4; @@ -392,7 +405,7 @@ void R_DrawVisSprite (vissprite_t *vis) } fixed_t centeryfrac = FLOAT2FIXED(CenterY); - dc_colormap = vis->Style.colormap; + R_SetColorMapLight(vis->Style.colormap, 0.0f, 0); mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); @@ -400,7 +413,7 @@ void R_DrawVisSprite (vissprite_t *vis) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - dc_colormap += vis->ColormapNum << COLORMAPSHIFT; + R_SetColorMapLight(dc_colormap, 0, vis->ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -445,21 +458,19 @@ void R_DrawVisSprite (vissprite_t *vis) { while ((dc_x < stop4) && (dc_x & 3)) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, false); + R_DrawMaskedColumn (tex, frac, false); dc_x++; frac += xiscale; } while (dc_x < stop4) { - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, true); + R_DrawMaskedColumn (tex, frac, true); dc_x++; frac += xiscale; } @@ -468,9 +479,8 @@ void R_DrawVisSprite (vissprite_t *vis) while (dc_x < x2) { - pixels = tex->GetColumn (frac >> FRACBITS, &spans); if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) - R_DrawMaskedColumn (pixels, spans, false); + R_DrawMaskedColumn (tex, frac, false); dc_x++; frac += xiscale; } @@ -522,11 +532,11 @@ void R_DrawWallSprite(vissprite_t *spr) rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = usecolormap->Maps + fixedlightlev; + R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; + R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; + R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -577,7 +587,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(false); @@ -588,9 +598,9 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, shade); } - rt_initcols(); + rt_initcols(nullptr); for (int zz = 4; zz; --zz) { if (!R_ClipSpriteColumnWithPortals(spr)) @@ -604,7 +614,7 @@ void R_DrawWallSprite(vissprite_t *spr) { if (calclighting) { // calculate lighting - dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); + R_SetColorMapLight(usecolormap, rw_light, shade); } if (!R_ClipSpriteColumnWithPortals(spr)) R_WallSpriteColumn(false); @@ -624,11 +634,8 @@ void R_WallSpriteColumn (bool useRt) else sprtopscreen = CenterY - dc_texturemid * spryscale; - const BYTE *column; - const FTexture::Span *spans; - column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans); dc_texturefrac = 0; - R_DrawMaskedColumn(column, spans, useRt); + R_DrawMaskedColumn(WallSpriteTile, lwall[dc_x], useRt); rw_light += rw_lightstep; } @@ -638,7 +645,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop int flags = 0; // Do setup for blending. - dc_colormap = spr->Style.colormap; + R_SetColorMapLight(spr->Style.colormap, 0.0f, 0); mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); if (mode == DontDraw) @@ -689,10 +696,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop } else { - unsigned int **tspan = &dc_ctspan[x & 3]; - (*tspan)[0] = span->Start; - (*tspan)[1] = span->Stop - 1; - *tspan += 2; + rt_span_coverage(x, span->Start, span->Stop - 1); } } if (!(flags & DVF_SPANSONLY) && (x & 3) == 3) @@ -2044,7 +2048,7 @@ void R_DrawSprite (vissprite_t *spr) else { // diminished light spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); - spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP ( + spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP( r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade) << COLORMAPSHIFT); } } @@ -3237,16 +3241,16 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new BYTE[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new BYTE[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } } OffscreenBufferWidth = width; OffscreenBufferHeight = height; } -} \ No newline at end of file +} diff --git a/src/r_things.h b/src/r_things.h index bf32b655f..6d694b8fd 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -128,7 +128,7 @@ extern double pspriteyscale; extern FTexture *WallSpriteTile; -void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans, bool useRt); +void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool useRt, bool unmasked = false); void R_WallSpriteColumn (bool useRt); void R_CacheSprite (spritedef_t *sprite); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 1524c7ba4..6f8bc5198 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -135,20 +135,9 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) using namespace swrenderer; using namespace drawerargs; - FTexture::Span unmaskedSpan[2]; - const FTexture::Span **spanptr, *spans; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; - if (parms.masked) - { - spanptr = &spans; - } - else - { - spanptr = NULL; - } - if (APART(parms.colorOverlay) != 0) { // The software renderer cannot invert the source without inverting the overlay @@ -198,18 +187,8 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) if (mode != DontDraw) { - const BYTE *pixels; int stop4; - if (spanptr == NULL) - { // Create a single span for forced unmasked images - spans = unmaskedSpan; - unmaskedSpan[0].TopOffset = 0; - unmaskedSpan[0].Length = img->GetHeight(); - unmaskedSpan[1].TopOffset = 0; - unmaskedSpan[1].Length = 0; - } - double centeryback = CenterY; CenterY = 0; @@ -301,8 +280,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { while ((dc_x < stop4) && (dc_x & 3)) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans, false); + R_DrawMaskedColumn(img, frac, false, !parms.masked); dc_x++; frac += xiscale_i; } @@ -312,8 +290,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) rt_initcols(); for (int zz = 4; zz; --zz) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans, true); + R_DrawMaskedColumn(img, frac, true, !parms.masked); dc_x++; frac += xiscale_i; } @@ -322,8 +299,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) while (dc_x < x2_i) { - pixels = img->GetColumn(frac >> FRACBITS, spanptr); - R_DrawMaskedColumn(pixels, spans, false); + R_DrawMaskedColumn(img, frac, false, !parms.masked); dc_x++; frac += xiscale_i; } From 2fea46a719b2084bde7d9e9e37f9a26a5a59c1ab Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Dec 2016 22:57:57 +0100 Subject: [PATCH 11/25] Removed leftovers from QZDoom --- src/r_segs.cpp | 3 +-- src/r_things.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 38db1a6b2..ccf6ccf20 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -54,9 +54,8 @@ CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); -EXTERN_CVAR(Bool, r_mipmap) -namespace swrenderer +namespace swrenderer { using namespace drawerargs; diff --git a/src/r_things.cpp b/src/r_things.cpp index f03bfbae0..a1ace0d49 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -3241,12 +3241,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new BYTE[width * height * 4]; + OffscreenColorBuffer = new BYTE[width * height]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new BYTE[width * height * 4]; + OffscreenColorBuffer = new BYTE[width * height]; } } OffscreenBufferWidth = width; From 3023af8223bd7c40941f5881b25f82b9d167160b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 17 Dec 2016 12:46:40 -0600 Subject: [PATCH 12/25] - Added A_SetSize(double newradius, double newheight = -1). - Changes the calling actor's radius and height. --- src/p_actionfunctions.cpp | 16 ++++++++++++++++ wadsrc/static/zscript/actor.txt | 1 + 2 files changed, 17 insertions(+) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 6ddfd5281..8c222a4f6 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -6846,3 +6846,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) } return 0; } + +DEFINE_ACTION_FUNCTION(AActor, A_SetSize) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(newradius); + PARAM_FLOAT_DEF(newheight); + + if (newradius < 0.) newradius = self->radius; + if (newheight < 0.) newheight = self->Height; + + self->UnlinkFromWorld(); + self->radius = newradius; + self->Height = newheight; + self->LinkToWorld(); + return 0; +} diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index d804a434c..2a5d8c53d 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -793,6 +793,7 @@ class Actor : Thinker native native bool A_CopySpriteFrame(int from, int to, int flags = 0); native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); + native void A_SetSize(double newradius, double newheight = -1); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); From 1bcebb091a059371496f025ebae5c2e3c416dba1 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 17 Dec 2016 18:31:25 -0600 Subject: [PATCH 13/25] Added option to check the location for resizing, changing the return into a bool. --- src/p_actionfunctions.cpp | 16 +++++++++++++++- wadsrc/static/zscript/actor.txt | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 8c222a4f6..13a347ef2 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -6852,13 +6852,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetSize) PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(newradius); PARAM_FLOAT_DEF(newheight); + PARAM_BOOL_DEF(testpos); if (newradius < 0.) newradius = self->radius; if (newheight < 0.) newheight = self->Height; + double oldradius = self->radius; + double oldheight = self->Height; + self->UnlinkFromWorld(); self->radius = newradius; self->Height = newheight; self->LinkToWorld(); - return 0; + + if (testpos && !P_TestMobjLocation(self)) + { + self->UnlinkFromWorld(); + self->radius = oldradius; + self->Height = oldheight; + self->LinkToWorld(); + ACTION_RETURN_BOOL(false); + } + + ACTION_RETURN_BOOL(true); } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 2a5d8c53d..0d264580a 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -793,7 +793,7 @@ class Actor : Thinker native native bool A_CopySpriteFrame(int from, int to, int flags = 0); native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); - native void A_SetSize(double newradius, double newheight = -1); + native bool A_SetSize(double newradius, double newheight = -1, bool testpos = false); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); From 8dd91f7129796d4bc26258f17e303c405d739b48 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Dec 2016 12:18:03 +0100 Subject: [PATCH 14/25] - added a missing null pointer check to FxIfStatement::Emit. --- src/scripting/codegeneration/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 90fbcfe68..57b554e25 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8964,7 +8964,7 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build) } if (WhenFalse != nullptr) { - if (!WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. + if (WhenTrue != nullptr && !WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. build->BackpatchListToHere(no); WhenFalse->EmitStatement(build); if (jumpspot != ~0u) build->BackpatchToHere(jumpspot); From 1fa37aaeb79d3ab1e5d4aa2b4376130e9f4826fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Dec 2016 14:09:16 +0100 Subject: [PATCH 15/25] - fixed code generation for if statements with empty 'true' part. For those the jump statement backpatching was not done correctly. --- src/scripting/codegeneration/codegen.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 57b554e25..8e5750660 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8955,7 +8955,7 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build) size_t jumpspot = ~0u; TArray yes, no; - Condition->EmitCompare(build, false, yes, no); + Condition->EmitCompare(build, WhenTrue == nullptr, yes, no); if (WhenTrue != nullptr) { @@ -8964,11 +8964,14 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build) } if (WhenFalse != nullptr) { - if (WhenTrue != nullptr && !WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. - build->BackpatchListToHere(no); + if (WhenTrue != nullptr) + { + if (!WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. + build->BackpatchListToHere(no); + } WhenFalse->EmitStatement(build); if (jumpspot != ~0u) build->BackpatchToHere(jumpspot); - if (WhenTrue == nullptr) build->BackpatchListToHere(yes); + if (WhenTrue == nullptr) build->BackpatchListToHere(no); } else { From 94f7bef2ff1a114133b04b6798d93bc9bef9aacc Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 19 Dec 2016 10:40:31 +0200 Subject: [PATCH 16/25] Added compatibility parameter to set sector special --- src/compatibility.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 24897ac27..60f9d8ad6 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -80,6 +80,7 @@ enum CP_CLEARSPECIAL, CP_SETACTIVATION, CP_SECTORFLOOROFFSET, + CP_SETSECTORSPECIAL, CP_SETWALLYSCALE, CP_SETTHINGZ, CP_SETTAG, @@ -294,6 +295,15 @@ void ParseCompatibility() sc.MustGetFloat(); CompatParams.Push(int(sc.Float*65536.)); } + else if (sc.Compare("setsectorspecial")) + { + if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size(); + CompatParams.Push(CP_SETSECTORSPECIAL); + sc.MustGetNumber(); + CompatParams.Push(sc.Number); + sc.MustGetNumber(); + CompatParams.Push(sc.Number); + } else if (sc.Compare("setwallyscale")) { if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size(); @@ -529,6 +539,16 @@ void SetCompatibilityParams() i += 3; break; } + case CP_SETSECTORSPECIAL: + { + const int index = CompatParams[i + 1]; + if (index < numsectors) + { + sectors[index].special = CompatParams[i + 2]; + } + i += 3; + break; + } case CP_SETWALLYSCALE: { if (CompatParams[i+1] < numlines) From 28a23d4ff3988fee9e83ecd184e386b7dfcb3cca Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 19 Dec 2016 10:43:20 +0200 Subject: [PATCH 17/25] Removed unreachable secrets from Doom IWADs See https://forum.zdoom.org/viewtopic.php?t=54632 --- wadsrc/static/compatibility.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 73a4f5af2..b131cd0ad 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -453,3 +453,27 @@ D7F6E9F08C39A17026349A04F8C0B0BE // Return to Hadron, e1m9 { pointonline } + +// Remove unreachable secrets +F6EE16F770AD309D608EA0B1F1E249FC // Ultimate Doom, e4m3 +{ + setsectorspecial 124 0 + setsectorspecial 125 0 +} +94D4C869A0C02EF4F7375022B36AAE45 // Ultimate Doom, e4m7 +{ + setsectorspecial 263 0 + setsectorspecial 264 0 +} +1A540BA717BF9EC85F8522594C352F2A // Doom II, map15 +{ + setsectorspecial 147 0 +} +110F84DE041052B59307FAF0293E6BC0 // Doom II, map27 +{ + setsectorspecial 93 0 +} +ABC4EB5A1535ECCD0061AD14F3547908 // Plutonia Experiment, map26 +{ + setsectorspecial 156 0 +} From f6b0f2648c62d8c35368ba272b261de862259078 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 19 Dec 2016 12:44:04 +0200 Subject: [PATCH 18/25] Cleared staircase to secret area in Ultimate Doom E4M3 Only the final room with goodies is marked as secret --- wadsrc/static/compatibility.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index b131cd0ad..c486b48ae 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -459,6 +459,25 @@ F6EE16F770AD309D608EA0B1F1E249FC // Ultimate Doom, e4m3 { setsectorspecial 124 0 setsectorspecial 125 0 + // clear staircase to secret area + setsectorspecial 127 0 + setsectorspecial 128 0 + setsectorspecial 129 0 + setsectorspecial 130 0 + setsectorspecial 131 0 + setsectorspecial 132 0 + setsectorspecial 133 0 + setsectorspecial 134 0 + setsectorspecial 136 0 + setsectorspecial 137 0 + setsectorspecial 138 0 + setsectorspecial 147 0 + setsectorspecial 148 0 + setsectorspecial 149 0 + setsectorspecial 150 0 + setsectorspecial 151 0 + setsectorspecial 152 0 + setsectorspecial 155 0 } 94D4C869A0C02EF4F7375022B36AAE45 // Ultimate Doom, e4m7 { From 5d85990d5f1bc3a6456ee2c195c6615774001d3a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 19 Dec 2016 07:18:20 -0500 Subject: [PATCH 19/25] - Implementing RGB666-to-Palette colormatching for textures. --- src/textures/ddstexture.cpp | 8 ++++---- src/textures/jpegtexture.cpp | 4 ++-- src/textures/multipatchtexture.cpp | 2 +- src/textures/pcxtexture.cpp | 2 +- src/textures/pngtexture.cpp | 6 +++--- src/textures/tgatexture.cpp | 8 ++++---- src/v_video.cpp | 7 +++++++ src/v_video.h | 8 ++++++++ 8 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 31e748022..a2c69b38b 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR; DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR; DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR; - *pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27]; + *pixelp = RGB256k.RGB[r >> 26][g >> 26][b >> 26]; } else { @@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) // Pick colors from the palette for each of the four colors. /*if (!tcbuf)*/ for (i = 3; i >= 0; --i) { - palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0; + palcol[i] = color[i].a ? RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2] : 0; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) @@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu // Pick colors from the palette for each of the four colors. if (!tcbuf) for (i = 3; i >= 0; --i) { - palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; + palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2]; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) @@ -822,7 +822,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu // Pick colors from the palette for each of the four colors. if (!tcbuf) for (i = 3; i >= 0; --i) { - palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; + palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2]; } // Now decode this 4x4 block to the pixel buffer. for (y = 0; y < 4; ++y) diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 225396598..c138edbfa 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -406,7 +406,7 @@ void FJPEGTexture::MakeTexture () case JCS_RGB: for (int x = Width; x > 0; --x) { - *out = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; out += Height; in += 3; } @@ -430,7 +430,7 @@ void FJPEGTexture::MakeTexture () int r = in[3] - (((256-in[0])*in[3]) >> 8); int g = in[3] - (((256-in[1])*in[3]) >> 8); int b = in[3] - (((256-in[2])*in[3]) >> 8); - *out = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; + *out = RGB256k.RGB[r >> 2][g >> 2][b >> 2]; out += Height; in += 4; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index e68c4e20f..991893845 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -531,7 +531,7 @@ void FMultiPatchTexture::MakeTexture () { if (*out == 0 && in[3] != 0) { - *out = RGB32k.RGB[in[2]>>3][in[1]>>3][in[0]>>3]; + *out = RGB256k.RGB[in[2]>>2][in[1]>>2][in[0]>>2]; } out += Height; in += 4; diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 0ec5d2933..dda431993 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -528,7 +528,7 @@ void FPCXTexture::MakeTexture() { for(int x=0; x < Width; x++) { - Pixels[y+Height*x] = RGB32k.RGB[row[0]>>3][row[1]>>3][row[2]>>3]; + Pixels[y+Height*x] = RGB256k.RGB[row[0]>>2][row[1]>>2][row[2]>>2]; row+=3; } } diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index d24cd92d1..414c424b8 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -536,7 +536,7 @@ void FPNGTexture::MakeTexture () { if (!HaveTrans) { - *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; } else { @@ -548,7 +548,7 @@ void FPNGTexture::MakeTexture () } else { - *out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; } } in += pitch; @@ -593,7 +593,7 @@ void FPNGTexture::MakeTexture () { for (y = Height; y > 0; --y) { - *out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; + *out++ = in[3] < 128 ? 0 : RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; in += pitch; } in -= backstep; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index b208a51a3..331747cfe 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -393,7 +393,7 @@ void FTGATexture::MakeTexture () for(int x=0;x>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f]; + Pixels[x*Height+y] = RGB256k.RGB[((v>>10) & 0x1f)*2][((v>>5) & 0x1f)*2][(v & 0x1f)*2]; p+=step_x; } } @@ -405,7 +405,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; + Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; p+=step_x; } } @@ -419,7 +419,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x>3][p[1]>>3][p[0]>>3]; + Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; p+=step_x; } } @@ -431,7 +431,7 @@ void FTGATexture::MakeTexture () BYTE * p = ptr + y * Pitch; for(int x=0;x= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0; + Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; p+=step_x; } } diff --git a/src/v_video.cpp b/src/v_video.cpp index efe93aa04..6077f878e 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -144,8 +144,10 @@ DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; ColorTable32k RGB32k; +ColorTable256k RGB256k; } + static DWORD Col2RGB8_2[63][256]; // [RH] The framebuffer is no longer a mere byte array. @@ -669,6 +671,11 @@ static void BuildTransTable (const PalEntry *palette) for (g = 0; g < 32; g++) for (b = 0; b < 32; b++) RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); + // create the RGB666 lookup table + for (r = 0; r < 64; r++) + for (g = 0; g < 64; g++) + for (b = 0; b < 64; b++) + RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); int x, y; diff --git a/src/v_video.h b/src/v_video.h index b72f67094..57d15869c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -462,6 +462,14 @@ union ColorTable32k }; extern "C" ColorTable32k RGB32k; +// [SP] RGB666 support +union ColorTable256k +{ + BYTE RGB[64][64][64]; + BYTE All[64 *64 *64]; +}; +extern "C" ColorTable256k RGB256k; + // Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a // special R10B10G10 format for efficient blending computation. // --RRRRRrrr--BBBBBbbb--GGGGGggg-- at level 64 From 2676ca1284b153a6e898d7f2c8926fa8e64c26b7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 19 Dec 2016 21:13:29 +0100 Subject: [PATCH 20/25] Rename wall drawer args and functions to closer match the general naming convention --- src/r_draw.cpp | 131 ++++++----------------- src/r_draw.h | 54 ++++------ src/r_draw_pal.cpp | 258 ++++++++++++++++++++++----------------------- src/r_draw_pal.h | 26 ++--- src/r_plane.cpp | 12 +-- src/r_walldraw.cpp | 61 ++++------- 6 files changed, 217 insertions(+), 325 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 25297f6c8..8206c2391 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -96,17 +96,15 @@ namespace swrenderer uint8_t *dc_destorg; int dc_destheight; int dc_count; - uint32_t vplce[4]; - uint32_t vince[4]; - uint8_t *palookupoffse[4]; - fixed_t palookuplight[4]; - const uint8_t *bufplce[4]; - const uint8_t *bufplce2[4]; - uint32_t buftexturefracx[4]; - uint32_t bufheight[4]; - int vlinebits; - int mvlinebits; - int tmvlinebits; + uint32_t dc_wall_texturefrac[4]; + uint32_t dc_wall_iscale[4]; + uint8_t *dc_wall_colormap[4]; + fixed_t dc_wall_light[4]; + const uint8_t *dc_wall_source[4]; + const uint8_t *dc_wall_source2[4]; + uint32_t dc_wall_texturefracx[4]; + uint32_t dc_wall_sourceheight[4]; + int dc_wall_fracbits; int ds_y; int ds_x1; int ds_x2; @@ -497,50 +495,35 @@ namespace swrenderer return tex->GetColumn(col, nullptr); } - bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()) + bool R_GetTransMaskDrawers(void(**drawCol1)(), void(**drawCol4)()) { if (colfunc == R_DrawAddColumn) { - *tmvline1 = tmvline1_add; - *tmvline4 = tmvline4_add; + *drawCol1 = R_DrawWallAddCol1; + *drawCol4 = R_DrawWallAddCol4; return true; } if (colfunc == R_DrawAddClampColumn) { - *tmvline1 = tmvline1_addclamp; - *tmvline4 = tmvline4_addclamp; + *drawCol1 = R_DrawWallAddClampCol1; + *drawCol4 = R_DrawWallAddClampCol4; return true; } if (colfunc == R_DrawSubClampColumn) { - *tmvline1 = tmvline1_subclamp; - *tmvline4 = tmvline4_subclamp; + *drawCol1 = R_DrawWallSubClampCol1; + *drawCol4 = R_DrawWallSubClampCol4; return true; } if (colfunc == R_DrawRevSubClampColumn) { - *tmvline1 = tmvline1_revsubclamp; - *tmvline4 = tmvline4_revsubclamp; + *drawCol1 = R_DrawWallRevSubClampCol1; + *drawCol4 = R_DrawWallRevSubClampCol4; return true; } return false; } - void setupvline(int fracbits) - { - drawerargs::vlinebits = fracbits; - } - - void setupmvline(int fracbits) - { - drawerargs::mvlinebits = fracbits; - } - - void setuptmvline(int fracbits) - { - drawerargs::tmvlinebits = fracbits; - } - void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade) { using namespace drawerargs; @@ -973,118 +956,64 @@ namespace swrenderer rt_revsubclamp4cols(sx, yl, yh); } - uint32_t vlinec1() + void R_DrawWallCol1() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; } - void vlinec4() + void R_DrawWallCol4() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; } - uint32_t mvlinec1() + void R_DrawWallMaskedCol1() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; } - void mvlinec4() + void R_DrawWallMaskedCol4() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; } - fixed_t tmvline1_add() + void R_DrawWallAddCol1() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; } - void tmvline4_add() + void R_DrawWallAddCol4() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; } - fixed_t tmvline1_addclamp() + void R_DrawWallAddClampCol1() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; } - void tmvline4_addclamp() + void R_DrawWallAddClampCol4() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; } - fixed_t tmvline1_subclamp() + void R_DrawWallSubClampCol1() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; } - void tmvline4_subclamp() + void R_DrawWallSubClampCol4() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; } - fixed_t tmvline1_revsubclamp() + void R_DrawWallRevSubClampCol1() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - return dc_texturefrac + dc_count * dc_iscale; } - void tmvline4_revsubclamp() + void R_DrawWallRevSubClampCol4() { - using namespace drawerargs; - DrawerCommandQueue::QueueCommand(); - - for (int i = 0; i < 4; i++) - vplce[i] += vince[i] * dc_count; } void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom) diff --git a/src/r_draw.h b/src/r_draw.h index ab430d2af..c245034d7 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -41,17 +41,15 @@ namespace swrenderer extern int dc_destheight; extern int dc_count; - extern uint32_t vplce[4]; - extern uint32_t vince[4]; - extern uint8_t *palookupoffse[4]; - extern fixed_t palookuplight[4]; - extern const uint8_t *bufplce[4]; - extern const uint8_t *bufplce2[4]; - extern uint32_t buftexturefracx[4]; - extern uint32_t bufheight[4]; - extern int vlinebits; - extern int mvlinebits; - extern int tmvlinebits; + extern uint32_t dc_wall_texturefrac[4]; + extern uint32_t dc_wall_iscale[4]; + extern uint8_t *dc_wall_colormap[4]; + extern fixed_t dc_wall_light[4]; + extern const uint8_t *dc_wall_source[4]; + extern const uint8_t *dc_wall_source2[4]; + extern uint32_t dc_wall_texturefracx[4]; + extern uint32_t dc_wall_sourceheight[4]; + extern int dc_wall_fracbits; extern int ds_y; extern int ds_x1; @@ -100,7 +98,7 @@ namespace swrenderer ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade - bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)()); + bool R_GetTransMaskDrawers(void(**drawCol1)(), void(**drawCol4)()); const uint8_t *R_GetColumn(FTexture *tex, int col); @@ -162,29 +160,21 @@ namespace swrenderer void R_SetupDrawSlab(uint8_t *colormap); void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p); void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip); - uint32_t vlinec1(); - void vlinec4(); - uint32_t mvlinec1(); - void mvlinec4(); - fixed_t tmvline1_add(); - void tmvline4_add(); - fixed_t tmvline1_addclamp(); - void tmvline4_addclamp(); - fixed_t tmvline1_subclamp(); - void tmvline4_subclamp(); - fixed_t tmvline1_revsubclamp(); - void tmvline4_revsubclamp(); void R_FillColumnHoriz(); void R_FillSpan(); - inline uint32_t dovline1() { return vlinec1(); } - inline void dovline4() { vlinec4(); } - inline uint32_t domvline1() { return mvlinec1(); } - inline void domvline4() { mvlinec4(); } - - void setupvline(int fracbits); - void setupmvline(int fracbits); - void setuptmvline(int fracbits); + void R_DrawWallCol1(); + void R_DrawWallCol4(); + void R_DrawWallMaskedCol1(); + void R_DrawWallMaskedCol4(); + void R_DrawWallAddCol1(); + void R_DrawWallAddCol4(); + void R_DrawWallAddClampCol1(); + void R_DrawWallAddClampCol4(); + void R_DrawWallSubClampCol1(); + void R_DrawWallSubClampCol4(); + void R_DrawWallRevSubClampCol1(); + void R_DrawWallRevSubClampCol4(); void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index cfb55a670..2cdeba314 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -95,9 +95,7 @@ namespace swrenderer _count = dc_count; _source = dc_source; _dest = dc_dest; - _vlinebits = vlinebits; - _mvlinebits = mvlinebits; - _tmvlinebits = tmvlinebits; + _fracbits = dc_wall_fracbits; _pitch = dc_pitch; _srcblend = dc_srcblend; _destblend = dc_destblend; @@ -110,15 +108,13 @@ namespace swrenderer _dest = dc_dest; _count = dc_count; _pitch = dc_pitch; - _vlinebits = vlinebits; - _mvlinebits = mvlinebits; - _tmvlinebits = tmvlinebits; + _fracbits = dc_wall_fracbits; for (int col = 0; col < 4; col++) { - _palookupoffse[col] = palookupoffse[col]; - _bufplce[col] = bufplce[col]; - _vince[col] = vince[col]; - _vplce[col] = vplce[col]; + _colormap[col] = dc_wall_colormap[col]; + _source[col] = dc_wall_source[col]; + _iscale[col] = dc_wall_iscale[col]; + _texturefrac[col] = dc_wall_texturefrac[col]; } _srcblend = dc_srcblend; _destblend = dc_destblend; @@ -132,7 +128,7 @@ namespace swrenderer int count = _count; const uint8_t *source = _source; uint8_t *dest = _dest; - int bits = _vlinebits; + int bits = _fracbits; int pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -156,24 +152,24 @@ namespace swrenderer { uint8_t *dest = _dest; int count = _count; - int bits = _vlinebits; + int bits = _fracbits; uint32_t place; - auto pal0 = _palookupoffse[0]; - auto pal1 = _palookupoffse[1]; - auto pal2 = _palookupoffse[2]; - auto pal3 = _palookupoffse[3]; - auto buf0 = _bufplce[0]; - auto buf1 = _bufplce[1]; - auto buf2 = _bufplce[2]; - auto buf3 = _bufplce[3]; - auto vince0 = _vince[0]; - auto vince1 = _vince[1]; - auto vince2 = _vince[2]; - auto vince3 = _vince[3]; - auto vplce0 = _vplce[0]; - auto vplce1 = _vplce[1]; - auto vplce2 = _vplce[2]; - auto vplce3 = _vplce[3]; + auto pal0 = _colormap[0]; + auto pal1 = _colormap[1]; + auto pal2 = _colormap[2]; + auto pal3 = _colormap[3]; + auto buf0 = _source[0]; + auto buf1 = _source[1]; + auto buf2 = _source[2]; + auto buf3 = _source[3]; + auto dc_wall_iscale0 = _iscale[0]; + auto dc_wall_iscale1 = _iscale[1]; + auto dc_wall_iscale2 = _iscale[2]; + auto dc_wall_iscale3 = _iscale[3]; + auto dc_wall_texturefrac0 = _texturefrac[0]; + auto dc_wall_texturefrac1 = _texturefrac[1]; + auto dc_wall_texturefrac2 = _texturefrac[2]; + auto dc_wall_texturefrac3 = _texturefrac[3]; auto pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -182,22 +178,22 @@ namespace swrenderer int skipped = thread->skipped_by_thread(_dest_y); dest = thread->dest_for_thread(_dest_y, pitch, dest); - vplce0 += vince0 * skipped; - vplce1 += vince1 * skipped; - vplce2 += vince2 * skipped; - vplce3 += vince3 * skipped; - vince0 *= thread->num_cores; - vince1 *= thread->num_cores; - vince2 *= thread->num_cores; - vince3 *= thread->num_cores; + dc_wall_texturefrac0 += dc_wall_iscale0 * skipped; + dc_wall_texturefrac1 += dc_wall_iscale1 * skipped; + dc_wall_texturefrac2 += dc_wall_iscale2 * skipped; + dc_wall_texturefrac3 += dc_wall_iscale3 * skipped; + dc_wall_iscale0 *= thread->num_cores; + dc_wall_iscale1 *= thread->num_cores; + dc_wall_iscale2 *= thread->num_cores; + dc_wall_iscale3 *= thread->num_cores; pitch *= thread->num_cores; do { - dest[0] = pal0[buf0[(place = vplce0) >> bits]]; vplce0 = place + vince0; - dest[1] = pal1[buf1[(place = vplce1) >> bits]]; vplce1 = place + vince1; - dest[2] = pal2[buf2[(place = vplce2) >> bits]]; vplce2 = place + vince2; - dest[3] = pal3[buf3[(place = vplce3) >> bits]]; vplce3 = place + vince3; + dest[0] = pal0[buf0[(place = dc_wall_texturefrac0) >> bits]]; dc_wall_texturefrac0 = place + dc_wall_iscale0; + dest[1] = pal1[buf1[(place = dc_wall_texturefrac1) >> bits]]; dc_wall_texturefrac1 = place + dc_wall_iscale1; + dest[2] = pal2[buf2[(place = dc_wall_texturefrac2) >> bits]]; dc_wall_texturefrac2 = place + dc_wall_iscale2; + dest[3] = pal3[buf3[(place = dc_wall_texturefrac3) >> bits]]; dc_wall_texturefrac3 = place + dc_wall_iscale3; dest += pitch; } while (--count); } @@ -210,7 +206,7 @@ namespace swrenderer int count = _count; const uint8_t *source = _source; uint8_t *dest = _dest; - int bits = _mvlinebits; + int bits = _fracbits; int pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -238,24 +234,24 @@ namespace swrenderer { uint8_t *dest = _dest; int count = _count; - int bits = _mvlinebits; + int bits = _fracbits; uint32_t place; - auto pal0 = _palookupoffse[0]; - auto pal1 = _palookupoffse[1]; - auto pal2 = _palookupoffse[2]; - auto pal3 = _palookupoffse[3]; - auto buf0 = _bufplce[0]; - auto buf1 = _bufplce[1]; - auto buf2 = _bufplce[2]; - auto buf3 = _bufplce[3]; - auto vince0 = _vince[0]; - auto vince1 = _vince[1]; - auto vince2 = _vince[2]; - auto vince3 = _vince[3]; - auto vplce0 = _vplce[0]; - auto vplce1 = _vplce[1]; - auto vplce2 = _vplce[2]; - auto vplce3 = _vplce[3]; + auto pal0 = _colormap[0]; + auto pal1 = _colormap[1]; + auto pal2 = _colormap[2]; + auto pal3 = _colormap[3]; + auto buf0 = _source[0]; + auto buf1 = _source[1]; + auto buf2 = _source[2]; + auto buf3 = _source[3]; + auto dc_wall_iscale0 = _iscale[0]; + auto dc_wall_iscale1 = _iscale[1]; + auto dc_wall_iscale2 = _iscale[2]; + auto dc_wall_iscale3 = _iscale[3]; + auto dc_wall_texturefrac0 = _texturefrac[0]; + auto dc_wall_texturefrac1 = _texturefrac[1]; + auto dc_wall_texturefrac2 = _texturefrac[2]; + auto dc_wall_texturefrac3 = _texturefrac[3]; auto pitch = _pitch; count = thread->count_for_thread(_dest_y, count); @@ -264,24 +260,24 @@ namespace swrenderer int skipped = thread->skipped_by_thread(_dest_y); dest = thread->dest_for_thread(_dest_y, pitch, dest); - vplce0 += vince0 * skipped; - vplce1 += vince1 * skipped; - vplce2 += vince2 * skipped; - vplce3 += vince3 * skipped; - vince0 *= thread->num_cores; - vince1 *= thread->num_cores; - vince2 *= thread->num_cores; - vince3 *= thread->num_cores; + dc_wall_texturefrac0 += dc_wall_iscale0 * skipped; + dc_wall_texturefrac1 += dc_wall_iscale1 * skipped; + dc_wall_texturefrac2 += dc_wall_iscale2 * skipped; + dc_wall_texturefrac3 += dc_wall_iscale3 * skipped; + dc_wall_iscale0 *= thread->num_cores; + dc_wall_iscale1 *= thread->num_cores; + dc_wall_iscale2 *= thread->num_cores; + dc_wall_iscale3 *= thread->num_cores; pitch *= thread->num_cores; do { uint8_t pix; - pix = buf0[(place = vplce0) >> bits]; if (pix) dest[0] = pal0[pix]; vplce0 = place + vince0; - pix = buf1[(place = vplce1) >> bits]; if (pix) dest[1] = pal1[pix]; vplce1 = place + vince1; - pix = buf2[(place = vplce2) >> bits]; if (pix) dest[2] = pal2[pix]; vplce2 = place + vince2; - pix = buf3[(place = vplce3) >> bits]; if (pix) dest[3] = pal3[pix]; vplce3 = place + vince3; + pix = buf0[(place = dc_wall_texturefrac0) >> bits]; if (pix) dest[0] = pal0[pix]; dc_wall_texturefrac0 = place + dc_wall_iscale0; + pix = buf1[(place = dc_wall_texturefrac1) >> bits]; if (pix) dest[1] = pal1[pix]; dc_wall_texturefrac1 = place + dc_wall_iscale1; + pix = buf2[(place = dc_wall_texturefrac2) >> bits]; if (pix) dest[2] = pal2[pix]; dc_wall_texturefrac2 = place + dc_wall_iscale2; + pix = buf3[(place = dc_wall_texturefrac3) >> bits]; if (pix) dest[3] = pal3[pix]; dc_wall_texturefrac3 = place + dc_wall_iscale3; dest += pitch; } while (--count); } @@ -294,7 +290,7 @@ namespace swrenderer int count = _count; const uint8_t *source = _source; uint8_t *dest = _dest; - int bits = _tmvlinebits; + int bits = _fracbits; int pitch = _pitch; uint32_t *fg2rgb = _srcblend; @@ -328,13 +324,13 @@ namespace swrenderer { uint8_t *dest = _dest; int count = _count; - int bits = _tmvlinebits; + int bits = _fracbits; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; - uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; - uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; + uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; count = thread->count_for_thread(_dest_y, count); if (count <= 0) @@ -345,8 +341,8 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); for (int i = 0; i < 4; i++) { - vplce[i] += vince[i] * skipped; - vince[i] *= thread->num_cores; + dc_wall_texturefrac[i] += dc_wall_iscale[i] * skipped; + dc_wall_iscale[i] *= thread->num_cores; } pitch *= thread->num_cores; @@ -354,15 +350,15 @@ namespace swrenderer { for (int i = 0; i < 4; ++i) { - uint8_t pix = _bufplce[i][vplce[i] >> bits]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; if (pix != 0) { - uint32_t fg = fg2rgb[_palookupoffse[i][pix]]; + uint32_t fg = fg2rgb[_colormap[i][pix]]; uint32_t bg = bg2rgb[dest[i]]; fg = (fg + bg) | 0x1f07c1f; dest[i] = RGB32k.All[fg & (fg >> 15)]; } - vplce[i] += vince[i]; + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } dest += pitch; } while (--count); @@ -376,7 +372,7 @@ namespace swrenderer int count = _count; const uint8_t *source = _source; uint8_t *dest = _dest; - int bits = _tmvlinebits; + int bits = _fracbits; int pitch = _pitch; uint32_t *fg2rgb = _srcblend; @@ -415,13 +411,13 @@ namespace swrenderer { uint8_t *dest = _dest; int count = _count; - int bits = _tmvlinebits; + int bits = _fracbits; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; - uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; - uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; + uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; count = thread->count_for_thread(_dest_y, count); if (count <= 0) @@ -432,8 +428,8 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); for (int i = 0; i < 4; i++) { - vplce[i] += vince[i] * skipped; - vince[i] *= thread->num_cores; + dc_wall_texturefrac[i] += dc_wall_iscale[i] * skipped; + dc_wall_iscale[i] *= thread->num_cores; } pitch *= thread->num_cores; @@ -441,10 +437,10 @@ namespace swrenderer { for (int i = 0; i < 4; ++i) { - uint8_t pix = _bufplce[i][vplce[i] >> bits]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; if (pix != 0) { - uint32_t a = fg2rgb[_palookupoffse[i][pix]] + bg2rgb[dest[i]]; + uint32_t a = fg2rgb[_colormap[i][pix]] + bg2rgb[dest[i]]; uint32_t b = a; a |= 0x01f07c1f; @@ -454,7 +450,7 @@ namespace swrenderer a |= b; dest[i] = RGB32k.All[a & (a >> 15)]; } - vplce[i] += vince[i]; + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } dest += pitch; } while (--count); @@ -468,7 +464,7 @@ namespace swrenderer int count = _count; const uint8_t *source = _source; uint8_t *dest = _dest; - int bits = _tmvlinebits; + int bits = _fracbits; int pitch = _pitch; uint32_t *fg2rgb = _srcblend; @@ -506,13 +502,13 @@ namespace swrenderer { uint8_t *dest = _dest; int count = _count; - int bits = _tmvlinebits; + int bits = _fracbits; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; - uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; - uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; + uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; count = thread->count_for_thread(_dest_y, count); if (count <= 0) @@ -523,8 +519,8 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); for (int i = 0; i < 4; i++) { - vplce[i] += vince[i] * skipped; - vince[i] *= thread->num_cores; + dc_wall_texturefrac[i] += dc_wall_iscale[i] * skipped; + dc_wall_iscale[i] *= thread->num_cores; } pitch *= thread->num_cores; @@ -532,10 +528,10 @@ namespace swrenderer { for (int i = 0; i < 4; ++i) { - uint8_t pix = _bufplce[i][vplce[i] >> bits]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; if (pix != 0) { - uint32_t a = (fg2rgb[_palookupoffse[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; + uint32_t a = (fg2rgb[_colormap[i][pix]] | 0x40100400) - bg2rgb[dest[i]]; uint32_t b = a; b &= 0x40100400; @@ -544,7 +540,7 @@ namespace swrenderer a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a >> 15)]; } - vplce[i] += vince[i]; + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } dest += pitch; } while (--count); @@ -558,7 +554,7 @@ namespace swrenderer int count = _count; const uint8_t *source = _source; uint8_t *dest = _dest; - int bits = _tmvlinebits; + int bits = _fracbits; int pitch = _pitch; uint32_t *fg2rgb = _srcblend; @@ -596,13 +592,13 @@ namespace swrenderer { uint8_t *dest = _dest; int count = _count; - int bits = _tmvlinebits; + int bits = _fracbits; uint32_t *fg2rgb = _srcblend; uint32_t *bg2rgb = _destblend; - uint32_t vplce[4] = { _vplce[0], _vplce[1], _vplce[2], _vplce[3] }; - uint32_t vince[4] = { _vince[0], _vince[1], _vince[2], _vince[3] }; + uint32_t dc_wall_texturefrac[4] = { _texturefrac[0], _texturefrac[1], _texturefrac[2], _texturefrac[3] }; + uint32_t dc_wall_iscale[4] = { _iscale[0], _iscale[1], _iscale[2], _iscale[3] }; count = thread->count_for_thread(_dest_y, count); if (count <= 0) @@ -613,8 +609,8 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); for (int i = 0; i < 4; i++) { - vplce[i] += vince[i] * skipped; - vince[i] *= thread->num_cores; + dc_wall_texturefrac[i] += dc_wall_iscale[i] * skipped; + dc_wall_iscale[i] *= thread->num_cores; } pitch *= thread->num_cores; @@ -622,10 +618,10 @@ namespace swrenderer { for (int i = 0; i < 4; ++i) { - uint8_t pix = _bufplce[i][vplce[i] >> bits]; + uint8_t pix = _source[i][dc_wall_texturefrac[i] >> bits]; if (pix != 0) { - uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_palookupoffse[i][pix]]; + uint32_t a = (bg2rgb[dest[i]] | 0x40100400) - fg2rgb[_colormap[i][pix]]; uint32_t b = a; b &= 0x40100400; @@ -634,7 +630,7 @@ namespace swrenderer a |= 0x01f07c1f; dest[i] = RGB32k.All[a & (a >> 15)]; } - vplce[i] += vince[i]; + dc_wall_texturefrac[i] += dc_wall_iscale[i]; } dest += _pitch; } while (--count); @@ -651,11 +647,11 @@ namespace swrenderer _pitch = dc_pitch; for (int col = 0; col < 4; col++) { - _bufplce[col] = bufplce[col]; - _bufplce2[col] = bufplce2[col]; - _bufheight[col] = bufheight[col]; - _vince[col] = vince[col]; - _vplce[col] = vplce[col]; + _source[col] = dc_wall_source[col]; + _source2[col] = dc_wall_source2[col]; + _sourceheight[col] = dc_wall_sourceheight[col]; + _iscale[col] = dc_wall_iscale[col]; + _texturefrac[col] = dc_wall_texturefrac[col]; } } @@ -664,11 +660,11 @@ namespace swrenderer uint8_t *dest = _dest; int count = _count; int pitch = _pitch; - const uint8_t *source0 = _bufplce[0]; - int textureheight0 = _bufheight[0]; + const uint8_t *source0 = _source[0]; + int textureheight0 = _sourceheight[0]; - int32_t frac = _vplce[0]; - int32_t fracstep = _vince[0]; + int32_t frac = _texturefrac[0]; + int32_t fracstep = _iscale[0]; int start_fade = 2; // How fast it should fade out @@ -729,11 +725,11 @@ namespace swrenderer uint8_t *dest = _dest; int count = _count; int pitch = _pitch; - const uint8_t *source0[4] = { _bufplce[0], _bufplce[1], _bufplce[2], _bufplce[3] }; - int textureheight0 = _bufheight[0]; + const uint8_t *source0[4] = { _source[0], _source[1], _source[2], _source[3] }; + int textureheight0 = _sourceheight[0]; const uint32_t *palette = (const uint32_t *)GPalette.BaseColors; - int32_t frac[4] = { (int32_t)_vplce[0], (int32_t)_vplce[1], (int32_t)_vplce[2], (int32_t)_vplce[3] }; - int32_t fracstep[4] = { (int32_t)_vince[0], (int32_t)_vince[1], (int32_t)_vince[2], (int32_t)_vince[3] }; + int32_t frac[4] = { (int32_t)_texturefrac[0], (int32_t)_texturefrac[1], (int32_t)_texturefrac[2], (int32_t)_texturefrac[3] }; + int32_t fracstep[4] = { (int32_t)_iscale[0], (int32_t)_iscale[1], (int32_t)_iscale[2], (int32_t)_iscale[3] }; uint8_t output[4]; int start_fade = 2; // How fast it should fade out @@ -870,13 +866,13 @@ namespace swrenderer uint8_t *dest = _dest; int count = _count; int pitch = _pitch; - const uint8_t *source0 = _bufplce[0]; - const uint8_t *source1 = _bufplce2[0]; - int textureheight0 = _bufheight[0]; - uint32_t maxtextureheight1 = _bufheight[1] - 1; + const uint8_t *source0 = _source[0]; + const uint8_t *source1 = _source2[0]; + int textureheight0 = _sourceheight[0]; + uint32_t maxtextureheight1 = _sourceheight[1] - 1; - int32_t frac = _vplce[0]; - int32_t fracstep = _vince[0]; + int32_t frac = _texturefrac[0]; + int32_t fracstep = _iscale[0]; int start_fade = 2; // How fast it should fade out @@ -942,13 +938,13 @@ namespace swrenderer uint8_t *dest = _dest; int count = _count; int pitch = _pitch; - const uint8_t *source0[4] = { _bufplce[0], _bufplce[1], _bufplce[2], _bufplce[3] }; - const uint8_t *source1[4] = { _bufplce2[0], _bufplce2[1], _bufplce2[2], _bufplce2[3] }; - int textureheight0 = _bufheight[0]; - uint32_t maxtextureheight1 = _bufheight[1] - 1; + const uint8_t *source0[4] = { _source[0], _source[1], _source[2], _source[3] }; + const uint8_t *source1[4] = { _source2[0], _source2[1], _source2[2], _source2[3] }; + int textureheight0 = _sourceheight[0]; + uint32_t maxtextureheight1 = _sourceheight[1] - 1; const uint32_t *palette = (const uint32_t *)GPalette.BaseColors; - int32_t frac[4] = { (int32_t)_vplce[0], (int32_t)_vplce[1], (int32_t)_vplce[2], (int32_t)_vplce[3] }; - int32_t fracstep[4] = { (int32_t)_vince[0], (int32_t)_vince[1], (int32_t)_vince[2], (int32_t)_vince[3] }; + int32_t frac[4] = { (int32_t)_texturefrac[0], (int32_t)_texturefrac[1], (int32_t)_texturefrac[2], (int32_t)_texturefrac[3] }; + int32_t fracstep[4] = { (int32_t)_iscale[0], (int32_t)_iscale[1], (int32_t)_iscale[2], (int32_t)_iscale[3] }; uint8_t output[4]; int start_fade = 2; // How fast it should fade out diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index f2b1f0571..ab3c98327 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -20,9 +20,7 @@ namespace swrenderer int _count; const uint8_t *_source; uint8_t *_dest; - int _vlinebits; - int _mvlinebits; - int _tmvlinebits; + int _fracbits; int _pitch; uint32_t *_srcblend; uint32_t *_destblend; @@ -38,13 +36,11 @@ namespace swrenderer uint8_t *_dest; int _count; int _pitch; - int _vlinebits; - int _mvlinebits; - int _tmvlinebits; - uint8_t *_palookupoffse[4]; - const uint8_t *_bufplce[4]; - uint32_t _vince[4]; - uint32_t _vplce[4]; + int _fracbits; + uint8_t *_colormap[4]; + const uint8_t *_source[4]; + uint32_t _iscale[4]; + uint32_t _texturefrac[4]; uint32_t *_srcblend; uint32_t *_destblend; }; @@ -75,11 +71,11 @@ namespace swrenderer uint8_t *_dest; int _count; int _pitch; - const uint8_t *_bufplce[4]; - const uint8_t *_bufplce2[4]; - int _bufheight[4]; - uint32_t _vince[4]; - uint32_t _vplce[4]; + const uint8_t *_source[4]; + const uint8_t *_source2[4]; + int _sourceheight[4]; + uint32_t _iscale[4]; + uint32_t _texturefrac[4]; }; class DrawSingleSky1PalCommand : public PalSkyCommand { public: using PalSkyCommand::PalSkyCommand; void Execute(DrawerThread *thread) override; }; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cd378aec1..64433b6d4 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -705,15 +705,15 @@ static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, doub angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); - bufplce[i] = (const BYTE *)frontskytex->GetColumn(angle1, nullptr); - bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumn(angle2, nullptr) : nullptr; + dc_wall_source[i] = (const BYTE *)frontskytex->GetColumn(angle1, nullptr); + dc_wall_source2[i] = backskytex ? (const BYTE *)backskytex->GetColumn(angle2, nullptr) : nullptr; - vince[i] = uv_step; - vplce[i] = uv_pos; + dc_wall_iscale[i] = uv_step; + dc_wall_texturefrac[i] = uv_pos; } - bufheight[0] = height; - bufheight[1] = backskytex ? backskytex->GetHeight() : height; + dc_wall_sourceheight[0] = height; + dc_wall_sourceheight[1] = backskytex ? backskytex->GetHeight() : height; dc_dest = (ylookup[y1] + start_x) + dc_destorg; dc_count = y2 - y1; diff --git a/src/r_walldraw.cpp b/src/r_walldraw.cpp index ee2e1a29d..c13786bba 100644 --- a/src/r_walldraw.cpp +++ b/src/r_walldraw.cpp @@ -96,7 +96,7 @@ WallSampler::WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, FT } // Draw a column with support for non-power-of-two ranges -static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, DWORD(*draw1column)()) +static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1column)()) { if (sampler.uv_max == 0 || sampler.uv_step == 0) // power of two { @@ -151,9 +151,9 @@ static void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw int count = y2 - y1; for (int i = 0; i < 4; i++) { - bufplce[i] = sampler[i].source; - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; + dc_wall_source[i] = sampler[i].source; + dc_wall_texturefrac[i] = sampler[i].uv_pos; + dc_wall_iscale[i] = sampler[i].uv_step; uint64_t step64 = sampler[i].uv_step; uint64_t pos64 = sampler[i].uv_pos; @@ -168,7 +168,7 @@ static void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw dc_dest = (ylookup[y1] + x) + dc_destorg; for (int i = 0; i < 4; i++) { - bufplce[i] = sampler[i].source; + dc_wall_source[i] = sampler[i].source; } uint32_t left = y2 - y1; @@ -188,8 +188,8 @@ static void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw // Draw until that column wraps for (int i = 0; i < 4; i++) { - vplce[i] = sampler[i].uv_pos; - vince[i] = sampler[i].uv_step; + dc_wall_texturefrac[i] = sampler[i].uv_pos; + dc_wall_iscale[i] = sampler[i].uv_step; } dc_count = count; draw4columns(); @@ -207,13 +207,11 @@ static void Draw4Columns(int x, int y1, int y2, WallSampler *sampler, void(*draw } } -typedef DWORD(*Draw1ColumnFuncPtr)(); -typedef void(*Draw4ColumnsFuncPtr)(); +typedef void(*DrawColumnFuncPtr)(); static void ProcessWallWorker( int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, - const BYTE *(*getcol)(FTexture *tex, int x), - void(setupProcessNormalWall(int bits, Draw1ColumnFuncPtr &draw1, Draw4ColumnsFuncPtr &draw2))) + const BYTE *(*getcol)(FTexture *tex, int x), DrawColumnFuncPtr draw1column, DrawColumnFuncPtr draw4columns) { if (rw_pic->UseType == FTexture::TEX_Null) return; @@ -228,17 +226,15 @@ static void ProcessWallWorker( dc_texturemid = 0; } - DWORD(*draw1column)(); - void(*draw4columns)(); - setupProcessNormalWall(fracbits, draw1column, draw4columns); + dc_wall_fracbits = fracbits; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) { - palookupoffse[0] = dc_colormap; - palookupoffse[1] = dc_colormap; - palookupoffse[2] = dc_colormap; - palookupoffse[3] = dc_colormap; + dc_wall_colormap[0] = dc_colormap; + dc_wall_colormap[1] = dc_colormap; + dc_wall_colormap[2] = dc_colormap; + dc_wall_colormap[3] = dc_colormap; } if (fixedcolormap) @@ -331,7 +327,7 @@ static void ProcessWallWorker( { for (int i = 0; i < 4; i++) { - palookupoffse[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); + dc_wall_colormap[i] = basecolormap->Maps + (GETPALOOKUP(lights[i], wallshade) << COLORMAPSHIFT); } } Draw4Columns(x, middle_y1, middle_y2, sampler, draw4columns); @@ -367,12 +363,7 @@ static void ProcessWallWorker( static void ProcessNormalWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) { - ProcessWallWorker(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupvline(bits); - line1 = dovline1; - line4 = dovline4; - }); + ProcessWallWorker(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, R_DrawWallCol1, R_DrawWallCol4); } static void ProcessMaskedWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) @@ -383,32 +374,22 @@ static void ProcessMaskedWall(int x1, int x2, short *uwal, short *dwal, float *s } else { - ProcessWallWorker(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setupmvline(bits); - line1 = domvline1; - line4 = domvline4; - }); + ProcessWallWorker(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, R_DrawWallMaskedCol1, R_DrawWallMaskedCol4); } } static void ProcessTranslucentWall(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) { - static fixed_t(*tmvline1)(); - static void(*tmvline4)(); - if (!R_GetTransMaskDrawers(&tmvline1, &tmvline4)) + void (*drawcol1)(); + void (*drawcol4)(); + if (!R_GetTransMaskDrawers(&drawcol1, &drawcol4)) { // The current translucency is unsupported, so draw with regular ProcessMaskedWall instead. ProcessMaskedWall(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); } else { - ProcessWallWorker(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, [](int bits, Draw1ColumnFuncPtr &line1, Draw4ColumnsFuncPtr &line4) - { - setuptmvline(bits); - line1 = reinterpret_cast(tmvline1); - line4 = tmvline4; - }); + ProcessWallWorker(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol, drawcol1, drawcol4); } } From a0595f17e8c33301a6b12f2217d3ab643e13c18b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 20 Dec 2016 13:13:50 +0200 Subject: [PATCH 21/25] Serializer now writes floating point zero if special value is encountered See https://forum.zdoom.org/viewtopic.php?t=54592 --- src/rapidjson/writer.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rapidjson/writer.h b/src/rapidjson/writer.h index a288f07ff..200abadae 100644 --- a/src/rapidjson/writer.h +++ b/src/rapidjson/writer.h @@ -527,7 +527,9 @@ inline bool Writer::WriteDouble(double d) { if (!(kWriteDefaultFlags & kWriteNanAndInfFlag)) { // At least ensure that the output does not get broken. - PutReserve(*os_, 1); + PutReserve(*os_, 3); + PutUnsafe(*os_, '0'); + PutUnsafe(*os_, '.'); PutUnsafe(*os_, '0'); return false; } From 9f6d8d2ba709af32e0a183774ae46e12edc8d37d Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 20 Dec 2016 13:14:02 +0200 Subject: [PATCH 22/25] Set goal values in decal stretcher to zeros even if they are not used See https://forum.zdoom.org/viewtopic.php?t=54592 --- src/decallib.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/decallib.cpp b/src/decallib.cpp index 5d24e44d5..7bfdfc3e7 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -1232,6 +1232,7 @@ DThinker *FDecalStretcherAnim::CreateThinker (DBaseDecal *actor, side_t *wall) c } else { + thinker->GoalX = 0; thinker->bStretchX = false; } if (GoalY >= 0) @@ -1241,6 +1242,7 @@ DThinker *FDecalStretcherAnim::CreateThinker (DBaseDecal *actor, side_t *wall) c } else { + thinker->GoalY = 0; thinker->bStretchY = false; } thinker->bStarted = false; From 1d77f1f72eb015a4ec314535e3236e864cf086c4 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 20 Dec 2016 15:19:06 +0200 Subject: [PATCH 23/25] Enabled building of GME static library by default See https://forum.zdoom.org/viewtopic.php?t=54651 --- game-music-emu/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game-music-emu/CMakeLists.txt b/game-music-emu/CMakeLists.txt index c6472b690..0af4f24d8 100644 --- a/game-music-emu/CMakeLists.txt +++ b/game-music-emu/CMakeLists.txt @@ -80,7 +80,7 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" ) #endif() # [ZDoom] Set always to OFF. -set(BUILD_SHARED_LIBS 0 BOOL "Build shared library (set to OFF for static library)") +set(BUILD_SHARED_LIBS OFF) # Check for GCC "visibility" support. if (CMAKE_COMPILER_IS_GNUCXX) From b15e620ea85ec545850fce384e9109b8287af525 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 Dec 2016 18:26:33 +0100 Subject: [PATCH 24/25] - fixed: Phased light setup did not check if a sector had been already visited and could cause infinite recursion. --- src/p_lights.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_lights.cpp b/src/p_lights.cpp index 910c52a64..a05199b91 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -31,6 +31,7 @@ #include "p_lnspec.h" #include "doomstat.h" +#include "p_maputl.h" // State. #include "r_state.h" @@ -914,7 +915,7 @@ void DPhased::Tick () int DPhased::PhaseHelper (sector_t *sector, int index, int light, sector_t *prev) { - if (!sector) + if (!sector || sector->validcount == validcount) { return index; } @@ -922,6 +923,7 @@ int DPhased::PhaseHelper (sector_t *sector, int index, int light, sector_t *prev { DPhased *l; int baselevel = sector->lightlevel ? sector->lightlevel : light; + sector->validcount = validcount; if (index == 0) { @@ -958,6 +960,7 @@ DPhased::DPhased (sector_t *sector, int baselevel) DPhased::DPhased (sector_t *sector) : DLighting (sector) { + validcount++; PhaseHelper (sector, 0, 0, NULL); } From 7dd51d6d1c2f1f425b529ed3742c342d032a4255 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 22 Dec 2016 11:00:20 +0200 Subject: [PATCH 25/25] Fixed infinite execution of error CCMD https://forum.zdoom.org/viewtopic.php?t=54659 --- src/c_console.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index 691c4a3ca..0a324eb8f 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1523,8 +1523,6 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) buffer.Text.StripLeftRight(); Printf(127, TEXTCOLOR_WHITE "]%s\n", buffer.Text.GetChars()); - AddCommandString(buffer.Text.LockBuffer()); - buffer.Text.UnlockBuffer(); if (buffer.Text.Len() == 0) { @@ -1568,7 +1566,21 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) } } HistPos = NULL; - buffer.SetString(""); + { + // Work with a copy of command to avoid side effects caused by + // exception raised during execution, like with 'error' CCMD. + // It's problematic to maintain FString's lock symmetry. + static TArray command; + const size_t length = buffer.Text.Len(); + + command.Resize(length + 1); + memcpy(&command[0], buffer.Text.GetChars(), length); + command[length] = '\0'; + + buffer.SetString(""); + + AddCommandString(&command[0]); + } TabbedLast = false; TabbedList = false; break;