Merge branch 'develop-SoapyMan' of https://github.com/SoapyMan/REDRIVER2 into develop-SoapyMan

This commit is contained in:
Ilya Shurumov 2020-10-02 14:46:21 +06:00
commit 36fe41e443
7 changed files with 207 additions and 93 deletions

View File

@ -145,15 +145,12 @@ int bcollided2d(CDATA2D *body, int needOverlap)
else
zover = xover;
if (xover > -1)
{
if (zover < xover)
boxOverlap = zover;
else
boxOverlap = xover;
}
else
if (xover <= -1)
boxOverlap = zover;
else if (zover < xover)
boxOverlap = zover;
else
boxOverlap = xover;
}
return 1;
@ -239,10 +236,10 @@ void bFindCollisionPoint(CDATA2D *body, CRET2D *collisionResult)
sign = 0;
carBarrierCollision = false;
smallest = body[0].limit[0] + 1; // [A] I doubt in this line
smallest = body[0].limit[0] + 1;
if (!body[0].isCameraOrTanner && !body[1].isCameraOrTanner &&
(body[1].length[1] >= body[1].length[0] / 8 || body[1].length[0] >= body[1].length[1] / 8))
(body[1].length[1] >= body[1].length[0] * 4 || body[1].length[0] >= body[1].length[1] * 4))
{
carBarrierCollision = true;
}
@ -306,15 +303,15 @@ void bFindCollisionPoint(CDATA2D *body, CRET2D *collisionResult)
cd = &body[(besti ^ 1)];
sign0 = sign;
if (cd->axis[0].vx * body[besti].axis[bestk].vx + cd->axis[0].vz * body[besti].axis[bestk].vz + 0x800 > -1)
if (cd->axis[0].vx * body[besti].axis[bestk].vx + cd->axis[0].vz * body[besti].axis[bestk].vz + 2048 > -1)
sign0 = -sign;
else
sign0 = sign;
sign1 = sign;
if (cd->axis[1].vx * body[besti].axis[bestk].vx + cd->axis[1].vz * body[besti].axis[bestk].vz + 0x800 > -1)
if (cd->axis[1].vx * body[besti].axis[bestk].vx + cd->axis[1].vz * body[besti].axis[bestk].vz + 2048 > -1)
sign1 = -sign;
else
sign1 = sign;
collisionResult->penetration = smallest;
@ -373,8 +370,8 @@ int bFindCollisionTime(CDATA2D *cd, CRET2D *collisionResult)
hit = 1;
neverfree = 1;
time = 0x1000;
step = 0x800;
time = 4096;
step = 2048;
i = 1;
do {
@ -999,7 +996,7 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop
cd[0].theta = cp->hd.direction;
if (cp->controlType == 6)
if (cp->controlType == CONTROL_TYPE_TANNERCOLLIDER)
{
cd[0].vel.vx = FIXEDH(cp->st.n.linearVelocity[0]);
cd[0].vel.vz = FIXEDH(cp->st.n.linearVelocity[2]);
@ -1046,11 +1043,11 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop
if (cp->controlType == CONTROL_TYPE_CAMERACOLLIDER)
{
collided = (bcollided2d(cd, 1) != 0);
collided = bcollided2d(cd, 1);
}
else
{
collided = (bcollided2d(cd, 0) != 0);
collided = bcollided2d(cd, 0);
#if defined(COLLISION_DEBUG) && !defined(PSX)

2
src_rebuild/gen_psx.bat Normal file
View File

@ -0,0 +1,2 @@
premake5 --os=psx gmake2
pause

View File

@ -1,19 +1,23 @@
-- premake5.lua
require "premake_modules/psx"
-- you can redefine dependencies
SDL2_DIR = os.getenv("SDL2_DIR") or "dependencies/SDL2"
GLEW_DIR = os.getenv("GLEW_DIR") or "dependencies/glew"
OPENAL_DIR = os.getenv("OPENAL_DIR") or "dependencies/openal-soft"
JPEG_DIR = os.getenv("JPEG_DIR") or "dependencies/jpeg"
PSYQ_DIR = os.getenv("PSYQ_DIR") or "PSY-Q"
GAME_REGION = os.getenv("GAME_REGION") or "NTSC_VERSION" -- or PAL_VERSION
if not (GAME_REGION == "NTSC_VERSION" or GAME_REGION == "PAL_VERSION") then
error("'GAME_REGION' should be 'NTSC_VERSION' or 'PAL_VERSION'")
end
workspace "REDRIVER2"
configurations { "Debug", "Release" }
configurations { "Debug", "Release", "Release Dev" }
defines { VERSION }
@ -31,72 +35,15 @@ workspace "REDRIVER2"
"NDEBUG",
}
if _TARGET_OS == "windows" then
dofile("premake_libjpeg.lua")
end
-- EMULATOR layer
project "PSX"
kind "StaticLib"
language "C++"
compileas "C++"
targetdir "bin/%{cfg.buildcfg}"
includedirs {
"EMULATOR"
}
defines { GAME_REGION }
files {
"EMULATOR/**.h",
"EMULATOR/**.H",
"EMULATOR/**.c",
"EMULATOR/**.C",
"EMULATOR/**.cpp",
"EMULATOR/**.CPP",
}
defines { "OGL", "GLEW" }
includedirs {
SDL2_DIR.."/include",
GLEW_DIR.."/include",
OPENAL_DIR.."/include",
}
filter "system:Windows"
links {
"opengl32",
"glew32",
"SDL2",
"OpenAL32"
}
libdirs {
SDL2_DIR.."/lib/x86",
GLEW_DIR.."/lib/Release/Win32",
OPENAL_DIR.."/libs/Win32",
}
filter "system:linux"
buildoptions {
"-Wno-narrowing"
}
includedirs {
"/usr/include/SDL2"
}
links {
"GL",
"GLEW",
"openal", -- FIXME: is linux using openal-soft?
"SDL2",
}
filter "configurations:Release"
optimize "Full"
if os.target() == "windows" then
dofile("premake_libjpeg.lua")
end
if os.target() ~= "psx" then
dofile("premake_emulator.lua")
end
-- TODO: overlays
-- game iteslf
project "REDRIVER2"
@ -115,9 +62,21 @@ project "REDRIVER2"
"GAME/**.H",
"GAME/**.C",
}
-- exclude sources which belong to overlays
if os.target() == "psx" then
excludes {
"GAME/MEMCARD/**.C",
"GAME/MEMCARD/**.H",
"GAME/FRONTEND/**.C",
"GAME/FRONTEND/**.H",
"GAME/C/LEADAI.C",
"GAME/C/PATHFIND.C",
}
end
filter "system:Windows or linux"
defines { "OGL", "GLEW" }
defines { "OGL", "GLEW", "SIMPLE_SPOOL" }
dependson { "PSX" }
links { "PSX", "jpeg" }
@ -133,6 +92,7 @@ project "REDRIVER2"
}
filter "system:Windows"
files {
"Windows/resource.h",
"Windows/Resource.rc",
@ -166,16 +126,36 @@ project "REDRIVER2"
}
linkoptions { "-z muldefs" }
filter "system:psx"
defines { "PSX" }
includedirs {
PSYQ_DIR.."/include"
}
links {
PSYQ_DIR.."/LIBETC",
PSYQ_DIR.."/LIBPAD",
PSYQ_DIR.."/LIBGTE",
PSYQ_DIR.."/LIBMCRD",
PSYQ_DIR.."/LIBCD",
PSYQ_DIR.."/LIBSN",
PSYQ_DIR.."/LIBSPU",
PSYQ_DIR.."/LIBAPI"
}
filter "configurations:Debug"
defines {
"DEBUG_OPTIONS",
"COLLISION_DEBUG"
}
symbols "On"
filter "configurations:Release"
optimize "Full"
filter "configurations:Release Dev"
defines {
--"DEBUG_OPTIONS",
--"COLLISION_DEBUG"
"DEBUG_OPTIONS",
"COLLISION_DEBUG"
}
optimize "Full"

View File

@ -0,0 +1,65 @@
-- EMULATOR layer
project "PSX"
kind "StaticLib"
language "C++"
compileas "C++"
targetdir "bin/%{cfg.buildcfg}"
removeplatforms "psx"
includedirs {
"EMULATOR"
}
defines { GAME_REGION }
files {
"EMULATOR/**.h",
"EMULATOR/**.H",
"EMULATOR/**.c",
"EMULATOR/**.C",
"EMULATOR/**.cpp",
"EMULATOR/**.CPP",
}
defines { "OGL", "GLEW" }
includedirs {
SDL2_DIR.."/include",
GLEW_DIR.."/include",
OPENAL_DIR.."/include",
}
filter "system:Windows"
defines { "_WINDOWS" }
links {
"opengl32",
"glew32",
"SDL2",
"OpenAL32"
}
libdirs {
SDL2_DIR.."/lib/x86",
GLEW_DIR.."/lib/Release/Win32",
OPENAL_DIR.."/libs/Win32",
}
filter "system:linux"
buildoptions {
"-Wno-narrowing"
}
includedirs {
"/usr/include/SDL2"
}
links {
"GL",
"GLEW",
"openal", -- FIXME: is linux using openal-soft?
"SDL2",
}
filter "configurations:Release"
optimize "Full"

View File

@ -0,0 +1,4 @@
return {
"_preload.lua",
"psx.lua",
}

View File

@ -0,0 +1,47 @@
-- Premake PSX module
-- By SoapyMan
local p = premake
local api = p.api
--
-- Register the PSX extension
--
p.PSX = "psx"
api.addAllowed("system", p.PSX)
api.addAllowed("architecture", { "mips32" })
local osoption = p.option.get("os")
if osoption ~= nil then
table.insert(osoption.allowed, { "psx", "PSX" })
end
-- add system tags for PSX
os.systemTags[p.PSX] = { "psx" }
filter { "system:psx", "kind:ConsoleApp or WindowedApp" }
targetextension ".exe"
-- overlays
filter { "system:psx", "kind:Overlay" }
targetprefix ""
targetextension ".bin"
implibextension ".lib"
filter { "system:psx", "kind:StaticLib" }
targetprefix ""
targetextension ".lib"
--
-- Register PSX properties
--
-- Compilation properties
-- TODO
return function(cfg)
return (cfg.system == p.PSX)
end

View File

@ -0,0 +1,19 @@
-- Premake PSX module
-- By SoapyMan
local p = premake
if not p.modules.psx then
include ( "_preload.lua" )
require ("gmake")
p.modules.psx = {}
if _ACTION == "gmake" or _ACTION == "gmake2" then
configuration { "psx" }
system "psx"
end
end
return p.modules.psx