mirror of
https://github.com/Mikompilation/Mikompilation.git
synced 2024-11-27 00:20:48 +00:00
GPhase boot (#16)
* Boot GPHASE Implemented * Fixed some thread issues in fs * Fully implemented `BOOT GPHASE` * Fail-Safe In Case File Doesn't Exist * Added a `return` in case the file does not exist * Rename & LoadFile Memory Ptr * Load file can now load to an already defined pointer like some files do for the original game * Fix clang File
This commit is contained in:
parent
97f721898b
commit
e9e6164d54
@ -3,16 +3,16 @@ BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignOperands: DontAlign
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
@ -21,6 +21,7 @@ BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterStruct: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
@ -30,11 +31,12 @@ BraceWrapping:
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
BeforeWhile: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
ColumnLimit: 80
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 4
|
||||
IndentCaseLabels: true
|
||||
@ -51,7 +53,7 @@ SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
|
@ -38,6 +38,11 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:${PROJECT_NAME}>/resources)
|
||||
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/game_files $<TARGET_FILE_DIR:${PROJECT_NAME}>/game_files)
|
||||
file(
|
||||
GENERATE
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/CopyConfigurationData$<CONFIG>.cmake"
|
||||
CONTENT "file(
|
||||
COPY \"${PROJECT_SOURCE_DIR}/game_files\"
|
||||
DESTINATION \"$<TARGET_FILE_DIR:${PROJECT_NAME}>/game_files\"
|
||||
)"
|
||||
)
|
@ -6,7 +6,7 @@ set(ENGINE_SOURCES
|
||||
sgd/sgdGlobals.cpp
|
||||
sgd/sgdRender.cpp
|
||||
sgd/sgdLoader.cpp
|
||||
fs/file.cpp
|
||||
fs/eecdvd.cpp
|
||||
texture/tim2.cpp
|
||||
controller/GameInput.cpp
|
||||
texture/Texture.cpp
|
||||
@ -27,8 +27,8 @@ set(ENGINE_HEADERS
|
||||
sgd/sgdRender.h
|
||||
sgd/sgdGlobals.h
|
||||
sgd/sgdLoader.h
|
||||
fs/file.h
|
||||
fs/fileLoadGlobals.h
|
||||
fs/eecdvd.h
|
||||
fs/iopsys.h
|
||||
controller/GameInput.h
|
||||
texture/tim2.h
|
||||
texture/ZeroShader.h
|
||||
|
99
engine/fs/eecdvd.cpp
Normal file
99
engine/fs/eecdvd.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "eecdvd.h"
|
||||
#include "iopsys.h"
|
||||
#include "logging/printing.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
int LoadReq(int fileId, void *memoryAddress, bool useParameterMemoryAddress)
|
||||
{
|
||||
if (gameFiles[fileId].isFileLoadedInMemory)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* fileTargetAddress = useParameterMemoryAddress ? memoryAddress : (void*) nullptr;
|
||||
|
||||
threadList.emplace_back(std::thread(LoadFile, fileId, fileTargetAddress));
|
||||
|
||||
return fileId;
|
||||
}
|
||||
|
||||
void ClearCompletedThreadList()
|
||||
{
|
||||
for (int i = 0; i < threadList.size();)
|
||||
{
|
||||
std::thread ¤tThread = threadList[i];
|
||||
|
||||
if (!currentThread.joinable())
|
||||
{
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
currentThread.join();
|
||||
|
||||
threadList.erase(threadList.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsLoadEnd(int fileId)
|
||||
{
|
||||
if (!gameFiles[fileId].isFileLoadedInMemory)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ClearCompletedThreadList();
|
||||
|
||||
return gameFiles[fileId].isFileLoadedInMemory;
|
||||
}
|
||||
|
||||
void LoadFile(int fileId, void *memoryAddress)
|
||||
{
|
||||
auto filename = GetGameFileWithPathFromFileId(fileId);
|
||||
|
||||
if (!std::filesystem::exists(filename))
|
||||
{
|
||||
auto engineLogger = spdlog::get(ENGINE_LOGGER);
|
||||
engineLogger->critical("File {:x} could not be found in your game_files folder", fileId);
|
||||
return;
|
||||
}
|
||||
|
||||
auto fileSize = GetFileSize_L(fileId);
|
||||
|
||||
std::ifstream infile(filename, std::ios::binary);
|
||||
|
||||
char *buffer = memoryAddress == nullptr ? new char[fileSize] : (char*) memoryAddress;
|
||||
|
||||
infile.read(buffer, fileSize);
|
||||
|
||||
infile.close();
|
||||
|
||||
gameFiles[fileId].fileSize = fileSize;
|
||||
gameFiles[fileId].fileContent = buffer;
|
||||
gameFiles[fileId].isFileLoadedInMemory = true;
|
||||
}
|
||||
|
||||
size_t GetFileSize_L(int fileId)
|
||||
{
|
||||
std::string filename = GetGameFileWithPathFromFileId(fileId);
|
||||
|
||||
return std::filesystem::file_size(filename);
|
||||
}
|
||||
|
||||
std::string GetGameFileWithPathFromFileId(int fileId)
|
||||
{
|
||||
return gameFolder.string() + "/" + std::to_string(fileId) + ".bin";
|
||||
}
|
||||
|
||||
bool IsLoadEndAll()
|
||||
{
|
||||
return AllFileLoadIsEnd();
|
||||
}
|
||||
|
||||
bool AllFileLoadIsEnd()
|
||||
{
|
||||
ClearCompletedThreadList();
|
||||
return threadList.empty();
|
||||
}
|
15
engine/fs/eecdvd.h
Normal file
15
engine/fs/eecdvd.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
inline std::vector<std::thread> threadList = std::vector<std::thread>();
|
||||
|
||||
int LoadReq(int fileId, void *memoryAddress = nullptr, bool useParameterMemoryAddress = false);
|
||||
void LoadFile(int fileId, void *memoryAddress);
|
||||
bool IsLoadEnd(int fileId);
|
||||
size_t GetFileSize_L(int fileId);
|
||||
std::string GetGameFileWithPathFromFileId(int fileId);
|
||||
bool IsLoadEndAll();
|
||||
bool AllFileLoadIsEnd();
|
||||
void ClearCompletedThreadList();
|
@ -1,58 +0,0 @@
|
||||
#include "file.h"
|
||||
#include "fileLoadGlobals.h"
|
||||
#include <fstream>
|
||||
|
||||
int LoadReq(int fileId, void *memoryAddress)
|
||||
{
|
||||
if (gameFiles[fileId].isFileLoadedInMemory)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
threadList.push_back(new std::thread(LoadFile, fileId));
|
||||
|
||||
return fileId;
|
||||
}
|
||||
|
||||
bool isFileLoadEnd(int fileId)
|
||||
{
|
||||
if (!gameFiles[fileId].isFileLoadedInMemory)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < threadList.size();)
|
||||
{
|
||||
auto currentThread = threadList[i];
|
||||
|
||||
if (!currentThread->joinable())
|
||||
{
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
threadList.erase(threadList.begin() + i);
|
||||
}
|
||||
|
||||
return gameFiles[fileId].isFileLoadedInMemory;
|
||||
}
|
||||
|
||||
void LoadFile(int fileId)
|
||||
{
|
||||
std::string filename = gameFolder.string() + "/" + std::to_string(fileId) + ".bin";
|
||||
std::ifstream infile(filename, std::ios::binary);
|
||||
|
||||
infile.seekg(0, std::ios::end);
|
||||
size_t length = infile.tellg();
|
||||
infile.seekg(0, std::ios::beg);
|
||||
|
||||
char *buffer = new char[length];
|
||||
|
||||
infile.read(buffer, length);
|
||||
|
||||
infile.close();
|
||||
|
||||
gameFiles[fileId].fileSize = length;
|
||||
gameFiles[fileId].fileContent = buffer;
|
||||
gameFiles[fileId].isFileLoadedInMemory = true;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
inline std::vector<std::thread*> threadList = std::vector<std::thread*>();
|
||||
|
||||
int LoadReq(int fileId, void *memoryAddress = nullptr);
|
||||
void LoadFile(int fileId);
|
||||
bool isFileLoadEnd(int fileId);
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
inline const int NUM_FILES_US = 0x106B;
|
||||
|
||||
inline std::filesystem::path gameFolder("game_files/");
|
||||
|
||||
struct GameFile
|
||||
{
|
||||
bool isFileLoadedInMemory = false;
|
||||
size_t fileSize;
|
||||
void *fileContent;
|
||||
};
|
||||
|
||||
inline GameFile gameFiles[NUM_FILES_US];
|
35
engine/fs/iopsys.h
Normal file
35
engine/fs/iopsys.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
inline const int NUM_FILES_US = 0x106B;
|
||||
|
||||
inline std::filesystem::path gameFolder("game_files/");
|
||||
|
||||
enum FileInfo : int
|
||||
{
|
||||
TECMO_LOGO_TEXTURE = 2,
|
||||
ZERO_LOGO_TEXTURE = 3,
|
||||
SYSTEM_TEXTURES_PAK2 = 4,
|
||||
GAME_TEXT = 0xCC6,
|
||||
SUBTITLE_TEXT = 0x1064
|
||||
};
|
||||
|
||||
///New redefined struct for loaded file for the Mikompilation project
|
||||
struct GameFile
|
||||
{
|
||||
bool isFileLoadedInMemory = false;
|
||||
size_t fileSize;
|
||||
void *fileContent;
|
||||
};
|
||||
|
||||
/// The struct used in the original game's source code
|
||||
struct ZeroFile
|
||||
{
|
||||
/// Contains the offset address in the archive file and
|
||||
/// some data like isFile or isCompressed on the first 3 bits
|
||||
uint32_t offset_info;
|
||||
uint32_t size;
|
||||
uint32_t sizeCompressed;
|
||||
};
|
||||
|
||||
inline GameFile gameFiles[NUM_FILES_US];
|
@ -16,7 +16,7 @@ set(GAME_SOURCES
|
||||
set(GAME_HEADERS
|
||||
game_main.h
|
||||
gphase.h
|
||||
gphaseTypes.h
|
||||
gphase_types.h
|
||||
gphase_data.h
|
||||
player/plyr_mdl.h
|
||||
logo/logo_main.h
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "game_main.h"
|
||||
#include "fs/eecdvd.h"
|
||||
#include "fs/iopsys.h"
|
||||
#include "gphase.h"
|
||||
#include "logging/printing.h"
|
||||
#include "player/plyr_mdl.h"
|
||||
@ -44,16 +46,31 @@ GPHASE_ID after_super(GPHASE_ID gphaseId)
|
||||
|
||||
void end_Boot_Init()
|
||||
{
|
||||
printNotImplemented(GAME_LOGGER, __FUNCTION__, __FILE__);
|
||||
return;
|
||||
}
|
||||
|
||||
void init_Boot_Init()
|
||||
{
|
||||
printNotImplemented(GAME_LOGGER, __FUNCTION__, __FILE__);
|
||||
LoadReq(SYSTEM_TEXTURES_PAK2, (void *) 0x1E79B0);
|
||||
LoadReq(GAME_TEXT, (void *) 0xD9EC00);
|
||||
|
||||
SubTitleAddr = (int*) malloc(GetFileSize_L(SUBTITLE_TEXT));
|
||||
LoadReq(SUBTITLE_TEXT, SubTitleAddr, true);
|
||||
}
|
||||
|
||||
GPHASE_ID one_Boot_Init(GPHASE_ID gphaseId)
|
||||
{
|
||||
printNotImplemented(GAME_LOGGER, __FUNCTION__, __FILE__);
|
||||
auto isAllFilesLoaded = IsLoadEndAll();
|
||||
|
||||
if (isAllFilesLoaded)
|
||||
{
|
||||
SetNextGPhase(AUTOLOAD_MAIN);
|
||||
}
|
||||
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
int *GetSubTitleAddr()
|
||||
{
|
||||
return SubTitleAddr;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include "gphaseTypes.h"
|
||||
#include "gphase_types.h"
|
||||
|
||||
inline int *SubTitleAddr;
|
||||
|
||||
void game_main();
|
||||
void game_init();
|
||||
@ -22,7 +24,7 @@ GPHASE_ID one_Boot_Init(GPHASE_ID gphaseId);
|
||||
|
||||
/// SoftResetUnlock(void)
|
||||
|
||||
/// GetSubTitleAddr(void)
|
||||
int *GetSubTitleAddr();
|
||||
/// DebugMemoryCheck(void)
|
||||
/// SoftResetLock(void)
|
||||
/// newAssert(char *)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "gphaseTypes.h"
|
||||
#include "gphase_types.h"
|
||||
|
||||
inline const int gphase_sys_num = 6;
|
||||
inline GPHASE_ID gphase_sys[gphase_sys_num];
|
||||
|
@ -5,7 +5,7 @@
|
||||
/// Header file for joining all game functions
|
||||
/// found in the funcs array
|
||||
|
||||
inline const int gphase_num = 94;
|
||||
inline const int gphase_num = 88;
|
||||
|
||||
inline void (*ini_func[gphase_num])() =
|
||||
{
|
||||
|
11
third-party/glew/glew.pc
vendored
11
third-party/glew/glew.pc
vendored
@ -1,11 +0,0 @@
|
||||
prefix=/usr/local
|
||||
exec_prefix=${prefix}
|
||||
libdir=/usr/local/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: glew
|
||||
Description: The OpenGL Extension Wrangler library
|
||||
Version: 2.1.0
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lGLEW
|
||||
Requires: glu
|
Loading…
Reference in New Issue
Block a user