From cb50e7d3f5b047a46a511fb73c35bdcef3cc4028 Mon Sep 17 00:00:00 2001 From: Daniel Monteiro Date: Tue, 22 Aug 2023 06:53:53 +0000 Subject: [PATCH] refactor EDirection_Utils to common --- .../include/EDirection_Utils.h | 0 .../base3d => common}/src/EDirection_Utils.c | 0 ee_frontend/CMakeLists.txt | 2 +- ee_frontend/Makefile | 58 ++++++------ gl_frontend/CMakeLists.txt | 2 +- gl_frontend/Makefile.SDL2 | 2 +- gl_frontend/Makefile.ntr | 2 +- gl_frontend/Makefile.ultra | 2 +- gl_frontend/base3d/include/EDirection_Utils.h | 12 --- gl_frontend/base3d/src/EDirection_Utils.c | 90 ------------------- mx_frontend/CMakeLists.txt | 2 +- mx_frontend/Makefile.DOS | 2 +- mx_frontend/Makefile.SDL1 | 2 +- mx_frontend/Makefile.SDL2 | 2 +- mx_frontend/Makefile.X11 | 2 +- mx_frontend/Makefile.aga | 2 +- mx_frontend/Makefile.ags | 2 +- mx_frontend/Makefile.cd32 | 2 +- mx_frontend/Makefile.em | 2 +- mx_frontend/Makefile.webos | 2 +- mx_frontend/base3d/include/EDirection_Utils.h | 12 --- mx_frontend/base3d/src/EDirection_Utils.c | 90 ------------------- 22 files changed, 44 insertions(+), 248 deletions(-) rename {ee_frontend/base3d => common}/include/EDirection_Utils.h (100%) rename {ee_frontend/base3d => common}/src/EDirection_Utils.c (100%) delete mode 100644 gl_frontend/base3d/include/EDirection_Utils.h delete mode 100644 gl_frontend/base3d/src/EDirection_Utils.c delete mode 100644 mx_frontend/base3d/include/EDirection_Utils.h delete mode 100644 mx_frontend/base3d/src/EDirection_Utils.c diff --git a/ee_frontend/base3d/include/EDirection_Utils.h b/common/include/EDirection_Utils.h similarity index 100% rename from ee_frontend/base3d/include/EDirection_Utils.h rename to common/include/EDirection_Utils.h diff --git a/ee_frontend/base3d/src/EDirection_Utils.c b/common/src/EDirection_Utils.c similarity index 100% rename from ee_frontend/base3d/src/EDirection_Utils.c rename to common/src/EDirection_Utils.c diff --git a/ee_frontend/CMakeLists.txt b/ee_frontend/CMakeLists.txt index dad61b7ac..0bfa25404 100644 --- a/ee_frontend/CMakeLists.txt +++ b/ee_frontend/CMakeLists.txt @@ -43,8 +43,8 @@ add_executable(derelict128 ../common/src/Common.c ../common/src/FixP.c ../common/src/MapWithCharKey.c + ../common/src/EDirection_Utils.c base3d/src/Events.c - base3d/src/EDirection_Utils.c SoundSystem/NullMusic.c base3d/src/Dungeon.c menu/src/UI.c diff --git a/ee_frontend/Makefile b/ee_frontend/Makefile index 2a154e1b7..b535435f2 100755 --- a/ee_frontend/Makefile +++ b/ee_frontend/Makefile @@ -13,35 +13,35 @@ EE_CFLAGS += -Ibase3d/include \ EE_BIN = derelict128.elf EE_OBJS= menu/src/Main.o \ - ../common/src/FixP.o \ - ../common/src/Vec.o \ - ../common/src/Common.o \ - ../common/src/MapWithCharKey.o \ - ../common/src/ArrayPackedFileReader.o \ - ../common/src/CTile3DProperties.o \ - base3d/src/VisibilityStrategy.o \ - base3d/src/Globals.o \ - base3d/src/Events.o \ - base3d/src/EDirection_Utils.o \ - base3d/src/Dungeon.o \ - menu/src/GameMenu.o \ - menu/src/MainMenu.o \ - menu/src/Engine.o \ - menu/src/UI.o \ - menu/src/HackingScreen.o \ - menu/src/BattleScreen.o \ - menu/src/HelpScreen.o \ - menu/src/CreditsScreen.o \ - menu/src/Crawler.o \ - ../core/src/Derelict.o \ - ../core/src/Core.o \ - ../core/src/Parser.o \ - SoundSystem/NullMusic.o \ - base3d/src/ee/LoadBitmap.o \ - base3d/src/ee/Renderer_Rasterization.o \ - base3d/src/ee/Renderer_Tesselation.o \ - base3d/src/ee/Renderer.o \ - base3d/src/ee/EmotionEngineRenderer.o + ../common/src/FixP.o \ + ../common/src/Vec.o \ + ../common/src/Common.o \ + ../common/src/MapWithCharKey.o \ + ../common/src/ArrayPackedFileReader.o \ + ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ + base3d/src/VisibilityStrategy.o \ + base3d/src/Globals.o \ + base3d/src/Events.o \ + base3d/src/Dungeon.o \ + menu/src/GameMenu.o \ + menu/src/MainMenu.o \ + menu/src/Engine.o \ + menu/src/UI.o \ + menu/src/HackingScreen.o \ + menu/src/BattleScreen.o \ + menu/src/HelpScreen.o \ + menu/src/CreditsScreen.o \ + menu/src/Crawler.o \ + ../core/src/Derelict.o \ + ../core/src/Core.o \ + ../core/src/Parser.o \ + SoundSystem/NullMusic.o \ + base3d/src/ee/LoadBitmap.o \ + base3d/src/ee/Renderer_Rasterization.o \ + base3d/src/ee/Renderer_Tesselation.o \ + base3d/src/ee/Renderer.o \ + base3d/src/ee/EmotionEngineRenderer.o all: $(EE_BIN) diff --git a/gl_frontend/CMakeLists.txt b/gl_frontend/CMakeLists.txt index a28560c12..e0317befd 100644 --- a/gl_frontend/CMakeLists.txt +++ b/gl_frontend/CMakeLists.txt @@ -45,8 +45,8 @@ add_executable(derelict64 ../common/src/FixP.c ../common/src/MapWithCharKey.c ../common/src/PackedFileReader.c + ../common/src/EDirection_Utils.c base3d/src/Events.c - base3d/src/EDirection_Utils.c SoundSystem/NullMusic.c base3d/src/Dungeon.c menu/src/UI.c diff --git a/gl_frontend/Makefile.SDL2 b/gl_frontend/Makefile.SDL2 index 5af866edb..451df286c 100644 --- a/gl_frontend/Makefile.SDL2 +++ b/gl_frontend/Makefile.SDL2 @@ -25,6 +25,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ GL1Common/LoadBitmapGL1.o \ GL1Common/RendererGL1.o \ base3d/src/VisibilityStrategy.o \ @@ -32,7 +33,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ GL1Common/Renderer_RasterizationGL1.o \ GL1Common/Renderer_TesselationGL1.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/gl_frontend/Makefile.ntr b/gl_frontend/Makefile.ntr index 51b2e0c65..4a2d755e6 100644 --- a/gl_frontend/Makefile.ntr +++ b/gl_frontend/Makefile.ntr @@ -92,8 +92,8 @@ CFILES := ../menu/src/MainMenu.c \ ../../common/src/FixP.c \ ../../common/src/MapWithCharKey.c \ ../../common/src/PackedFileReader.c \ + ../../common/src/EDirection_Utils.c \ ../base3d/src/Events.c \ - ../base3d/src/EDirection_Utils.c \ ../SoundSystem/NullMusic.c \ ../base3d/src/Dungeon.c \ ../menu/src/UI.c \ diff --git a/gl_frontend/Makefile.ultra b/gl_frontend/Makefile.ultra index 7a1d5e7da..695bdb448 100644 --- a/gl_frontend/Makefile.ultra +++ b/gl_frontend/Makefile.ultra @@ -39,8 +39,8 @@ src = menu/src/MainMenu.c \ ../common/src/FixP.c \ ../common/src/MapWithCharKey.c \ ../common/src/PackedFileReader.c \ + ../common/src/EDirection_Utils.c \ base3d/src/Events.c \ - base3d/src/EDirection_Utils.c \ SoundSystem/NullMusic.c \ base3d/src/Dungeon.c \ menu/src/UI.c \ diff --git a/gl_frontend/base3d/include/EDirection_Utils.h b/gl_frontend/base3d/include/EDirection_Utils.h deleted file mode 100644 index e3e3c66a1..000000000 --- a/gl_frontend/base3d/include/EDirection_Utils.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H - -enum EDirection leftOf(const enum EDirection d); - -enum EDirection rightOf(const enum EDirection d); - -struct Vec2i mapOffsetForDirection(const enum EDirection direction); - -int oppositeOf(int d); - -#endif diff --git a/gl_frontend/base3d/src/EDirection_Utils.c b/gl_frontend/base3d/src/EDirection_Utils.c deleted file mode 100644 index 4ca5961cc..000000000 --- a/gl_frontend/base3d/src/EDirection_Utils.c +++ /dev/null @@ -1,90 +0,0 @@ -#include - -#ifdef WIN32 -#include "Win32Int.h" -#else - -#include -#include - -#endif - -#include "Enums.h" -#include "Enums.h" -#include "FixP.h" -#include "Vec.h" -#include "Common.h" -#include "EDirection_Utils.h" - -struct Vec2i mapOffsetForDirection(const enum EDirection aDirection) { - - struct Vec2i toReturn; - - switch (aDirection) { - case kEast: - initVec2i(&toReturn, 1, 0); - break; - case kWest: - initVec2i(&toReturn, -1, 0); - break; - case kSouth: - initVec2i(&toReturn, 0, 1); - break; - case kNorth: - initVec2i(&toReturn, 0, -1); - break; - default: - assert (FALSE); - } - - return toReturn; -} - -enum EDirection leftOf(const enum EDirection d) { - switch (d) { - case kNorth: - return kWest; - case kSouth: - return kEast; - case kEast: - return kNorth; - case kWest: - return kSouth; - default: - return d; - } -} - -enum EDirection rightOf(const enum EDirection d) { - switch (d) { - case kNorth: - return kEast; - case kSouth: - return kWest; - case kEast: - return kSouth; - case kWest: - return kNorth; - default: - assert (FALSE); - } -} - -int oppositeOf(int d) { - switch (d) { - case 0: - return 2; - case 2: - return 0; - case 1: - return 3; - case 3: - return 1; - case 5: - return 4; - case 4: - return 5; - default: - assert (FALSE); - } -} diff --git a/mx_frontend/CMakeLists.txt b/mx_frontend/CMakeLists.txt index 795c97918..c3462510e 100644 --- a/mx_frontend/CMakeLists.txt +++ b/mx_frontend/CMakeLists.txt @@ -39,9 +39,9 @@ add_executable(derelict32 ../common/src/FixP.c ../common/src/MapWithCharKey.c ../common/src/PackedFileReader.c + ../common/src/EDirection_Utils.c base3d/src/Events.c base3d/src/CRenderer_Rasterization.c - base3d/src/EDirection_Utils.c base3d/src/CRenderer_Tesselation.c SoundSystem/NullMusic.c base3d/src/Dungeon.c diff --git a/mx_frontend/Makefile.DOS b/mx_frontend/Makefile.DOS index d2e4a6c99..ce19f1dfe 100644 --- a/mx_frontend/Makefile.DOS +++ b/mx_frontend/Makefile.DOS @@ -48,6 +48,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ SoundSystem/MusicDOS.o \ SoundSystem/timer.o \ SoundSystem/OPL2.o \ @@ -60,7 +61,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ base3d/src/CRenderer_Tesselation.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/mx_frontend/Makefile.SDL1 b/mx_frontend/Makefile.SDL1 index 6da352ad9..cbf0173de 100644 --- a/mx_frontend/Makefile.SDL1 +++ b/mx_frontend/Makefile.SDL1 @@ -24,6 +24,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ base3d/src/LoadBitmap.o \ base3d/src/CRenderer.o \ base3d/src/VisibilityStrategy.o \ @@ -31,7 +32,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ base3d/src/CRenderer_Tesselation.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/mx_frontend/Makefile.SDL2 b/mx_frontend/Makefile.SDL2 index 762d1bbcc..1822b2349 100644 --- a/mx_frontend/Makefile.SDL2 +++ b/mx_frontend/Makefile.SDL2 @@ -24,6 +24,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ base3d/src/LoadBitmap.o \ base3d/src/CRenderer.o \ base3d/src/VisibilityStrategy.o \ @@ -31,7 +32,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ base3d/src/CRenderer_Tesselation.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/mx_frontend/Makefile.X11 b/mx_frontend/Makefile.X11 index 5906c8d5c..3bf545ec6 100644 --- a/mx_frontend/Makefile.X11 +++ b/mx_frontend/Makefile.X11 @@ -24,6 +24,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ base3d/src/LoadBitmap.o \ base3d/src/CRenderer.o \ base3d/src/VisibilityStrategy.o \ @@ -31,7 +32,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ base3d/src/CRenderer_Tesselation.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/mx_frontend/Makefile.aga b/mx_frontend/Makefile.aga index de2872ae5..219c33eef 100644 --- a/mx_frontend/Makefile.aga +++ b/mx_frontend/Makefile.aga @@ -15,6 +15,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ base3d/src/LoadBitmap.o \ base3d/src/CRenderer.o \ base3d/src/VisibilityStrategy.o \ @@ -22,7 +23,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ base3d/src/CRenderer_Tesselation.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/mx_frontend/Makefile.ags b/mx_frontend/Makefile.ags index 3db6570dc..d02cd8745 100644 --- a/mx_frontend/Makefile.ags +++ b/mx_frontend/Makefile.ags @@ -89,9 +89,9 @@ CFILES := ../menu/src/MainMenu.c \ ../../common/src/Common.c \ ../../common/src/FixP.c \ ../../common/src/MapWithCharKey.c \ + ../../common/src/EDirection_Utils.o \ ../base3d/src/Events.c \ ../base3d/src/CRenderer_Rasterization.c \ - ../base3d/src/EDirection_Utils.c \ ../base3d/src/CRenderer_Tesselation.c \ ../SoundSystem/NullMusic.c \ ../base3d/src/Dungeon.c \ diff --git a/mx_frontend/Makefile.cd32 b/mx_frontend/Makefile.cd32 index 6f4cdaab5..9a7589954 100644 --- a/mx_frontend/Makefile.cd32 +++ b/mx_frontend/Makefile.cd32 @@ -13,6 +13,7 @@ MENU_OBJ= menu/src/Main.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ base3d/src/LoadBitmap.o \ base3d/src/CRenderer.o \ base3d/src/VisibilityStrategy.o \ @@ -20,7 +21,6 @@ MENU_OBJ= menu/src/Main.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ base3d/src/CRenderer_Tesselation.o \ - base3d/src/EDirection_Utils.o \ base3d/src/Dungeon.o \ menu/src/GameMenu.o \ menu/src/MainMenu.o \ diff --git a/mx_frontend/Makefile.em b/mx_frontend/Makefile.em index 2fb7bdfd0..37b679edb 100644 --- a/mx_frontend/Makefile.em +++ b/mx_frontend/Makefile.em @@ -25,6 +25,7 @@ MENU_OBJ=menu/src/MainMenu.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ menu/src/Crawler.o \ menu/src/Engine.o \ menu/src/UI.o \ @@ -36,7 +37,6 @@ MENU_OBJ=menu/src/MainMenu.o \ base3d/src/VisibilityStrategy.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ - base3d/src/EDirection_Utils.o \ base3d/src/CRenderer_Tesselation.o \ SoundSystem/NullMusic.o \ menu/src/HelpScreen.o \ diff --git a/mx_frontend/Makefile.webos b/mx_frontend/Makefile.webos index a3ae9f3b6..f679a6d50 100644 --- a/mx_frontend/Makefile.webos +++ b/mx_frontend/Makefile.webos @@ -25,6 +25,7 @@ MENU_OBJ=menu/src/MainMenu.o \ ../common/src/PackedFileReader.o \ ../common/src/MapWithCharKey.o \ ../common/src/CTile3DProperties.o \ + ../common/src/EDirection_Utils.o \ menu/src/Crawler.o \ menu/src/Engine.o \ menu/src/UI.o \ @@ -36,7 +37,6 @@ MENU_OBJ=menu/src/MainMenu.o \ base3d/src/VisibilityStrategy.o \ base3d/src/Events.o \ base3d/src/CRenderer_Rasterization.o \ - base3d/src/EDirection_Utils.o \ base3d/src/CRenderer_Tesselation.o \ SoundSystem/NullMusic.o \ menu/src/HelpScreen.o \ diff --git a/mx_frontend/base3d/include/EDirection_Utils.h b/mx_frontend/base3d/include/EDirection_Utils.h deleted file mode 100644 index e3e3c66a1..000000000 --- a/mx_frontend/base3d/include/EDirection_Utils.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H - -enum EDirection leftOf(const enum EDirection d); - -enum EDirection rightOf(const enum EDirection d); - -struct Vec2i mapOffsetForDirection(const enum EDirection direction); - -int oppositeOf(int d); - -#endif diff --git a/mx_frontend/base3d/src/EDirection_Utils.c b/mx_frontend/base3d/src/EDirection_Utils.c deleted file mode 100644 index 4ca5961cc..000000000 --- a/mx_frontend/base3d/src/EDirection_Utils.c +++ /dev/null @@ -1,90 +0,0 @@ -#include - -#ifdef WIN32 -#include "Win32Int.h" -#else - -#include -#include - -#endif - -#include "Enums.h" -#include "Enums.h" -#include "FixP.h" -#include "Vec.h" -#include "Common.h" -#include "EDirection_Utils.h" - -struct Vec2i mapOffsetForDirection(const enum EDirection aDirection) { - - struct Vec2i toReturn; - - switch (aDirection) { - case kEast: - initVec2i(&toReturn, 1, 0); - break; - case kWest: - initVec2i(&toReturn, -1, 0); - break; - case kSouth: - initVec2i(&toReturn, 0, 1); - break; - case kNorth: - initVec2i(&toReturn, 0, -1); - break; - default: - assert (FALSE); - } - - return toReturn; -} - -enum EDirection leftOf(const enum EDirection d) { - switch (d) { - case kNorth: - return kWest; - case kSouth: - return kEast; - case kEast: - return kNorth; - case kWest: - return kSouth; - default: - return d; - } -} - -enum EDirection rightOf(const enum EDirection d) { - switch (d) { - case kNorth: - return kEast; - case kSouth: - return kWest; - case kEast: - return kSouth; - case kWest: - return kNorth; - default: - assert (FALSE); - } -} - -int oppositeOf(int d) { - switch (d) { - case 0: - return 2; - case 2: - return 0; - case 1: - return 3; - case 3: - return 1; - case 5: - return 4; - case 4: - return 5; - default: - assert (FALSE); - } -}