Implemented rel building and loading

This commit is contained in:
dbalatoni13 2025-04-06 06:30:30 +02:00
parent 3b31d9fcfc
commit d3b45cf2b4
14 changed files with 1045 additions and 922 deletions

View file

@ -40,27 +40,32 @@ set(DOLPHIN_FILES
set(GAME_FILES set(GAME_FILES
src/game/armem.c src/game/armem.c
src/game/audio.c
src/game/card.c src/game/card.c
src/game/ClusterExec.c src/game/ClusterExec.c
src/game/data.c src/game/data.c
src/game/decode.c src/game/decode.c
src/game/dvd.c src/game/dvd.c
src/game/EnvelopeExec.c src/game/EnvelopeExec.c
src/game/esprite.c
src/game/fault.c src/game/fault.c
src/game/flag.c src/game/flag.c
src/game/font.c src/game/font.c
src/game/frand.c src/game/frand.c
src/game/gamework.c
src/game/hsfanim.c src/game/hsfanim.c
src/game/hsfdraw.c src/game/hsfdraw.c
src/game/hsfex.c src/game/hsfex.c
src/game/hsfload.c src/game/hsfload.c
src/game/hsfman.c src/game/hsfman.c
src/game/hsfmotion.c src/game/hsfmotion.c
src/game/gamework.c src/game/init.c
src/game/main.c src/game/main.c
src/game/malloc.c src/game/malloc.c
src/game/memory.c src/game/memory.c
src/game/init.c src/game/objdll.c
src/game/objmain.c
src/game/ovllist.c
src/game/ShapeExec.c src/game/ShapeExec.c
src/game/sprman.c src/game/sprman.c
src/game/sprput.c src/game/sprput.c
@ -94,8 +99,20 @@ set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=
endforeach() endforeach()
endif () endif ()
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
add_executable(marioparty4 ${DOLPHIN_FILES} ${GAME_FILES} ${PORT_FILES}) add_executable(marioparty4 ${DOLPHIN_FILES} ${GAME_FILES} ${PORT_FILES})
target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=0) set_property(TARGET marioparty4 PROPERTY ENABLE_EXPORTS ON)
target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=0 TARGET_MAIN)
target_compile_definitions(musyx PRIVATE MUSY_VERSION_MAJOR=1 MUSY_VERSION_MINOR=5 MUSY_VERSION_PATCH=4) target_compile_definitions(musyx PRIVATE MUSY_VERSION_MAJOR=1 MUSY_VERSION_MINOR=5 MUSY_VERSION_PATCH=4)
target_include_directories(marioparty4 PRIVATE include build/GMPE01_00/include) target_include_directories(marioparty4 PRIVATE include build/GMPE01_00/include)
if (MSVC)
target_link_options(marioparty4 PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def")
endif ()
target_link_libraries(marioparty4 PRIVATE aurora::aurora aurora::main musyx) target_link_libraries(marioparty4 PRIVATE aurora::aurora aurora::main musyx)
add_library(bootDll SHARED src/REL/bootDll/main.c src/REL/bootDll/language.c)
target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=0 TARGET_REL)
target_include_directories(bootDll PRIVATE include build/GMPE01_00/include)
set_target_properties(bootDll PROPERTIES LINK_FLAGS "/EXPORT:ObjectSetup")
target_link_libraries(bootDll PRIVATE musyx marioparty4)

27
dol.def Normal file
View file

@ -0,0 +1,27 @@
EXPORTS
OSReport
OSGetTick
HuMemDirectMalloc
HuMemDirectFree
HuDataSelHeapReadNum
HuDecodeData
Hu3DBGColorSet
Hu3DModelCreate
Hu3DModelAttrSet
Hu3DModelAttrReset
Hu3DCameraCreate
Hu3DCameraPerspectiveSet
Hu3DCameraViewportSet
Hu3DCameraPosSet
Hu3DModelCameraInfoSet
Hu3DModelLightInfoSet
HuPrcEnd
HuPrcCreate
HuPrcCurrentGet
HuPrcSleep
HuPrcVSleep
omOvlCallEx
omOvlReturnEx
omOvlHisChg
omOvlHisGet
omInitObjMan

View file

@ -225,7 +225,7 @@ BOOL OSRestoreInterrupts(BOOL level);
#endif // _DEBUG #endif // _DEBUG
void OSReport(const char *msg, ...); __declspec(dllexport) void OSReport(const char *msg, ...);
void OSPanic(const char *file, int line, const char *msg, ...); void OSPanic(const char *file, int line, const char *msg, ...);
void OSFatal(GXColor fg, GXColor bg, const char *msg); void OSFatal(GXColor fg, GXColor bg, const char *msg);

View file

@ -145,13 +145,13 @@ typedef struct game_stat {
/* 0x110 */ PauseBackupConfig party_pause; /* 0x110 */ PauseBackupConfig party_pause;
} GameStat; } GameStat;
extern s16 GwLanguage; SHARED_SYM extern s16 GwLanguage;
extern s16 GwLanguageSave; SHARED_SYM extern s16 GwLanguageSave;
extern PlayerConfig GWPlayerCfg[4]; SHARED_SYM extern PlayerConfig GWPlayerCfg[4];
extern PlayerState GWPlayer[4]; SHARED_SYM extern PlayerState GWPlayer[4];
extern SystemState GWSystem; SHARED_SYM extern SystemState GWSystem;
extern GameStat GWGameStat; SHARED_SYM extern GameStat GWGameStat;
static inline s32 GWPlayerCfgGroupGet(s32 player) static inline s32 GWPlayerCfgGroupGet(s32 player)
{ {

View file

@ -5,6 +5,10 @@
#include "game/process.h" #include "game/process.h"
#include "game/dvd.h" #include "game/dvd.h"
#ifdef _WIN32
#include <windows.h>
#endif
#define OM_DLL_MAX 20 #define OM_DLL_MAX 20
#define OVL_DEFINE(name, path) name, #define OVL_DEFINE(name, path) name,
@ -60,9 +64,14 @@ typedef struct om_obj_data {
typedef struct om_dll_data { typedef struct om_dll_data {
char *name; char *name;
#if _WIN32
HMODULE hModule;
#else
OSModuleHeader *module; OSModuleHeader *module;
void *bss; void *bss;
s32 ret; s32 ret;
#endif
} omDllData; } omDllData;
void omMasterInit(s32 prio, FileListEntry *ovl_list, s32 ovl_count, OverlayID start_ovl); void omMasterInit(s32 prio, FileListEntry *ovl_list, s32 ovl_count, OverlayID start_ovl);
@ -112,26 +121,26 @@ void omSysPauseCtrl(s16 flag);
extern omObjData *omDBGSysKeyObj; extern omObjData *omDBGSysKeyObj;
extern Process *omwatchproc; extern Process *omwatchproc;
extern OverlayID omnextovl; extern OverlayID omnextovl;
extern OverlayID omcurovl; SHARED_SYM extern OverlayID omcurovl;
extern s32 omcurdll; extern s32 omcurdll;
extern s32 omovlhisidx; SHARED_SYM extern s32 omovlhisidx;
extern s32 omovlevtno; SHARED_SYM extern s32 omovlevtno;
extern s32 omnextovlevtno; extern s32 omnextovlevtno;
extern u32 omovlstat; SHARED_SYM extern u32 omovlstat;
extern char omUPauseFlag; extern char omUPauseFlag;
extern s16 omSysExitReq; SHARED_SYM extern s16 omSysExitReq;
extern s16 omdispinfo; extern s16 omdispinfo;
extern u8 omSysPauseEnableFlag; extern u8 omSysPauseEnableFlag;
extern OverlayID omprevovl; extern OverlayID omprevovl;
extern omDllData *omDLLinfoTbl[OM_DLL_MAX]; extern omDllData *omDLLinfoTbl[OM_DLL_MAX];
extern Vec CRot; SHARED_SYM extern Vec CRot;
extern Vec Center; SHARED_SYM extern Vec Center;
extern float CZoom; SHARED_SYM extern float CZoom;
extern Vec CRotM[16]; SHARED_SYM extern Vec CRotM[16];
extern Vec CenterM[16]; SHARED_SYM extern Vec CenterM[16];
extern float CZoomM[16]; SHARED_SYM extern float CZoomM[16];
extern s16 omDBGMenuButton; SHARED_SYM extern s16 omDBGMenuButton;
#endif #endif

View file

@ -1,108 +1,108 @@
#include "version.h" #include "version.h"
OVL_DEFINE(OVL__MINI, "dll/_minigameDLL.rel") OVL_DEFINE(OVL__MINI, "_minigameDLL")
OVL_DEFINE(OVL_BOOT, "dll/bootdll.rel") OVL_DEFINE(OVL_BOOT, "bootdll")
OVL_DEFINE(OVL_E3SETUP, "dll/e3setupDLL.rel") OVL_DEFINE(OVL_E3SETUP, "e3setupDLL")
OVL_DEFINE(OVL_INST, "dll/instdll.rel") OVL_DEFINE(OVL_INST, "instdll")
OVL_DEFINE(OVL_M300, "dll/m300dll.rel") OVL_DEFINE(OVL_M300, "m300dll")
OVL_DEFINE(OVL_M302, "dll/m302dll.rel") OVL_DEFINE(OVL_M302, "m302dll")
OVL_DEFINE(OVL_M303, "dll/m303dll.rel") OVL_DEFINE(OVL_M303, "m303dll")
OVL_DEFINE(OVL_M330, "dll/m330dll.rel") OVL_DEFINE(OVL_M330, "m330dll")
OVL_DEFINE(OVL_M333, "dll/m333dll.rel") OVL_DEFINE(OVL_M333, "m333dll")
OVL_DEFINE(OVL_M401, "dll/m401dll.rel") OVL_DEFINE(OVL_M401, "m401dll")
OVL_DEFINE(OVL_M402, "dll/m402dll.rel") OVL_DEFINE(OVL_M402, "m402dll")
OVL_DEFINE(OVL_M403, "dll/m403dll.rel") OVL_DEFINE(OVL_M403, "m403dll")
OVL_DEFINE(OVL_M404, "dll/m404dll.rel") OVL_DEFINE(OVL_M404, "m404dll")
OVL_DEFINE(OVL_M405, "dll/m405dll.rel") OVL_DEFINE(OVL_M405, "m405dll")
OVL_DEFINE(OVL_M406, "dll/m406dll.rel") OVL_DEFINE(OVL_M406, "m406dll")
OVL_DEFINE(OVL_M407, "dll/m407dll.rel") OVL_DEFINE(OVL_M407, "m407dll")
OVL_DEFINE(OVL_M408, "dll/m408dll.rel") OVL_DEFINE(OVL_M408, "m408dll")
OVL_DEFINE(OVL_M409, "dll/m409dll.rel") OVL_DEFINE(OVL_M409, "m409dll")
OVL_DEFINE(OVL_M410, "dll/m410dll.rel") OVL_DEFINE(OVL_M410, "m410dll")
OVL_DEFINE(OVL_M411, "dll/m411dll.rel") OVL_DEFINE(OVL_M411, "m411dll")
OVL_DEFINE(OVL_M412, "dll/m412dll.rel") OVL_DEFINE(OVL_M412, "m412dll")
OVL_DEFINE(OVL_M413, "dll/m413dll.rel") OVL_DEFINE(OVL_M413, "m413dll")
OVL_DEFINE(OVL_M414, "dll/m414dll.rel") OVL_DEFINE(OVL_M414, "m414dll")
OVL_DEFINE(OVL_M415, "dll/m415dll.rel") OVL_DEFINE(OVL_M415, "m415dll")
OVL_DEFINE(OVL_M416, "dll/m416dll.rel") OVL_DEFINE(OVL_M416, "m416dll")
OVL_DEFINE(OVL_M417, "dll/m417dll.rel") OVL_DEFINE(OVL_M417, "m417dll")
OVL_DEFINE(OVL_M418, "dll/m418dll.rel") OVL_DEFINE(OVL_M418, "m418dll")
OVL_DEFINE(OVL_M419, "dll/m419dll.rel") OVL_DEFINE(OVL_M419, "m419dll")
OVL_DEFINE(OVL_M420, "dll/m420dll.rel") OVL_DEFINE(OVL_M420, "m420dll")
OVL_DEFINE(OVL_M421, "dll/m421dll.rel") OVL_DEFINE(OVL_M421, "m421dll")
OVL_DEFINE(OVL_M422, "dll/m422dll.rel") OVL_DEFINE(OVL_M422, "m422dll")
OVL_DEFINE(OVL_M423, "dll/m423dll.rel") OVL_DEFINE(OVL_M423, "m423dll")
OVL_DEFINE(OVL_M424, "dll/m424dll.rel") OVL_DEFINE(OVL_M424, "m424dll")
OVL_DEFINE(OVL_M425, "dll/m425dll.rel") OVL_DEFINE(OVL_M425, "m425dll")
OVL_DEFINE(OVL_M426, "dll/m426dll.rel") OVL_DEFINE(OVL_M426, "m426dll")
OVL_DEFINE(OVL_M427, "dll/m427dll.rel") OVL_DEFINE(OVL_M427, "m427dll")
OVL_DEFINE(OVL_M428, "dll/m428dll.rel") OVL_DEFINE(OVL_M428, "m428dll")
OVL_DEFINE(OVL_M429, "dll/m429dll.rel") OVL_DEFINE(OVL_M429, "m429dll")
OVL_DEFINE(OVL_M430, "dll/m430dll.rel") OVL_DEFINE(OVL_M430, "m430dll")
OVL_DEFINE(OVL_M431, "dll/m431dll.rel") OVL_DEFINE(OVL_M431, "m431dll")
OVL_DEFINE(OVL_M432, "dll/m432dll.rel") OVL_DEFINE(OVL_M432, "m432dll")
OVL_DEFINE(OVL_M433, "dll/m433dll.rel") OVL_DEFINE(OVL_M433, "m433dll")
OVL_DEFINE(OVL_M434, "dll/m434dll.rel") OVL_DEFINE(OVL_M434, "m434dll")
OVL_DEFINE(OVL_M435, "dll/m435dll.rel") OVL_DEFINE(OVL_M435, "m435dll")
OVL_DEFINE(OVL_M436, "dll/m436dll.rel") OVL_DEFINE(OVL_M436, "m436dll")
OVL_DEFINE(OVL_M437, "dll/m437dll.rel") OVL_DEFINE(OVL_M437, "m437dll")
OVL_DEFINE(OVL_M438, "dll/m438dll.rel") OVL_DEFINE(OVL_M438, "m438dll")
OVL_DEFINE(OVL_M439, "dll/m439dll.rel") OVL_DEFINE(OVL_M439, "m439dll")
OVL_DEFINE(OVL_M440, "dll/m440dll.rel") OVL_DEFINE(OVL_M440, "m440dll")
OVL_DEFINE(OVL_M441, "dll/m441dll.rel") OVL_DEFINE(OVL_M441, "m441dll")
OVL_DEFINE(OVL_M442, "dll/m442dll.rel") OVL_DEFINE(OVL_M442, "m442dll")
OVL_DEFINE(OVL_M443, "dll/m443dll.rel") OVL_DEFINE(OVL_M443, "m443dll")
OVL_DEFINE(OVL_M444, "dll/m444dll.rel") OVL_DEFINE(OVL_M444, "m444dll")
OVL_DEFINE(OVL_M445, "dll/m445dll.rel") OVL_DEFINE(OVL_M445, "m445dll")
OVL_DEFINE(OVL_M446, "dll/m446dll.rel") OVL_DEFINE(OVL_M446, "m446dll")
OVL_DEFINE(OVL_M447, "dll/m447dll.rel") OVL_DEFINE(OVL_M447, "m447dll")
OVL_DEFINE(OVL_M448, "dll/m448dll.rel") OVL_DEFINE(OVL_M448, "m448dll")
OVL_DEFINE(OVL_M449, "dll/m449dll.rel") OVL_DEFINE(OVL_M449, "m449dll")
OVL_DEFINE(OVL_M450, "dll/m450dll.rel") OVL_DEFINE(OVL_M450, "m450dll")
OVL_DEFINE(OVL_M451, "dll/m451dll.rel") OVL_DEFINE(OVL_M451, "m451dll")
OVL_DEFINE(OVL_M453, "dll/m453dll.rel") OVL_DEFINE(OVL_M453, "m453dll")
OVL_DEFINE(OVL_M455, "dll/m455dll.rel") OVL_DEFINE(OVL_M455, "m455dll")
OVL_DEFINE(OVL_M456, "dll/m456dll.rel") OVL_DEFINE(OVL_M456, "m456dll")
OVL_DEFINE(OVL_M457, "dll/m457dll.rel") OVL_DEFINE(OVL_M457, "m457dll")
OVL_DEFINE(OVL_M458, "dll/m458dll.rel") OVL_DEFINE(OVL_M458, "m458dll")
OVL_DEFINE(OVL_M459, "dll/m459dll.rel") OVL_DEFINE(OVL_M459, "m459dll")
OVL_DEFINE(OVL_M460, "dll/m460dll.rel") OVL_DEFINE(OVL_M460, "m460dll")
OVL_DEFINE(OVL_M461, "dll/m461dll.rel") OVL_DEFINE(OVL_M461, "m461dll")
OVL_DEFINE(OVL_M462, "dll/m462dll.rel") OVL_DEFINE(OVL_M462, "m462dll")
OVL_DEFINE(OVL_M463, "dll/m463dll.rel") OVL_DEFINE(OVL_M463, "m463dll")
OVL_DEFINE(OVL_MENT, "dll/mentdll.rel") OVL_DEFINE(OVL_MENT, "mentdll")
#if VERSION_JP #if VERSION_JP
OVL_DEFINE(OVL_MGMODE, "dll/mgmodedll.rel") OVL_DEFINE(OVL_MGMODE, "mgmodedll")
OVL_DEFINE(OVL_MODELTEST, "dll/modeltestdll.rel") OVL_DEFINE(OVL_MODELTEST, "modeltestdll")
OVL_DEFINE(OVL_MODESEL, "dll/modeseldll.rel") OVL_DEFINE(OVL_MODESEL, "modeseldll")
OVL_DEFINE(OVL_MOVIE, "dll/moviedll.rel") OVL_DEFINE(OVL_MOVIE, "moviedll")
#else #else
OVL_DEFINE(OVL_MESS, "dll/messdll.rel") OVL_DEFINE(OVL_MESS, "messdll")
OVL_DEFINE(OVL_MGMODE, "dll/mgmodedll.rel") OVL_DEFINE(OVL_MGMODE, "mgmodedll")
OVL_DEFINE(OVL_MODELTEST, "dll/modeltestdll.rel") OVL_DEFINE(OVL_MODELTEST, "modeltestdll")
OVL_DEFINE(OVL_MODESEL, "dll/modeseldll.rel") OVL_DEFINE(OVL_MODESEL, "modeseldll")
#endif #endif
OVL_DEFINE(OVL_MPEX, "dll/mpexdll.rel") OVL_DEFINE(OVL_MPEX, "mpexdll")
OVL_DEFINE(OVL_MSETUP, "dll/msetupdll.rel") OVL_DEFINE(OVL_MSETUP, "msetupdll")
OVL_DEFINE(OVL_MSTORY2, "dll/mstory2dll.rel") OVL_DEFINE(OVL_MSTORY2, "mstory2dll")
OVL_DEFINE(OVL_MSTORY3, "dll/mstory3dll.rel") OVL_DEFINE(OVL_MSTORY3, "mstory3dll")
OVL_DEFINE(OVL_MSTORY4, "dll/mstory4dll.rel") OVL_DEFINE(OVL_MSTORY4, "mstory4dll")
OVL_DEFINE(OVL_MSTORY, "dll/mstorydll.rel") OVL_DEFINE(OVL_MSTORY, "mstorydll")
OVL_DEFINE(OVL_NIS, "dll/nisdll.rel") OVL_DEFINE(OVL_NIS, "nisdll")
OVL_DEFINE(OVL_OPTION, "dll/option.rel") OVL_DEFINE(OVL_OPTION, "option")
OVL_DEFINE(OVL_PRESENT, "dll/present.rel") OVL_DEFINE(OVL_PRESENT, "present")
OVL_DEFINE(OVL_RESULT, "dll/resultdll.rel") OVL_DEFINE(OVL_RESULT, "resultdll")
OVL_DEFINE(OVL_SAF, "dll/safdll.rel") OVL_DEFINE(OVL_SAF, "safdll")
OVL_DEFINE(OVL_SELMENU, "dll/selmenuDLL.rel") OVL_DEFINE(OVL_SELMENU, "selmenuDLL")
OVL_DEFINE(OVL_STAFF, "dll/staffdll.rel") OVL_DEFINE(OVL_STAFF, "staffdll")
OVL_DEFINE(OVL_SUBCHRSEL, "dll/subchrseldll.rel") OVL_DEFINE(OVL_SUBCHRSEL, "subchrseldll")
OVL_DEFINE(OVL_W01, "dll/w01dll.rel") OVL_DEFINE(OVL_W01, "w01dll")
OVL_DEFINE(OVL_W02, "dll/w02dll.rel") OVL_DEFINE(OVL_W02, "w02dll")
OVL_DEFINE(OVL_W03, "dll/w03dll.rel") OVL_DEFINE(OVL_W03, "w03dll")
OVL_DEFINE(OVL_W04, "dll/w04dll.rel") OVL_DEFINE(OVL_W04, "w04dll")
OVL_DEFINE(OVL_W05, "dll/w05dll.rel") OVL_DEFINE(OVL_W05, "w05dll")
OVL_DEFINE(OVL_W06, "dll/w06dll.rel") OVL_DEFINE(OVL_W06, "w06dll")
OVL_DEFINE(OVL_W10, "dll/w10dll.rel") OVL_DEFINE(OVL_W10, "w10dll")
OVL_DEFINE(OVL_W20, "dll/w20dll.rel") OVL_DEFINE(OVL_W20, "w20dll")
OVL_DEFINE(OVL_W21, "dll/w21dll.rel") OVL_DEFINE(OVL_W21, "w21dll")
OVL_DEFINE(OVL_ZTAR, "dll/ztardll.rel") OVL_DEFINE(OVL_ZTAR, "ztardll")

View file

@ -21,4 +21,15 @@
#define REFRESH_RATE 60 #define REFRESH_RATE 60
#endif #endif
#if _WIN32
#ifdef TARGET_MAIN
#define SHARED_SYM __declspec(dllexport)
#else
#define SHARED_SYM __declspec(dllimport)
#endif
#else
#define SHARED_SYM
#endif
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -4,14 +4,14 @@
#include "string.h" #include "string.h"
#include "version.h" #include "version.h"
s16 GwLanguage = 1; SHARED_SYM s16 GwLanguage = 1;
s16 GwLanguageSave = -1; SHARED_SYM s16 GwLanguageSave = -1;
GameStat GWGameStatDefault; SHARED_SYM GameStat GWGameStatDefault;
GameStat GWGameStat; SHARED_SYM GameStat GWGameStat;
SystemState GWSystem; SHARED_SYM SystemState GWSystem;
PlayerState GWPlayer[4]; SHARED_SYM PlayerState GWPlayer[4];
PlayerConfig GWPlayerCfg[4]; SHARED_SYM PlayerConfig GWPlayerCfg[4];
static inline void GWErase(void) static inline void GWErase(void)
{ {

View file

@ -125,7 +125,7 @@ void main(void)
GWPlayerCfg[i].character = -1; GWPlayerCfg[i].character = -1;
} }
//omMasterInit(0, _ovltbl, OVL_COUNT, OVL_BOOT); omMasterInit(0, _ovltbl, OVL_COUNT, OVL_BOOT);
VIWaitForRetrace(); VIWaitForRetrace();
if (VIGetNextField() == 0) { if (VIGetNextField() == 0) {

View file

@ -5,6 +5,10 @@
typedef s32 (*DLLProlog)(void); typedef s32 (*DLLProlog)(void);
typedef void (*DLLEpilog)(void); typedef void (*DLLEpilog)(void);
#ifdef TARGET_PC
typedef void (*DLLObjectSetup)(void);
#endif
omDllData *omDLLinfoTbl[OM_DLL_MAX]; omDllData *omDLLinfoTbl[OM_DLL_MAX];
static FileListEntry *omDLLFileList; static FileListEntry *omDLLFileList;
@ -31,6 +35,10 @@ s32 omDLLStart(s16 overlay, s16 flag)
dllno = omDLLSearch(overlay); dllno = omDLLSearch(overlay);
if(dllno >= 0 && !flag) { if(dllno >= 0 && !flag) {
omDllData *dll = omDLLinfoTbl[dllno]; omDllData *dll = omDLLinfoTbl[dllno];
#ifdef TARGET_PC
// TODO PC
OSReport("objdll>Already Loaded %s\n", dll->name);
#else
OSReport("objdll>Already Loaded %s(%08x %08x)\n", dll->name, dll->module, dll->bss); OSReport("objdll>Already Loaded %s(%08x %08x)\n", dll->name, dll->module, dll->bss);
omDLLInfoDump(&dll->module->info); omDLLInfoDump(&dll->module->info);
@ -38,6 +46,7 @@ s32 omDLLStart(s16 overlay, s16 flag)
memset(dll->bss, 0, dll->module->bssSize); memset(dll->bss, 0, dll->module->bssSize);
HuMemDCFlushAll(); HuMemDCFlushAll();
dll->ret = ((DLLProlog)dll->module->prolog)(); dll->ret = ((DLLProlog)dll->module->prolog)();
#endif
OSReport("objdll> %s prolog end\n", dll->name); OSReport("objdll> %s prolog end\n", dll->name);
return dllno; return dllno;
} else { } else {
@ -80,8 +89,10 @@ void omDLLEnd(s16 dllno, s16 flag)
} else { } else {
omDllData *dll; omDllData *dll;
dll = omDLLinfoTbl[dllno]; dll = omDLLinfoTbl[dllno];
#ifdef __MWERKS__
OSReport("objdll>Call Epilog\n"); OSReport("objdll>Call Epilog\n");
((DLLEpilog)dll->module->epilog)(); ((DLLEpilog)dll->module->epilog)();
#endif
OSReport("objdll>End DLL stayed:%s\n", omDLLinfoTbl[dllno]->name); OSReport("objdll>End DLL stayed:%s\n", omDLLinfoTbl[dllno]->name);
} }
OSReport("objdll>End DLL finish\n"); OSReport("objdll>End DLL finish\n");
@ -95,6 +106,12 @@ omDllData *omDLLLink(omDllData **dll_ptr, s16 overlay, s16 flag)
dll = HuMemDirectMalloc(HEAP_SYSTEM, sizeof(omDllData)); dll = HuMemDirectMalloc(HEAP_SYSTEM, sizeof(omDllData));
*dll_ptr = dll; *dll_ptr = dll;
dll->name = dllFile->name; dll->name = dllFile->name;
#ifdef _WIN32
dll->hModule = LoadLibrary(dllFile->name);
if (dll->hModule == NULL) {
OSReport("objdll>++++++++++++++++ DLL Link Failed\n");
}
#else
dll->module = HuDvdDataReadDirect(dllFile->name, HEAP_SYSTEM); dll->module = HuDvdDataReadDirect(dllFile->name, HEAP_SYSTEM);
dll->bss = HuMemDirectMalloc(HEAP_SYSTEM, dll->module->bssSize); dll->bss = HuMemDirectMalloc(HEAP_SYSTEM, dll->module->bssSize);
if(OSLink(&dll->module->info, dll->bss) != TRUE) { if(OSLink(&dll->module->info, dll->bss) != TRUE) {
@ -103,9 +120,17 @@ omDllData *omDLLLink(omDllData **dll_ptr, s16 overlay, s16 flag)
omDLLInfoDump(&dll->module->info); omDLLInfoDump(&dll->module->info);
omDLLHeaderDump(dll->module); omDLLHeaderDump(dll->module);
OSReport("objdll>LinkOK %08x %08x\n", dll->module, dll->bss); OSReport("objdll>LinkOK %08x %08x\n", dll->module, dll->bss);
#endif
if(flag == 1) { if(flag == 1) {
OSReport("objdll> %s prolog start\n", dllFile->name); OSReport("objdll> %s prolog start\n", dllFile->name);
#ifdef _WIN32
{
DLLObjectSetup objectSetup = (DLLObjectSetup)GetProcAddress(dll->hModule, "ObjectSetup");
objectSetup();
}
#else
dll->ret = ((DLLProlog)dll->module->prolog)(); dll->ret = ((DLLProlog)dll->module->prolog)();
#endif
OSReport("objdll> %s prolog end\n", dllFile->name); OSReport("objdll> %s prolog end\n", dllFile->name);
} }
return dll; return dll;
@ -114,6 +139,9 @@ omDllData *omDLLLink(omDllData **dll_ptr, s16 overlay, s16 flag)
void omDLLUnlink(omDllData *dll_ptr, s16 flag) void omDLLUnlink(omDllData *dll_ptr, s16 flag)
{ {
OSReport("odjdll>Unlink DLL:%s\n", dll_ptr->name); OSReport("odjdll>Unlink DLL:%s\n", dll_ptr->name);
#ifdef _WIN32
FreeLibrary(dll_ptr->hModule);
#else
if(flag == 1) { if(flag == 1) {
OSReport("objdll>Unlink DLL epilog\n"); OSReport("objdll>Unlink DLL epilog\n");
((DLLEpilog)dll_ptr->module->epilog)(); ((DLLEpilog)dll_ptr->module->epilog)();
@ -124,6 +152,7 @@ void omDLLUnlink(omDllData *dll_ptr, s16 flag)
} }
HuMemDirectFree(dll_ptr->bss); HuMemDirectFree(dll_ptr->bss);
HuMemDirectFree(dll_ptr->module); HuMemDirectFree(dll_ptr->module);
#endif
HuMemDirectFree(dll_ptr); HuMemDirectFree(dll_ptr);
} }
@ -169,4 +198,4 @@ void omDLLHeaderDump(OSModuleHeader *module)
OSReport(" epilog func:0x%08x\n", module->epilog); OSReport(" epilog func:0x%08x\n", module->epilog);
OSReport(" unresolved func:0x%08x\n", module->unresolved); OSReport(" unresolved func:0x%08x\n", module->unresolved);
OSReport("================================\n"); OSReport("================================\n");
} }

View file

@ -1,12 +1,13 @@
#include "game/audio.h" #include "game/audio.h"
#include "game/chrman.h" #include "game/chrman.h"
#include "game/esprite.h" #include "game/esprite.h"
#include "game/flag.h"
#include "game/hsfdraw.h" #include "game/hsfdraw.h"
#include "game/hsfman.h" #include "game/hsfman.h"
#include "game/printfunc.h"
#include "game/object.h" #include "game/object.h"
#include "game/pad.h" #include "game/pad.h"
#include "game/flag.h" #include "game/printfunc.h"
#define OM_OVL_HIS_MAX 16 #define OM_OVL_HIS_MAX 16
#define OM_MAX_GROUPS 10 #define OM_MAX_GROUPS 10
@ -33,21 +34,21 @@ typedef struct om_obj_man {
omObjData *omDBGSysKeyObj; omObjData *omDBGSysKeyObj;
Process *omwatchproc; Process *omwatchproc;
OverlayID omnextovl; OverlayID omnextovl;
OverlayID omcurovl; SHARED_SYM OverlayID omcurovl;
s32 omcurdll; s32 omcurdll;
s32 omovlhisidx; SHARED_SYM s32 omovlhisidx;
s32 omovlevtno; SHARED_SYM s32 omovlevtno;
s32 omnextovlevtno; s32 omnextovlevtno;
u32 omovlstat; SHARED_SYM u32 omovlstat;
static s32 omnextovlstat; static s32 omnextovlstat;
char omUPauseFlag; char omUPauseFlag;
s16 omSysExitReq; SHARED_SYM s16 omSysExitReq;
s16 omdispinfo; s16 omdispinfo;
static omOvlHisData omovlhis[OM_OVL_HIS_MAX]; static omOvlHisData omovlhis[OM_OVL_HIS_MAX];
u8 omSysPauseEnableFlag = TRUE; SHARED_SYM u8 omSysPauseEnableFlag = TRUE;
OverlayID omprevovl = OVL_INVALID; SHARED_SYM OverlayID omprevovl = OVL_INVALID;
static void omWatchOverlayProc(void); static void omWatchOverlayProc(void);
static void omInsertObj(Process *objman_process, omObjData *object); static void omInsertObj(Process *objman_process, omObjData *object);
@ -61,14 +62,17 @@ void omMasterInit(s32 prio, FileListEntry *ovl_list, s32 ovl_count, OverlayID st
omovlhisidx = -1; omovlhisidx = -1;
omOvlCallEx(start_ovl, 1, 0, 0); omOvlCallEx(start_ovl, 1, 0, 0);
omDBGSysKeyObj = NULL; omDBGSysKeyObj = NULL;
#ifdef __MWERKS__
// TODO PC
omSysPauseEnable(TRUE); omSysPauseEnable(TRUE);
#endif
} }
static void omWatchOverlayProc(void) static void omWatchOverlayProc(void)
{ {
while(1) { while (1) {
if(omcurovl == OVL_INVALID) { if (omcurovl == OVL_INVALID) {
if(omnextovl >= 0 && fadeStat == 0) { if (omnextovl >= 0 && fadeStat == 0) {
HuPrcSleep(0); HuPrcSleep(0);
OSReport("++++++++++++++++++++ Start New OVL %d (EVT:%d STAT:0x%08x) ++++++++++++++++++\n", omnextovl, omnextovlevtno, omnextovlstat); OSReport("++++++++++++++++++++ Start New OVL %d (EVT:%d STAT:0x%08x) ++++++++++++++++++\n", omnextovl, omnextovlevtno, omnextovlstat);
HuMemHeapDump(HuMemHeapPtrGet(HEAP_SYSTEM), -1); HuMemHeapDump(HuMemHeapPtrGet(HEAP_SYSTEM), -1);
@ -79,28 +83,37 @@ static void omWatchOverlayProc(void)
OSReport("objman>Init esp\n"); OSReport("objman>Init esp\n");
espInit(); espInit();
OSReport("objman>Call objectsetup\n"); OSReport("objman>Call objectsetup\n");
#ifdef __MWERKS__
// TODO PC
HuAudVoiceInit(omnextovl); HuAudVoiceInit(omnextovl);
HuAudDllSndGrpSet(omnextovl); HuAudDllSndGrpSet(omnextovl);
#endif
omcurovl = omnextovl; omcurovl = omnextovl;
omovlevtno = omnextovlevtno; omovlevtno = omnextovlevtno;
omovlstat = omnextovlstat; omovlstat = omnextovlstat;
omnextovl = OVL_INVALID; omnextovl = OVL_INVALID;
if(_CheckFlag(FLAG_ID_MAKE(1, 12))) { #ifdef __MWERKS__
// TODO PC
if (_CheckFlag(FLAG_ID_MAKE(1, 12))) {
MGSeqPracticeInit(); MGSeqPracticeInit();
} }
omSysPauseEnable(TRUE); omSysPauseEnable(TRUE);
#endif
omcurdll = omDLLStart(omcurovl, 0); omcurdll = omDLLStart(omcurovl, 0);
OSReport("objman>ObjectSetup end\n"); OSReport("objman>ObjectSetup end\n");
if(omcurovl != OVL_INVALID) { if (omcurovl != OVL_INVALID) {
goto watch_child; goto watch_child;
} else { }
else {
continue; continue;
} }
} else { }
else {
HuPrcVSleep(); HuPrcVSleep();
} }
} else { }
watch_child: else {
watch_child:
HuPrcChildWatch(); HuPrcChildWatch();
} }
} }
@ -109,7 +122,7 @@ static void omWatchOverlayProc(void)
void omOvlCallEx(OverlayID overlay, s16 arg2, s32 event, s32 stat) void omOvlCallEx(OverlayID overlay, s16 arg2, s32 event, s32 stat)
{ {
OSReport("objman>Call New Ovl %d(%d)\n", overlay, arg2); OSReport("objman>Call New Ovl %d(%d)\n", overlay, arg2);
if(omovlhisidx >= OM_OVL_HIS_MAX) { if (omovlhisidx >= OM_OVL_HIS_MAX) {
OSReport("objman>OVL Call over error\n"); OSReport("objman>OVL Call over error\n");
return; return;
} }
@ -122,7 +135,7 @@ void omOvlCallEx(OverlayID overlay, s16 arg2, s32 event, s32 stat)
void omOvlGotoEx(OverlayID overlay, s16 arg2, s32 event, s32 stat) void omOvlGotoEx(OverlayID overlay, s16 arg2, s32 event, s32 stat)
{ {
omprevovl = omcurovl; omprevovl = omcurovl;
if(omcurovl >= 0) { if (omcurovl >= 0) {
omOvlKill(arg2); omOvlKill(arg2);
} }
omnextovl = overlay; omnextovl = overlay;
@ -134,7 +147,7 @@ void omOvlReturnEx(s16 level, s16 arg2)
{ {
omovlhisidx -= level; omovlhisidx -= level;
OSReport("objman>Ovl Return %d=%d(%d)\n", level, omovlhisidx, arg2); OSReport("objman>Ovl Return %d=%d(%d)\n", level, omovlhisidx, arg2);
if(omovlhisidx < 0) { if (omovlhisidx < 0) {
OSReport("objman>OVL under error\n"); OSReport("objman>OVL under error\n");
omovlhisidx = 0; omovlhisidx = 0;
} }
@ -143,10 +156,16 @@ void omOvlReturnEx(s16 level, s16 arg2)
void omOvlKill(s16 arg) void omOvlKill(s16 arg)
{ {
#ifdef __MWERKS__
// TODO PC
CharModelKill(-1); CharModelKill(-1);
MGSeqKillAll(); MGSeqKillAll();
#endif
Hu3DAllKill(); Hu3DAllKill();
#ifdef __MWERKS__
// TODO PC
HuWinAllKill(); HuWinAllKill();
#endif
HuSprClose(); HuSprClose();
HuPrcChildKill(omwatchproc); HuPrcChildKill(omwatchproc);
HuMemDirectFreeNum(HEAP_SYSTEM, MEMORY_DEFAULT_NUM); HuMemDirectFreeNum(HEAP_SYSTEM, MEMORY_DEFAULT_NUM);
@ -154,7 +173,10 @@ void omOvlKill(s16 arg)
HuMemDirectFreeNum(HEAP_DVD, MEMORY_DEFAULT_NUM); HuMemDirectFreeNum(HEAP_DVD, MEMORY_DEFAULT_NUM);
HuMemDirectFreeNum(HEAP_DATA, MEMORY_DEFAULT_NUM); HuMemDirectFreeNum(HEAP_DATA, MEMORY_DEFAULT_NUM);
HuPadRumbleAllStop(); HuPadRumbleAllStop();
#ifdef __MWERKS__
// TODO PC
HuAudFXListnerKill(); HuAudFXListnerKill();
#endif
OSReport("OvlKill %d\n", arg); OSReport("OvlKill %d\n", arg);
omSysExitReq = FALSE; omSysExitReq = FALSE;
omDLLNumEnd(omcurovl, arg); omDLLNumEnd(omcurovl, arg);
@ -165,11 +187,11 @@ void omOvlKill(s16 arg)
void omOvlHisChg(s32 level, OverlayID overlay, s32 event, s32 stat) void omOvlHisChg(s32 level, OverlayID overlay, s32 event, s32 stat)
{ {
omOvlHisData *history; omOvlHisData *history;
if(omovlhisidx-level < 0 || omovlhisidx-level >= OM_OVL_HIS_MAX) { if (omovlhisidx - level < 0 || omovlhisidx - level >= OM_OVL_HIS_MAX) {
OSReport("objman> omOvlHisChg: overlay 実行履歴の範囲外を変更しようとしました\n"); OSReport("objman> omOvlHisChg: overlay 実行履歴の範囲外を変更しようとしました\n");
return; return;
} }
history = &omovlhis[omovlhisidx-level]; history = &omovlhis[omovlhisidx - level];
history->overlay = overlay; history->overlay = overlay;
history->event = event; history->event = event;
history->stat = stat; history->stat = stat;
@ -177,11 +199,11 @@ void omOvlHisChg(s32 level, OverlayID overlay, s32 event, s32 stat)
omOvlHisData *omOvlHisGet(s32 level) omOvlHisData *omOvlHisGet(s32 level)
{ {
if(omovlhisidx-level < 0 || omovlhisidx-level >= OM_OVL_HIS_MAX) { if (omovlhisidx - level < 0 || omovlhisidx - level >= OM_OVL_HIS_MAX) {
OSReport("objman> omOvlHisGet: overlay 実行履歴の範囲外を参照しようとしました\n"); OSReport("objman> omOvlHisGet: overlay 実行履歴の範囲外を参照しようとしました\n");
return NULL; return NULL;
} }
return &omovlhis[omovlhisidx-level]; return &omovlhis[omovlhisidx - level];
} }
Process *omInitObjMan(s16 max_objs, s32 prio) Process *omInitObjMan(s16 max_objs, s32 prio)
@ -196,7 +218,7 @@ Process *omInitObjMan(s16 max_objs, s32 prio)
max_objs += 2; max_objs += 2;
omSysExitReq = FALSE; omSysExitReq = FALSE;
process = HuPrcChildCreate(omMain, prio, 16384, 0, omwatchproc); process = HuPrcChildCreate(omMain, prio, 16384, 0, omwatchproc);
HuPrcSetStat(process, PROCESS_STAT_PAUSE_EN|PROCESS_STAT_UPAUSE_EN); HuPrcSetStat(process, PROCESS_STAT_PAUSE_EN | PROCESS_STAT_UPAUSE_EN);
objman = HuMemDirectMallocNum(HEAP_SYSTEM, sizeof(omObjMan), MEMORY_DEFAULT_NUM); objman = HuMemDirectMallocNum(HEAP_SYSTEM, sizeof(omObjMan), MEMORY_DEFAULT_NUM);
objman->max_objs = max_objs; objman->max_objs = max_objs;
process->user_data = objman; process->user_data = objman;
@ -205,24 +227,24 @@ Process *omInitObjMan(s16 max_objs, s32 prio)
objman->next_idx = 0; objman->next_idx = 0;
objman->obj_last = -1; objman->obj_last = -1;
objman->obj_first = -1; objman->obj_first = -1;
obj_all = HuMemDirectMallocNum(HEAP_SYSTEM, max_objs*sizeof(omObjData), MEMORY_DEFAULT_NUM); obj_all = HuMemDirectMallocNum(HEAP_SYSTEM, max_objs * sizeof(omObjData), MEMORY_DEFAULT_NUM);
objman->obj = obj_all; objman->obj = obj_all;
group_all = HuMemDirectMallocNum(HEAP_SYSTEM, OM_MAX_GROUPS*sizeof(omObjGroup), MEMORY_DEFAULT_NUM); group_all = HuMemDirectMallocNum(HEAP_SYSTEM, OM_MAX_GROUPS * sizeof(omObjGroup), MEMORY_DEFAULT_NUM);
objman->group = group_all; objman->group = group_all;
for(i=0; i<max_objs;i++) { for (i = 0; i < max_objs; i++) {
obj = &obj_all[i]; obj = &obj_all[i];
obj->stat = 1; obj->stat = 1;
obj->prio = obj->prev =obj->next = -1; obj->prio = obj->prev = obj->next = -1;
obj->unk10 = 0; obj->unk10 = 0;
obj->trans.x = obj->trans.y = obj->trans.z = obj->rot.x = obj->rot.y = obj->rot.z = 0.0f; obj->trans.x = obj->trans.y = obj->trans.z = obj->rot.x = obj->rot.y = obj->rot.z = 0.0f;
obj->scale.x = obj->scale.y = obj->scale.z = 1.0f; obj->scale.x = obj->scale.y = obj->scale.z = 1.0f;
obj->model = obj->motion = NULL; obj->model = obj->motion = NULL;
obj->func = obj->data = NULL; obj->func = obj->data = NULL;
obj->next_idx = i+1; obj->next_idx = i + 1;
obj->mtncnt = 0; obj->mtncnt = 0;
obj->motion = NULL; obj->motion = NULL;
} }
for(i=0; i<OM_MAX_GROUPS;i++) { for (i = 0; i < OM_MAX_GROUPS; i++) {
group_all[i].max_objs = 0; group_all[i].max_objs = 0;
group_all[i].num_objs = 0; group_all[i].num_objs = 0;
group_all[i].next_idx = 0; group_all[i].next_idx = 0;
@ -250,7 +272,7 @@ omObjData *omAddObjEx(Process *objman_process, s16 prio, u16 mdlcnt, u16 mtncnt,
s16 next_idx; s16 next_idx;
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
omObjData *obj_base = objman->obj; omObjData *obj_base = objman->obj;
if(objman->num_objs == objman->max_objs) { if (objman->num_objs == objman->max_objs) {
return NULL; return NULL;
} }
next_idx = objman->next_idx; next_idx = objman->next_idx;
@ -258,26 +280,29 @@ omObjData *omAddObjEx(Process *objman_process, s16 prio, u16 mdlcnt, u16 mtncnt,
object->next_idx_alloc = next_idx; object->next_idx_alloc = next_idx;
object->prio = prio; object->prio = prio;
omInsertObj(objman_process, object); omInsertObj(objman_process, object);
if(mdlcnt) { if (mdlcnt) {
object->model = HuMemDirectMallocNum(HEAP_SYSTEM, mdlcnt*sizeof(s16), MEMORY_DEFAULT_NUM); object->model = HuMemDirectMallocNum(HEAP_SYSTEM, mdlcnt * sizeof(s16), MEMORY_DEFAULT_NUM);
object->mdlcnt = mdlcnt; object->mdlcnt = mdlcnt;
for(i=0; i<mdlcnt; i++) { for (i = 0; i < mdlcnt; i++) {
object->model[i] = -1; object->model[i] = -1;
} }
} else { }
else {
object->model = NULL; object->model = NULL;
object->mdlcnt = 0; object->mdlcnt = 0;
} }
if(mtncnt) { if (mtncnt) {
object->motion = HuMemDirectMallocNum(HEAP_SYSTEM, mtncnt*sizeof(s16), MEMORY_DEFAULT_NUM); object->motion = HuMemDirectMallocNum(HEAP_SYSTEM, mtncnt * sizeof(s16), MEMORY_DEFAULT_NUM);
object->mtncnt = mtncnt; object->mtncnt = mtncnt;
} else { }
else {
object->motion = NULL; object->motion = NULL;
object->mtncnt = 0; object->mtncnt = 0;
} }
if(group >= 0) { if (group >= 0) {
omAddMember(objman_process, group, object); omAddMember(objman_process, group, object);
} else { }
else {
object->group = group; object->group = group;
object->group_idx = 0; object->group_idx = 0;
} }
@ -302,31 +327,33 @@ static void omInsertObj(Process *objman_process, omObjData *object)
s16 prio = object->prio; s16 prio = object->prio;
s16 obj_idx; s16 obj_idx;
s16 prev_idx; s16 prev_idx;
if(objman->obj_first == -1) { if (objman->obj_first == -1) {
object->prev = -1; object->prev = -1;
object->next = -1; object->next = -1;
objman->obj_first = next_idx_alloc; objman->obj_first = next_idx_alloc;
objman->obj_last = next_idx_alloc; objman->obj_last = next_idx_alloc;
(void)objman; //HACK for matching (void)objman; // HACK for matching
return; return;
} }
for(obj_idx = objman->obj_first; obj_idx != -1; obj_idx = obj_new->next) { for (obj_idx = objman->obj_first; obj_idx != -1; obj_idx = obj_new->next) {
obj_new = &obj_all[obj_idx]; obj_new = &obj_all[obj_idx];
if(obj_new->prio <= prio) { if (obj_new->prio <= prio) {
break; break;
} }
prev_idx = obj_idx; prev_idx = obj_idx;
} }
if(obj_idx != -1) { if (obj_idx != -1) {
object->prev = obj_new->prev; object->prev = obj_new->prev;
object->next = obj_idx; object->next = obj_idx;
if(obj_new->prev != -1) { if (obj_new->prev != -1) {
obj_all[obj_new->prev].next = next_idx_alloc; obj_all[obj_new->prev].next = next_idx_alloc;
} else { }
else {
objman->obj_first = next_idx_alloc; objman->obj_first = next_idx_alloc;
} }
obj_new->prev = next_idx_alloc; obj_new->prev = next_idx_alloc;
} else { }
else {
object->next = -1; object->next = -1;
object->prev = prev_idx; object->prev = prev_idx;
obj_new->next = next_idx_alloc; obj_new->next = next_idx_alloc;
@ -338,7 +365,7 @@ void omAddMember(Process *objman_process, u16 group, omObjData *object)
{ {
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
omObjGroup *group_ptr = &objman->group[group]; omObjGroup *group_ptr = &objman->group[group];
if(group_ptr->num_objs != group_ptr->max_objs) { if (group_ptr->num_objs != group_ptr->max_objs) {
object->group = group; object->group = group;
object->group_idx = group_ptr->next_idx; object->group_idx = group_ptr->next_idx;
group_ptr->obj[group_ptr->next_idx] = object; group_ptr->obj[group_ptr->next_idx] = object;
@ -352,40 +379,41 @@ void omDelObjEx(Process *objman_process, omObjData *object)
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
omObjData *obj_all = objman->obj; omObjData *obj_all = objman->obj;
s16 next_idx_alloc = object->next_idx_alloc; s16 next_idx_alloc = object->next_idx_alloc;
if(objman->num_objs == 0 || object->stat == 1) { if (objman->num_objs == 0 || object->stat == 1) {
return; return;
} }
objman->num_objs--; objman->num_objs--;
if(object->group >= 0) { if (object->group >= 0) {
omDelMember(objman_process, object); omDelMember(objman_process, object);
} }
if(object->motion != NULL) { if (object->motion != NULL) {
HuMemDirectFree(object->motion); HuMemDirectFree(object->motion);
object->motion = NULL; object->motion = NULL;
} }
if(object->model != NULL) { if (object->model != NULL) {
HuMemDirectFree(object->model); HuMemDirectFree(object->model);
object->model = NULL; object->model = NULL;
} }
if(object->data != NULL) { if (object->data != NULL) {
HuMemDirectFree(object->data); HuMemDirectFree(object->data);
object->data = NULL; object->data = NULL;
} }
object->stat = OM_STAT_DELETED; object->stat = OM_STAT_DELETED;
if(object->next >= 0) { if (object->next >= 0) {
obj_all[object->next].prev = object->prev; obj_all[object->next].prev = object->prev;
} }
if(object->prev >= 0) { if (object->prev >= 0) {
obj_all[object->prev].next = object->next; obj_all[object->prev].next = object->next;
} }
if(objman->num_objs != 0) { if (objman->num_objs != 0) {
if(object->prev < 0) { if (object->prev < 0) {
objman->obj_first = obj_all[object->next].next_idx_alloc; objman->obj_first = obj_all[object->next].next_idx_alloc;
} }
if(object->next < 0) { if (object->next < 0) {
objman->obj_last = obj_all[object->prev].next_idx_alloc; objman->obj_last = obj_all[object->prev].next_idx_alloc;
} }
} else { }
else {
objman->obj_first = objman->obj_last = -1; objman->obj_first = objman->obj_last = -1;
} }
object->next_idx = objman->next_idx; object->next_idx = objman->next_idx;
@ -394,7 +422,7 @@ void omDelObjEx(Process *objman_process, omObjData *object)
void omDelMember(Process *objman_process, omObjData *object) void omDelMember(Process *objman_process, omObjData *object)
{ {
if(object->group != -1) { if (object->group != -1) {
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
omObjData *obj_all = objman->obj; omObjData *obj_all = objman->obj;
omObjGroup *group = &objman->group[object->group]; omObjGroup *group = &objman->group[object->group];
@ -411,20 +439,20 @@ void omMakeGroupEx(Process *objman_process, u16 group, u16 max_objs)
s32 i; s32 i;
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
omObjGroup *group_ptr = &objman->group[group]; omObjGroup *group_ptr = &objman->group[group];
if(group_ptr->obj != NULL) { if (group_ptr->obj != NULL) {
HuMemDirectFree(group_ptr->obj); HuMemDirectFree(group_ptr->obj);
} }
if(group_ptr->next != NULL) { if (group_ptr->next != NULL) {
HuMemDirectFree(group_ptr->next); HuMemDirectFree(group_ptr->next);
} }
group_ptr->next_idx = 0; group_ptr->next_idx = 0;
group_ptr->max_objs = max_objs; group_ptr->max_objs = max_objs;
group_ptr->num_objs = 0; group_ptr->num_objs = 0;
group_ptr->obj = HuMemDirectMallocNum(HEAP_SYSTEM, max_objs*sizeof(omObjData *), MEMORY_DEFAULT_NUM); group_ptr->obj = HuMemDirectMallocNum(HEAP_SYSTEM, max_objs * sizeof(omObjData *), MEMORY_DEFAULT_NUM);
group_ptr->next = HuMemDirectMallocNum(HEAP_SYSTEM, max_objs*sizeof(u16), MEMORY_DEFAULT_NUM); group_ptr->next = HuMemDirectMallocNum(HEAP_SYSTEM, max_objs * sizeof(u16), MEMORY_DEFAULT_NUM);
for(i=0; i<max_objs; i++) { for (i = 0; i < max_objs; i++) {
group_ptr->obj[i] = NULL; group_ptr->obj[i] = NULL;
group_ptr->next[i] = i+1; group_ptr->next[i] = i + 1;
} }
} }
@ -473,38 +501,38 @@ void omMain(void)
omObjData *object; omObjData *object;
s16 obj_index; s16 obj_index;
omDLLDBGOut(); omDLLDBGOut();
while(1) { while (1) {
if(omdispinfo) { if (omdispinfo) {
float scale = 1.5f; float scale = 1.5f;
GXColor color; GXColor color;
color.a = 96; color.a = 96;
color.r = 0; color.r = 0;
color.g = 0; color.g = 0;
color.b = 255; color.b = 255;
printWin(7, 23, 128*scale, 40*scale, &color); printWin(7, 23, 128 * scale, 40 * scale, &color);
fontcolor = FONT_COLOR_YELLOW; fontcolor = FONT_COLOR_YELLOW;
print8(8, 24, scale, "\xFD\x01H:%08lX(%ld)", HuMemUsedMallocSizeGet(HEAP_SYSTEM), HuMemUsedMallocBlockGet(HEAP_SYSTEM)); print8(8, 24, scale, "\xFD\x01H:%08lX(%ld)", HuMemUsedMallocSizeGet(HEAP_SYSTEM), HuMemUsedMallocBlockGet(HEAP_SYSTEM));
print8(8, 24+(8*scale), scale, "\xFD\x01M:%08lX(%ld)", HuMemUsedMallocSizeGet(HEAP_DATA), HuMemUsedMallocBlockGet(HEAP_DATA)); print8(8, 24 + (8 * scale), scale, "\xFD\x01M:%08lX(%ld)", HuMemUsedMallocSizeGet(HEAP_DATA), HuMemUsedMallocBlockGet(HEAP_DATA));
print8(8, 24+(16*scale), scale, "\xFD\x01OBJ:%d/%d", objman->num_objs, objman->max_objs); print8(8, 24 + (16 * scale), scale, "\xFD\x01OBJ:%d/%d", objman->num_objs, objman->max_objs);
print8(8, 24+(24*scale), scale, "\xFD\x01OVL:%ld(%ld<%ld)", omovlhisidx, omcurovl, omprevovl); print8(8, 24 + (24 * scale), scale, "\xFD\x01OVL:%ld(%ld<%ld)", omovlhisidx, omcurovl, omprevovl);
print8(8, 24+(32*scale), scale, "\xFD\x01POL:%ld", totalPolyCnted); print8(8, 24 + (32 * scale), scale, "\xFD\x01POL:%ld", totalPolyCnted);
} }
obj_index = objman->obj_last; obj_index = objman->obj_last;
while(obj_index != -1) { while (obj_index != -1) {
object = &obj_all[obj_index]; object = &obj_all[obj_index];
obj_index = object->prev; obj_index = object->prev;
if((object->stat & (OM_STAT_DELETED|OM_STAT_DISABLED)) == 0) { if ((object->stat & (OM_STAT_DELETED | OM_STAT_DISABLED)) == 0) {
if(object->func != NULL && (object->stat & (0x40|0x8|OM_STAT_PAUSED)) == 0) { if (object->func != NULL && (object->stat & (0x40 | 0x8 | OM_STAT_PAUSED)) == 0) {
object->func(object); object->func(object);
} }
if(omcurovl == -1 || objman->obj_last == -1) { if (omcurovl == -1 || objman->obj_last == -1) {
break; break;
} }
if((object->stat & (OM_STAT_DELETED|OM_STAT_DISABLED)) == 0) { if ((object->stat & (OM_STAT_DELETED | OM_STAT_DISABLED)) == 0) {
if((obj_all[obj_index].stat & (OM_STAT_DELETED|OM_STAT_DISABLED)) != 0) { if ((obj_all[obj_index].stat & (OM_STAT_DELETED | OM_STAT_DISABLED)) != 0) {
obj_index = object->prev; obj_index = object->prev;
} }
if(object->model != NULL && object->model[0] != -1 && !(object->stat & OM_STAT_MODEL_PAUSED)) { if (object->model != NULL && object->model[0] != -1 && !(object->stat & OM_STAT_MODEL_PAUSED)) {
Hu3DModelPosSet(object->model[0], object->trans.x, object->trans.y, object->trans.z); Hu3DModelPosSet(object->model[0], object->trans.x, object->trans.y, object->trans.z);
Hu3DModelRotSet(object->model[0], object->rot.x, object->rot.y, object->rot.z); Hu3DModelRotSet(object->model[0], object->rot.x, object->rot.y, object->rot.z);
Hu3DModelScaleSet(object->model[0], object->scale.x, object->scale.y, object->scale.z); Hu3DModelScaleSet(object->model[0], object->scale.x, object->scale.y, object->scale.z);
@ -516,7 +544,7 @@ void omMain(void)
} }
} }
//Dummy function to force string literals in binary // Dummy function to force string literals in binary
static void omDumpObj(Process *objman_process) static void omDumpObj(Process *objman_process)
{ {
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
@ -524,14 +552,12 @@ static void omDumpObj(Process *objman_process)
s32 i; s32 i;
OSReport("=================== 現在登録されている OBJECT ==================\n"); OSReport("=================== 現在登録されている OBJECT ==================\n");
OSReport("STAT PRI GRPN MEMN PROG (TRA) (ROT) (SCA) mdlcnt mtncnt work[0] work[1] work[2] work[3] *data\n"); OSReport("STAT PRI GRPN MEMN PROG (TRA) (ROT) (SCA) mdlcnt mtncnt work[0] work[1] work[2] work[3] *data\n");
for(i=0; i<objman->max_objs; i++) { for (i = 0; i < objman->max_objs; i++) {
omObjData *object = &obj_all[i]; omObjData *object = &obj_all[i];
OSReport("%04d:%04X %04X %d %d %08X (%.2f %.2f %.2f) (%.2f %.2f %.2f) (%.2f %.2f %.2f) %d %d %08X %08X %08X %08X %08X\n", OSReport("%04d:%04X %04X %d %d %08X (%.2f %.2f %.2f) (%.2f %.2f %.2f) (%.2f %.2f %.2f) %d %d %08X %08X %08X %08X %08X\n", object->stat,
object->stat, object->stat, object->prio, object->group, object->unk10, object->func, object->stat, object->prio, object->group, object->unk10, object->func, object->trans.x, object->trans.y, object->trans.z, object->rot.x,
object->trans.x, object->trans.y, object->trans.z, object->rot.y, object->rot.z, object->scale.x, object->scale.y, object->scale.z, object->mdlcnt, object->mtncnt, object->work[0],
object->rot.x, object->rot.y, object->rot.z, object->work[1], object->work[2], object->work[3], object->data);
object->scale.x, object->scale.y, object->scale.z,
object->mdlcnt, object->mtncnt, object->work[0], object->work[1], object->work[2], object->work[3], object->data);
} }
OSReport("================================================================\n"); OSReport("================================================================\n");
} }
@ -541,15 +567,16 @@ void omAllPause(BOOL pause)
Process *objman_process = HuPrcCurrentGet(); Process *objman_process = HuPrcCurrentGet();
omObjMan *objman = objman_process->user_data; omObjMan *objman = objman_process->user_data;
s32 i; s32 i;
if(pause) { if (pause) {
for(i=0; i<objman->max_objs; i++) { for (i = 0; i < objman->max_objs; i++) {
if((objman->obj[i].stat & (OM_STAT_DELETED|OM_STAT_NOPAUSE)) == 0) { if ((objman->obj[i].stat & (OM_STAT_DELETED | OM_STAT_NOPAUSE)) == 0) {
omSetStatBit(&objman->obj[i], OM_STAT_PAUSED); omSetStatBit(&objman->obj[i], OM_STAT_PAUSED);
} }
} }
} else { }
for(i=0; i<objman->max_objs; i++) { else {
if((objman->obj[i].stat & (OM_STAT_DELETED|OM_STAT_NOPAUSE)) == 0) { for (i = 0; i < objman->max_objs; i++) {
if ((objman->obj[i].stat & (OM_STAT_DELETED | OM_STAT_NOPAUSE)) == 0) {
omResetStatBit(&objman->obj[i], OM_STAT_PAUSED); omResetStatBit(&objman->obj[i], OM_STAT_PAUSED);
} }
} }
@ -558,9 +585,10 @@ void omAllPause(BOOL pause)
char omPauseChk(void) char omPauseChk(void)
{ {
if(omDBGSysKeyObj == NULL) { if (omDBGSysKeyObj == NULL) {
return 0; return 0;
} else { }
else {
return omDBGSysKeyObj->work[0] & 0x1; return omDBGSysKeyObj->work[0] & 0x1;
} }
} }

View file

@ -1,11 +1,15 @@
#include "game/dvd.h" #include "game/dvd.h"
#include "game/object.h" #include "game/object.h"
#define OVL_DEFINE(name, path) { path, 0 }, #ifdef _WIN32
#define OVL_DEFINE(name, path) { path ".dll", 0 },
#else
#define OVL_DEFINE(name, path) { "dll/" path ".rel", 0 },
#endif
FileListEntry _ovltbl[OVL_COUNT+1] = { FileListEntry _ovltbl[OVL_COUNT+1] = {
#include "ovl_table.h" #include "ovl_table.h"
{ NULL, -1 } { NULL, -1 }
}; };
#undef OVL_DEFINE #undef OVL_DEFINE

View file

@ -9,7 +9,7 @@
// Credits: Super Monkey Ball // Credits: Super Monkey Ball
void OSReport(const char *msg, ...) __declspec(dllexport) void OSReport(const char *msg, ...)
{ {
va_list args; va_list args;
va_start(args, msg); va_start(args, msg);
@ -353,7 +353,7 @@ BOOL OSInitFont(OSFontHeader *fontData)
BOOL OSLink(OSModuleInfo *newModule, void *bss) BOOL OSLink(OSModuleInfo *newModule, void *bss)
{ {
puts("OSLink is a stub"); puts("OSLink is a stub");
return FALSE; return TRUE;
} }
void OSLoadContext(OSContext *context) void OSLoadContext(OSContext *context)
@ -699,7 +699,5 @@ void MGSeqMain(void)
puts("MGSeqMain is a stub"); puts("MGSeqMain is a stub");
} }
void omMasterInit(s32 prio, FileListEntry *ovl_list, s32 ovl_count, OverlayID start_ovl) // TODO remove
{ u8 fadeStat = 0;
puts("omMasterInit is a stub");
}