Merge remote-tracking branch 'origin/removeasmstuff' into Saturn
This commit is contained in:
commit
1bc674d73f
38 files changed
+359
-3883
No files matched your search
@@ -43,7 +43,7 @@ jobs:
|
||||
- v1-SRB2-APT
|
||||
- run:
|
||||
name: Install SDK
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
- save_cache:
|
||||
key: v1-SRB2-APT
|
||||
paths:
|
||||
|
||||
@@ -68,7 +68,6 @@
|
||||
- You tell us! c:
|
||||
|
||||
## Dependencies
|
||||
- NASM (x86 builds only)
|
||||
- SDL2 (Linux/OS X only)
|
||||
- SDL2-Mixer (Linux/OS X only)
|
||||
- libupnp (Linux/OS X only)
|
||||
|
||||
@@ -1996,24 +1996,6 @@ HW3SOUND for 3D hardware sound support
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/v_video.h" />
|
||||
<Unit filename="src/vid_copy.s">
|
||||
<Option compilerVar="CC" />
|
||||
<Option compiler="avrgcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="gnu_gcc_compiler_for_mingw32" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="gnu_gcc_compiler_for_mingw64" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="armelfgcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="tricoregcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="ppcgcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option compiler="gcc" use="1" buildCommand="$compiler $options -x assembler-with-cpp -c $file -o $object" />
|
||||
<Option target="Debug Native/SDL" />
|
||||
<Option target="Release Native/SDL" />
|
||||
<Option target="Debug Linux/SDL" />
|
||||
<Option target="Release Linux/SDL" />
|
||||
<Option target="Debug Mingw/SDL" />
|
||||
<Option target="Release Mingw/SDL" />
|
||||
<Option target="Debug Mingw/DirectX" />
|
||||
<Option target="Release Mingw/DirectX" />
|
||||
</Unit>
|
||||
<Unit filename="src/w_wad.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x86'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>USEASM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
|
||||
@@ -5,7 +5,7 @@ Ver=3
|
||||
IsCpp=0
|
||||
Type=0
|
||||
UnitCount=279
|
||||
Folders=A_Asm,B_Bot,BLUA,D_Doom,F_Frame,G_Game,H_Hud,Hw_Hardware,Hw_Hardware/r_opengl,I_Interface,I_Interface/Dummy,I_Interface/SDL,I_Interface/Win32,LUA,M_Misc,P_Play,R_Rend,S_Sounds,W_Wad
|
||||
Folders=B_Bot,BLUA,D_Doom,F_Frame,G_Game,H_Hud,Hw_Hardware,Hw_Hardware/r_opengl,I_Interface,I_Interface/Dummy,I_Interface/SDL,I_Interface/Win32,LUA,M_Misc,P_Play,R_Rend,S_Sounds,W_Wad
|
||||
CommandLine=
|
||||
CompilerSettings=00000000000100000111e1
|
||||
PchHead=-1
|
||||
@@ -1473,36 +1473,6 @@ Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit149]
|
||||
FileName=src\tmap.nas
|
||||
Folder=A_Asm
|
||||
Compile=0
|
||||
CompileCpp=0
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=1
|
||||
BuildCmd=nasm.exe -g -o $@ -f win32 src/tmap.nas
|
||||
|
||||
[Unit150]
|
||||
FileName=src\asm_defs.inc
|
||||
Folder=A_Asm
|
||||
Compile=0
|
||||
CompileCpp=0
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit151]
|
||||
FileName=src\vid_copy.s
|
||||
Folder=A_Asm
|
||||
Compile=1
|
||||
CompileCpp=0
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=1
|
||||
BuildCmd=$(CC) $(CFLAGS) -x assembler-with-cpp -c src/vid_copy.s -o $@
|
||||
|
||||
[Unit152]
|
||||
FileName=src\y_inter.h
|
||||
Folder=H_Hud
|
||||
@@ -1543,26 +1513,6 @@ Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit156]
|
||||
FileName=src\p5prof.h
|
||||
Folder=A_Asm
|
||||
Compile=1
|
||||
CompileCpp=0
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit157]
|
||||
FileName=src\tmap_mmx.nas
|
||||
Folder=A_Asm
|
||||
Compile=0
|
||||
CompileCpp=0
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=1
|
||||
BuildCmd=nasm.exe -g -o $@ -f win32 src/tmap_mmx.nas
|
||||
|
||||
[Unit159]
|
||||
FileName=src\lzf.h
|
||||
Folder=W_Wad
|
||||
|
||||
@@ -11,8 +11,6 @@ environment:
|
||||
# c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead
|
||||
MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
|
||||
CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn
|
||||
NASM_ZIP: nasm-2.12.01
|
||||
NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip
|
||||
UPX_ZIP: upx391w
|
||||
UPX_URL: http://upx.sourceforge.net/download/upx391w.zip
|
||||
CCACHE_EXE: ccache.exe
|
||||
@@ -46,7 +44,6 @@ environment:
|
||||
ASSET_CLEAN: 0
|
||||
|
||||
cache:
|
||||
- nasm-2.12.01.zip
|
||||
- upx391w.zip
|
||||
- ccache.exe
|
||||
- C:\Users\appveyor\.ccache
|
||||
@@ -58,10 +55,6 @@ install:
|
||||
- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" )
|
||||
- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" )
|
||||
|
||||
- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip"
|
||||
- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0
|
||||
|
||||
- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip"
|
||||
- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0
|
||||
@@ -78,7 +71,6 @@ before_build:
|
||||
- set "Path=%MINGW_SDK%\bin;%Path%"
|
||||
- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version )
|
||||
- mingw32-make --version
|
||||
- if not [%X86_64%] == [1] ( nasm -v )
|
||||
- if not [%NOUPX%] == [1] ( upx -V )
|
||||
- ccache -V
|
||||
- ccache -s
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# support for the yasm assembler
|
||||
|
||||
set(CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS nasm yasm asm)
|
||||
|
||||
if(NOT CMAKE_ASM_YASM_OBJECT_FORMAT)
|
||||
if(WIN32)
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT win64)
|
||||
else()
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT win32)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT macho64)
|
||||
else()
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT macho)
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT elf64)
|
||||
else()
|
||||
set(CMAKE_ASM_YASM_OBJECT_FORMAT elf)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_ASM_YASM_COMPILE_OBJECT "<CMAKE_ASM_YASM_COMPILER> <FLAGS> -f ${CMAKE_ASM_YASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
|
||||
|
||||
# Load the generic ASMInformation file:
|
||||
set(ASM_DIALECT "_YASM")
|
||||
include(CMakeASMInformation)
|
||||
set(ASM_DIALECT)
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible
|
||||
|
||||
set(CMAKE_ASM_YASM_COMPILER_LIST nasm yasm)
|
||||
|
||||
if(NOT CMAKE_ASM_YASM_COMPILER)
|
||||
find_program(CMAKE_ASM_YASM_COMPILER yasm
|
||||
"$ENV{ProgramFiles}/YASM")
|
||||
endif()
|
||||
|
||||
# Load the generic DetermineASM compiler file with the DIALECT set properly:
|
||||
set(ASM_DIALECT "_YASM")
|
||||
include(CMakeDetermineASMCompiler)
|
||||
set(ASM_DIALECT)
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# This file is used by EnableLanguage in cmGlobalGenerator to
|
||||
# determine that the selected ASM_NASM "compiler" works.
|
||||
# For assembler this can only check whether the compiler has been found,
|
||||
# because otherwise there would have to be a separate assembler source file
|
||||
# for each assembler on every architecture.
|
||||
|
||||
set(ASM_DIALECT "_YASM")
|
||||
include(CMakeTestASMCompiler)
|
||||
set(ASM_DIALECT)
|
||||
+1
-1
@@ -76,7 +76,7 @@ LOCAL_SRC_FILES := am_map.c \
|
||||
android/i_system.c \
|
||||
android/i_video.c
|
||||
|
||||
LOCAL_CFLAGS += -DPLATFORM_ANDROID -DNONX86 -DLINUX -DDEBUGMODE -DNOASM -DNOPIX -DUNIXCOMMON -DNOTERMIOS
|
||||
LOCAL_CFLAGS += -DPLATFORM_ANDROID -DNONX86 -DLINUX -DDEBUGMODE -DNOPIX -DUNIXCOMMON -DNOTERMIOS
|
||||
|
||||
LOCAL_MODULE := libsrb2
|
||||
|
||||
|
||||
@@ -198,32 +198,6 @@ source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||
|
||||
|
||||
set(SRB2_ASM_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vid_copy.s
|
||||
)
|
||||
|
||||
set(SRB2_NASM_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tmap_mmx.nas
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tmap.nas
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND SRB2_NASM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tmap_vc.nas)
|
||||
endif()
|
||||
|
||||
set(SRB2_NASM_OBJECTS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tmap_mmx.obj
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tmap.obj
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND SRB2_NASM_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/tmap_vc.obj)
|
||||
endif()
|
||||
|
||||
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
|
||||
|
||||
|
||||
### Configuration
|
||||
set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL
|
||||
"Enable Lua interpreter support")
|
||||
@@ -241,10 +215,6 @@ set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
|
||||
"Enable curl support, used for downloading files via HTTP.")
|
||||
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
|
||||
"Enable hardware rendering through OpenGL.")
|
||||
set(SRB2_CONFIG_USEASM OFF CACHE BOOL
|
||||
"Enable NASM tmap implementation for software mode speedup.")
|
||||
set(SRB2_CONFIG_YASM OFF CACHE BOOL
|
||||
"Use YASM in place of NASM.")
|
||||
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
|
||||
"Use statically linked OpenGL. NOT RECOMMENDED.")
|
||||
|
||||
@@ -535,28 +505,6 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_USEASM})
|
||||
#SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm.
|
||||
if(${CMAKE_SYSTEM} MATCHES "Linux")
|
||||
set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_YASM})
|
||||
set(CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS} nas)
|
||||
set(CMAKE_ASM_YASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
|
||||
enable_language(ASM_YASM)
|
||||
else()
|
||||
set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS} nas)
|
||||
set(CMAKE_ASM_NASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
|
||||
enable_language(ASM_NASM)
|
||||
endif()
|
||||
set(SRB2_USEASM ON)
|
||||
add_definitions(-DUSEASM)
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -msse3 -mfpmath=sse)
|
||||
else()
|
||||
set(SRB2_USEASM OFF)
|
||||
add_definitions(-DNONX86 -DNORUSEASM)
|
||||
endif()
|
||||
|
||||
# Targets
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
# Compile a debug version, add 'DEBUGMODE=1'
|
||||
# Compile with less warnings, add 'RELAXWARNINGS=1'
|
||||
# Generate compiler errors for most compiler warnings, add 'ERRORMODE=1'
|
||||
# Compile without NASM's tmap.nas, add 'NOASM=1'
|
||||
# Compile without 3D hardware support, add 'NOHW=1'
|
||||
# Compile with GDBstubs, add 'RDB=1'
|
||||
# Compile without PNG, add 'NOPNG=1'
|
||||
@@ -166,7 +165,6 @@ endif
|
||||
ifdef MINGW64
|
||||
MINGW=1
|
||||
NONX86=1
|
||||
NOASM=1
|
||||
# MINGW64 should not necessarily imply X86_64=1, but we make that assumption elsewhere
|
||||
# Once that changes, remove this
|
||||
X86_64=1
|
||||
@@ -189,7 +187,6 @@ NOPNG=1
|
||||
NOZLIB=1
|
||||
NONET=1
|
||||
NOHW=1
|
||||
NOASM=1
|
||||
NOIPX=1
|
||||
EXENAME?=srb2dummy
|
||||
OBJS=$(OBJDIR)/i_video.o
|
||||
@@ -198,7 +195,6 @@ endif
|
||||
|
||||
ifdef HAIKU
|
||||
NOIPX=1
|
||||
NOASM=1
|
||||
ifndef NONET
|
||||
LIBS=-lnetwork
|
||||
endif
|
||||
@@ -272,7 +268,6 @@ NOPNG=1
|
||||
NOZLIB=1
|
||||
NONET=1
|
||||
#NOHW=1
|
||||
NOASM=1
|
||||
NOIPX=1
|
||||
NONX86=1
|
||||
OBJS+=$(OBJDIR)/i_video.o
|
||||
@@ -300,7 +295,6 @@ endif
|
||||
MSGFMT?=msgfmt
|
||||
|
||||
ifndef ECHO
|
||||
NASM:=@$(NASM)
|
||||
REMOVE:=@$(REMOVE)
|
||||
CC:=@$(CC)
|
||||
CXX:=@$(CXX)
|
||||
@@ -355,12 +349,6 @@ ifdef X86_64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NOASM
|
||||
ifndef NONX86
|
||||
OBJS+=$(OBJDIR)/tmap.o $(OBJDIR)/tmap_mmx.o
|
||||
OPTS+=-DUSEASM
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NOPNG
|
||||
OPTS+=-DHAVE_PNG
|
||||
@@ -511,16 +499,6 @@ else
|
||||
endif
|
||||
CFLAGS+=-g $(OPTS) $(ARCHOPTS) $(WINDRESFLAGS)
|
||||
|
||||
ifdef YASM
|
||||
ifdef STABS
|
||||
NASMOPTS?= -g stabs
|
||||
else
|
||||
NASMOPTS?= -g dwarf2
|
||||
endif
|
||||
else
|
||||
NASMOPTS?= -g
|
||||
endif
|
||||
|
||||
ifdef PROFILEMODE
|
||||
# build with profiling information
|
||||
CFLAGS+=-pg
|
||||
@@ -624,7 +602,6 @@ OBJS:=$(i_main_o) \
|
||||
$(OBJDIR)/i_tcp.o \
|
||||
$(OBJDIR)/i_time.o \
|
||||
$(OBJDIR)/lzf.o \
|
||||
$(OBJDIR)/vid_copy.o \
|
||||
$(OBJDIR)/b_bot.o \
|
||||
$(OBJDIR)/args.o \
|
||||
$(i_cdmus_o) \
|
||||
@@ -718,11 +695,6 @@ ifdef CYGWIN32
|
||||
$(REMOVE) $(OBJDIR)/*.res
|
||||
endif
|
||||
|
||||
#make a big srb2.s that is the disasm of the exe (dos only ?)
|
||||
asm:
|
||||
$(CC) $(LDFLAGS) $(OBJS) -o $(OBJDIR)/tmp.exe $(LIBS)
|
||||
$(OBJDUMP) -d $(OBJDIR)/tmp.exe --no-show-raw-insn > srb2.s
|
||||
$(REMOVE) $(OBJDIR)/tmp.exe
|
||||
|
||||
# executable
|
||||
# NOTE: DJGPP's objcopy do not have --add-gnu-debuglink
|
||||
@@ -908,12 +880,6 @@ $(OBJDIR)/%.o: hardware/%.c
|
||||
$(OBJDIR)/%.o: blua/%.c
|
||||
$(CC) $(CFLAGS) $(LUA_CFLAGS) $(WFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o: %.nas
|
||||
$(NASM) $(NASMOPTS) -o $@ -f $(NASMFORMAT) $<
|
||||
|
||||
$(OBJDIR)/vid_copy.o: vid_copy.s asm_defs.inc
|
||||
$(CC) $(OPTS) $(ASFLAGS) -x assembler-with-cpp -c $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o: %.s
|
||||
$(CC) $(OPTS) -x assembler-with-cpp -c $< -o $@
|
||||
|
||||
|
||||
@@ -383,12 +383,6 @@ i_main_o=$(OBJDIR)/i_main.o
|
||||
#set OBJDIR and BIN's starting place
|
||||
OBJDIR=../objs
|
||||
BIN=../bin
|
||||
#Nasm ASM and rm
|
||||
ifdef YASM
|
||||
NASM?=yasm
|
||||
else
|
||||
NASM?=nasm
|
||||
endif
|
||||
REMOVE?=rm -f
|
||||
CP?=cp
|
||||
MKDIR?=mkdir -p
|
||||
@@ -406,7 +400,6 @@ endif
|
||||
#Interface Setup
|
||||
ifdef DJGPPDOS
|
||||
INTERFACE=djgppdos
|
||||
NASMFORMAT=coff
|
||||
OBJDIR:=$(OBJDIR)/djgppdos
|
||||
ifdef WATTCP
|
||||
OBJDIR:=$(OBJDIR)/wattcp
|
||||
@@ -420,7 +413,6 @@ ifdef DUMMY
|
||||
BIN:=$(BIN)/dummy
|
||||
else
|
||||
ifdef LINUX
|
||||
NASMFORMAT=elf -DLINUX
|
||||
SDL=1
|
||||
ifdef LINUX64
|
||||
OBJDIR:=$(OBJDIR)/Linux64
|
||||
@@ -432,7 +424,6 @@ endif
|
||||
else
|
||||
ifdef FREEBSD
|
||||
INTERFACE=sdl
|
||||
NASMFORMAT=elf -DLINUX
|
||||
SDL=1
|
||||
|
||||
OBJDIR:=$(OBJDIR)/FreeBSD
|
||||
@@ -440,7 +431,6 @@ ifdef FREEBSD
|
||||
else
|
||||
ifdef SOLARIS
|
||||
INTERFACE=sdl
|
||||
NASMFORMAT=elf -DLINUX
|
||||
SDL=1
|
||||
|
||||
OBJDIR:=$(OBJDIR)/Solaris
|
||||
@@ -448,7 +438,6 @@ ifdef SOLARIS
|
||||
else
|
||||
ifdef CYGWIN32
|
||||
INTERFACE=sdl
|
||||
NASMFORMAT=win32
|
||||
SDL=1
|
||||
|
||||
OBJDIR:=$(OBJDIR)/cygwin
|
||||
@@ -456,7 +445,6 @@ ifdef CYGWIN32
|
||||
else
|
||||
ifdef MINGW64
|
||||
INTERFACE=win32
|
||||
#NASMFORMAT=win64
|
||||
OBJDIR:=$(OBJDIR)/Mingw64
|
||||
BIN:=$(BIN)/Mingw64
|
||||
else
|
||||
@@ -488,13 +476,11 @@ ifdef PS3N
|
||||
else
|
||||
ifdef MINGW
|
||||
INTERFACE=win32
|
||||
NASMFORMAT=win32
|
||||
OBJDIR:=$(OBJDIR)/Mingw
|
||||
BIN:=$(BIN)/Mingw
|
||||
else
|
||||
ifdef XBOX
|
||||
INTERFACE=sdl12
|
||||
NASMFORMAT=win32
|
||||
PREFIX?=/usr/local/openxdk/bin/i386-pc-xbox
|
||||
SDL=1
|
||||
SDL12=1
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file asm_defs.inc
|
||||
/// \brief must match the C structures
|
||||
|
||||
#ifndef __ASM_DEFS__
|
||||
#define __ASM_DEFS__
|
||||
|
||||
// this makes variables more noticable,
|
||||
// and make the label match with C code
|
||||
|
||||
// Linux, unlike DOS, has no "_" 19990119 by Kin
|
||||
// and nasm needs .data code segs under linux 20010210 by metzgermeister
|
||||
// FIXME: nasm ignores these settings, so I put the macros into the makefile
|
||||
#ifdef __ELF__
|
||||
#define C(label) label
|
||||
#define CODE_SEG .data
|
||||
#else
|
||||
#define C(label) _##label
|
||||
#define CODE_SEG .text
|
||||
#endif
|
||||
|
||||
/* This is a more readable way to access the arguments passed from C code */
|
||||
/* PLEASE NOTE: it is supposed that all arguments passed from C code are */
|
||||
/* 32bit integer (INT32, long, and most *pointers) */
|
||||
#define ARG1 8(%ebp)
|
||||
#define ARG2 12(%ebp)
|
||||
#define ARG3 16(%ebp)
|
||||
#define ARG4 20(%ebp)
|
||||
#define ARG5 24(%ebp)
|
||||
#define ARG6 28(%ebp)
|
||||
#define ARG7 32(%ebp)
|
||||
#define ARG8 36(%ebp)
|
||||
#define ARG9 40(%ebp) //(c)tm ... Allegro by Shawn Hargreaves.
|
||||
|
||||
#endif
|
||||
@@ -5024,11 +5024,6 @@ static void Command_Version_f(void)
|
||||
else // 16-bit? 128-bit?
|
||||
CONS_Printf("Bits Unknown ");
|
||||
|
||||
// No ASM?
|
||||
#ifdef NOASM
|
||||
CONS_Printf("\x85" "NOASM " "\x80");
|
||||
#endif
|
||||
|
||||
// Debug build
|
||||
#ifdef _DEBUG
|
||||
CONS_Printf("\x85" "DEBUG " "\x80");
|
||||
|
||||
+1
-1
@@ -562,7 +562,7 @@ INT32 CL_CheckFiles(void)
|
||||
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
||||
|
||||
// Check in already loaded files
|
||||
for (j = mainwads+1; wadfiles[j]; j++)
|
||||
for (j = mainwads+1; j < numwadfiles; j++)
|
||||
{
|
||||
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
||||
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
||||
|
||||
@@ -84,7 +84,7 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
|
||||
{
|
||||
huddrawlist_h drawlist;
|
||||
|
||||
drawlist = (huddrawlist_h) Z_CallocAlign(sizeof(struct huddrawlist_s), PU_STATIC, NULL, 64);
|
||||
drawlist = (huddrawlist_h) Z_Calloc(sizeof(struct huddrawlist_s), PU_STATIC, NULL);
|
||||
drawlist->items = NULL;
|
||||
drawlist->items_capacity = 0;
|
||||
drawlist->items_len = 0;
|
||||
@@ -145,7 +145,7 @@ static size_t AllocateDrawItem(huddrawlist_h list)
|
||||
{
|
||||
if (list->items_capacity == 0) list->items_capacity = 128;
|
||||
else list->items_capacity *= 2;
|
||||
list->items = (drawitem_t *) Z_ReallocAlign(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL, 64);
|
||||
list->items = (drawitem_t *) Z_Realloc(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL);
|
||||
}
|
||||
|
||||
return list->items_len++;
|
||||
@@ -164,7 +164,7 @@ static size_t CopyString(huddrawlist_h list, const char* str)
|
||||
{
|
||||
if (list->strbuf_capacity == 0) list->strbuf_capacity = 256;
|
||||
else list->strbuf_capacity *= 2;
|
||||
list->strbuf = (char*) Z_ReallocAlign(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL, 8);
|
||||
list->strbuf = (char*) Z_Realloc(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -23,50 +23,6 @@
|
||||
#include "m_fixed.h"
|
||||
#include "tables.h" // ANGLETOFINESHIFT
|
||||
|
||||
#ifdef __USE_C_FIXEDMUL__
|
||||
|
||||
/** \brief The FixedMul function
|
||||
|
||||
\param a fixed_t number
|
||||
\param b fixed_t number
|
||||
|
||||
\return a*b>>FRACBITS
|
||||
|
||||
*/
|
||||
fixed_t FixedMul(fixed_t a, fixed_t b)
|
||||
{
|
||||
// Need to cast to unsigned before shifting to avoid undefined behaviour
|
||||
// for negative integers
|
||||
return (fixed_t)(((UINT64)((INT64)a * b)) >> FRACBITS);
|
||||
}
|
||||
|
||||
#endif //__USE_C_FIXEDMUL__
|
||||
|
||||
#ifdef __USE_C_FIXEDDIV__
|
||||
/** \brief The FixedDiv2 function
|
||||
|
||||
\param a fixed_t number
|
||||
\param b fixed_t number
|
||||
|
||||
\return a/b * FRACUNIT
|
||||
|
||||
*/
|
||||
fixed_t FixedDiv2(fixed_t a, fixed_t b)
|
||||
{
|
||||
INT64 ret;
|
||||
|
||||
if (b == 0)
|
||||
I_Error("FixedDiv: divide by zero");
|
||||
|
||||
ret = (((INT64)a * FRACUNIT)) / b;
|
||||
|
||||
if ((ret > INT32_MAX) || (ret < INT32_MIN))
|
||||
I_Error("FixedDiv: divide by zero");
|
||||
return (fixed_t)ret;
|
||||
}
|
||||
|
||||
#endif // __USE_C_FIXEDDIV__
|
||||
|
||||
fixed_t FixedSqrt(fixed_t x)
|
||||
{
|
||||
#ifdef HAVE_SQRT
|
||||
|
||||
+22
-113
@@ -62,126 +62,35 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f)
|
||||
#define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((float)FRACUNIT))
|
||||
|
||||
|
||||
#if defined (__WATCOMC__) && FRACBITS == 16
|
||||
#pragma aux FixedMul = \
|
||||
"imul ebx", \
|
||||
"shrd eax,edx,16" \
|
||||
parm [eax] [ebx] \
|
||||
value [eax] \
|
||||
modify exact [eax edx]
|
||||
/** \brief The FixedMul function
|
||||
|
||||
#pragma aux FixedDiv2 = \
|
||||
"cdq", \
|
||||
"shld edx,eax,16", \
|
||||
"sal eax,16", \
|
||||
"idiv ebx" \
|
||||
parm [eax] [ebx] \
|
||||
value [eax] \
|
||||
modify exact [eax edx]
|
||||
#elif defined (__GNUC__) && defined (__i386__) && !defined (NOASM)
|
||||
// DJGPP, i386 linux, cygwin or mingw
|
||||
FUNCMATH FUNCINLINE static inline fixed_t FixedMul(fixed_t a, fixed_t b) // asm
|
||||
{
|
||||
fixed_t ret;
|
||||
asm
|
||||
(
|
||||
"imull %2;" // a*b
|
||||
"shrdl %3,%%edx,%0;" // shift logical right FRACBITS bits
|
||||
:"=a" (ret) // eax is always the result and the first operand (%0,%1)
|
||||
:"0" (a), "r" (b) // and %2 is what we use imull on with what in %1
|
||||
, "I" (FRACBITS) // %3 holds FRACBITS (normally 16)
|
||||
:"cc", "%edx" // edx and condition codes clobbered
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
\param a fixed_t number
|
||||
\param b fixed_t number
|
||||
|
||||
FUNCMATH FUNCINLINE static inline fixed_t FixedDiv2(fixed_t a, fixed_t b)
|
||||
{
|
||||
fixed_t ret;
|
||||
asm
|
||||
(
|
||||
"movl %1,%%edx;" // these two instructions allow the next two to pair, on the Pentium processor.
|
||||
"sarl $31,%%edx;" // shift arithmetic right 31 on EDX
|
||||
"shldl %3,%1,%%edx;" // DP shift logical left FRACBITS on EDX
|
||||
"sall %3,%0;" // shift arithmetic left FRACBITS on EAX
|
||||
"idivl %2;" // EDX/b = EAX
|
||||
: "=a" (ret)
|
||||
: "0" (a), "r" (b)
|
||||
, "I" (FRACBITS)
|
||||
: "%edx"
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
#elif defined (__GNUC__) && defined (__arm__) && !defined(__thumb__) && !defined(NOASM) //ARMv4 ASM
|
||||
FUNCMATH FUNCINLINE static inline fixed_t FixedMul(fixed_t a, fixed_t b) // let abuse smull
|
||||
{
|
||||
fixed_t ret;
|
||||
asm
|
||||
(
|
||||
"smull %[lo], r1, %[a], %[b];"
|
||||
"mov %[lo], %[lo], lsr %3;"
|
||||
"orr %[lo], %[lo], r1, lsl %3;"
|
||||
: [lo] "=&r" (ret) // rhi, rlo and rm must be distinct registers
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
, "i" (FRACBITS)
|
||||
: "r1"
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
\return a*b>>FRACBITS
|
||||
|
||||
#define __USE_C_FIXEDDIV__ // no double or asm div in ARM land
|
||||
#elif defined (__GNUC__) && defined (__ppc__) && !defined(NOASM) && 0 // WII: PPC CPU
|
||||
FUNCMATH FUNCINLINE static inline fixed_t FixedMul(fixed_t a, fixed_t b) // asm
|
||||
{
|
||||
fixed_t ret, hi, lo;
|
||||
asm
|
||||
(
|
||||
"mullw %0, %2, %3;"
|
||||
"mulhw %1, %2, %3"
|
||||
: "=r" (hi), "=r" (lo)
|
||||
: "r" (a), "r" (b)
|
||||
, "I" (FRACBITS)
|
||||
);
|
||||
ret = (INT64)((hi>>FRACBITS)+lo)<<FRACBITS;
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedMul(fixed_t a, fixed_t b)
|
||||
{
|
||||
// Need to cast to unsigned before shifting to avoid undefined behaviour
|
||||
// for negative integers
|
||||
return (fixed_t)(((UINT64)((INT64)a * b)) >> FRACBITS);
|
||||
}
|
||||
|
||||
#define __USE_C_FIXEDDIV__// Alam: I am lazy
|
||||
#elif defined (__GNUC__) && defined (__mips__) && !defined(NOASM) && 0 // PSP: MIPS CPU
|
||||
FUNCMATH FUNCINLINE static inline fixed_t FixedMul(fixed_t a, fixed_t b) // asm
|
||||
{
|
||||
fixed_t ret;
|
||||
asm
|
||||
(
|
||||
"mult %3, %4;" // a*b=h<32+l
|
||||
: "=r" (ret), "=l" (a), "=h" (b) //todo: abuse shr opcode
|
||||
: "0" (a), "r" (b)
|
||||
, "I" (FRACBITS)
|
||||
//: "+l", "+h"
|
||||
);
|
||||
ret = (INT64)((a>>FRACBITS)+b)<<FRACBITS;
|
||||
return ret;
|
||||
}
|
||||
/** \brief The FixedDiv2 function
|
||||
|
||||
#define __USE_C_FIXEDDIV__ // no 64b asm div in MIPS land
|
||||
#elif defined (__GNUC__) && defined (__sh__) && 0 // DC: SH4 CPU
|
||||
#elif defined (__GNUC__) && defined (__m68k__) && 0 // DEAD: Motorola 6800 CPU
|
||||
#elif defined (_MSC_VER) && defined(USEASM) && FRACBITS == 16
|
||||
// Microsoft Visual C++ (no asm inline)
|
||||
fixed_t __cdecl FixedMul(fixed_t a, fixed_t b);
|
||||
fixed_t __cdecl FixedDiv2(fixed_t a, fixed_t b);
|
||||
#else
|
||||
#define __USE_C_FIXEDMUL__
|
||||
#define __USE_C_FIXEDDIV__
|
||||
#endif
|
||||
\param a fixed_t number
|
||||
\param b fixed_t number
|
||||
|
||||
#ifdef __USE_C_FIXEDMUL__
|
||||
FUNCMATH fixed_t FixedMul(fixed_t a, fixed_t b);
|
||||
#endif
|
||||
\return a/b * FRACUNIT
|
||||
|
||||
#ifdef __USE_C_FIXEDDIV__
|
||||
FUNCMATH fixed_t FixedDiv2(fixed_t a, fixed_t b);
|
||||
#endif
|
||||
*/
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv2(fixed_t a, fixed_t b)
|
||||
{
|
||||
// This does not check for division overflow or division by 0!
|
||||
// That is the caller's responsibility.
|
||||
return (fixed_t)(((INT64)a * FRACUNIT) / b);
|
||||
}
|
||||
|
||||
/** \brief The FixedInt function
|
||||
|
||||
|
||||
-278
@@ -1,278 +0,0 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* File: p5prof.h
|
||||
* By: Kevin Baca
|
||||
*
|
||||
* MODIFIED BY Fab SO THAT RDMSR(...) WRITES EDX : EAX TO A LONG LONG
|
||||
* (WHICH MEANS WRITE THE LOW DWORD FIRST)
|
||||
*
|
||||
* Now in yer code do:
|
||||
* INT64 count,total;
|
||||
*
|
||||
* ...
|
||||
* RDMSR(0x10,&count); //inner loop count
|
||||
* total += count;
|
||||
* ...
|
||||
*
|
||||
* printf("0x%x %x", (INT32)total, *((INT32 *)&total+1));
|
||||
* // HIGH LOW
|
||||
*
|
||||
*********************************************************/
|
||||
/**\file
|
||||
\brief This file provides macros to profile your code.
|
||||
|
||||
Here's how they work...
|
||||
|
||||
As you may or may not know, the Pentium class of
|
||||
processors provides extremely fine grained profiling
|
||||
capabilities through the use of what are called
|
||||
Machine Specific Registers (MSRs). These registers
|
||||
can provide information about almost any aspect of
|
||||
CPU performance down to a single cycle.
|
||||
|
||||
The MSRs of interest for profiling are specified by
|
||||
indices 0x10, 0x11, 0x12, and 0x13. Here is a brief
|
||||
description of each of these registers:
|
||||
|
||||
MSR 0x10
|
||||
This register is simple a cycle counter.
|
||||
|
||||
MSR 0x11
|
||||
This register controls what type of profiling data
|
||||
will be gathered.
|
||||
|
||||
MSRs 0x12 and 0x13
|
||||
These registers gather the profiling data specified in
|
||||
MSR 0x11.
|
||||
|
||||
Each MSR is 64 bits wide. For the Pentium processor,
|
||||
only the lower 32 bits of MSR 0x11 are valid. Bits 0-15
|
||||
specify what data will be gathered in MSR 0x12. Bits 16-31
|
||||
specify what data will be gathered in MSR 0x13. Both sets
|
||||
of bits have the same format:
|
||||
|
||||
Bits 0-5 specify which hardware event will be tracked.
|
||||
Bit 6, if set, indicates events will be tracked in
|
||||
rings 0-2.
|
||||
Bit 7, if set, indicates events will be tracked in
|
||||
ring 3.
|
||||
Bit 8, if set, indicates cycles should be counted for
|
||||
the specified event. If clear, it indicates the
|
||||
number of events should be counted.
|
||||
|
||||
Two instructions are provided for manupulating the MSRs.
|
||||
RDMSR (Read Machine Specific Register) and WRMSR
|
||||
(Write Machine Specific Register). These opcodes were
|
||||
originally undocumented and therefore most assemblers don't
|
||||
recognize them. Their byte codes are provided in the
|
||||
macros below.
|
||||
|
||||
RDMSR takes the MSR index in ecx and the profiling criteria
|
||||
in edx : eax.
|
||||
|
||||
WRMSR takes the MSR index in ecx and returns the profile data
|
||||
in edx : eax.
|
||||
|
||||
Two profiling registers limits profiling capability to
|
||||
gathering only two types of information. The register
|
||||
usage can, however, be combined in interesting ways.
|
||||
For example, you can set one register to gather the
|
||||
number of a specific type of event while the other gathers
|
||||
the number of cycles for the same event. Or you can
|
||||
gather the number of two separate events while using
|
||||
MSR 0x10 to gather the number of cycles.
|
||||
|
||||
The enumerated list provides somewhat readable labels for
|
||||
the types of events that can be tracked.
|
||||
|
||||
For more information, get ahold of appendix H from the
|
||||
Intel Pentium programmer's manual (I don't remember the
|
||||
order number) or go to
|
||||
http://green.kaist.ac.kr/jwhahn/art3.htm.
|
||||
That's an article by Terje Mathisen where I got most of
|
||||
my information.
|
||||
|
||||
You may use this code however you wish. I hope it's
|
||||
useful and I hope I got everything right.
|
||||
|
||||
-Kevin
|
||||
|
||||
kbaca@skygames.com
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#define RDTSC(_dst) \
|
||||
__asm__("
|
||||
.byte 0x0F,0x31
|
||||
movl %%edx,(%%edi)
|
||||
movl %%eax,4(%%edi)"\
|
||||
: : "D" (_dst) : "eax", "edx", "edi")
|
||||
|
||||
// the old code... swapped it
|
||||
// movl %%edx,(%%edi)
|
||||
// movl %%eax,4(%%edi)"
|
||||
#define RDMSR(_msri, _msrd) \
|
||||
__asm__("
|
||||
.byte 0x0F,0x32
|
||||
movl %%eax,(%%edi)
|
||||
movl %%edx,4(%%edi)"\
|
||||
: : "c" (_msri), "D" (_msrd) : "eax", "ecx", "edx", "edi")
|
||||
|
||||
#define WRMSR(_msri, _msrd) \
|
||||
__asm__("
|
||||
xorl %%edx,%%edx
|
||||
.byte 0x0F,0x30"\
|
||||
: : "c" (_msri), "a" (_msrd) : "eax", "ecx", "edx")
|
||||
|
||||
#define RDMSR_0x12_0x13(_msr12, _msr13) \
|
||||
__asm__("
|
||||
movl $0x12,%%ecx
|
||||
.byte 0x0F,0x32
|
||||
movl %%edx,(%%edi)
|
||||
movl %%eax,4(%%edi)
|
||||
movl $0x13,%%ecx
|
||||
.byte 0x0F,0x32
|
||||
movl %%edx,(%%esi)
|
||||
movl %%eax,4(%%esi)"\
|
||||
: : "D" (_msr12), "S" (_msr13) : "eax", "ecx", "edx", "edi")
|
||||
|
||||
#define ZERO_MSR_0x12_0x13() \
|
||||
__asm__("
|
||||
xorl %%edx,%%edx
|
||||
xorl %%eax,%%eax
|
||||
movl $0x12,%%ecx
|
||||
.byte 0x0F,0x30
|
||||
movl $0x13,%%ecx
|
||||
.byte 0x0F,0x30"\
|
||||
: : : "eax", "ecx", "edx")
|
||||
|
||||
#elif defined (__WATCOMC__)
|
||||
|
||||
extern void RDTSC(UINT32 *dst);
|
||||
#pragma aux RDTSC =\
|
||||
"db 0x0F,0x31"\
|
||||
"mov [edi],edx"\
|
||||
"mov [4+edi],eax"\
|
||||
parm [edi]\
|
||||
modify [eax edx edi];
|
||||
|
||||
extern void RDMSR(UINT32 msri, UINT32 *msrd);
|
||||
#pragma aux RDMSR =\
|
||||
"db 0x0F,0x32"\
|
||||
"mov [edi],edx"\
|
||||
"mov [4+edi],eax"\
|
||||
parm [ecx] [edi]\
|
||||
modify [eax ecx edx edi];
|
||||
|
||||
extern void WRMSR(UINT32 msri, UINT32 msrd);
|
||||
#pragma aux WRMSR =\
|
||||
"xor edx,edx"\
|
||||
"db 0x0F,0x30"\
|
||||
parm [ecx] [eax]\
|
||||
modify [eax ecx edx];
|
||||
|
||||
extern void RDMSR_0x12_0x13(UINT32 *msr12, UINT32 *msr13);
|
||||
#pragma aux RDMSR_0x12_0x13 =\
|
||||
"mov ecx,0x12"\
|
||||
"db 0x0F,0x32"\
|
||||
"mov [edi],edx"\
|
||||
"mov [4+edi],eax"\
|
||||
"mov ecx,0x13"\
|
||||
"db 0x0F,0x32"\
|
||||
"mov [esi],edx"\
|
||||
"mov [4+esi],eax"\
|
||||
parm [edi] [esi]\
|
||||
modify [eax ecx edx edi esi];
|
||||
|
||||
extern void ZERO_MSR_0x12_0x13(void);
|
||||
#pragma aux ZERO_MSR_0x12_0x13 =\
|
||||
"xor edx,edx"\
|
||||
"xor eax,eax"\
|
||||
"mov ecx,0x12"\
|
||||
"db 0x0F,0x30"\
|
||||
"mov ecx,0x13"\
|
||||
"db 0x0F,0x30"\
|
||||
modify [eax ecx edx];
|
||||
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DataRead,
|
||||
DataWrite,
|
||||
DataTLBMiss,
|
||||
DataReadMiss,
|
||||
DataWriteMiss,
|
||||
WriteHitEM,
|
||||
DataCacheLinesWritten,
|
||||
DataCacheSnoops,
|
||||
DataCacheSnoopHit,
|
||||
MemAccessBothPipes,
|
||||
BankConflict,
|
||||
MisalignedDataRef,
|
||||
CodeRead,
|
||||
CodeTLBMiss,
|
||||
CodeCacheMiss,
|
||||
SegRegLoad,
|
||||
RESERVED0,
|
||||
RESERVED1,
|
||||
Branch,
|
||||
BTBHit,
|
||||
TakenBranchOrBTBHit,
|
||||
PipelineFlush,
|
||||
InstructionsExeced,
|
||||
InstructionsExecedVPipe,
|
||||
BusUtilizationClocks,
|
||||
PipelineStalledWriteBackup,
|
||||
PipelineStalledDateMemRead,
|
||||
PipeLineStalledWriteEM,
|
||||
LockedBusCycle,
|
||||
IOReadOrWriteCycle,
|
||||
NonCacheableMemRef,
|
||||
AGI,
|
||||
RESERVED2,
|
||||
RESERVED3,
|
||||
FPOperation,
|
||||
Breakpoint0Match,
|
||||
Breakpoint1Match,
|
||||
Breakpoint2Match,
|
||||
Breakpoint3Match,
|
||||
HWInterrupt,
|
||||
DataReadOrWrite,
|
||||
DataReadOrWriteMiss
|
||||
};
|
||||
|
||||
#define PROF_CYCLES (0x100)
|
||||
#define PROF_EVENTS (0x000)
|
||||
#define RING_012 (0x40)
|
||||
#define RING_3 (0x80)
|
||||
#define RING_0123 (RING_012 | RING_3)
|
||||
|
||||
/*void ProfSetProfiles(UINT32 msr12, UINT32 msr13);*/
|
||||
#define ProfSetProfiles(_msr12, _msr13)\
|
||||
{\
|
||||
UINT32 prof;\
|
||||
\
|
||||
prof = (_msr12) | ((_msr13) << 16);\
|
||||
WRMSR(0x11, prof);\
|
||||
}
|
||||
|
||||
/*void ProfBeginProfiles(void);*/
|
||||
#define ProfBeginProfiles()\
|
||||
ZERO_MSR_0x12_0x13();
|
||||
|
||||
/*void ProfGetProfiles(UINT32 msr12[2], UINT32 msr13[2]);*/
|
||||
#define ProfGetProfiles(_msr12, _msr13)\
|
||||
RDMSR_0x12_0x13(_msr12, _msr13);
|
||||
|
||||
/*void ProfZeroTimer(void);*/
|
||||
#define ProfZeroTimer()\
|
||||
WRMSR(0x10, 0);
|
||||
|
||||
/*void ProfReadTimer(UINT32 timer[2]);*/
|
||||
#define ProfReadTimer(timer)\
|
||||
RDMSR(0x10, timer);
|
||||
|
||||
/*EOF*/
|
||||
@@ -144,20 +144,6 @@ void R_DrawColumn_8(void);
|
||||
void R_DrawShadeColumn_8(void);
|
||||
void R_DrawTranslucentColumn_8(void);
|
||||
|
||||
#ifdef USEASM
|
||||
void ASMCALL R_DrawColumn_8_ASM(void);
|
||||
#define R_DrawWallColumn_8_ASM R_DrawColumn_8_ASM
|
||||
void ASMCALL R_DrawShadeColumn_8_ASM(void);
|
||||
void ASMCALL R_DrawTranslucentColumn_8_ASM(void);
|
||||
void ASMCALL R_Draw2sMultiPatchColumn_8_ASM(void);
|
||||
|
||||
void ASMCALL R_DrawColumn_8_MMX(void);
|
||||
#define R_DrawWallColumn_8_MMX R_DrawColumn_8_MMX
|
||||
|
||||
void ASMCALL R_Draw2sMultiPatchColumn_8_MMX(void);
|
||||
void ASMCALL R_DrawSpan_8_MMX(void);
|
||||
#endif
|
||||
|
||||
void R_DrawTranslatedColumn_8(void);
|
||||
void R_DrawTranslatedTranslucentColumn_8(void);
|
||||
void R_DrawSpan_8(void);
|
||||
|
||||
+6
-11
@@ -357,12 +357,11 @@ static void AddInterpolator(levelinterpolator_t* interpolator)
|
||||
levelinterpolators_size *= 2;
|
||||
}
|
||||
|
||||
levelinterpolators = Z_ReallocAlign(
|
||||
levelinterpolators = Z_Realloc(
|
||||
(void*) levelinterpolators,
|
||||
sizeof(levelinterpolator_t*) * levelinterpolators_size,
|
||||
PU_LEVEL,
|
||||
NULL,
|
||||
sizeof(levelinterpolator_t*) * 8
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -372,11 +371,8 @@ static void AddInterpolator(levelinterpolator_t* interpolator)
|
||||
|
||||
static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker)
|
||||
{
|
||||
levelinterpolator_t *ret = (levelinterpolator_t*) Z_CallocAlign(
|
||||
sizeof(levelinterpolator_t),
|
||||
PU_LEVEL,
|
||||
NULL,
|
||||
sizeof(levelinterpolator_t) * 8
|
||||
levelinterpolator_t *ret = (levelinterpolator_t*) Z_Calloc(
|
||||
sizeof(levelinterpolator_t), PU_LEVEL, NULL
|
||||
);
|
||||
|
||||
ret->type = type;
|
||||
@@ -691,12 +687,11 @@ void R_AddMobjInterpolator(mobj_t *mobj)
|
||||
interpolated_mobjs_capacity *= 2;
|
||||
}
|
||||
|
||||
interpolated_mobjs = Z_ReallocAlign(
|
||||
interpolated_mobjs = Z_Realloc(
|
||||
interpolated_mobjs,
|
||||
sizeof(mobj_t *) * interpolated_mobjs_capacity,
|
||||
PU_LEVEL,
|
||||
NULL,
|
||||
64
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,6 @@ static wallsplat_t wallsplats[MAXLEVELSPLATS]; // WALL splats
|
||||
static INT32 freewallsplat;
|
||||
#endif
|
||||
|
||||
#ifdef USEASM
|
||||
/// \brief for floorsplats \note accessed by asm code
|
||||
struct rastery_s *prastertab;
|
||||
#endif
|
||||
|
||||
#ifdef FLOORSPLATS
|
||||
static floorsplat_t floorsplats[1]; // FLOOR splats
|
||||
static INT32 freefloorsplat;
|
||||
@@ -339,12 +334,6 @@ void R_AddVisibleFloorSplats(subsector_t *subsec)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USEASM
|
||||
// tv1, tv2 = x/y qui varie dans la texture, tc = x/y qui est constant.
|
||||
void ASMCALL rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2,
|
||||
INT32 tc, INT32 dir);
|
||||
#endif
|
||||
|
||||
// current test with floor tile
|
||||
//#define FLOORSPLATSOLIDCOLOR
|
||||
|
||||
|
||||
@@ -33,10 +33,6 @@
|
||||
// SRB2Kart
|
||||
#include "r_fps.h" // R_GetFramerateCap
|
||||
|
||||
#if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200))
|
||||
#define RUSEASM //MSC.NET can't patch itself
|
||||
#endif
|
||||
|
||||
// --------------------------------------------
|
||||
// assembly or c drawer routines for 8bpp/16bpp
|
||||
// --------------------------------------------
|
||||
@@ -94,7 +90,6 @@ UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_
|
||||
// Short and Tall sky drawer, for the current color mode
|
||||
void (*walldrawerfunc)(void);
|
||||
|
||||
boolean R_ASM = true;
|
||||
boolean R_486 = false;
|
||||
boolean R_586 = false;
|
||||
boolean R_MMX = false;
|
||||
@@ -132,30 +127,6 @@ void SCR_SetMode(void)
|
||||
walldrawerfunc = R_DrawWallColumn_8;
|
||||
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8;
|
||||
twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8;
|
||||
#ifdef RUSEASM
|
||||
if (R_ASM)
|
||||
{
|
||||
if (R_MMX)
|
||||
{
|
||||
//colfunc = basecolfunc = R_DrawColumn_8_MMX; Can we please not use this function it seems to break sometimes????
|
||||
colfunc = basecolfunc = R_DrawColumn_8_ASM;
|
||||
//shadecolfunc = R_DrawShadeColumn_8_ASM;
|
||||
//fuzzcolfunc = R_DrawTranslucentColumn_8_ASM;
|
||||
//walldrawerfunc = R_DrawWallColumn_8_MMX; This is just an alias to R_DrawColumn_8_MMX
|
||||
walldrawerfunc = R_DrawWallColumn_8_ASM;
|
||||
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_MMX;
|
||||
spanfunc = basespanfunc = R_DrawSpan_8_MMX;
|
||||
}
|
||||
else
|
||||
{
|
||||
colfunc = basecolfunc = R_DrawColumn_8_ASM;
|
||||
//shadecolfunc = R_DrawShadeColumn_8_ASM;
|
||||
//fuzzcolfunc = R_DrawTranslucentColumn_8_ASM;
|
||||
walldrawerfunc = R_DrawWallColumn_8_ASM;
|
||||
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_ASM;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* else if (vid.bpp > 1)
|
||||
{
|
||||
@@ -204,8 +175,6 @@ void SCR_Startup(void)
|
||||
CONS_Printf("CPU Info: 486: %i, 586: %i, MMX: %i, 3DNow: %i, MMXExt: %i, SSE2: %i\n", R_486, R_586, R_MMX, R_3DNow, R_MMXExt, R_SSE2);
|
||||
}
|
||||
|
||||
if (M_CheckParm("-noASM"))
|
||||
R_ASM = false;
|
||||
if (M_CheckParm("-486"))
|
||||
R_486 = true;
|
||||
if (M_CheckParm("-586"))
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
NOHW=1
|
||||
NOHS=1
|
||||
NOASM=1
|
||||
|
||||
OPTS+=-DLINUX
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ endif
|
||||
#
|
||||
ifdef SOLARIS
|
||||
NOIPX=1
|
||||
NOASM=1
|
||||
OPTS+=-DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
|
||||
OPTS+=-I/usr/local/include -I/opt/sfw/include
|
||||
LDFLAGS+=-L/opt/sfw/lib
|
||||
|
||||
@@ -38,13 +38,6 @@ endif
|
||||
endif
|
||||
|
||||
|
||||
#use the x86 asm code
|
||||
ifndef CYGWIN32
|
||||
ifndef NOASM
|
||||
USEASM=1
|
||||
endif
|
||||
endif
|
||||
|
||||
OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o
|
||||
|
||||
OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL
|
||||
|
||||
@@ -67,40 +67,6 @@ char logfilename[1024];
|
||||
typedef BOOL (WINAPI *p_IsDebuggerPresent)(VOID);
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
static inline VOID MakeCodeWritable(VOID)
|
||||
{
|
||||
#ifdef USEASM // Disable write-protection of code segment
|
||||
DWORD OldRights;
|
||||
const DWORD NewRights = PAGE_EXECUTE_READWRITE;
|
||||
PBYTE pBaseOfImage = (PBYTE)GetModuleHandle(NULL);
|
||||
PIMAGE_DOS_HEADER dosH =(PIMAGE_DOS_HEADER)pBaseOfImage;
|
||||
PIMAGE_NT_HEADERS ntH = (PIMAGE_NT_HEADERS)(pBaseOfImage + dosH->e_lfanew);
|
||||
PIMAGE_OPTIONAL_HEADER oH = (PIMAGE_OPTIONAL_HEADER)
|
||||
((PBYTE)ntH + sizeof (IMAGE_NT_SIGNATURE) + sizeof (IMAGE_FILE_HEADER));
|
||||
LPVOID pA = pBaseOfImage+oH->BaseOfCode;
|
||||
SIZE_T pS = oH->SizeOfCode;
|
||||
#if 1 // try to find the text section
|
||||
PIMAGE_SECTION_HEADER ntS = IMAGE_FIRST_SECTION (ntH);
|
||||
WORD s;
|
||||
for (s = 0; s < ntH->FileHeader.NumberOfSections; s++)
|
||||
{
|
||||
if (memcmp (ntS[s].Name, ".text\0\0", 8) == 0)
|
||||
{
|
||||
pA = pBaseOfImage+ntS[s].VirtualAddress;
|
||||
pS = ntS[s].Misc.VirtualSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!VirtualProtect(pA,pS,NewRights,&OldRights))
|
||||
I_Error("Could not make code writable\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
static void
|
||||
ChDirToExe (void)
|
||||
@@ -177,7 +143,6 @@ int main(int argc, char **argv)
|
||||
ExcHndlInit();
|
||||
}
|
||||
}
|
||||
MakeCodeWritable();
|
||||
#endif
|
||||
|
||||
// startup SRB2
|
||||
|
||||
-1587
File diff suppressed because it is too large.
Load diff
-322
@@ -1,322 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file tmap_asm.s
|
||||
/// \brief ???
|
||||
|
||||
//.comm _dc_colormap,4
|
||||
//.comm _dc_x,4
|
||||
//.comm _dc_yl,4
|
||||
//.comm _dc_yh,4
|
||||
//.comm _dc_iscale,4
|
||||
//.comm _dc_texturemid,4
|
||||
//.comm _dc_source,4
|
||||
//.comm _ylookup,4
|
||||
//.comm _columnofs,4
|
||||
//.comm _loopcount,4
|
||||
//.comm _pixelcount,4
|
||||
.data
|
||||
_pixelcount:
|
||||
.long 0x00000000
|
||||
_loopcount:
|
||||
.long 0x00000000
|
||||
.align 8
|
||||
_mmxcomm:
|
||||
.long 0x00000000
|
||||
.text
|
||||
|
||||
.align 4
|
||||
.globl _R_DrawColumn8_NOMMX
|
||||
_R_DrawColumn8_NOMMX:
|
||||
pushl %ebp
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl _dc_yl,%edx
|
||||
movl _dc_yh,%eax
|
||||
subl %edx,%eax
|
||||
leal 1(%eax),%ebx
|
||||
testl %ebx,%ebx
|
||||
jle rdc8ndone
|
||||
movl _dc_x,%eax
|
||||
movl _ylookup, %edi
|
||||
movl (%edi,%edx,4),%esi
|
||||
movl _columnofs, %edi
|
||||
addl (%edi,%eax,4),%esi
|
||||
movl _dc_iscale,%edi
|
||||
movl %edx,%eax
|
||||
imull %edi,%eax
|
||||
movl _dc_texturemid,%ecx
|
||||
addl %eax,%ecx
|
||||
|
||||
movl _dc_source,%ebp
|
||||
xorl %edx, %edx
|
||||
subl $0x12345678, %esi
|
||||
.globl rdc8nwidth1
|
||||
rdc8nwidth1:
|
||||
.align 4,0x90
|
||||
rdc8nloop:
|
||||
movl %ecx,%eax
|
||||
shrl $16,%eax
|
||||
addl %edi,%ecx
|
||||
andl $127,%eax
|
||||
addl $0x12345678,%esi
|
||||
.globl rdc8nwidth2
|
||||
rdc8nwidth2:
|
||||
movb (%eax,%ebp),%dl
|
||||
movl _dc_colormap,%eax
|
||||
movb (%eax,%edx),%al
|
||||
movb %al,(%esi)
|
||||
decl %ebx
|
||||
jne rdc8nloop
|
||||
rdc8ndone:
|
||||
popl %ebx
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
//
|
||||
// Optimised specifically for P54C/P55C (aka Pentium with/without MMX)
|
||||
// By ES 1998/08/01
|
||||
//
|
||||
|
||||
.globl _R_DrawColumn_8_Pentium
|
||||
_R_DrawColumn_8_Pentium:
|
||||
pushl %ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl _dc_yl,%eax // Top pixel
|
||||
movl _dc_yh,%ebx // Bottom pixel
|
||||
movl _ylookup, %edi
|
||||
movl (%edi,%ebx,4),%ecx
|
||||
subl %eax,%ebx // ebx=number of pixels-1
|
||||
jl rdc8pdone // no pixel to draw, done
|
||||
jnz rdc8pmany
|
||||
movl _dc_x,%edx // Special case: only one pixel
|
||||
movl _columnofs, %edi
|
||||
addl (%edi,%edx,4),%ecx // dest pixel at (%ecx)
|
||||
movl _dc_iscale,%esi
|
||||
imull %esi,%eax
|
||||
movl _dc_texturemid,%edi
|
||||
addl %eax,%edi // texture index in edi
|
||||
movl _dc_colormap,%edx
|
||||
shrl $16, %edi
|
||||
movl _dc_source,%ebp
|
||||
andl $127,%edi
|
||||
movb (%edi,%ebp),%dl // read texture pixel
|
||||
movb (%edx),%al // lookup for light
|
||||
movb %al,0(%ecx) // write it
|
||||
jmp rdc8pdone // done!
|
||||
.align 4, 0x90
|
||||
rdc8pmany: // draw >1 pixel
|
||||
movl _dc_x,%edx
|
||||
movl _columnofs, %edi
|
||||
movl (%edi,%edx,4),%edx
|
||||
leal 0x12345678(%edx, %ecx), %edi // edi = two pixels above bottom
|
||||
.globl rdc8pwidth5
|
||||
rdc8pwidth5: // DeadBeef = -2*SCREENWIDTH
|
||||
movl _dc_iscale,%edx // edx = fracstep
|
||||
imull %edx,%eax
|
||||
shll $9, %edx // fixme: Should get 7.25 fix as input
|
||||
movl _dc_texturemid,%ecx
|
||||
addl %eax,%ecx // ecx = frac
|
||||
movl _dc_colormap,%eax // eax = lighting/special effects LUT
|
||||
shll $9, %ecx
|
||||
movl _dc_source,%esi // esi = source ptr
|
||||
|
||||
imull $0x12345678, %ebx // ebx = negative offset to pixel
|
||||
.globl rdc8pwidth6
|
||||
rdc8pwidth6: // DeadBeef = -SCREENWIDTH
|
||||
|
||||
// Begin the calculation of the two first pixels
|
||||
leal (%ecx, %edx), %ebp
|
||||
shrl $25, %ecx
|
||||
movb (%esi, %ecx), %al
|
||||
leal (%edx, %ebp), %ecx
|
||||
shrl $25, %ebp
|
||||
movb (%eax), %dl
|
||||
|
||||
// The main loop
|
||||
rdc8ploop:
|
||||
movb (%esi,%ebp), %al // load 1
|
||||
leal (%ecx, %edx), %ebp // calc frac 3
|
||||
|
||||
shrl $25, %ecx // shift frac 2
|
||||
movb %dl, 0x12345678(%edi, %ebx)// store 0
|
||||
.globl rdc8pwidth1
|
||||
rdc8pwidth1: // DeadBeef = 2*SCREENWIDTH
|
||||
|
||||
movb (%eax), %al // lookup 1
|
||||
|
||||
movb %al, 0x12345678(%edi, %ebx)// store 1
|
||||
.globl rdc8pwidth2
|
||||
rdc8pwidth2: // DeadBeef = 3*SCREENWIDTH
|
||||
movb (%esi, %ecx), %al // load 2
|
||||
|
||||
leal (%ebp, %edx), %ecx // calc frac 4
|
||||
|
||||
shrl $25, %ebp // shift frac 3
|
||||
movb (%eax), %dl // lookup 2
|
||||
|
||||
addl $0x12345678, %ebx // counter
|
||||
.globl rdc8pwidth3
|
||||
rdc8pwidth3: // DeadBeef = 2*SCREENWIDTH
|
||||
jl rdc8ploop // loop
|
||||
|
||||
// End of loop. Write extra pixel or just exit.
|
||||
jnz rdc8pdone
|
||||
movb %dl, 0x12345678(%edi, %ebx)// Write odd pixel
|
||||
.globl rdc8pwidth4
|
||||
rdc8pwidth4: // DeadBeef = 2*SCREENWIDTH
|
||||
|
||||
rdc8pdone:
|
||||
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
//
|
||||
// MMX asm version, optimised for K6
|
||||
// By ES 1998/07/05
|
||||
//
|
||||
|
||||
.globl _R_DrawColumn_8_K6_MMX
|
||||
_R_DrawColumn_8_K6_MMX:
|
||||
pushl %ebp
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
|
||||
movl %esp, %eax // Push 8 or 12, so that (%esp) gets aligned by 8
|
||||
andl $7,%eax
|
||||
addl $8,%eax
|
||||
movl %eax, _mmxcomm // Temp storage in mmxcomm: (%esp) is used instead
|
||||
subl %eax,%esp
|
||||
|
||||
movl _dc_yl,%edx // Top pixel
|
||||
movl _dc_yh,%ebx // Bottom pixel
|
||||
movl _ylookup, %edi
|
||||
movl (%edi,%ebx,4),%ecx
|
||||
subl %edx,%ebx // ebx=number of pixels-1
|
||||
jl 0x12345678 // no pixel to draw, done
|
||||
.globl rdc8moffs1
|
||||
rdc8moffs1:
|
||||
jnz rdc8mmany
|
||||
movl _dc_x,%eax // Special case: only one pixel
|
||||
movl _columnofs, %edi
|
||||
addl (%edi,%eax,4),%ecx // dest pixel at (%ecx)
|
||||
movl _dc_iscale,%esi
|
||||
imull %esi,%edx
|
||||
movl _dc_texturemid,%edi
|
||||
addl %edx,%edi // texture index in edi
|
||||
movl _dc_colormap,%edx
|
||||
shrl $16, %edi
|
||||
movl _dc_source,%ebp
|
||||
andl $127,%edi
|
||||
movb (%edi,%ebp),%dl // read texture pixel
|
||||
movb (%edx),%al // lookup for light
|
||||
movb %al,0(%ecx) // write it
|
||||
jmp rdc8mdone // done!
|
||||
.globl rdc8moffs2
|
||||
rdc8moffs2:
|
||||
.align 4, 0x90
|
||||
rdc8mmany: // draw >1 pixel
|
||||
movl _dc_x,%eax
|
||||
movl _columnofs, %edi
|
||||
movl (%edi,%eax,4),%eax
|
||||
leal 0x12345678(%eax, %ecx), %esi // esi = two pixels above bottom
|
||||
.globl rdc8mwidth3
|
||||
rdc8mwidth3: // DeadBeef = -2*SCREENWIDTH
|
||||
movl _dc_iscale,%ecx // ecx = fracstep
|
||||
imull %ecx,%edx
|
||||
shll $9, %ecx // fixme: Should get 7.25 fix as input
|
||||
movl _dc_texturemid,%eax
|
||||
addl %edx,%eax // eax = frac
|
||||
movl _dc_colormap,%edx // edx = lighting/special effects LUT
|
||||
shll $9, %eax
|
||||
leal (%ecx, %ecx), %edi
|
||||
movl _dc_source,%ebp // ebp = source ptr
|
||||
movl %edi, 0(%esp) // Start moving frac and fracstep to MMX regs
|
||||
|
||||
imull $0x12345678, %ebx // ebx = negative offset to pixel
|
||||
.globl rdc8mwidth5
|
||||
rdc8mwidth5: // DeadBeef = -SCREENWIDTH
|
||||
|
||||
movl %edi, 4(%esp)
|
||||
leal (%eax, %ecx), %edi
|
||||
movq 0(%esp), %mm1 // fracstep:fracstep in mm1
|
||||
movl %eax, 0(%esp)
|
||||
shrl $25, %eax
|
||||
movl %edi, 4(%esp)
|
||||
movzbl (%ebp, %eax), %eax
|
||||
movq 0(%esp), %mm0 // frac:frac in mm0
|
||||
|
||||
paddd %mm1, %mm0
|
||||
shrl $25, %edi
|
||||
movq %mm0, %mm2
|
||||
psrld $25, %mm2 // texture index in mm2
|
||||
paddd %mm1, %mm0
|
||||
movq %mm2, 0(%esp)
|
||||
|
||||
.globl rdc8mloop
|
||||
rdc8mloop: // The main loop
|
||||
movq %mm0, %mm2 // move 4-5 to temp reg
|
||||
movzbl (%ebp, %edi), %edi // read 1
|
||||
|
||||
psrld $25, %mm2 // shift 4-5
|
||||
movb (%edx,%eax), %cl // lookup 0
|
||||
|
||||
movl 0(%esp), %eax // load 2
|
||||
addl $0x12345678, %ebx // counter
|
||||
.globl rdc8mwidth2
|
||||
rdc8mwidth2: // DeadBeef = 2*SCREENWIDTH
|
||||
|
||||
movb %cl, (%esi, %ebx) // write 0
|
||||
movb (%edx,%edi), %ch // lookup 1
|
||||
|
||||
movb %ch, 0x12345678(%esi, %ebx) // write 1
|
||||
.globl rdc8mwidth1
|
||||
rdc8mwidth1: // DeadBeef = SCREENWIDTH
|
||||
movl 4(%esp), %edi // load 3
|
||||
|
||||
paddd %mm1, %mm0 // frac 6-7
|
||||
movzbl (%ebp, %eax), %eax // lookup 2
|
||||
|
||||
movq %mm2, 0(%esp) // store texture index 4-5
|
||||
jl rdc8mloop
|
||||
|
||||
jnz rdc8mno_odd
|
||||
movb (%edx,%eax), %cl // write the last odd pixel
|
||||
movb %cl, 0x12345678(%esi)
|
||||
.globl rdc8mwidth4
|
||||
rdc8mwidth4: // DeadBeef = 2*SCREENWIDTH
|
||||
rdc8mno_odd:
|
||||
|
||||
.globl rdc8mdone
|
||||
rdc8mdone:
|
||||
emms
|
||||
|
||||
addl _mmxcomm, %esp
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebx
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
// Need some extra space to align run-time
|
||||
.globl R_DrawColumn_8_K6_MMX_end
|
||||
R_DrawColumn_8_K6_MMX_end:
|
||||
nop;nop;nop;nop;nop;nop;nop;nop;
|
||||
nop;nop;nop;nop;nop;nop;nop;nop;
|
||||
nop;nop;nop;nop;nop;nop;nop;nop;
|
||||
nop;nop;nop;nop;nop;nop;nop;
|
||||
@@ -1,674 +0,0 @@
|
||||
;; SONIC ROBO BLAST 2
|
||||
;;-----------------------------------------------------------------------------
|
||||
;; Copyright (C) 1998-2000 by DOSDOOM.
|
||||
;; Copyright (C) 2010-2018 by Sonic Team Junior.
|
||||
;;
|
||||
;; This program is free software distributed under the
|
||||
;; terms of the GNU General Public License, version 2.
|
||||
;; See the 'LICENSE' file for more details.
|
||||
;;-----------------------------------------------------------------------------
|
||||
;; FILE:
|
||||
;; tmap_mmx.nas
|
||||
;; DESCRIPTION:
|
||||
;; Assembler optimised rendering code for software mode, using SIMD
|
||||
;; instructions.
|
||||
;; Draw wall columns.
|
||||
|
||||
|
||||
[BITS 32]
|
||||
|
||||
%define FRACBITS 16
|
||||
%define TRANSPARENTPIXEL 247
|
||||
|
||||
%ifdef LINUX
|
||||
%macro cextern 1
|
||||
[extern %1]
|
||||
%endmacro
|
||||
|
||||
%macro cglobal 1
|
||||
[global %1]
|
||||
%endmacro
|
||||
|
||||
%else
|
||||
%macro cextern 1
|
||||
%define %1 _%1
|
||||
[extern %1]
|
||||
%endmacro
|
||||
|
||||
%macro cglobal 1
|
||||
%define %1 _%1
|
||||
[global %1]
|
||||
%endmacro
|
||||
|
||||
%endif
|
||||
|
||||
|
||||
; The viddef_s structure. We only need the width field.
|
||||
struc viddef_s
|
||||
resb 12
|
||||
.width: resb 4
|
||||
resb 44
|
||||
endstruc
|
||||
|
||||
|
||||
;; externs
|
||||
;; columns
|
||||
cextern dc_colormap
|
||||
cextern dc_x
|
||||
cextern dc_yl
|
||||
cextern dc_yh
|
||||
cextern dc_iscale
|
||||
cextern dc_texturemid
|
||||
cextern dc_texheight
|
||||
cextern dc_source
|
||||
cextern dc_hires
|
||||
cextern centery
|
||||
cextern centeryfrac
|
||||
cextern dc_transmap
|
||||
|
||||
cextern R_DrawColumn_8_ASM
|
||||
cextern R_Draw2sMultiPatchColumn_8_ASM
|
||||
|
||||
;; spans
|
||||
cextern nflatshiftup
|
||||
cextern nflatxshift
|
||||
cextern nflatyshift
|
||||
cextern nflatmask
|
||||
cextern ds_xfrac
|
||||
cextern ds_yfrac
|
||||
cextern ds_xstep
|
||||
cextern ds_ystep
|
||||
cextern ds_x1
|
||||
cextern ds_x2
|
||||
cextern ds_y
|
||||
cextern ds_source
|
||||
cextern ds_colormap
|
||||
|
||||
cextern ylookup
|
||||
cextern columnofs
|
||||
cextern vid
|
||||
|
||||
[SECTION .data]
|
||||
|
||||
nflatmask64 dq 0
|
||||
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
;;----------------------------------------------------------------------
|
||||
;;
|
||||
;; R_DrawColumn : 8bpp column drawer
|
||||
;;
|
||||
;; MMX column drawer.
|
||||
;;
|
||||
;;----------------------------------------------------------------------
|
||||
;; eax = accumulator
|
||||
;; ebx = colormap
|
||||
;; ecx = count
|
||||
;; edx = accumulator
|
||||
;; esi = source
|
||||
;; edi = dest
|
||||
;; ebp = vid.width
|
||||
;; mm0 = accumulator
|
||||
;; mm1 = heightmask, twice
|
||||
;; mm2 = 2 * fracstep, twice
|
||||
;; mm3 = pair of consecutive fracs
|
||||
;;----------------------------------------------------------------------
|
||||
|
||||
|
||||
cglobal R_DrawColumn_8_MMX
|
||||
R_DrawColumn_8_MMX:
|
||||
push ebp ;; preserve caller's stack frame pointer
|
||||
push esi ;; preserve register variables
|
||||
push edi
|
||||
push ebx
|
||||
|
||||
;;
|
||||
;; Our algorithm requires that the texture height be a power of two.
|
||||
;; If not, fall back to the non-MMX drawer.
|
||||
;;
|
||||
.texheightcheck:
|
||||
mov edx, [dc_texheight]
|
||||
sub edx, 1 ;; edx = heightmask
|
||||
test edx, [dc_texheight]
|
||||
jnz near .usenonMMX
|
||||
|
||||
mov ebp, edx ;; Keep a copy of heightmask in a
|
||||
;; GPR for the time being.
|
||||
|
||||
;;
|
||||
;; Fill mm1 with heightmask
|
||||
;;
|
||||
movd mm1, edx ;; low dword = heightmask
|
||||
punpckldq mm1, mm1 ;; copy low dword to high dword
|
||||
|
||||
;;
|
||||
;; dest = ylookup[dc_yl] + columnofs[dc_x];
|
||||
;;
|
||||
mov eax, [dc_yl]
|
||||
mov edi, [ylookup+eax*4]
|
||||
mov ebx, [dc_x]
|
||||
add edi, [columnofs+ebx*4] ;; edi = dest
|
||||
|
||||
|
||||
;;
|
||||
;; pixelcount = yh - yl + 1
|
||||
;;
|
||||
mov ecx, [dc_yh]
|
||||
add ecx, 1
|
||||
sub ecx, eax ;; pixel count
|
||||
jle near .done ;; nothing to scale
|
||||
|
||||
;;
|
||||
;; fracstep = dc_iscale;
|
||||
;;
|
||||
movd mm2, [dc_iscale] ;; fracstep in low dword
|
||||
punpckldq mm2, mm2 ;; copy to high dword
|
||||
|
||||
mov ebx, [dc_colormap]
|
||||
mov esi, [dc_source]
|
||||
|
||||
;;
|
||||
;; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep));
|
||||
;;
|
||||
;; eax == dc_yl already
|
||||
shl eax, FRACBITS
|
||||
sub eax, [centeryfrac]
|
||||
imul dword [dc_iscale]
|
||||
shrd eax, edx, FRACBITS
|
||||
add eax, [dc_texturemid]
|
||||
|
||||
;;
|
||||
;; if (dc_hires) frac = 0;
|
||||
;;
|
||||
test byte [dc_hires], 0x01
|
||||
jz .mod2
|
||||
xor eax, eax
|
||||
|
||||
|
||||
;;
|
||||
;; Do mod-2 pixel.
|
||||
;;
|
||||
.mod2:
|
||||
test ecx, 1
|
||||
jz .pairprepare
|
||||
mov edx, eax ;; edx = frac
|
||||
add eax, [dc_iscale] ;; eax += fracstep
|
||||
sar edx, FRACBITS
|
||||
and edx, ebp ;; edx &= heightmask
|
||||
movzx edx, byte [esi + edx]
|
||||
movzx edx, byte [ebx + edx]
|
||||
mov [edi], dl
|
||||
|
||||
add edi, [vid + viddef_s.width]
|
||||
sub ecx, 1
|
||||
jz .done
|
||||
|
||||
.pairprepare:
|
||||
;;
|
||||
;; Prepare for the main loop.
|
||||
;;
|
||||
movd mm3, eax ;; Low dword = frac
|
||||
movq mm4, mm3 ;; Copy to intermediate register
|
||||
paddd mm4, mm2 ;; dwords of mm4 += fracstep
|
||||
punpckldq mm3, mm4 ;; Low dword = first frac, high = second
|
||||
pslld mm2, 1 ;; fracstep *= 2
|
||||
|
||||
;;
|
||||
;; ebp = vid.width
|
||||
;;
|
||||
mov ebp, [vid + viddef_s.width]
|
||||
|
||||
align 16
|
||||
.pairloop:
|
||||
movq mm0, mm3 ;; 3B 1u.
|
||||
psrad mm0, FRACBITS ;; 4B 1u.
|
||||
pand mm0, mm1 ;; 3B 1u. frac &= heightmask
|
||||
paddd mm3, mm2 ;; 3B 1u. frac += fracstep
|
||||
|
||||
movd eax, mm0 ;; 3B 1u. Get first frac
|
||||
;; IFETCH boundary
|
||||
movzx eax, byte [esi + eax] ;; 4B 1u. Texture map
|
||||
movzx eax, byte [ebx + eax] ;; 4B 1u. Colormap
|
||||
|
||||
punpckhdq mm0, mm0 ;; 3B 1(2)u. low dword = high dword
|
||||
movd edx, mm0 ;; 3B 1u. Get second frac
|
||||
mov [edi], al ;; 2B 1(2)u. First pixel
|
||||
;; IFETCH boundary
|
||||
|
||||
movzx edx, byte [esi + edx] ;; 4B 1u. Texture map
|
||||
movzx edx, byte [ebx + edx] ;; 4B 1u. Colormap
|
||||
mov [edi + 1*ebp], dl ;; 3B 1(2)u. Second pixel
|
||||
|
||||
lea edi, [edi + 2*ebp] ;; 3B 1u. edi += 2 * vid.width
|
||||
;; IFETCH boundary
|
||||
sub ecx, 2 ;; 3B 1u. count -= 2
|
||||
jnz .pairloop ;; 2B 1u. if(count != 0) goto .pairloop
|
||||
|
||||
|
||||
.done:
|
||||
;;
|
||||
;; Clear MMX state, or else FPU operations will go badly awry.
|
||||
;;
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
.usenonMMX:
|
||||
call R_DrawColumn_8_ASM
|
||||
jmp .done
|
||||
|
||||
|
||||
;;----------------------------------------------------------------------
|
||||
;;
|
||||
;; R_Draw2sMultiPatchColumn : Like R_DrawColumn, but omits transparent
|
||||
;; pixels.
|
||||
;;
|
||||
;; MMX column drawer.
|
||||
;;
|
||||
;;----------------------------------------------------------------------
|
||||
;; eax = accumulator
|
||||
;; ebx = colormap
|
||||
;; ecx = count
|
||||
;; edx = accumulator
|
||||
;; esi = source
|
||||
;; edi = dest
|
||||
;; ebp = vid.width
|
||||
;; mm0 = accumulator
|
||||
;; mm1 = heightmask, twice
|
||||
;; mm2 = 2 * fracstep, twice
|
||||
;; mm3 = pair of consecutive fracs
|
||||
;;----------------------------------------------------------------------
|
||||
|
||||
|
||||
cglobal R_Draw2sMultiPatchColumn_8_MMX
|
||||
R_Draw2sMultiPatchColumn_8_MMX:
|
||||
push ebp ;; preserve caller's stack frame pointer
|
||||
push esi ;; preserve register variables
|
||||
push edi
|
||||
push ebx
|
||||
|
||||
;;
|
||||
;; Our algorithm requires that the texture height be a power of two.
|
||||
;; If not, fall back to the non-MMX drawer.
|
||||
;;
|
||||
.texheightcheck:
|
||||
mov edx, [dc_texheight]
|
||||
sub edx, 1 ;; edx = heightmask
|
||||
test edx, [dc_texheight]
|
||||
jnz near .usenonMMX
|
||||
|
||||
mov ebp, edx ;; Keep a copy of heightmask in a
|
||||
;; GPR for the time being.
|
||||
|
||||
;;
|
||||
;; Fill mm1 with heightmask
|
||||
;;
|
||||
movd mm1, edx ;; low dword = heightmask
|
||||
punpckldq mm1, mm1 ;; copy low dword to high dword
|
||||
|
||||
;;
|
||||
;; dest = ylookup[dc_yl] + columnofs[dc_x];
|
||||
;;
|
||||
mov eax, [dc_yl]
|
||||
mov edi, [ylookup+eax*4]
|
||||
mov ebx, [dc_x]
|
||||
add edi, [columnofs+ebx*4] ;; edi = dest
|
||||
|
||||
|
||||
;;
|
||||
;; pixelcount = yh - yl + 1
|
||||
;;
|
||||
mov ecx, [dc_yh]
|
||||
add ecx, 1
|
||||
sub ecx, eax ;; pixel count
|
||||
jle near .done ;; nothing to scale
|
||||
;;
|
||||
;; fracstep = dc_iscale;
|
||||
;;
|
||||
movd mm2, [dc_iscale] ;; fracstep in low dword
|
||||
punpckldq mm2, mm2 ;; copy to high dword
|
||||
|
||||
mov ebx, [dc_colormap]
|
||||
mov esi, [dc_source]
|
||||
|
||||
;;
|
||||
;; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep));
|
||||
;;
|
||||
;; eax == dc_yl already
|
||||
shl eax, FRACBITS
|
||||
sub eax, [centeryfrac]
|
||||
imul dword [dc_iscale]
|
||||
shrd eax, edx, FRACBITS
|
||||
add eax, [dc_texturemid]
|
||||
|
||||
;;
|
||||
;; if (dc_hires) frac = 0;
|
||||
;;
|
||||
test byte [dc_hires], 0x01
|
||||
jz .mod2
|
||||
xor eax, eax
|
||||
|
||||
|
||||
;;
|
||||
;; Do mod-2 pixel.
|
||||
;;
|
||||
.mod2:
|
||||
test ecx, 1
|
||||
jz .pairprepare
|
||||
mov edx, eax ;; edx = frac
|
||||
add eax, [dc_iscale] ;; eax += fracstep
|
||||
sar edx, FRACBITS
|
||||
and edx, ebp ;; edx &= heightmask
|
||||
movzx edx, byte [esi + edx]
|
||||
cmp dl, TRANSPARENTPIXEL
|
||||
je .nextmod2
|
||||
movzx edx, byte [ebx + edx]
|
||||
mov [edi], dl
|
||||
|
||||
.nextmod2:
|
||||
add edi, [vid + viddef_s.width]
|
||||
sub ecx, 1
|
||||
jz .done
|
||||
|
||||
.pairprepare:
|
||||
;;
|
||||
;; Prepare for the main loop.
|
||||
;;
|
||||
movd mm3, eax ;; Low dword = frac
|
||||
movq mm4, mm3 ;; Copy to intermediate register
|
||||
paddd mm4, mm2 ;; dwords of mm4 += fracstep
|
||||
punpckldq mm3, mm4 ;; Low dword = first frac, high = second
|
||||
pslld mm2, 1 ;; fracstep *= 2
|
||||
|
||||
;;
|
||||
;; ebp = vid.width
|
||||
;;
|
||||
mov ebp, [vid + viddef_s.width]
|
||||
|
||||
align 16
|
||||
.pairloop:
|
||||
movq mm0, mm3 ;; 3B 1u.
|
||||
psrad mm0, FRACBITS ;; 4B 1u.
|
||||
pand mm0, mm1 ;; 3B 1u. frac &= heightmask
|
||||
paddd mm3, mm2 ;; 3B 1u. frac += fracstep
|
||||
|
||||
movd eax, mm0 ;; 3B 1u. Get first frac
|
||||
;; IFETCH boundary
|
||||
movzx eax, byte [esi + eax] ;; 4B 1u. Texture map
|
||||
punpckhdq mm0, mm0 ;; 3B 1(2)u. low dword = high dword
|
||||
movd edx, mm0 ;; 3B 1u. Get second frac
|
||||
cmp al, TRANSPARENTPIXEL ;; 2B 1u.
|
||||
je .secondinpair ;; 2B 1u.
|
||||
;; IFETCH boundary
|
||||
movzx eax, byte [ebx + eax] ;; 4B 1u. Colormap
|
||||
mov [edi], al ;; 2B 1(2)u. First pixel
|
||||
|
||||
.secondinpair:
|
||||
movzx edx, byte [esi + edx] ;; 4B 1u. Texture map
|
||||
cmp dl, TRANSPARENTPIXEL ;; 2B 1u.
|
||||
je .nextpair ;; 2B 1u.
|
||||
;; IFETCH boundary
|
||||
movzx edx, byte [ebx + edx] ;; 4B 1u. Colormap
|
||||
mov [edi + 1*ebp], dl ;; 3B 1(2)u. Second pixel
|
||||
|
||||
.nextpair:
|
||||
lea edi, [edi + 2*ebp] ;; 3B 1u. edi += 2 * vid.width
|
||||
sub ecx, 2 ;; 3B 1u. count -= 2
|
||||
jnz .pairloop ;; 2B 1u. if(count != 0) goto .pairloop
|
||||
|
||||
|
||||
.done:
|
||||
;;
|
||||
;; Clear MMX state, or else FPU operations will go badly awry.
|
||||
;;
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
.usenonMMX:
|
||||
call R_Draw2sMultiPatchColumn_8_ASM
|
||||
jmp .done
|
||||
|
||||
|
||||
;;----------------------------------------------------------------------
|
||||
;;
|
||||
;; R_DrawSpan : 8bpp span drawer
|
||||
;;
|
||||
;; MMX span drawer.
|
||||
;;
|
||||
;;----------------------------------------------------------------------
|
||||
;; eax = accumulator
|
||||
;; ebx = colormap
|
||||
;; ecx = count
|
||||
;; edx = accumulator
|
||||
;; esi = source
|
||||
;; edi = dest
|
||||
;; ebp = two pixels
|
||||
;; mm0 = accumulator
|
||||
;; mm1 = xposition
|
||||
;; mm2 = yposition
|
||||
;; mm3 = 2 * xstep
|
||||
;; mm4 = 2 * ystep
|
||||
;; mm5 = nflatxshift
|
||||
;; mm6 = nflatyshift
|
||||
;; mm7 = accumulator
|
||||
;;----------------------------------------------------------------------
|
||||
|
||||
cglobal R_DrawSpan_8_MMX
|
||||
R_DrawSpan_8_MMX:
|
||||
push ebp ;; preserve caller's stack frame pointer
|
||||
push esi ;; preserve register variables
|
||||
push edi
|
||||
push ebx
|
||||
|
||||
;;
|
||||
;; esi = ds_source
|
||||
;; ebx = ds_colormap
|
||||
;;
|
||||
mov esi, [ds_source]
|
||||
mov ebx, [ds_colormap]
|
||||
|
||||
;;
|
||||
;; edi = ylookup[ds_y] + columnofs[ds_x1]
|
||||
;;
|
||||
mov eax, [ds_y]
|
||||
mov edi, [ylookup + eax*4]
|
||||
mov edx, [ds_x1]
|
||||
add edi, [columnofs + edx*4]
|
||||
|
||||
;;
|
||||
;; ecx = ds_x2 - ds_x1 + 1
|
||||
;;
|
||||
mov ecx, [ds_x2]
|
||||
sub ecx, edx
|
||||
add ecx, 1
|
||||
|
||||
;;
|
||||
;; Needed for fracs and steps
|
||||
;;
|
||||
movd mm7, [nflatshiftup]
|
||||
|
||||
;;
|
||||
;; mm3 = xstep
|
||||
;;
|
||||
movd mm3, [ds_xstep]
|
||||
pslld mm3, mm7
|
||||
punpckldq mm3, mm3
|
||||
|
||||
;;
|
||||
;; mm4 = ystep
|
||||
;;
|
||||
movd mm4, [ds_ystep]
|
||||
pslld mm4, mm7
|
||||
punpckldq mm4, mm4
|
||||
|
||||
;;
|
||||
;; mm1 = pair of consecutive xpositions
|
||||
;;
|
||||
movd mm1, [ds_xfrac]
|
||||
pslld mm1, mm7
|
||||
movq mm6, mm1
|
||||
paddd mm6, mm3
|
||||
punpckldq mm1, mm6
|
||||
|
||||
;;
|
||||
;; mm2 = pair of consecutive ypositions
|
||||
;;
|
||||
movd mm2, [ds_yfrac]
|
||||
pslld mm2, mm7
|
||||
movq mm6, mm2
|
||||
paddd mm6, mm4
|
||||
punpckldq mm2, mm6
|
||||
|
||||
;;
|
||||
;; mm5 = nflatxshift
|
||||
;; mm6 = nflatyshift
|
||||
;;
|
||||
movd mm5, [nflatxshift]
|
||||
movd mm6, [nflatyshift]
|
||||
|
||||
;;
|
||||
;; Mask is in memory due to lack of registers.
|
||||
;;
|
||||
mov eax, [nflatmask]
|
||||
mov [nflatmask64], eax
|
||||
mov [nflatmask64 + 4], eax
|
||||
|
||||
|
||||
;;
|
||||
;; Go until we reach a dword boundary.
|
||||
;;
|
||||
.unaligned:
|
||||
test edi, 3
|
||||
jz .alignedprep
|
||||
.stragglers:
|
||||
cmp ecx, 0
|
||||
je .done ;; If ecx == 0, we're finished.
|
||||
|
||||
;;
|
||||
;; eax = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)
|
||||
;;
|
||||
movq mm0, mm1 ;; mm0 = xposition
|
||||
movq mm7, mm2 ;; mm7 = yposition
|
||||
paddd mm1, mm3 ;; xposition += xstep (once!)
|
||||
paddd mm2, mm4 ;; yposition += ystep (once!)
|
||||
psrld mm0, mm5 ;; shift
|
||||
psrld mm7, mm6 ;; shift
|
||||
pand mm7, [nflatmask64] ;; mask
|
||||
por mm0, mm7 ;; or x and y together
|
||||
|
||||
movd eax, mm0 ;; eax = index of first pixel
|
||||
movzx eax, byte [esi + eax] ;; al = source[eax]
|
||||
movzx eax, byte [ebx + eax] ;; al = colormap[al]
|
||||
|
||||
mov [edi], al
|
||||
add edi, 1
|
||||
|
||||
sub ecx, 1
|
||||
jmp .unaligned
|
||||
|
||||
|
||||
.alignedprep:
|
||||
;;
|
||||
;; We can double the steps now.
|
||||
;;
|
||||
pslld mm3, 1
|
||||
pslld mm4, 1
|
||||
|
||||
|
||||
;;
|
||||
;; Generate chunks of four pixels.
|
||||
;;
|
||||
.alignedloop:
|
||||
|
||||
;;
|
||||
;; Make sure we have at least four pixels.
|
||||
;;
|
||||
cmp ecx, 4
|
||||
jl .prestragglers
|
||||
|
||||
;;
|
||||
;; First two pixels.
|
||||
;;
|
||||
movq mm0, mm1 ;; mm0 = xposition
|
||||
movq mm7, mm2 ;; mm7 = yposition
|
||||
paddd mm1, mm3 ;; xposition += xstep
|
||||
paddd mm2, mm4 ;; yposition += ystep
|
||||
psrld mm0, mm5 ;; shift
|
||||
psrld mm7, mm6 ;; shift
|
||||
pand mm7, [nflatmask64] ;; mask
|
||||
por mm0, mm7 ;; or x and y together
|
||||
|
||||
movd eax, mm0 ;; eax = index of first pixel
|
||||
movzx eax, byte [esi + eax] ;; al = source[eax]
|
||||
movzx ebp, byte [ebx + eax] ;; ebp = colormap[al]
|
||||
|
||||
punpckhdq mm0, mm0 ;; both dwords = high dword
|
||||
movd eax, mm0 ;; eax = index of second pixel
|
||||
movzx eax, byte [esi + eax] ;; al = source[eax]
|
||||
movzx eax, byte [ebx + eax] ;; al = colormap[al]
|
||||
shl eax, 8 ;; get pixel in right byte
|
||||
or ebp, eax ;; put pixel in ebp
|
||||
|
||||
;;
|
||||
;; Next two pixels.
|
||||
;;
|
||||
movq mm0, mm1 ;; mm0 = xposition
|
||||
movq mm7, mm2 ;; mm7 = yposition
|
||||
paddd mm1, mm3 ;; xposition += xstep
|
||||
paddd mm2, mm4 ;; yposition += ystep
|
||||
psrld mm0, mm5 ;; shift
|
||||
psrld mm7, mm6 ;; shift
|
||||
pand mm7, [nflatmask64] ;; mask
|
||||
por mm0, mm7 ;; or x and y together
|
||||
|
||||
movd eax, mm0 ;; eax = index of third pixel
|
||||
movzx eax, byte [esi + eax] ;; al = source[eax]
|
||||
movzx eax, byte [ebx + eax] ;; al = colormap[al]
|
||||
shl eax, 16 ;; get pixel in right byte
|
||||
or ebp, eax ;; put pixel in ebp
|
||||
|
||||
punpckhdq mm0, mm0 ;; both dwords = high dword
|
||||
movd eax, mm0 ;; eax = index of second pixel
|
||||
movzx eax, byte [esi + eax] ;; al = source[eax]
|
||||
movzx eax, byte [ebx + eax] ;; al = colormap[al]
|
||||
shl eax, 24 ;; get pixel in right byte
|
||||
or ebp, eax ;; put pixel in ebp
|
||||
|
||||
;;
|
||||
;; Write pixels.
|
||||
;;
|
||||
mov [edi], ebp
|
||||
add edi, 4
|
||||
|
||||
sub ecx, 4
|
||||
jmp .alignedloop
|
||||
|
||||
.prestragglers:
|
||||
;;
|
||||
;; Back to one step at a time.
|
||||
;;
|
||||
psrad mm3, 1
|
||||
psrad mm4, 1
|
||||
jmp .stragglers
|
||||
|
||||
.done:
|
||||
;;
|
||||
;; Clear MMX state, or else FPU operations will go badly awry.
|
||||
;;
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
@@ -1,48 +0,0 @@
|
||||
;; SONIC ROBO BLAST 2
|
||||
;;-----------------------------------------------------------------------------
|
||||
;; Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
;; Copyright (C) 1999-2018 by Sonic Team Junior.
|
||||
;;
|
||||
;; This program is free software distributed under the
|
||||
;; terms of the GNU General Public License, version 2.
|
||||
;; See the 'LICENSE' file for more details.
|
||||
;;-----------------------------------------------------------------------------
|
||||
;; FILE:
|
||||
;; tmap_vc.nas
|
||||
;; DESCRIPTION:
|
||||
;; Assembler optimised math code for Visual C++.
|
||||
|
||||
|
||||
[BITS 32]
|
||||
|
||||
%macro cglobal 1
|
||||
%define %1 _%1
|
||||
[global %1]
|
||||
%endmacro
|
||||
|
||||
[SECTION .text write]
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;fixed_t FixedMul (fixed_t a, fixed_t b)
|
||||
;----------------------------------------------------------------------------
|
||||
cglobal FixedMul
|
||||
; align 16
|
||||
FixedMul:
|
||||
mov eax,[esp+4]
|
||||
imul dword [esp+8]
|
||||
shrd eax,edx,16
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;fixed_t FixedDiv2 (fixed_t a, fixed_t b);
|
||||
;----------------------------------------------------------------------------
|
||||
cglobal FixedDiv2
|
||||
; align 16
|
||||
FixedDiv2:
|
||||
mov eax,[esp+4]
|
||||
mov edx,eax ;; these two instructions allow the next
|
||||
sar edx,31 ;; two to pair, on the Pentium processor.
|
||||
shld edx,eax,16
|
||||
sal eax,16
|
||||
idiv dword [esp+8]
|
||||
ret
|
||||
@@ -285,27 +285,17 @@ static void CV_Gammaxxx_ONChange(void)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (__GNUC__) && defined (__i386__) && !defined (NOASM) && !defined (__APPLE__) && !defined (NORUSEASM)
|
||||
void VID_BlitLinearScreen_ASM(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes,
|
||||
size_t destrowbytes);
|
||||
#define HAVE_VIDCOPY
|
||||
#endif
|
||||
|
||||
static void CV_constextsize_OnChange(void)
|
||||
{
|
||||
con_recalc = true;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Copy a rectangular area from one bitmap to another (8bpp)
|
||||
// --------------------------------------------------------------------------
|
||||
void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes,
|
||||
size_t destrowbytes)
|
||||
{
|
||||
#ifdef HAVE_VIDCOPY
|
||||
VID_BlitLinearScreen_ASM(srcptr,destptr,width,height,srcrowbytes,destrowbytes);
|
||||
#else
|
||||
if ((srcrowbytes == destrowbytes) && (srcrowbytes == (size_t)width))
|
||||
M_Memcpy(destptr, srcptr, srcrowbytes * height);
|
||||
else
|
||||
@@ -318,7 +308,6 @@ void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT3
|
||||
srcptr += srcrowbytes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file vid_copy.s
|
||||
/// \brief code for updating the linear frame buffer screen.
|
||||
|
||||
#include "asm_defs.inc" // structures, must match the C structures!
|
||||
|
||||
// DJGPPv2 is as fast as this one, but then someone may compile with a less
|
||||
// good version of DJGPP than mine, so this little asm will do the trick!
|
||||
|
||||
#define srcptr 4+16
|
||||
#define destptr 8+16
|
||||
#define width 12+16
|
||||
#define height 16+16
|
||||
#define srcrowbytes 20+16
|
||||
#define destrowbytes 24+16
|
||||
|
||||
// VID_BlitLinearScreen( src, dest, width, height, srcwidth, destwidth );
|
||||
// width is given as BYTES
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
.globl C(VID_BlitLinearScreen_ASM)
|
||||
C(VID_BlitLinearScreen_ASM):
|
||||
pushl %ebp // preserve caller's stack frame
|
||||
pushl %edi
|
||||
pushl %esi // preserve register variables
|
||||
pushl %ebx
|
||||
|
||||
cld
|
||||
movl srcptr(%esp),%esi
|
||||
movl destptr(%esp),%edi
|
||||
movl width(%esp),%ebx
|
||||
movl srcrowbytes(%esp),%eax
|
||||
subl %ebx,%eax
|
||||
movl destrowbytes(%esp),%edx
|
||||
subl %ebx,%edx
|
||||
shrl $2,%ebx
|
||||
movl height(%esp),%ebp
|
||||
LLRowLoop:
|
||||
movl %ebx,%ecx
|
||||
rep/movsl (%esi),(%edi)
|
||||
addl %eax,%esi
|
||||
addl %edx,%edi
|
||||
decl %ebp
|
||||
jnz LLRowLoop
|
||||
|
||||
popl %ebx // restore register variables
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp // restore the caller's stack frame
|
||||
|
||||
ret
|
||||
#endif
|
||||
@@ -33,10 +33,6 @@ endif
|
||||
SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
|
||||
endif
|
||||
|
||||
ifndef NOASM
|
||||
USEASM=1
|
||||
endif
|
||||
|
||||
ifndef NONET
|
||||
ifndef MINGW64 #miniupnc is broken with MINGW64
|
||||
HAVE_MINIUPNPC=1
|
||||
|
||||
+234
-232
@@ -1,7 +1,7 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2006 by Graue.
|
||||
// Copyright (C) 2006-2018 by Sonic Team Junior.
|
||||
// Copyright (C) 2006-2023 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_patch.h"
|
||||
#include "i_system.h" // I_GetFreeMem
|
||||
#include "i_video.h" // rendermode
|
||||
#include "z_zone.h"
|
||||
@@ -49,27 +50,11 @@ static boolean Z_calloc = false;
|
||||
//#define ZDEBUG2
|
||||
#endif
|
||||
|
||||
struct memblock_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct memblock_s *block; // Describing this memory
|
||||
UINT32 id; // Should be ZONEID
|
||||
} ATTRPACK memhdr_t;
|
||||
|
||||
// Some code might want aligned memory. Assume it wants memory n bytes
|
||||
// aligned -- then we allocate n-1 extra bytes and return a pointer to
|
||||
// the first byte aligned as requested.
|
||||
// Thus, "real" is the pointer we get from malloc() and will free()
|
||||
// later, but "hdr" is where the memhdr_t starts.
|
||||
// For non-aligned allocations they will be the same.
|
||||
typedef struct memblock_s
|
||||
{
|
||||
void *real;
|
||||
memhdr_t *hdr;
|
||||
|
||||
void **user;
|
||||
INT32 tag; // purgelevel
|
||||
UINT32 id; // Should be ZONEID
|
||||
|
||||
size_t size; // including the header and blocks
|
||||
size_t realsize; // size of real data only
|
||||
@@ -80,64 +65,31 @@ typedef struct memblock_s
|
||||
#endif
|
||||
|
||||
struct memblock_s *next, *prev;
|
||||
} ATTRPACK memblock_t;
|
||||
} memblock_t;
|
||||
|
||||
#ifdef ZDEBUG
|
||||
#define Ptr2Memblock(s, f) Ptr2Memblock2(s, f, __FILE__, __LINE__)
|
||||
static memblock_t *Ptr2Memblock2(void *ptr, const char* func, const char *file, INT32 line)
|
||||
#else
|
||||
static memblock_t *Ptr2Memblock(void *ptr, const char* func)
|
||||
#endif
|
||||
{
|
||||
memhdr_t *hdr;
|
||||
memblock_t *block;
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
#ifdef ZDEBUG2
|
||||
CONS_Printf("%s %s:%d\n", func, file, line);
|
||||
#endif
|
||||
|
||||
hdr = (memhdr_t *)((UINT8 *)ptr - sizeof *hdr);
|
||||
|
||||
#ifdef VALGRIND_MAKE_MEM_DEFINED
|
||||
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
|
||||
#endif
|
||||
|
||||
#ifdef VALGRIND_MEMPOOL_EXISTS
|
||||
if (!VALGRIND_MEMPOOL_EXISTS(hdr->block))
|
||||
{
|
||||
#ifdef ZDEBUG
|
||||
I_Error("%s: bad memblock from %s:%d", func, file, line);
|
||||
#else
|
||||
I_Error("%s: bad memblock", func);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
if (hdr->id != ZONEID)
|
||||
{
|
||||
#ifdef ZDEBUG
|
||||
I_Error("%s: wrong id from %s:%d", func, file, line);
|
||||
#else
|
||||
I_Error("%s: wrong id", func);
|
||||
#endif
|
||||
}
|
||||
block = hdr->block;
|
||||
#ifdef VALGRIND_MAKE_MEM_NOACCESS
|
||||
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
|
||||
#endif
|
||||
return block;
|
||||
|
||||
}
|
||||
#define MEMORY(x) (void *)((uintptr_t)(x) + sizeof(memblock_t))
|
||||
#define MEMBLOCK(x) (memblock_t *)((uintptr_t)(x) - sizeof(memblock_t))
|
||||
|
||||
// both the head and tail of the zone memory block list
|
||||
static memblock_t head;
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
static void Command_Memfree_f(void);
|
||||
#ifdef ZDEBUG
|
||||
static void Command_Memdump_f(void);
|
||||
#endif
|
||||
|
||||
// --------------------------
|
||||
// Zone memory initialisation
|
||||
// --------------------------
|
||||
|
||||
/** Initialises zone memory.
|
||||
* Used at game startup.
|
||||
*
|
||||
* \sa I_GetFreeMem, Command_Memfree_f, Command_Memdump_f
|
||||
*/
|
||||
void Z_Init(void)
|
||||
{
|
||||
size_t total, memfree;
|
||||
@@ -157,6 +109,17 @@ void Z_Init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ----------------------
|
||||
// Zone memory allocation
|
||||
// ----------------------
|
||||
|
||||
/** Frees allocated memory.
|
||||
*
|
||||
* \param ptr A pointer to allocated memory,
|
||||
* assumed to have been allocated with Z_Malloc/Z_Calloc.
|
||||
* \sa Z_FreeTags
|
||||
*/
|
||||
#ifdef ZDEBUG
|
||||
void Z_Free2(void *ptr, const char *file, INT32 line)
|
||||
#else
|
||||
@@ -172,10 +135,14 @@ void Z_Free(void *ptr)
|
||||
CONS_Debug(DBG_MEMORY, "Z_Free %s:%d\n", file, line);
|
||||
#endif
|
||||
|
||||
block = MEMBLOCK(ptr);
|
||||
#ifdef PARANOIA
|
||||
if (block->id != ZONEID)
|
||||
#ifdef ZDEBUG
|
||||
block = Ptr2Memblock2(ptr, "Z_Free", file, line);
|
||||
I_Error("Z_Free at %s:%d: wrong id", file, line);
|
||||
#else
|
||||
block = Ptr2Memblock(ptr, "Z_Free");
|
||||
I_Error("Z_Free: wrong id");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ZDEBUG
|
||||
@@ -183,11 +150,9 @@ void Z_Free(void *ptr)
|
||||
CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
// anything that isn't by lua gets passed to lua just in case.
|
||||
if (block->tag != PU_LUA)
|
||||
LUA_InvalidateUserdata(ptr);
|
||||
#endif
|
||||
|
||||
// TODO: if zdebugging, make sure no other block has a user
|
||||
// that is about to be freed.
|
||||
@@ -196,21 +161,27 @@ void Z_Free(void *ptr)
|
||||
if (block->user != NULL)
|
||||
*block->user = NULL;
|
||||
|
||||
// Free the memory and get rid of the block.
|
||||
free(block->real);
|
||||
block->prev->next = block->next;
|
||||
block->next->prev = block->prev;
|
||||
free(block);
|
||||
#ifdef VALGRIND_DESTROY_MEMPOOL
|
||||
VALGRIND_DESTROY_MEMPOOL(block);
|
||||
#endif
|
||||
block->prev->next = block->next;
|
||||
block->next->prev = block->prev;
|
||||
free(block);
|
||||
}
|
||||
|
||||
// malloc() that doesn't accept failure.
|
||||
/** malloc() that doesn't accept failure.
|
||||
*
|
||||
* \param size Amount of memory to be allocated, in bytes.
|
||||
* \return A pointer to the allocated memory.
|
||||
*/
|
||||
static void *xm(size_t size)
|
||||
{
|
||||
const size_t padedsize = size+sizeof (size_t);
|
||||
void *p = malloc(padedsize);
|
||||
void *p;
|
||||
|
||||
if (padedsize < size)/* overflow check */
|
||||
I_Error("You are allocating memory too large!");
|
||||
p = malloc(padedsize);
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
@@ -220,10 +191,6 @@ static void *xm(size_t size)
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
#if defined (_NDS) | defined (_PSP)
|
||||
// Temporary-ish debugging measure
|
||||
Command_Memfree_f();
|
||||
#endif
|
||||
I_Error("Out of memory allocating %s bytes", sizeu1(size));
|
||||
}
|
||||
}
|
||||
@@ -231,10 +198,18 @@ static void *xm(size_t size)
|
||||
return p;
|
||||
}
|
||||
|
||||
// Z_Malloc
|
||||
// You can pass Z_Malloc() a NULL user if the tag is less than
|
||||
// PU_PURGELEVEL.
|
||||
|
||||
/** The Z_MallocAlign function.
|
||||
* Allocates a block of memory, adds it to a linked list so we can keep track of it.
|
||||
*
|
||||
* \param size Amount of memory to be allocated, in bytes.
|
||||
* \param tag Purge tag.
|
||||
* \param user The address of a pointer to the memory to be allocated.
|
||||
* When the memory is freed by Z_Free later,
|
||||
* the pointer at this address will then be automatically set to NULL.
|
||||
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
|
||||
* \note You can pass Z_Malloc() a NULL user if the tag is less than PU_PURGELEVEL.
|
||||
* \sa Z_CallocAlign, Z_ReallocAlign
|
||||
*/
|
||||
#ifdef ZDEBUG
|
||||
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
|
||||
const char *file, INT32 line)
|
||||
@@ -242,75 +217,67 @@ void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
|
||||
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
|
||||
#endif
|
||||
{
|
||||
size_t extrabytes = (1<<alignbits) - 1;
|
||||
size_t padsize = 0;
|
||||
memblock_t *block;
|
||||
void *ptr;
|
||||
memhdr_t *hdr;
|
||||
void *given;
|
||||
size_t blocksize = extrabytes + sizeof *hdr + size;
|
||||
(void)(alignbits); // no longer used, so silence warnings.
|
||||
|
||||
#ifdef ZDEBUG2
|
||||
CONS_Debug(DBG_MEMORY, "Z_Malloc %s:%d\n", file, line);
|
||||
#endif
|
||||
|
||||
block = xm(sizeof *block);
|
||||
block = xm(sizeof (memblock_t) + size);
|
||||
ptr = MEMORY(block);
|
||||
I_Assert((intptr_t)ptr % sizeof (void *) == 0);
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
padsize += (1<<sizeof(size_t))*2;
|
||||
#endif
|
||||
ptr = xm(blocksize + padsize*2);
|
||||
|
||||
// This horrible calculation makes sure that "given" is aligned
|
||||
// properly.
|
||||
given = (void *)((size_t)((UINT8 *)ptr + extrabytes + sizeof *hdr + padsize/2)
|
||||
& ~extrabytes);
|
||||
|
||||
// The mem header lives 'sizeof (memhdr_t)' bytes before given.
|
||||
hdr = (memhdr_t *)((UINT8 *)given - sizeof *hdr);
|
||||
|
||||
#ifdef VALGRIND_CREATE_MEMPOOL
|
||||
VALGRIND_CREATE_MEMPOOL(block, padsize, Z_calloc);
|
||||
Z_calloc = false;
|
||||
#endif
|
||||
#ifdef VALGRIND_MEMPOOL_ALLOC
|
||||
VALGRIND_MEMPOOL_ALLOC(block, hdr, size + sizeof *hdr);
|
||||
#endif
|
||||
|
||||
block->next = head.next;
|
||||
block->prev = &head;
|
||||
head.next = block;
|
||||
block->next->prev = block;
|
||||
|
||||
block->real = ptr;
|
||||
block->hdr = hdr;
|
||||
block->tag = tag;
|
||||
block->user = NULL;
|
||||
#ifdef ZDEBUG
|
||||
block->ownerline = line;
|
||||
block->ownerfile = file;
|
||||
#endif
|
||||
block->size = blocksize;
|
||||
block->size = sizeof (memblock_t) + size;
|
||||
block->realsize = size;
|
||||
|
||||
hdr->id = ZONEID;
|
||||
hdr->block = block;
|
||||
|
||||
#ifdef VALGRIND_MAKE_MEM_NOACCESS
|
||||
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
|
||||
#ifdef VALGRIND_CREATE_MEMPOOL
|
||||
VALGRIND_CREATE_MEMPOOL(block, size, Z_calloc);
|
||||
#endif
|
||||
|
||||
block->id = ZONEID;
|
||||
|
||||
if (user != NULL)
|
||||
{
|
||||
block->user = user;
|
||||
*(void **)user = given;
|
||||
*(void **)user = ptr;
|
||||
}
|
||||
else if (tag >= PU_PURGELEVEL)
|
||||
I_Error("Z_Malloc: attempted to allocate purgable block "
|
||||
"(size %s) with no user", sizeu1(size));
|
||||
|
||||
return given;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/** The Z_CallocAlign function.
|
||||
* Allocates a block of memory, adds it to a linked list so we can keep track of it.
|
||||
* Unlike Z_MallocAlign, this also initialises the bytes to zero.
|
||||
*
|
||||
* \param size Amount of memory to be allocated, in bytes.
|
||||
* \param tag Purge tag.
|
||||
* \param user The address of a pointer to the memory to be allocated.
|
||||
* When the memory is freed by Z_Free later,
|
||||
* the pointer at this address will then be automatically set to NULL.
|
||||
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
|
||||
* \note You can pass Z_Calloc() a NULL user if the tag is less than PU_PURGELEVEL.
|
||||
* \sa Z_MallocAlign, Z_ReallocAlign
|
||||
*/
|
||||
#ifdef ZDEBUG
|
||||
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line)
|
||||
#else
|
||||
@@ -327,10 +294,26 @@ void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
|
||||
#endif
|
||||
}
|
||||
|
||||
/** The Z_ReallocAlign function.
|
||||
* Reallocates a block of memory with a new size.
|
||||
*
|
||||
* \param ptr A pointer to allocated memory,
|
||||
* assumed to have been allocated with Z_Malloc/Z_Calloc.
|
||||
* If NULL, this function instead acts as a wrapper for Z_CallocAlign.
|
||||
* \param size New size of memory block, in bytes.
|
||||
* If zero, then the memory is freed and NULL is returned.
|
||||
* \param tag New purge tag.
|
||||
* \param user The address of a pointer to the memory to be reallocated.
|
||||
* This can be a different user to the one originally assigned to the memory block.
|
||||
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
|
||||
* \return A pointer to the reallocated memory. Can be NULL if memory was freed.
|
||||
* \note You can pass Z_Realloc() a NULL user if the tag is less than PU_PURGELEVEL.
|
||||
* \sa Z_MallocAlign, Z_CallocAlign
|
||||
*/
|
||||
#ifdef ZDEBUG
|
||||
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line)
|
||||
#else
|
||||
void *Z_ReallocAlign(void *ptr, size_t size,INT32 tag, void *user, INT32 alignbits)
|
||||
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits)
|
||||
#endif
|
||||
{
|
||||
void *rez;
|
||||
@@ -356,10 +339,14 @@ void *Z_ReallocAlign(void *ptr, size_t size,INT32 tag, void *user, INT32 alignb
|
||||
#endif
|
||||
}
|
||||
|
||||
block = MEMBLOCK(ptr);
|
||||
#ifdef PARANOIA
|
||||
if (block->id != ZONEID)
|
||||
#ifdef ZDEBUG
|
||||
block = Ptr2Memblock2(ptr, "Z_Realloc", file, line);
|
||||
I_Error("Z_ReallocAlign at %s:%d: wrong id", file, line);
|
||||
#else
|
||||
block = Ptr2Memblock(ptr, "Z_Realloc");
|
||||
I_Error("Z_ReallocAlign: wrong id");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (block == NULL)
|
||||
@@ -397,6 +384,11 @@ void *Z_ReallocAlign(void *ptr, size_t size,INT32 tag, void *user, INT32 alignb
|
||||
return rez;
|
||||
}
|
||||
|
||||
/** Frees all memory for a given set of tags.
|
||||
*
|
||||
* \param lowtag The lowest tag to consider.
|
||||
* \param hightag The highest tag to consider.
|
||||
*/
|
||||
void Z_FreeTags(INT32 lowtag, INT32 hightag)
|
||||
{
|
||||
memblock_t *block, *next;
|
||||
@@ -405,28 +397,57 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag)
|
||||
for (block = head.next; block != &head; block = next)
|
||||
{
|
||||
next = block->next; // get link before freeing
|
||||
|
||||
if (block->tag >= lowtag && block->tag <= hightag)
|
||||
Z_Free((UINT8 *)block->hdr + sizeof *block->hdr);
|
||||
Z_Free(MEMORY(block));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Z_CheckMemCleanup
|
||||
//
|
||||
// TODO: Currently blocks >= PU_PURGELEVEL are freed every
|
||||
// CLEANUPCOUNT. It might be better to keep track of
|
||||
// the total size of all purgable memory and free it when the
|
||||
// size exceeds some value.
|
||||
//
|
||||
// This was in Z_Malloc, but was freeing data at
|
||||
// unsafe times. Now it is only called when it is safe
|
||||
// to cleanup memory.
|
||||
/** Iterates through all memory for a given set of tags.
|
||||
*
|
||||
* \param lowtag The lowest tag to consider.
|
||||
* \param hightag The highest tag to consider.
|
||||
* \param iterfunc The iterator function.
|
||||
*/
|
||||
void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *))
|
||||
{
|
||||
memblock_t *block, *next;
|
||||
|
||||
if (!iterfunc)
|
||||
I_Error("Z_IterateTags: no iterator function was given");
|
||||
|
||||
for (block = head.next; block != &head; block = next)
|
||||
{
|
||||
next = block->next; // get link before possibly freeing
|
||||
|
||||
if (block->tag >= lowtag && block->tag <= hightag)
|
||||
{
|
||||
void *mem = MEMORY(block);
|
||||
boolean free = iterfunc(mem);
|
||||
if (free)
|
||||
Z_Free(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------
|
||||
// Utility functions
|
||||
// -----------------
|
||||
|
||||
// starting value of nextcleanup
|
||||
#define CLEANUPCOUNT 2000
|
||||
|
||||
// number of function calls left before next cleanup
|
||||
static INT32 nextcleanup = CLEANUPCOUNT;
|
||||
|
||||
/** This was in Z_Malloc, but was freeing data at
|
||||
* unsafe times. Now it is only called when it is safe
|
||||
* to cleanup memory.
|
||||
*
|
||||
* \todo Currently blocks >= PU_PURGELEVEL are freed every
|
||||
* CLEANUPCOUNT. It might be better to keep track of
|
||||
* the total size of all purgable memory and free it when the
|
||||
* size exceeds some value.
|
||||
*/
|
||||
void Z_CheckMemCleanup(void)
|
||||
{
|
||||
if (nextcleanup-- == 0)
|
||||
@@ -445,15 +466,13 @@ void Z_CheckMemCleanup(void)
|
||||
void Z_CheckHeap(INT32 i)
|
||||
{
|
||||
memblock_t *block;
|
||||
memhdr_t *hdr;
|
||||
UINT32 blocknumon = 0;
|
||||
void *given;
|
||||
|
||||
for (block = head.next; block != &head; block = block->next)
|
||||
{
|
||||
blocknumon++;
|
||||
hdr = block->hdr;
|
||||
given = (UINT8 *)hdr + sizeof *hdr;
|
||||
given = MEMORY(block);
|
||||
#ifdef ZDEBUG2
|
||||
CONS_Debug(DBG_MEMORY, "block %u owned by %s:%d\n",
|
||||
blocknumon, block->ownerfile, block->ownerline);
|
||||
@@ -469,7 +488,7 @@ void Z_CheckHeap(INT32 i)
|
||||
#ifdef ZDEBUG
|
||||
, block->ownerfile, block->ownerline
|
||||
#endif
|
||||
);
|
||||
);
|
||||
}
|
||||
#endif
|
||||
if (block->user != NULL && *(block->user) != given)
|
||||
@@ -482,7 +501,7 @@ void Z_CheckHeap(INT32 i)
|
||||
#ifdef ZDEBUG
|
||||
, block->ownerfile, block->ownerline
|
||||
#endif
|
||||
);
|
||||
);
|
||||
}
|
||||
if (block->next->prev != block)
|
||||
{
|
||||
@@ -494,7 +513,7 @@ void Z_CheckHeap(INT32 i)
|
||||
#ifdef ZDEBUG
|
||||
, block->ownerfile, block->ownerline
|
||||
#endif
|
||||
);
|
||||
);
|
||||
}
|
||||
if (block->prev->next != block)
|
||||
{
|
||||
@@ -506,25 +525,9 @@ void Z_CheckHeap(INT32 i)
|
||||
#ifdef ZDEBUG
|
||||
, block->ownerfile, block->ownerline
|
||||
#endif
|
||||
);
|
||||
);
|
||||
}
|
||||
#ifdef VALGRIND_MAKE_MEM_DEFINED
|
||||
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
|
||||
#endif
|
||||
if (hdr->block != block)
|
||||
{
|
||||
I_Error("Z_CheckHeap %d: block %u"
|
||||
#ifdef ZDEBUG
|
||||
"(owned by %s:%d)"
|
||||
#endif
|
||||
" doesn't have linkback from allocated memory",
|
||||
i, blocknumon
|
||||
#ifdef ZDEBUG
|
||||
, block->ownerfile, block->ownerline
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (hdr->id != ZONEID)
|
||||
if (block->id != ZONEID)
|
||||
{
|
||||
I_Error("Z_CheckHeap %d: block %u"
|
||||
#ifdef ZDEBUG
|
||||
@@ -534,50 +537,37 @@ void Z_CheckHeap(INT32 i)
|
||||
#ifdef ZDEBUG
|
||||
, block->ownerfile, block->ownerline
|
||||
#endif
|
||||
);
|
||||
);
|
||||
}
|
||||
#ifdef VALGRIND_MAKE_MEM_NOACCESS
|
||||
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Zone memory modification
|
||||
// ------------------------
|
||||
|
||||
/** Changes a memory block's purge tag.
|
||||
*
|
||||
* \param ptr A pointer to allocated memory,
|
||||
* assumed to have been allocated with Z_Malloc/Z_Calloc.
|
||||
* \param tag The new tag.
|
||||
* \sa Z_SetUser
|
||||
*/
|
||||
#ifdef PARANOIA
|
||||
void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line)
|
||||
#else
|
||||
void Z_ChangeTag2(void *ptr, INT32 tag)
|
||||
void Z_ChangeTag(void *ptr, INT32 tag)
|
||||
#endif
|
||||
{
|
||||
memblock_t *block;
|
||||
memhdr_t *hdr;
|
||||
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
hdr = (memhdr_t *)((UINT8 *)ptr - sizeof *hdr);
|
||||
block = MEMBLOCK(ptr);
|
||||
|
||||
#ifdef VALGRIND_MAKE_MEM_DEFINED
|
||||
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
|
||||
#endif
|
||||
|
||||
#ifdef VALGRIND_MEMPOOL_EXISTS
|
||||
if (!VALGRIND_MEMPOOL_EXISTS(hdr->block))
|
||||
{
|
||||
#ifdef PARANOIA
|
||||
I_Error("Z_CT at %s:%d: bad memblock", file, line);
|
||||
#else
|
||||
I_Error("Z_CT: bad memblock");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef PARANOIA
|
||||
if (hdr->id != ZONEID) I_Error("Z_CT at %s:%d: wrong id", file, line);
|
||||
#endif
|
||||
|
||||
block = hdr->block;
|
||||
|
||||
#ifdef VALGRIND_MAKE_MEM_NOACCESS
|
||||
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
|
||||
if (block->id != ZONEID) I_Error("Z_ChangeTag at %s:%d: wrong id", file, line);
|
||||
#endif
|
||||
|
||||
if (tag >= PU_PURGELEVEL && block->user == NULL)
|
||||
@@ -587,12 +577,48 @@ void Z_ChangeTag2(void *ptr, INT32 tag)
|
||||
block->tag = tag;
|
||||
}
|
||||
|
||||
/** Changes a memory block's user.
|
||||
*
|
||||
* \param ptr A pointer to allocated memory,
|
||||
* assumed to have been allocated with Z_Malloc/Z_Calloc.
|
||||
* \param newuser The new user for the memory block.
|
||||
* \sa Z_ChangeTag
|
||||
*/
|
||||
#ifdef PARANOIA
|
||||
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line)
|
||||
#else
|
||||
void Z_SetUser(void *ptr, void **newuser)
|
||||
#endif
|
||||
{
|
||||
memblock_t *block;
|
||||
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
block = MEMBLOCK(ptr);
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (block->id != ZONEID) I_Error("Z_SetUser at %s:%d: wrong id", file, line);
|
||||
#endif
|
||||
|
||||
if (block->tag >= PU_PURGELEVEL && newuser == NULL)
|
||||
I_Error("Internal memory management error: "
|
||||
"tried to make block purgable but it has no owner");
|
||||
|
||||
block->user = (void*)newuser;
|
||||
*newuser = ptr;
|
||||
}
|
||||
|
||||
// -----------------
|
||||
// Zone memory usage
|
||||
// -----------------
|
||||
|
||||
/** Calculates memory usage for a given set of tags.
|
||||
*
|
||||
* \param lowtag The lowest tag to consider.
|
||||
* \param hightag The highest tag to consider.
|
||||
* \return Number of bytes currently allocated in the heap for the
|
||||
* given tags.
|
||||
* \sa Z_TagUsage
|
||||
*/
|
||||
size_t Z_TagsUsage(INT32 lowtag, INT32 hightag)
|
||||
{
|
||||
@@ -609,12 +635,14 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag)
|
||||
return cnt;
|
||||
}
|
||||
|
||||
size_t Z_TagUsage(INT32 tagnum)
|
||||
{
|
||||
return Z_TagsUsage(tagnum, tagnum);
|
||||
}
|
||||
// -----------------------
|
||||
// Miscellaneous functions
|
||||
// -----------------------
|
||||
|
||||
void Command_Memfree_f(void)
|
||||
/** The function called by the "memfree" console command.
|
||||
* Prints the memory being used by each part of the game to the console.
|
||||
*/
|
||||
static void Command_Memfree_f(void)
|
||||
{
|
||||
size_t freebytes, totalbytes;
|
||||
|
||||
@@ -638,7 +666,7 @@ void Command_Memfree_f(void)
|
||||
CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10));
|
||||
CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10));
|
||||
CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10));
|
||||
CONS_Printf(M_GetText("All GPU textures : %7s KB\n"), sizeu1(HWR_GetTextureUsed()>>10));
|
||||
CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), HWR_GetTextureUsed()>>10);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -648,7 +676,14 @@ void Command_Memfree_f(void)
|
||||
CONS_Printf(M_GetText("Available physical memory: %s KB\n"), sizeu1(freebytes>>10));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef ZDEBUG
|
||||
/** The function called by the "memdump" console command.
|
||||
* Prints zone memory debugging information (i.e. tag, size, location in code allocated).
|
||||
* Can be all memory allocated in game, or between a set of tags (if -min/-max args used).
|
||||
* This command is available only if ZDEBUG is enabled.
|
||||
*/
|
||||
static void Command_Memdump_f(void)
|
||||
{
|
||||
memblock_t *block;
|
||||
@@ -670,45 +705,12 @@ static void Command_Memdump_f(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creates a copy of a string.
|
||||
/** Creates a copy of a string.
|
||||
*
|
||||
* \param s The string to be copied.
|
||||
* \return A copy of the string, allocated in zone memory.
|
||||
*/
|
||||
char *Z_StrDup(const char *s)
|
||||
{
|
||||
return strcpy(ZZ_Alloc(strlen(s) + 1), s);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PARANOIA
|
||||
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line)
|
||||
#else
|
||||
void Z_SetUser2(void *ptr, void **newuser)
|
||||
#endif
|
||||
{
|
||||
memblock_t *block;
|
||||
memhdr_t *hdr;
|
||||
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
hdr = (memhdr_t *)((UINT8 *)ptr - sizeof *hdr);
|
||||
|
||||
#ifdef VALGRIND_MAKE_MEM_DEFINED
|
||||
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
|
||||
#endif
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (hdr->id != ZONEID) I_Error("Z_CT at %s:%d: wrong id", file, line);
|
||||
#endif
|
||||
|
||||
block = hdr->block;
|
||||
|
||||
#ifdef VALGRIND_MAKE_MEM_NOACCESS
|
||||
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
|
||||
#endif
|
||||
|
||||
if (block->tag >= PU_PURGELEVEL && newuser == NULL)
|
||||
I_Error("Internal memory management error: "
|
||||
"tried to make block purgable but it has no owner");
|
||||
|
||||
block->user = (void*)newuser;
|
||||
*newuser = ptr;
|
||||
}
|
||||
+90
-66
@@ -2,7 +2,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
@@ -15,6 +15,7 @@
|
||||
#define __Z_ZONE__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "doomdef.h"
|
||||
#include "doomtype.h"
|
||||
|
||||
#ifdef __GNUC__ // __attribute__ ((X))
|
||||
@@ -30,97 +31,120 @@
|
||||
//#define ZDEBUG
|
||||
|
||||
//
|
||||
// ZONE MEMORY
|
||||
// PU - purge tags.
|
||||
// Tags < PU_LEVEL are not purged until freed explicitly.
|
||||
#define PU_STATIC 1 // static entire execution time
|
||||
#define PU_LUA 2 // static entire execution time -- used by lua so it doesn't get caught in loops forever
|
||||
#define PU_PERFSTATS 3 // static between changes to ps_samplesize cvar
|
||||
// Purge tags
|
||||
//
|
||||
// Now they are an enum! -- Monster Iestyn 15/02/18
|
||||
//
|
||||
enum
|
||||
{
|
||||
// Tags < PU_LEVEL are not purged until freed explicitly.
|
||||
PU_STATIC = 1, // static entire execution time
|
||||
PU_LUA = 2, // static entire execution time -- used by lua so it doesn't get caught in loops forever
|
||||
PU_PERFSTATS = 3, // static between changes to ps_samplesize cvar
|
||||
|
||||
#define PU_SOUND 11 // static while playing
|
||||
#define PU_MUSIC 12 // static while playing
|
||||
#define PU_HUDGFX 13 // static until WAD added
|
||||
PU_SOUND = 11, // static while playing
|
||||
PU_MUSIC = 12, // static while playing
|
||||
PU_HUDGFX = 13, // static until WAD added
|
||||
|
||||
#define PU_HWRPATCHINFO 21 // Hardware GLPatch_t struct for OpenGL texture cache
|
||||
#define PU_HWRPATCHCOLMIPMAP 22 // Hardware GLMipmap_t struct colromap variation of patch
|
||||
PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache
|
||||
PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch
|
||||
|
||||
#define PU_HWRCACHE 48 // static until unlocked
|
||||
#define PU_CACHE 49 // static until unlocked
|
||||
PU_HWRCACHE = 48, // static until unlocked
|
||||
PU_CACHE = 49, // static until unlocked
|
||||
|
||||
// Tags s.t. PU_LEVEL <= tag < PU_PURGELEVEL are purged at level start
|
||||
#define PU_LEVEL 50 // static until level exited
|
||||
#define PU_LEVSPEC 51 // a special thinker in a level
|
||||
#define PU_HWRPLANE 52
|
||||
// Tags s.t. PU_LEVEL <= tag < PU_PURGELEVEL are purged at level start
|
||||
PU_LEVEL = 50, // static until level exited
|
||||
PU_LEVSPEC = 51, // a special thinker in a level
|
||||
PU_HWRPLANE = 52, // if ZPLANALLOC is enabled in hw_bsp.c, this is used to alloc polygons for OpenGL
|
||||
|
||||
// Tags >= PU_PURGELEVEL are purgable whenever needed
|
||||
#define PU_PURGELEVEL 100
|
||||
#define PU_CACHE_UNLOCKED 101
|
||||
#define PU_HWRCACHE_UNLOCKED 102 // 'second-level' cache for graphics
|
||||
// stored in hardware format and downloaded as needed
|
||||
#define PU_HWRPATCHINFO_UNLOCKED 103
|
||||
// Tags >= PU_PURGELEVEL are purgable whenever needed
|
||||
PU_PURGELEVEL = 100, // Note: this is never actually used as a tag
|
||||
PU_CACHE_UNLOCKED = 101, // Note: unused
|
||||
PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory:
|
||||
// 'second-level' cache for graphics
|
||||
// stored in hardware format and downloaded as needed
|
||||
PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRMODELTEXTURE memory
|
||||
};
|
||||
|
||||
//
|
||||
// Zone memory initialisation
|
||||
//
|
||||
void Z_Init(void);
|
||||
void Z_FreeTags(INT32 lowtag, INT32 hightag);
|
||||
void Z_CheckMemCleanup(void);
|
||||
void Z_CheckHeap(INT32 i);
|
||||
#ifdef PARANOIA
|
||||
void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line);
|
||||
#else
|
||||
void Z_ChangeTag2(void *ptr, INT32 tag);
|
||||
#endif
|
||||
|
||||
#ifdef PARANOIA
|
||||
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line);
|
||||
#else
|
||||
void Z_SetUser2(void *ptr, void **newuser);
|
||||
#endif
|
||||
//
|
||||
// Zone memory allocation
|
||||
//
|
||||
// enable ZDEBUG to get the file + line the functions were called from
|
||||
// for ZZ_Alloc, see doomdef.h
|
||||
//
|
||||
|
||||
// Z_Free and alloc with alignment
|
||||
#ifdef ZDEBUG
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
void Z_Free2(void *ptr, const char *file, INT32 line);
|
||||
#define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, 0, __FILE__, __LINE__)
|
||||
#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__)
|
||||
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
|
||||
#define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, 0, __FILE__, __LINE__)
|
||||
#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__)
|
||||
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
|
||||
#define Z_Realloc(p,s,t,u) Z_Realloc2(p, s, t, u, 0, __FILE__, __LINE__)
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__)
|
||||
#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__)
|
||||
#define Z_ReallocAlign(p,s,t,u,a) Z_Realloc2(p,s, t, u, a, __FILE__, __LINE__)
|
||||
void Z_Free2(void *ptr, const char *file, INT32 line);
|
||||
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
|
||||
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
|
||||
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(2);
|
||||
#else
|
||||
void Z_Free(void *ptr);
|
||||
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1);
|
||||
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, 0)
|
||||
void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1);
|
||||
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, 0)
|
||||
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2) ;
|
||||
#define Z_Realloc(p, s,t,u) Z_ReallocAlign(p, s, t, u, 0)
|
||||
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2);
|
||||
#endif
|
||||
|
||||
size_t Z_TagUsage(INT32 tagnum);
|
||||
size_t Z_TagsUsage(INT32 lowtag, INT32 hightag);
|
||||
// Alloc with standard alignment
|
||||
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, sizeof(void *))
|
||||
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, sizeof(void *))
|
||||
#define Z_Realloc(p,s,t,u) Z_ReallocAlign(p, s, t, u, sizeof(void *))
|
||||
|
||||
char *Z_StrDup(const char *in);
|
||||
// Free all memory by tag
|
||||
// these don't give line numbers for ZDEBUG currently though
|
||||
// (perhaps this should be changed in future?)
|
||||
#define Z_FreeTag(tagnum) Z_FreeTags(tagnum, tagnum)
|
||||
void Z_FreeTags(INT32 lowtag, INT32 hightag);
|
||||
|
||||
// This is used to get the local FILE : LINE info from CPP
|
||||
// prior to really call the function in question.
|
||||
// Iterate memory by tag
|
||||
#define Z_IterateTag(tagnum, func) Z_IterateTags(tagnum, tagnum, func)
|
||||
void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *));
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
void Z_CheckMemCleanup(void);
|
||||
void Z_CheckHeap(INT32 i);
|
||||
|
||||
//
|
||||
// Zone memory modification
|
||||
//
|
||||
// enable PARANOIA to get the file + line the functions were called from
|
||||
//
|
||||
#ifdef PARANOIA
|
||||
#define Z_ChangeTag(p,t) Z_ChangeTag2(p, t, __FILE__, __LINE__)
|
||||
#define Z_SetUser(p,u) Z_SetUser2(p, u, __FILE__, __LINE__)
|
||||
void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line);
|
||||
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line);
|
||||
#else
|
||||
#define Z_ChangeTag(p,t) Z_ChangeTag2(p, t)
|
||||
void Z_ChangeTag(void *ptr, INT32 tag);
|
||||
void Z_SetUser(void *ptr, void **newuser);
|
||||
#endif
|
||||
|
||||
#ifdef PARANOIA
|
||||
#define Z_SetUser(p,u) Z_SetUser2(p, u, __FILE__, __LINE__)
|
||||
#else
|
||||
#define Z_SetUser(p,u) Z_SetUser2(p, u)
|
||||
#endif
|
||||
//
|
||||
// Zone memory usage
|
||||
//
|
||||
// Note: These give the memory used in bytes,
|
||||
// shift down by 10 to convert to KB
|
||||
//
|
||||
#define Z_TagUsage(tagnum) Z_TagsUsage(tagnum, tagnum)
|
||||
size_t Z_TagsUsage(INT32 lowtag, INT32 hightag);
|
||||
#define Z_TotalUsage() Z_TagsUsage(0, INT32_MAX)
|
||||
|
||||
#ifdef _NDS ///TODO: need a lock reference system
|
||||
#define Z_Unlock(p) Z_ChangeTag(p, PU_CACHE_UNLOCKED)
|
||||
#else
|
||||
#define Z_Unlock(p) (void)p
|
||||
#endif
|
||||
//
|
||||
// Miscellaneous functions
|
||||
//
|
||||
char *Z_StrDup(const char *in);
|
||||
#define Z_Unlock(p) (void)p // TODO: remove this now that NDS code has been removed
|
||||
|
||||
#endif
|
||||
@@ -22,7 +22,6 @@
|
||||
#ifdef _MSC_VER
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#define NOASM
|
||||
#include "../src/tables.h"
|
||||
#define NO_M
|
||||
#include "../src/m_fixed.c"
|
||||
|
||||
Reference in new issue
Block a user