diff --git a/.gitignore b/.gitignore index 2fa85e7a9c..ae7fa75384 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,10 @@ orig/*/* *.map *.MAP +# Save files +*.raw +*.gci + # Build files build/ .ninja_* @@ -32,6 +36,7 @@ compile_commands.json # Miscellaneous *.exe +*.zip # MacOS .DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index 051e5700fb..d162a704b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.16) if (APPLE) project(dusk LANGUAGES C CXX OBJC OBJCXX) else () @@ -115,13 +115,18 @@ add_library(game SHARED ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${J src/dusk/imgui/ImGuiStubLog.cpp src/dusk/imgui/ImGuiAudio.cpp) +<<<<<<< 26-03-28-movie-player target_link_libraries(game PRIVATE game_debug cxxopts::cxxopts) if (DUSK_MOVIE_SUPPORT_REAL) target_link_libraries(game PRIVATE libjpeg-turbo::turbojpeg-static) target_compile_definitions(game PRIVATE MOVIE_SUPPORT=1) endif () +======= +target_link_libraries(game PRIVATE game_debug cxxopts::cxxopts absl::flat_hash_map) +>>>>>>> main target_compile_definitions(game PRIVATE TARGET_PC AVOID_UB=1 VERSION=0 NDEBUG=1 NDEBUG_DEFINED=1 DEBUG_DEFINED=0 DUSK_TP_VERSION="${DUSK_TP_VERSION}" DUSK_GAME_NAME="${DUSK_GAME_NAME}" DUSK_GAME_VERSION="${DUSK_GAME_VERSION}") +target_precompile_headers(game PRIVATE "$<$:${CMAKE_SOURCE_DIR}/include/dusk_pch.hpp>") add_executable(dusk src/dusk/main.cpp) target_compile_definitions(dusk PRIVATE TARGET_PC AVOID_UB=1 VERSION=0) target_include_directories(dusk PRIVATE include) diff --git a/extern/aurora b/extern/aurora index 236a7a5e9a..6b9f614d32 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 236a7a5e9a65b3d74371c2eae8fd161f3c5eacb1 +Subproject commit 6b9f614d326aaa4a4dead870ffd22393d2a4ef53 diff --git a/include/Z2AudioCS/SpkTable.h b/include/Z2AudioCS/SpkTable.h index 8fc12bd735..862fdba3c1 100644 --- a/include/Z2AudioCS/SpkTable.h +++ b/include/Z2AudioCS/SpkTable.h @@ -18,10 +18,10 @@ public: SpkTable(void); void setResource(void* res); - inline s32 getName(s32 num) { + inline const char* getName(s32 num) { JUT_ASSERT(0x35, num >= 0); JUT_ASSERT(0x36, num < mNumOfSound); - return *(mDataOffsets + num); + return (const char*)*(mDataOffsets + num); } inline s32 getNumOfSound() const { return mNumOfSound; } inline bool isValid(void) const { return mIsInitialized; } diff --git a/include/Z2AudioCS/Z2AudioCS.h b/include/Z2AudioCS/Z2AudioCS.h index 7d13accabc..694218ab4f 100644 --- a/include/Z2AudioCS/Z2AudioCS.h +++ b/include/Z2AudioCS/Z2AudioCS.h @@ -19,7 +19,7 @@ public: static SpkSoundHandle* getHandleSoundID(s32 soundNum); static SpkSoundHandle* start(s32 id, s32 chan); static SpkSoundHandle* startLevel(s32 id, s32 chan); - static s32 getName(s32 num); + static const char* getName(s32 num); static s32 getNumOfSound(void); static void stopAll(s32 chan, s32 msec); static void stop(s32 chan); diff --git a/include/Z2AudioLib/Z2Instances.h b/include/Z2AudioLib/Z2Instances.h index 0f1a02cdb1..b8e6af7a3e 100644 --- a/include/Z2AudioLib/Z2Instances.h +++ b/include/Z2AudioLib/Z2Instances.h @@ -6,6 +6,9 @@ #include "JSystem/JAudio2/JASAudioThread.h" #include "JSystem/JAudio2/JAUSoundTable.h" +#if TARGET_PC +#define AUDIO_INSTANCES +#else #define AUDIO_INSTANCES \ template<> JASDefaultBankTable* JASGlobalInstance::sInstance; \ template<> JASAudioThread* JASGlobalInstance::sInstance; \ @@ -32,5 +35,6 @@ template<> Z2EnvSeMgr* JASGlobalInstance::sInstance; \ template<> Z2SpeechMgr* JASGlobalInstance::sInstance; \ template<> Z2WolfHowlMgr* JASGlobalInstance::sInstance; +#endif #endif diff --git a/include/Z2AudioLib/Z2SoundPlayer.h b/include/Z2AudioLib/Z2SoundPlayer.h index 6937ba63af..3baf4c15b5 100644 --- a/include/Z2AudioLib/Z2SoundPlayer.h +++ b/include/Z2AudioLib/Z2SoundPlayer.h @@ -3,6 +3,7 @@ #include "JSystem/JAWExtSystem/JAWWindow.h" #include "JSystem/JAudio2/JAISoundHandles.h" +#include "JSystem/JAudio2/JAUSoundTable.h" class Z2SoundPlayer : public JAWWindow { public: @@ -24,43 +25,32 @@ public: virtual void onKeyRight(const JUTGamePad&); u32 getCursorMoveMax(const JUTGamePad&); + int getMenuNumberMax(); + void correctSeNumber(); - /* 0x3ED */ u8 field_0x3ed; - /* 0x3EE */ u8 field_0x3ee; - /* 0x3EF */ u8 field_0x3ef; - /* 0x3F0 */ u8 field_0x3f0; - /* 0x3F4 */ const char* field_0x3f4; - /* 0x3F8 */ short field_0x3f8; - /* 0x3FA */ short field_0x3fa; - /* 0x3FC */ short field_0x3fc; - /* 0x3FE */ short field_0x3fe; - /* 0x400 */ short field_0x400; - /* 0x402 */ short field_0x402; - /* 0x404 */ const char* field_0x404; - /* 0x408 */ const char* field_0x408; - /* 0x40C */ const char* field_0x40c; - /* 0x410 */ const char* field_0x410; - /* 0x414 */ const char* field_0x414; - /* 0x418 */ const char* field_0x418; - /* 0x41C */ const char* field_0x41c; - /* 0x420 */ const char* field_0x420; - /* 0x424 */ const char* field_0x424; - /* 0x428 */ const char* field_0x428; - /* 0x42C */ const char* field_0x42c; - /* 0x430 */ const char* field_0x430; - /* 0x434 */ const char* field_0x434; - /* 0x438 */ const char* field_0x438; - /* 0x43C */ const char* field_0x43c; - /* 0x440 */ const char* field_0x440; - /* 0x444 */ short field_0x444; + void onDrawSoundItem(JAWGraphContext*, JAUSoundNameTable*, int, const JUtility::TColor&, const JUtility::TColor&, const char*, u32, u32, u32); + + /* 0x3ED */ bool field_0x3ed; + /* 0x3EE */ bool field_0x3ee; + /* 0x3EF */ bool field_0x3ef; + /* 0x3F0 */ bool field_0x3f0; + /* 0x3F4 */ const char* m_name; + /* 0x3F8 */ s16 field_0x3f8; + /* 0x3FA */ s16 field_0x3fa; + /* 0x3FC */ s16 field_0x3fc; + /* 0x3FE */ s16 field_0x3fe; + /* 0x400 */ s16 field_0x400; + /* 0x402 */ s16 m_portNum; + /* 0x404 */ const char* m_portNames[16]; + /* 0x444 */ s16 m_portVal; /* 0x446 */ u8 field_0x446; - /* 0x448 */ short* field_0x448[7]; - /* 0x464 */ int field_0x464; - /* 0x468 */ int field_0x468; + /* 0x448 */ s16* field_0x448[7]; + /* 0x464 */ u32 m_cursorY; + /* 0x468 */ int m_cursorMax; /* 0x46C */ JAISoundHandle field_0x46c[8]; /* 0x48C */ JAISoundHandles field_0x48c; /* 0x494 */ JAISoundHandle field_0x494; - /* 0x498 */ JAISoundHandle* field_0x498; + /* 0x498 */ JAISoundHandle* mp_subBgmHandle; /* 0x49C */ JAISoundHandle field_0x49c; /* 0x4A0 */ int field_0x4a0; /* 0x4A4 */ f32 field_0x4a4; diff --git a/include/Z2AudioLib/Z2WaveArcLoader.h b/include/Z2AudioLib/Z2WaveArcLoader.h index 81a4bc2123..ac15c50001 100644 --- a/include/Z2AudioLib/Z2WaveArcLoader.h +++ b/include/Z2AudioLib/Z2WaveArcLoader.h @@ -2,10 +2,39 @@ #define Z2WAVEARCLOADER_H #include "JSystem/JAWExtSystem/JAWWindow.h" +#include "JSystem/JAudio2/JASWaveArcLoader.h" +#include "JSystem/JAudio2/JASWaveInfo.h" class Z2WaveArcLoader : public JAWWindow { public: Z2WaveArcLoader(); + virtual ~Z2WaveArcLoader(); + + virtual void onDraw(JAWGraphContext*); + + void checkWaveBank(); + void checkWaveArc(); + + virtual void onKeyUp(const JUTGamePad&); + virtual void onKeyDown(const JUTGamePad&); + virtual void onKeyLeft(const JUTGamePad&); + virtual void onKeyRight(const JUTGamePad&); + virtual void onTrigA(const JUTGamePad&); + virtual void onTrigB(const JUTGamePad&); + virtual void onTrigZ(const JUTGamePad&); + + /* 0x3F0 */ JASWaveBank* mpWaveBank; + /* 0x3F4 */ JASWaveArc* mpWaveArc; + /* 0x3F8 */ u32 mWaveUsedSize; + /* 0x3FC */ int mTotalUsedSize; + /* 0x400 */ u8 mBankNo; + /* 0x404 */ u32 mArcCount; + /* 0x408 */ u32 field_0x408; + /* 0x40C */ u32 field_0x40c; + /* 0x410 */ u32 field_0x410; + /* 0x414 */ u8 field_0x414; + /* 0x415 */ u8 field_0x415; + /* 0x416 */ bool mIsLoadTail; }; #endif /* Z2WAVEARCLOADER_H */ diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index 7c70ea54e5..a4d38efc43 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -8425,4 +8425,10 @@ inline daAlink_c* daAlink_getAlinkActorClass() { return (daAlink_c*)dComIfGp_getLinkPlayer(); } +#if TARGET_PC +namespace dusk::tweaks { + extern bool FastIronBoots; +} +#endif + #endif /* D_A_D_A_ALINK_H */ diff --git a/include/d/actor/d_a_e_ws.h b/include/d/actor/d_a_e_ws.h index c7b6ae5c58..ada0509d24 100644 --- a/include/d/actor/d_a_e_ws.h +++ b/include/d/actor/d_a_e_ws.h @@ -50,30 +50,30 @@ public: int create(); /* 0x5AC */ request_of_phase_process_class mPhase; - /* 0x5B4 */ mDoExt_McaMorfSO* mpModelMorf; + /* 0x5B4 */ mDoExt_McaMorfSO* mAnm_p; /* 0x5B8 */ Z2CreatureEnemy mSound; - /* 0x65C */ cXyz field_0x65c; - /* 0x668 */ csXyz field_0x668; - /* 0x66E */ csXyz field_0x66e; + /* 0x65C */ cXyz mHomePos; + /* 0x668 */ csXyz mTargetWallAngle; + /* 0x66E */ csXyz mWallAngle; /* 0x674 */ f32 mDownColor; /* 0x678 */ f32 mBodyScale; /* 0x67C */ int mAction; /* 0x680 */ int mMode; /* 0x684 */ u32 mShadowId; /* 0x688 */ s16 mTargetAngle; - /* 0x68A */ s16 mTargetStep; - /* 0x68C */ u8 mMoveWaitTimer; + /* 0x68A */ s16 mStepAngle; + /* 0x68C */ u8 mWaitTimer; /* 0x68E */ s16 mInvulnerabilityTimer; - /* 0x690 */ u8 field_0x690; - /* 0x691 */ u8 field_0x691; - /* 0x692 */ u8 mSwbit; - /* 0x694 */ dBgS_AcchCir mAcchCir; + /* 0x690 */ u8 mIsReturnHome; + /* 0x691 */ u8 arg0; + /* 0x692 */ u8 bitSw; + /* 0x694 */ dBgS_AcchCir mBgc; /* 0x6D4 */ dBgS_ObjAcch mAcch; /* 0x8AC */ dCcD_Stts mCcStts; /* 0x8E8 */ dCcD_Sph mCcSph; /* 0xA20 */ dCcD_Sph mCcBokkuriSph; /* 0xB58 */ dCcU_AtInfo mAtInfo; - /* 0xB7C */ u8 mHIOInit; + /* 0xB7C */ u8 mHioSet; }; STATIC_ASSERT(sizeof(daE_WS_c) == 0xb80); diff --git a/include/d/actor/d_a_npc_sola.h b/include/d/actor/d_a_npc_sola.h index 6d6cf742f8..0b13842f9c 100644 --- a/include/d/actor/d_a_npc_sola.h +++ b/include/d/actor/d_a_npc_sola.h @@ -77,7 +77,7 @@ public: int CreateHeap(); int Delete(); int Execute(); - void Draw(); + int Draw(); static BOOL createHeapCallBack(fopAc_ac_c*); static BOOL ctrlJointCallBack(J3DJoint*, int); bool getType(); diff --git a/include/d/actor/d_flower.h b/include/d/actor/d_flower.h index 92bdad59a2..cd505335a8 100644 --- a/include/d/actor/d_flower.h +++ b/include/d/actor/d_flower.h @@ -103,6 +103,11 @@ public: /* 0x12A48 */ u32 m_Jhana01DL_size; /* 0x12A4C */ u8* mp_Jhana01_cDL; /* 0x12A50 */ u32 m_Jhana01_cDL_size; + +#if TARGET_PC + TGXTexObj mTexObj_l_J_Ohana00_64TEX; + TGXTexObj mTexObj_l_J_Ohana01_64128_0419TEX; +#endif }; // Size: 0x12A54 #endif /* D_FLOWER_H */ diff --git a/include/d/actor/d_grass.h b/include/d/actor/d_grass.h index 5a152ed478..47b948679d 100644 --- a/include/d/actor/d_grass.h +++ b/include/d/actor/d_grass.h @@ -108,8 +108,8 @@ public: /* 0x1D714 */ s16 field_0x1d714; #if TARGET_PC - GXTexObj mTexObj_l_M_Hijiki00TEX{}; - GXTexObj mTexObj_l_M_kusa05_RGBATEX{}; + TGXTexObj mTexObj_l_M_Hijiki00TEX; + TGXTexObj mTexObj_l_M_kusa05_RGBATEX; #endif }; // Size: 0x1D718 diff --git a/include/d/d_map.h b/include/d/d_map.h index 66a51aae75..28786e4f94 100644 --- a/include/d/d_map.h +++ b/include/d/d_map.h @@ -66,14 +66,14 @@ struct dMap_prm_res_s { /* 0x1A7 */ u8 field_0x1a7; /* 0x1A8 */ u8 field_0x1a8; /* 0x1A9 */ u8 field_0x1a9; - /* 0x1AA */ s16 field_0x1aa; - /* 0x1AC */ s16 field_0x1ac; - /* 0x1AE */ s16 field_0x1ae; - /* 0x1B0 */ s16 field_0x1b0; - /* 0x1B2 */ s16 field_0x1b2; - /* 0x1B4 */ s16 field_0x1b4; - /* 0x1B6 */ s16 field_0x1b6; - /* 0x1B8 */ f32 cursor_size; + /* 0x1AA */ BE(s16) field_0x1aa; + /* 0x1AC */ BE(s16) field_0x1ac; + /* 0x1AE */ BE(s16) field_0x1ae; + /* 0x1B0 */ BE(s16) field_0x1b0; + /* 0x1B2 */ BE(s16) field_0x1b2; + /* 0x1B4 */ BE(s16) field_0x1b4; + /* 0x1B6 */ BE(s16) field_0x1b6; + /* 0x1B8 */ BE(f32) cursor_size; }; struct dMap_prm_hio_s { diff --git a/include/d/d_map_path.h b/include/d/d_map_path.h index 3dcfd2b38d..495fdf396a 100644 --- a/include/d/d_map_path.h +++ b/include/d/d_map_path.h @@ -5,7 +5,7 @@ #include "JSystem/JHostIO/JORMContext.h" struct dMpath_RGB5A3_s { - u16 color; + BE(u16) color; }; namespace dMpath_ColorCnv_n { diff --git a/include/d/d_menu_map_common.h b/include/d/d_menu_map_common.h index 84da15328c..989aee7d8b 100644 --- a/include/d/d_menu_map_common.h +++ b/include/d/d_menu_map_common.h @@ -75,9 +75,9 @@ public: /* 0x00 */ char mName[8]; /* 0x08 */ u8 mRoomNo; /* 0x09 */ u8 mRegionNo; - /* 0x0A */ u16 mAreaName; - /* 0x0C */ f32 mOffsetX; - /* 0x10 */ f32 mOffsetZ; + /* 0x0A */ BE(u16) mAreaName; + /* 0x0C */ BE(f32) mOffsetX; + /* 0x10 */ BE(f32) mOffsetZ; }; /* 0x0 */ u8 mCount; diff --git a/include/d/d_meter2_info.h b/include/d/d_meter2_info.h index 72ca6ad9b2..51f07f4dc3 100644 --- a/include/d/d_meter2_info.h +++ b/include/d/d_meter2_info.h @@ -321,6 +321,7 @@ int dMeter2Info_setNewLetterSender(); bool dMeter2Info_isItemOpenCheck(); bool dMeter2Info_isMapOpenCheck(); s16 dMeter2Info_getNowLifeGauge(); +bool dMeter2Info_isNextStage(const char*, s16, s16, s16); #if WIDESCREEN_SUPPORT void dMeter2Info_onWide2D(); @@ -844,10 +845,6 @@ inline void dMeter2Info_onTempBit(int i_bit) { g_meter2_info.onTempBit(i_bit); } -inline bool dMeter2Info_isNextStage(const char*, s16, s16, s16) { - return false; -} - inline void dMeter2Info_setFloatingMessage(u16 i_msgID, s16 i_msgTimer, bool i_wakuVisible) { g_meter2_info.setFloatingMessage(i_msgID, i_msgTimer, i_wakuVisible); } diff --git a/include/d/d_meter_map.h b/include/d/d_meter_map.h index ecf645a6ac..b17f51846e 100644 --- a/include/d/d_meter_map.h +++ b/include/d/d_meter_map.h @@ -89,7 +89,7 @@ public: virtual void draw(); virtual ~dMeterMap_c(); - bool isDispPosInsideFlg() { return field_0x2d != 0; } + bool isDispPosInsideFlg() { return mMapIsInside != 0; } dMeterMap_c* getMapPointer() { return (dMeterMap_c*)mMap; } void setSizeW(f32 w) { mSizeW = w; } void setSizeH(f32 h) { mSizeH = h; } @@ -108,15 +108,15 @@ private: /* 0x0C */ s32 mIsCompass; /* 0x10 */ s32 mIsMap; /* 0x14 */ u32 field_0x14; - /* 0x18 */ f32 field_0x18; - /* 0x1C */ f32 field_0x1c; + /* 0x18 */ f32 mDrawPosX; + /* 0x1C */ f32 mDrawPosY; /* 0x20 */ f32 mSizeW; /* 0x24 */ f32 mSizeH; - /* 0x28 */ s16 field_0x28; + /* 0x28 */ s16 mSlidePositionOffset; /* 0x2A */ u8 field_0x2a; /* 0x2B */ u8 field_0x2b; /* 0x2C */ u8 mMapAlpha; - /* 0x2D */ u8 field_0x2d; + /* 0x2D */ u8 mMapIsInside; /* 0x2E */ u8 field_0x2e; /* 0x30 */ int field_0x30; }; diff --git a/include/d/d_msg_object.h b/include/d/d_msg_object.h index 45606e4e81..b55ea73904 100644 --- a/include/d/d_msg_object.h +++ b/include/d/d_msg_object.h @@ -562,6 +562,10 @@ inline void dMsgObject_setOffering(u16 i_num) { dComIfGs_setEventReg(0xF8FF, i_num & 0xFF); } +inline void dMsgObject_setLetterNameID(u16 id) { + dMsgObject_getMsgObjectClass()->setLetterNameID(id); +} + class dMsgObject_HowlHIO_c { public: dMsgObject_HowlHIO_c(); diff --git a/include/d/d_path.h b/include/d/d_path.h index 6e4e159a61..fb83709bad 100644 --- a/include/d/d_path.h +++ b/include/d/d_path.h @@ -20,7 +20,7 @@ struct dPath { /* 0x2 */ BE(u16) m_nextID; /* 0x4 */ u8 field_0x4; /* 0x5 */ bool m_closed; - /* 0x6 */ u8 field_0x6; + /* 0x6 */ u8 swbit; /* 0x7 */ u8 field_0x7; /* 0x8 */ OFFSET_PTR(dPnt) m_points; }; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 03dd7491b0..bd8e7d5728 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -267,7 +267,7 @@ struct dStage_MemoryConfig_c { // PATH / RPAT struct dPath; struct dStage_dPath_c { - /* 0x0 */ BE(int) m_num; + /* 0x0 */ BE(int) num; /* 0x4 */ OFFSET_PTR(dPath) m_path; }; diff --git a/include/d/d_vibration.h b/include/d/d_vibration.h index 204f6e759c..4018acea50 100644 --- a/include/d/d_vibration.h +++ b/include/d/d_vibration.h @@ -47,18 +47,21 @@ class dVibTest_c : public JORReflexible { public: dVibTest_c(); + void Init(); + void setDefault(); + virtual void listenPropertyEvent(const JORPropertyEvent*); virtual void genMessage(JORMContext*); - virtual ~dVibTest_c() {} + virtual ~dVibTest_c(); - /* 0x04 */ s8 field_0x4; + /* 0x04 */ s8 id; /* 0x06 */ u16 m_pattern; /* 0x08 */ u16 m_pattern2; /* 0x0A */ u16 field_0xa; /* 0x0C */ s16 m_randombit; /* 0x0E */ s16 m_length; /* 0x10 */ int field_0x10; - /* 0x14 */ int m_vibswitch; + /* 0x14 */ s32 m_vibswitch; /* 0x18 */ u16 m_displayDbg; }; @@ -82,6 +85,10 @@ public: void Pause(); void Remove(); + #if DEBUG + int testShake(); + #endif + static const vib_pattern MS_patt[VIBMODE_S_MAX]; static const vib_pattern CS_patt[VIBMODE_S_MAX]; static const vib_pattern MQ_patt[VIBMODE_Q_MAX]; @@ -123,4 +130,7 @@ private: /* 0x8C */ s32 mMode; }; // Size: 0x90 +extern const char* shock_names[VIBMODE_S_MAX]; +extern const char* quake_names[VIBMODE_Q_MAX]; + #endif /* D_D_VIBRATION_H */ diff --git a/include/d/dolzel_base.pch b/include/d/dolzel_base.pch index ac45474890..e603a50e14 100644 --- a/include/d/dolzel_base.pch +++ b/include/d/dolzel_base.pch @@ -2,7 +2,9 @@ #define DOLZEL_BASE_PCH // Fixes weak .bss +#if !TARGET_PC #include "weak_bss_1109_to_1009.h" // IWYU pragma: export +#endif #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/dusk/gx_helper.h b/include/dusk/gx_helper.h index adb547ac29..bf81424c99 100644 --- a/include/dusk/gx_helper.h +++ b/include/dusk/gx_helper.h @@ -42,4 +42,13 @@ typedef GXTexObjRAII TGXTexObj; typedef GXTexObj TGXTexObj; #endif +struct GXScopedDebugGroup { + explicit GXScopedDebugGroup(const char* text) { + GXPushDebugGroup(text); + } + ~GXScopedDebugGroup() { + GXPopDebugGroup(); + } +}; + #endif // DUSK_GX_HELPER_H diff --git a/include/dusk_pch.hpp b/include/dusk_pch.hpp new file mode 100644 index 0000000000..adac2d33d2 --- /dev/null +++ b/include/dusk_pch.hpp @@ -0,0 +1,7 @@ +#pragma once + +#define PROCS_DUMP_NAMES 1 + +#include "d/dolzel.pch" +#include "d/dolzel_base.pch" +#include "d/dolzel_rel.pch" diff --git a/include/m_Do/m_Do_controller_pad.h b/include/m_Do/m_Do_controller_pad.h index 6960a7da7d..05e4490d4a 100644 --- a/include/m_Do/m_Do_controller_pad.h +++ b/include/m_Do/m_Do_controller_pad.h @@ -61,7 +61,7 @@ public: static f32 getAnalogR(u32 pad) { return getCpadInfo(pad).mTriggerRight; } static f32 getAnalogL(u32 pad) { return getCpadInfo(pad).mTriggerLeft; } static BOOL isConnect(u32 pad) { return JUTGamePad::getPortStatus((JUTGamePad::EPadPort)pad) == 0; } - static void startMotorWave(u32 pad, void* data, JUTGamePad::CRumble::ERumble rumble, u32 length) { + static void startMotorWave(u32 pad, u8* data, JUTGamePad::CRumble::ERumble rumble, u32 length) { m_gamePad[pad]->startMotorWave(data, rumble, length); } static void stopMotor(u32 pad) { m_gamePad[pad]->stopMotor(); } diff --git a/include/m_Do/m_Do_graphic.h b/include/m_Do/m_Do_graphic.h index c30c28a517..b4f947546d 100644 --- a/include/m_Do/m_Do_graphic.h +++ b/include/m_Do/m_Do_graphic.h @@ -4,7 +4,6 @@ #include "JSystem/JFramework/JFWDisplay.h" #include "m_Do/m_Do_mtx.h" #include "global.h" -#include "dusk/logging.h" #if TARGET_PC #include #endif @@ -100,9 +99,7 @@ public: } static int startFadeOut(int param_0) { return JFWDisplay::getManager()->startFadeOut(param_0); } - static int startFadeIn(int param_0) { - DuskLog.debug("mDoGph_gInf_c::startFadeIn START"); - return JFWDisplay::getManager()->startFadeIn(param_0); } + static int startFadeIn(int param_0) { return JFWDisplay::getManager()->startFadeIn(param_0); } static void setFadeColor(JUtility::TColor& color) { mFader->setColor(color); } static void setClearColor(JUtility::TColor color) { JFWDisplay::getManager()->setClearColor(color); } static void setBackColor(GXColor& color) { mBackColor = color; } diff --git a/include/os_report.h b/include/os_report.h index 1fcf08bc57..78177a199d 100644 --- a/include/os_report.h +++ b/include/os_report.h @@ -31,4 +31,10 @@ extern u8 __OSReport_Warning_disable; extern u8 __OSReport_System_disable; extern u8 __OSReport_enable; +#if TARGET_PC +namespace dusk { + extern bool OSReportReallyForceEnable; +} +#endif + #endif // _OS_REPORT_H diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h index 9c806c92ba..b3c4f1eb16 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h @@ -150,13 +150,13 @@ struct J3DSys { void setModelDrawMtx(Mtx* pMtxArr) { J3D_ASSERT_NULLPTR(230, pMtxArr); mModelDrawMtx = pMtxArr; - GXSETARRAY(GX_POS_MTX_ARRAY, mModelDrawMtx, sizeof(*mModelDrawMtx), sizeof(*mModelDrawMtx)); + GXSETARRAY(GX_POS_MTX_ARRAY, mModelDrawMtx, 10 * sizeof(Mtx), sizeof(*mModelDrawMtx), true); } void setModelNrmMtx(Mtx33* pMtxArr) { J3D_ASSERT_NULLPTR(241, pMtxArr); mModelNrmMtx = pMtxArr; - GXSETARRAY(GX_NRM_MTX_ARRAY, mModelNrmMtx, sizeof(*mModelNrmMtx), sizeof(*mModelNrmMtx)); + GXSETARRAY(GX_NRM_MTX_ARRAY, mModelNrmMtx, 10 * sizeof(Mtx33), sizeof(*mModelNrmMtx), true); } void* getVtxPos() { return mVtxPos; } diff --git a/libs/JSystem/include/JSystem/JAWExtSystem/JAWGraphContext.h b/libs/JSystem/include/JSystem/JAWExtSystem/JAWGraphContext.h index 2719500e1c..99fac05626 100644 --- a/libs/JSystem/include/JSystem/JAWExtSystem/JAWGraphContext.h +++ b/libs/JSystem/include/JSystem/JAWExtSystem/JAWGraphContext.h @@ -24,6 +24,15 @@ public: void setGXforPrint(); void setGXforDraw(); + void color(const JUtility::TColor& color0, const JUtility::TColor& color1) { + color(color0, color1, color0, color1); + } + + void lineWidth(u8 width) { + field_0x16 = width; + GXSetLineWidth(field_0x16, GX_TO_ZERO); + } + /* 0x00 */ J2DPrint* field_0x0; /* 0x04 */ JUtility::TColor field_0x4; /* 0x08 */ JUtility::TColor field_0x8; diff --git a/libs/JSystem/include/JSystem/JAWExtSystem/JAWWindow.h b/libs/JSystem/include/JSystem/JAWExtSystem/JAWWindow.h index 7a570565cd..7ada3a548e 100644 --- a/libs/JSystem/include/JSystem/JAWExtSystem/JAWWindow.h +++ b/libs/JSystem/include/JSystem/JAWExtSystem/JAWWindow.h @@ -16,8 +16,8 @@ public: y = i_y; } - /* 0x00*/ int x; - /* 0x04*/ int y; + /* 0x00 */ int x; + /* 0x04 */ int y; }; class JAWWindow { @@ -29,9 +29,9 @@ public: virtual void drawSelf(f32, f32); virtual void drawSelf(f32, f32, Mtx*); - /* 0x0FC */ JAWGraphContext field_0xfc; + /* 0x0FC */ JAWGraphContext m_graf; /* 0x118 */ JAWWindow* m_pParent; - /* 0x11C */ JUTPoint field_0x11c; + /* 0x11C */ JUTPoint m_point; }; class TJ2DWindowDraw : public J2DWindow { @@ -94,21 +94,29 @@ public: static JUtility::TColor convJudaColor(u16); void padProc(const JUTGamePad&); + void setWindowColor(const JUtility::TColor& color) { + setWindowColor(color, color, color, color); + } + + void setWindowColor(u8 r, u8 g, u8 b, u8 a) { + setWindowColor(JUtility::TColor(r, g, b, a)); + } + /* 0x004 */ Mtx mMatrix; /* 0x034 */ u8 field_0x34[0x38 - 0x34]; - /* 0x038 */ TJ2DWindowDraw field_0x38; - /* 0x180 */ J2DTextBox field_0x180; - /* 0x2B0 */ TWindowText field_0x2b0; - /* 0x3D8 */ JUtility::TColor field_0x3d8; - /* 0x3DC */ JUtility::TColor field_0x3dc; - /* 0x3E0 */ JUtility::TColor field_0x3e0; - /* 0x3E4 */ JUtility::TColor field_0x3e4; + /* 0x038 */ TJ2DWindowDraw m_drawWindow; + /* 0x180 */ J2DTextBox m_titleText; + /* 0x2B0 */ TWindowText m_windowText; + /* 0x3D8 */ JUtility::TColor m_windowColor0; + /* 0x3DC */ JUtility::TColor m_windowColor1; + /* 0x3E0 */ JUtility::TColor m_windowColor2; + /* 0x3E4 */ JUtility::TColor m_windowColor3; /* 0x3E8 */ int field_0x3e8; - /* 0x3EC */ u8 field_0x3ec; + /* 0x3EC */ u8 m_isInit; void setMatrix(Mtx mtx) { MTXCopy(mtx, mMatrix); } - void setAlpha(u8 alpha) { field_0x38.setAlpha(alpha); } - void draw(int x, int y, const J2DGrafContext* p_grafCtx) { field_0x38.drawPane(x, y, p_grafCtx); } + void setAlpha(u8 alpha) { m_drawWindow.setAlpha(alpha); } + void draw(int x, int y, const J2DGrafContext* p_grafCtx) { m_drawWindow.drawPane(x, y, p_grafCtx); } }; #endif /* JAWWINDOW_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JAISound.h b/libs/JSystem/include/JSystem/JAudio2/JAISound.h index 155eca1e65..e96053fc9f 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAISound.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAISound.h @@ -50,6 +50,12 @@ public: JAISoundID(const JAISoundID& other) { id_.composite_ = other.id_.composite_; }; + JAISoundID(unsigned int sectionID, unsigned int groupID, unsigned int waveID) { + id_.info.type.parts.sectionID = sectionID; + id_.info.type.parts.groupID = groupID; + id_.info.waveID = waveID; + } + JAISoundID() {} bool isAnonymous() const { return id_.composite_ == -1; } @@ -323,6 +329,8 @@ public: status_.field_0x0.flags.paused = param_0; } + bool isPaused() const { return status_.field_0x0.flags.paused; } + void updateLifeTime(u32 lifeTime) { if (lifeTime > lifeTime_) { lifeTime_ = lifeTime; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h b/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h index 8e1381cda3..7a3ae12470 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h @@ -33,6 +33,9 @@ public: bool isAllocated() const { return mBase; } u32 getSize() const { return mSize; } + JSUTree* getFirstChild() { return mTree.getFirstChild(); } + JSUTree* getEndChild() { return mTree.getEndChild(); } + /* 0x00 */ JSUTree mTree; /* 0x1C */ OSMutex mMutex; /* 0x34 */ JASDisposer* mDisposer; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h b/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h index 593e69f1fd..eea3eddac3 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h @@ -54,6 +54,8 @@ struct JASWaveArc : JASDisposer { virtual void onEraseDone() {} s32 getStatus() const { return mStatus; } + u32 getFileSize() const { return mFileLength; } + JASHeap* getHeap() { return &mHeap; } struct loadToAramCallbackParams { // not official struct name diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h b/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h index 5dab15abc0..4cc48f2a0b 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h @@ -149,6 +149,8 @@ struct JAUSoundTable : public JASGlobalInstance { void init(void const*); u8 getTypeID(JAISoundID) const; JAUSoundTableItem* getData(JAISoundID) const; + int getNumGroups_inSection(u8) const; + int getNumItems_inGroup(u8, u8) const; JAUSoundTableItem* getItem(JAUSoundTableGroup* group, int index) const { u32 offset = group->getItemOffset(index); diff --git a/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h b/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h index 82b9c21a2e..0720605efb 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h @@ -36,6 +36,9 @@ public: static JSUList sDvdAsyncList; static u32 sSZSBufferSize; static bool errorRetry; +#if TARGET_PC + static JKRHeap* sHeap; +#endif enum EAllocDirection { UNKNOWN_EALLOC_DIRECTION = 0, @@ -54,6 +57,12 @@ public: static bool isErrorRetry(void) { return errorRetry; } inline static u32 getSZSBufferSize() { return sSZSBufferSize; } + +#if TARGET_PC + static inline JKRHeap* getHeap() { return sHeap; } + static inline void setHeap(JKRHeap* i_heap) { sHeap = i_heap; } + +#endif }; // void JKRDecompressFromDVD(JKRDvdFile*, void*, u32, u32, u32, u32, u32*); diff --git a/libs/JSystem/include/JSystem/JKernel/JKRExpHeap.h b/libs/JSystem/include/JSystem/JKernel/JKRExpHeap.h index a31b2c5e84..09687e688b 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRExpHeap.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRExpHeap.h @@ -121,6 +121,13 @@ public: static s32 getUsedSize_(JKRExpHeap* heap) { return heap->mSize - heap->getTotalFreeSize(); } static void* getState_(TState* state) { return getState_buf_(state); } + +#if TARGET_PC + [[nodiscard]] CMemBlock* getFreeHead() { return mHeadFreeList; } + [[nodiscard]] const CMemBlock* getFreeHead() const { return mHeadFreeList; } + [[nodiscard]] CMemBlock* getUsedHead() { return mHeadUsedList; } + [[nodiscard]] const CMemBlock* getUsedHead() const { return mHeadUsedList; } +#endif }; inline JKRExpHeap* JKRCreateExpHeap(u32 size, JKRHeap* parent, bool errorFlag) { diff --git a/libs/JSystem/include/JSystem/JSupport/JSUList.h b/libs/JSystem/include/JSystem/JSupport/JSUList.h index 3021a3a879..69356600a7 100644 --- a/libs/JSystem/include/JSystem/JSupport/JSUList.h +++ b/libs/JSystem/include/JSystem/JSupport/JSUList.h @@ -230,6 +230,8 @@ public: return *this; } + operator int() { return (int)mTree; } + T* getObject() const { return this->mTree->getObject(); } bool operator==(const JSUTree* other) const { return this->mTree == other; } diff --git a/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h b/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h index bf939f0831..30bf685700 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h @@ -117,7 +117,7 @@ public: } void stopMotorWave() { mRumble.stopPatternedRumbleAtThePeriod(); } - void stopMotor() { mRumble.stopMotor(mPortNum, false); } + void stopMotor() { mRumble.stopMotor(mPortNum); } void stopMotorHard() { CRumble::stopMotorHard(mPortNum); } static s8 getPortStatus(EPadPort port) { @@ -233,7 +233,7 @@ public: /* 0x10 */ u8* field_0x10; }; // Size: 0x14 - void startMotorWave(void* data, CRumble::ERumble rumble, u32 length) { + void startMotorWave(u8* data, CRumble::ERumble rumble, u32 length) { mRumble.startPatternedRumble(data, rumble, length); } diff --git a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp index b3c16f00a7..76f58b7586 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp @@ -134,12 +134,13 @@ void J3DLoadCPCmd(u8 addr, u32 val) { } #if TARGET_PC -static void J3DLoadArrayBasePtr(GXAttr attr, void* data, u32 size) { +static void J3DLoadArrayBasePtr(GXAttr attr, void* data, u32 size, bool le) { u32 idx = (attr == GX_VA_NBT) ? 1 : (attr - GX_VA_POS); GXCmd1u8(GX_LOAD_AURORA); GXCmd1u16(GX_LOAD_AURORA_ARRAYBASE | idx); GXCmd1u64((u64)data); - GXCmd1u64((u64)size); + GXCmd1u32(size); + GXCmd1u8(le ? 1 : 0); } #else static void J3DLoadArrayBasePtr(GXAttr attr, void* data) { @@ -152,15 +153,15 @@ void J3DShape::loadVtxArray() const { #if TARGET_PC // TODO: these can very easily overcount if the data isn't in F32 format if (j3dSys.getVtxPos() != mVertexData->getVtxPosArray()) { - J3DLoadArrayBasePtr(GX_VA_POS, j3dSys.getVtxPos(), j3dSys.mVtxPosNum * sizeof(Vec)); + J3DLoadArrayBasePtr(GX_VA_POS, j3dSys.getVtxPos(), j3dSys.mVtxPosNum * sizeof(Vec), true); } if (!mHasNBT && j3dSys.getVtxNrm() != mVertexData->getVtxNrmArray()) { - J3DLoadArrayBasePtr(GX_VA_NRM, j3dSys.getVtxNrm(), j3dSys.mVtxNrmNum * sizeof(Vec)); + J3DLoadArrayBasePtr(GX_VA_NRM, j3dSys.getVtxNrm(), j3dSys.mVtxNrmNum * sizeof(Vec), true); } if (j3dSys.getVtxCol() != mVertexData->getVtxColorArray(0)) { - J3DLoadArrayBasePtr(GX_VA_CLR0, j3dSys.getVtxCol(), j3dSys.mVtxColNum * sizeof(GXColor)); + J3DLoadArrayBasePtr(GX_VA_CLR0, j3dSys.getVtxCol(), j3dSys.mVtxColNum * sizeof(GXColor), true); } #else J3DLoadArrayBasePtr(GX_VA_POS, j3dSys.getVtxPos()); @@ -257,9 +258,9 @@ void J3DShape::makeVtxArrayCmd() { for (u32 i = 0; i < 12; i++) { GXAttr attr = GXAttr(i + GX_VA_POS); if (array[i] != nullptr) - GDSetArraySized(attr, array[i], mVertexData->getVtxArrByteSize(attr), mVertexData->getVtxArrStride(attr)); + GDSetArraySized(attr, array[i], mVertexData->getVtxArrByteSize(attr), mVertexData->getVtxArrStride(attr), true); else - GDSetArraySized(attr, nullptr, 0, mVertexData->getVtxArrStride(attr)); + GDSetArraySized(attr, nullptr, 0, mVertexData->getVtxArrStride(attr), true); } #else for (u32 i = 0; i < 12; i++) { diff --git a/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp b/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp index 0c712dac81..09ddc0b405 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp @@ -276,7 +276,7 @@ bool isTexNoReg(void* pDL) { } u16 getTexNoReg(void* pDL) { - u32 var_r31 = *(u32*)((u8*)pDL + 1); + u32 var_r31 = *(BE(u32)*)((u8*)pDL + 1); return var_r31 & 0xFFFFFF; } diff --git a/libs/JSystem/src/JAWExtSystem/JAWWindow.cpp b/libs/JSystem/src/JAWExtSystem/JAWWindow.cpp index 5163355615..e551e59952 100644 --- a/libs/JSystem/src/JAWExtSystem/JAWWindow.cpp +++ b/libs/JSystem/src/JAWExtSystem/JAWWindow.cpp @@ -6,29 +6,29 @@ #include "JSystem/JGeometry.h" JAWWindow::JAWWindow(const char* param_1, int param_2, int param_3) : - field_0x38('WIN1', JGeometry::TBox2(0.0f, 0.0f, param_2, param_3), "frame_lu.bti"), - field_0x180('TITL', JGeometry::TBox2(10.0f, 10.0f, 640.0f, 170.0f), (const ResFONT*)JUTResFONT_Ascfont_fix16, param_1, -1, HBIND_LEFT, VBIND_TOP), - field_0x2b0(this), - field_0x3d8(JUtility::TColor(0, 0, 0, 255)), - field_0x3dc(JUtility::TColor(0, 0, 0, 255)), - field_0x3e0(JUtility::TColor(0, 0, 0, 255)), - field_0x3e4(JUtility::TColor(0, 0, 0, 255)) { + m_drawWindow('WIN1', JGeometry::TBox2(0.0f, 0.0f, param_2, param_3), "frame_lu.bti"), + m_titleText('TITL', JGeometry::TBox2(10.0f, 10.0f, 640.0f, 170.0f), (const ResFONT*)JUTResFONT_Ascfont_fix16, param_1, -1, HBIND_LEFT, VBIND_TOP), + m_windowText(this), + m_windowColor0(JUtility::TColor(0, 0, 0, 255)), + m_windowColor1(JUtility::TColor(0, 0, 0, 255)), + m_windowColor2(JUtility::TColor(0, 0, 0, 255)), + m_windowColor3(JUtility::TColor(0, 0, 0, 255)) { field_0x3e8 = 0; - field_0x3ec = 0; - field_0x38.setContentsColor(field_0x3d8, field_0x3e0, field_0x3dc, field_0x3e4); - field_0x180.setCharColor(JUtility::TColor(0, 255, 0, 255)); - field_0x180.setGradColor(JUtility::TColor(255, 255, 255, 255)); - field_0x38.appendChild(&field_0x180); - field_0x38.appendChild(&field_0x2b0); + m_isInit = FALSE; + m_drawWindow.setContentsColor(m_windowColor0, m_windowColor2, m_windowColor1, m_windowColor3); + m_titleText.setCharColor(JUtility::TColor(0, 255, 0, 255)); + m_titleText.setGradColor(JUtility::TColor(255, 255, 255, 255)); + m_drawWindow.appendChild(&m_titleText); + m_drawWindow.appendChild(&m_windowText); } JAWWindow::~JAWWindow() {} BOOL JAWWindow::initIf() { - if (field_0x3ec) { + if (m_isInit) { return TRUE; } else { - field_0x3ec = TRUE; + m_isInit = TRUE; return onInit(); } } @@ -36,30 +36,30 @@ BOOL JAWWindow::initIf() { BOOL JAWWindow::onInit() { return TRUE; } void JAWWindow::setTitleColor(const JUtility::TColor& param_1, const JUtility::TColor& param_2) { - field_0x180.setCharColor(param_1); - field_0x180.setGradColor(param_2); + m_titleText.setCharColor(param_1); + m_titleText.setGradColor(param_2); } void JAWWindow::setWindowColor(const JUtility::TColor& param_1, const JUtility::TColor& param_2, const JUtility::TColor& param_3, const JUtility::TColor& param_4) { - field_0x3d8 = param_1; - field_0x3dc = param_2; - field_0x3e0 = param_3; - field_0x3e4 = param_4; - field_0x38.setContentsColor(field_0x3d8, field_0x3e0, field_0x3dc, field_0x3e4); + m_windowColor0 = param_1; + m_windowColor1 = param_2; + m_windowColor2 = param_3; + m_windowColor3 = param_4; + m_drawWindow.setContentsColor(m_windowColor0, m_windowColor2, m_windowColor1, m_windowColor3); } void JAWWindow::onDraw(JAWGraphContext*) {} void JAWWindow::move(f32 param_1, f32 param_2) { - field_0x38.move(param_1, param_2); + m_drawWindow.move(param_1, param_2); } void JAWWindow::addPosition(f32 param_1, f32 param_2) { - field_0x38.add(param_1, param_2); + m_drawWindow.add(param_1, param_2); } void JAWWindow::addSize(f32 width, f32 height) { - JGeometry::TBox2 bounds = field_0x38.getBounds(); + JGeometry::TBox2 bounds = m_drawWindow.getBounds(); f32 newWidth = width + bounds.getWidth(); f32 newHeight = height + bounds.getHeight(); if (newWidth < 36.0f) { @@ -72,7 +72,7 @@ void JAWWindow::addSize(f32 width, f32 height) { } else if (newHeight > 480.0f) { newHeight = 480.0f; } - field_0x38.resize(newWidth, newHeight); + m_drawWindow.resize(newWidth, newHeight); } JUtility::TColor JAWWindow::convJudaColor(u16 param_1) { @@ -189,7 +189,7 @@ void JAWWindow::padProc(const JUTGamePad& pad) { JAWWindow::TWindowText::TWindowText(JAWWindow* window) : J2DPane('TEXT', JGeometry::TBox2(10.0f, 30.0f, 650.0f, 510.0f)), m_pParent(window), - field_0x11c(0, 0) { + m_point(0, 0) { } JAWWindow::TWindowText::~TWindowText() {} @@ -201,15 +201,15 @@ void JAWWindow::TWindowText::drawSelf(f32 param_1, f32 param_2) { } void JAWWindow::TWindowText::drawSelf(f32, f32, Mtx* param_3) { - field_0xfc.reset(); - MTXTrans(*param_3, -field_0x11c.x, -field_0x11c.y, 0.0f); + m_graf.reset(); + MTXTrans(*param_3, -m_point.x, -m_point.y, 0.0f); Mtx stack_48; MTXConcat(*param_3, mGlobalMtx, stack_48); GXLoadPosMtxImm(stack_48, 0); - field_0xfc.setParentAlpha(mColorAlpha); + m_graf.setParentAlpha(mColorAlpha); JUT_ASSERT(209, m_pParent != NULL); m_pParent->setMatrix(stack_48); - m_pParent->onDraw(&field_0xfc); + m_pParent->onDraw(&m_graf); } static void dummy(J2DPane* pane, J2DWindow* window) { diff --git a/libs/JSystem/src/JKernel/JKRDvdRipper.cpp b/libs/JSystem/src/JKernel/JKRDvdRipper.cpp index ae644ee9e1..ae65f42ba3 100644 --- a/libs/JSystem/src/JKernel/JKRDvdRipper.cpp +++ b/libs/JSystem/src/JKernel/JKRDvdRipper.cpp @@ -13,6 +13,8 @@ #include #include +#include "JSystem/JKernel/JKRExpHeap.h" + static int JKRDecompressFromDVD(JKRDvdFile*, void*, u32, u32, u32, u32, u32*); static int decompSZS_subroutine(u8*, u8*); static u8* firstSrcData(); @@ -240,6 +242,8 @@ static OSMutex decompMutex; u32 JKRDvdRipper::sSZSBufferSize = 0x00000400; +JKRHeap* JKRDvdRipper::sHeap = NULL; + static u8* szpBuf; static u8* szpEnd; @@ -282,12 +286,20 @@ static int JKRDecompressFromDVD(JKRDvdFile* dvdFile, void* dst, u32 fileSize, u3 OSLockMutex(&decompMutex); u32 result = 0; u32 szsBufferSize = JKRDvdRipper::getSZSBufferSize(); +#if TARGET_PC + szpBuf = (u8 *)JKRAllocFromHeap(JKRDvdRipper::getHeap(), szsBufferSize, -0x20); +#else szpBuf = (u8 *)JKRAllocFromSysHeap(szsBufferSize, -0x20); +#endif JUT_ASSERT(909, szpBuf != NULL); szpEnd = szpBuf + szsBufferSize; if (inFileOffset != 0) { +#if TARGET_PC + refBuf = (u8 *)JKRAllocFromHeap(JKRDvdRipper::getHeap(), 0x1120, -4); +#else refBuf = (u8 *)JKRAllocFromSysHeap(0x1120, -4); +#endif JUT_ASSERT(918, refBuf != NULL); refEnd = refBuf + 0x1120; refCurrent = refBuf; diff --git a/libs/JSystem/src/JKernel/JKRExpHeap.cpp b/libs/JSystem/src/JKernel/JKRExpHeap.cpp index 3ec15cd161..4a6712cb65 100644 --- a/libs/JSystem/src/JKernel/JKRExpHeap.cpp +++ b/libs/JSystem/src/JKernel/JKRExpHeap.cpp @@ -214,9 +214,33 @@ void* JKRExpHeap::do_alloc(u32 size, int alignment) { #endif #if TARGET_PC - JUT_ASSERT_MSG_F(__LINE__, ptr != nullptr, - "Failed to alloc memory! (%s) (0x%X bytes).\n Heap size: %u\n Used size: %u", - this->getName(), size, getSize(), getTotalUsedSize()); + if (!ptr) { + // Allocation failed. + OSReport_Error( + "Failed to alloc memory! (%s) (0x%X bytes).\n Heap size: 0x%X\n Used size: 0x%X\n", + this->getName(), size, getSize(), getTotalUsedSize()); + OSReport_Error("Free block list as follows:\n"); + OSReport_Error("Start | End | Size \n"); + + int i = 0; + for (const CMemBlock* block = mHeadFreeList; block; block = block->mNext) { + if (block->mMagic) { + // Allocated, ignore. + continue; + } + if (i++ > 10) { + OSReport_Error("\n"); + break; + } + + auto blockStart = (uintptr_t)block - (uintptr_t)mStart; + auto blockEnd = (uintptr_t)block + block->size - (uintptr_t)mStart; + auto blockSize = block->size; + OSReport_Error("%08X | %08X | %08X\n", (u32) blockStart, (u32) blockEnd, (u32) blockSize); + } + + CRASH("Aborting due to allocation failure!"); + } #else if (ptr == NULL) { JUTWarningConsole_f(":::cannot alloc memory (0x%x byte).\n", size); @@ -472,7 +496,7 @@ void JKRExpHeap::do_freeAll() { JKRHeap::callAllDisposer(); mHeadFreeList = (CMemBlock*)mStart; mTailFreeList = mHeadFreeList; - mHeadFreeList->initiate(NULL, NULL, mSize - 0x10, 0, 0); + mHeadFreeList->initiate(NULL, NULL, mSize - sizeof(CMemBlock), 0, 0); mHeadUsedList = NULL; mTailUsedList = NULL; #if DEBUG diff --git a/libs/JSystem/src/JMath/JMath.cpp b/libs/JSystem/src/JMath/JMath.cpp index 43b9680308..899210e293 100644 --- a/libs/JSystem/src/JMath/JMath.cpp +++ b/libs/JSystem/src/JMath/JMath.cpp @@ -77,8 +77,6 @@ void JMAFastVECNormalize(__REGISTER const Vec* src, __REGISTER Vec* dst) { dst->y = src->y * length; dst->z = src->z * length; #endif // clang-format on - - OSPanic(__FILE__, __LINE__, "UNIMPLEMENTED"); } void JMAVECScaleAdd(__REGISTER const Vec* vec1, __REGISTER const Vec* vec2, __REGISTER Vec* dst, diff --git a/libs/JSystem/src/JParticle/JPAResource.cpp b/libs/JSystem/src/JParticle/JPAResource.cpp index 5c232a09f3..4a33ed0aab 100644 --- a/libs/JSystem/src/JParticle/JPAResource.cpp +++ b/libs/JSystem/src/JParticle/JPAResource.cpp @@ -932,8 +932,8 @@ void JPAResource::setPTev() { int center_offset = pEsp != NULL ? (pEsp->getScaleCenterX() + 3 * pEsp->getScaleCenterY()) * 0xC : 0x30; int pos_offset = center_offset + base_plane_type * 0x6C; int crd_offset = (pBsp->getTilingS() + 2 * pBsp->getTilingT()) * 8; - GXSETARRAY(GX_VA_POS, jpa_pos + pos_offset, ARRAY_SIZEU(jpa_pos) - pos_offset, 3); - GXSETARRAY(GX_VA_TEX0, jpa_crd + crd_offset, ARRAY_SIZEU(jpa_crd) - crd_offset, 2); + GXSETARRAY(GX_VA_POS, jpa_pos + pos_offset, ARRAY_SIZEU(jpa_pos) - pos_offset, 3, true); + GXSETARRAY(GX_VA_TEX0, jpa_crd + crd_offset, ARRAY_SIZEU(jpa_crd) - crd_offset, 2, true); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); if (pEts != NULL) { @@ -978,8 +978,8 @@ void JPAResource::setCTev(JPAEmitterWorkData* work) { int base_plane_type = (pCsp->getType() == 3 || pCsp->getType() == 7) ? pCsp->getBasePlaneType() : 0; int pos_offset = 0x30 + base_plane_type * 0x6C; - GXSETARRAY(GX_VA_POS, jpa_pos + pos_offset, ARRAY_SIZEU(jpa_pos) - pos_offset, 3); - GXSETARRAY(GX_VA_TEX0, jpa_crd, ARRAY_SIZEU(jpa_crd), 2); + GXSETARRAY(GX_VA_POS, jpa_pos + pos_offset, ARRAY_SIZEU(jpa_pos) - pos_offset, 3, true); + GXSETARRAY(GX_VA_TEX0, jpa_crd, ARRAY_SIZEU(jpa_crd), 2, true); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP1, GX_COLOR_NULL); GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3C); GXSetTevDirect(GX_TEVSTAGE0); diff --git a/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp b/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp index e4ce109f09..9bdde8b5cc 100644 --- a/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp @@ -225,7 +225,9 @@ void JStudio_JAudio2::TAdaptor_sound::adaptor_do_PARENT_NODE(JStudio::data::TEOp case JStudio::data::UNK_0x18: if (field_0x13c != NULL) { JUT_ASSERT(431, pContent!=NULL); +#if DUSK_SUSPICIOUS_ASSERTS JUT_ASSERT(432, uSize==0); +#endif field_0x140 = field_0x13c->JSGFindNodeID((char*)pContent); if (field_0x140 == -1) { return; diff --git a/libs/JSystem/src/JUtility/JUTGamePad.cpp b/libs/JSystem/src/JUtility/JUTGamePad.cpp index 31b8d59f1a..091cc382d1 100644 --- a/libs/JSystem/src/JUtility/JUTGamePad.cpp +++ b/libs/JSystem/src/JUtility/JUTGamePad.cpp @@ -535,6 +535,14 @@ void JUTGamePad::CRumble::stopPatternedRumble(s16 port) { } void JUTGamePad::CRumble::stopPatternedRumbleAtThePeriod() { +#if TARGET_PC + if (mFrameCount == 0) { + // Does not trap on hardware + // PowerPC spec says result is "undefined". Let's just write zero. + mLength = 0; + return; + } +#endif u32 r31 = mFrame % mFrameCount; mLength = (mFrame + mFrameCount - 1) % mFrameCount; } diff --git a/src/SSystem/SComponent/c_m3d_g_cyl.cpp b/src/SSystem/SComponent/c_m3d_g_cyl.cpp index 19bf8d795c..c2f292e08d 100644 --- a/src/SSystem/SComponent/c_m3d_g_cyl.cpp +++ b/src/SSystem/SComponent/c_m3d_g_cyl.cpp @@ -6,6 +6,8 @@ #include "SSystem/SComponent/c_m3d_g_cyl.h" #include "SSystem/SComponent/c_m3d.h" +#include "JSystem/JUtility/JUTAssert.h" + cM3dGCyl::cM3dGCyl(const cXyz* center, f32 radius, f32 height) { SetC(*center); SetR(radius); @@ -24,21 +26,30 @@ void cM3dGCyl::Set(const cXyz& center, f32 radius, f32 height) { SetH(height); } -void cM3dGCyl::SetC(const cXyz& center) { - mCenter = center; +void cM3dGCyl::SetC(const cXyz& pos) { + JUT_ASSERT(67, !isnan(pos.x)); + JUT_ASSERT(68, !isnan(pos.y)); + JUT_ASSERT(69, !isnan(pos.z)); + + JUT_ASSERT(72, -1.0e32f < pos.x && pos.x < 1.0e32f && -1.0e32f < pos.y && pos.y < 1.0e32f && -1.0e32f < pos.z && pos.z < 1.0e32f); + + mCenter = pos; } -void cM3dGCyl::SetH(f32 height) { - mHeight = height; +void cM3dGCyl::SetH(f32 h) { + JUT_ASSERT(82, !isnan(h)); + JUT_ASSERT(83, -1.0e32f < h && h < 1.0e32f); + mHeight = h; } -void cM3dGCyl::SetR(f32 radius) { - mRadius = radius; +void cM3dGCyl::SetR(f32 r) { + JUT_ASSERT(106, !isnan(r)); + JUT_ASSERT(107, -1.0e32f < r && r < 1.0e32f); + mRadius = r; } bool cM3dGCyl::cross(const cM3dGSph* other, cXyz* out) const { - f32 f; - return cM3d_Cross_CylSph(this, other, out, &f); + return cM3d_Cross_CylSph(this, other, out); } bool cM3dGCyl::cross(const cM3dGCyl* other, cXyz* out) const { diff --git a/src/SSystem/SComponent/c_m3d_g_sph.cpp b/src/SSystem/SComponent/c_m3d_g_sph.cpp index 3fd65af53a..9d730b0579 100644 --- a/src/SSystem/SComponent/c_m3d_g_sph.cpp +++ b/src/SSystem/SComponent/c_m3d_g_sph.cpp @@ -6,8 +6,16 @@ #include "SSystem/SComponent/c_m3d_g_sph.h" #include "SSystem/SComponent/c_m3d.h" -void cM3dGSph::SetC(const cXyz& center) { - mCenter = center; +#include "JSystem/JUtility/JUTAssert.h" + +void cM3dGSph::SetC(const cXyz& p) { + JUT_ASSERT(19, !isnan(p.x)); + JUT_ASSERT(20, !isnan(p.y)); + JUT_ASSERT(21, !isnan(p.z)); + + JUT_ASSERT(24, -1.0e32f < p.x && p.x < 1.0e32f && -1.0e32f < p.y && p.y < 1.0e32f && -1.0e32f < p.z && p.z < 1.0e32f); + + mCenter = p; } void cM3dGSph::Set(const cXyz& center, f32 radius) { @@ -20,8 +28,10 @@ void cM3dGSph::Set(const cM3dGSphS& other) { SetR(other.mRadius); } -void cM3dGSph::SetR(f32 radius) { - mRadius = radius; +void cM3dGSph::SetR(f32 r) { + JUT_ASSERT(54, !isnan(r)); + JUT_ASSERT(55, -1.0e32f < r && r < 1.0e32f); + mRadius = r; } bool cM3dGSph::cross(const cM3dGSph* other, cXyz* out) const { diff --git a/src/Z2AudioCS/Z2AudioCS.cpp b/src/Z2AudioCS/Z2AudioCS.cpp index 3a85e7adf1..992eb30a96 100644 --- a/src/Z2AudioCS/Z2AudioCS.cpp +++ b/src/Z2AudioCS/Z2AudioCS.cpp @@ -127,12 +127,12 @@ SpkSoundHandle* Z2AudioCS::startLevel(s32 id, s32 chan) { return handle; } -s32 Z2AudioCS::getName(s32 num) { +const char* Z2AudioCS::getName(s32 num) { if (JASGlobalInstance::getInstance() == NULL) { - return 0; + return NULL; } if (JASGlobalInstance::getInstance()->getData() == NULL) { - return 0; + return NULL; } return JASGlobalInstance::getInstance()->getData()->getTableMgr().getName(num); diff --git a/src/Z2AudioLib/Z2SeView.cpp b/src/Z2AudioLib/Z2SeView.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Z2AudioLib/Z2SoundPlayer.cpp b/src/Z2AudioLib/Z2SoundPlayer.cpp index d2d6fdecf3..1302d07674 100644 --- a/src/Z2AudioLib/Z2SoundPlayer.cpp +++ b/src/Z2AudioLib/Z2SoundPlayer.cpp @@ -1,46 +1,55 @@ #include "Z2AudioLib/Z2SoundPlayer.h" -#include "Z2AudioLib/Z2SeqMgr.h" +#include "Z2AudioLib/Z2AudioMgr.h" +#include "Z2AudioCS/Z2AudioCS.h" +#include "JSystem/JUtility/JUTGamePad.h" -Z2SoundPlayer::Z2SoundPlayer(const char* param_1) : JAWWindow("Player for JAudio2", 500, 140), field_0x48c(field_0x46c, 8) { - field_0x3ed = 0; - field_0x3ee = 0; - field_0x3ef = 0; - field_0x3f0 = 0; - field_0x3f4 = param_1; +Z2SoundPlayer::Z2SoundPlayer(const char* projectName) + : JAWWindow("Player for JAudio2", 500, 140), + field_0x48c(field_0x46c, 8) +{ + field_0x3ed = false; + field_0x3ee = false; + field_0x3ef = false; + field_0x3f0 = false; + + m_name = projectName; field_0x3f8 = 0; field_0x3fc = 0; field_0x3fa = 0; field_0x3fe = 0; field_0x400 = 0; - field_0x402 = 0; - field_0x444 = 0; + m_portNum = 0; + m_portVal = 0; field_0x446 = 0; - field_0x404 = "CMD_PORT"; - field_0x408 = "END_PORT"; - field_0x40c = "STA_PORT"; - field_0x410 = "WAIT_PORT"; - field_0x414 = "NUM_PORT"; - field_0x418 = "PORT_5"; - field_0x41c = "MAP_PORT"; - field_0x420 = "NOTE_PORT"; - field_0x424 = "SE_SELECT_PORT"; - field_0x428 = "BGM_STATUS_PORT"; - field_0x42c = "BGM_PORT2"; - field_0x430 = "BGM_PORT3"; - field_0x434 = "PORT12"; - field_0x438 = "PORT13"; - field_0x43c = "FILTER_PORT"; - field_0x440 = "FX_PORT"; + + m_portNames[0] = "CMD_PORT"; + m_portNames[1] = "END_PORT"; + m_portNames[2] = "STA_PORT"; + m_portNames[3] = "WAIT_PORT"; + m_portNames[4] = "NUM_PORT"; + m_portNames[5] = "PORT_5"; + m_portNames[6] = "MAP_PORT"; + m_portNames[7] = "NOTE_PORT"; + m_portNames[8] = "SE_SELECT_PORT"; + m_portNames[9] = "BGM_STATUS_PORT"; + m_portNames[10] = "BGM_PORT2"; + m_portNames[11] = "BGM_PORT3"; + m_portNames[12] = "PORT12"; + m_portNames[13] = "PORT13"; + m_portNames[14] = "FILTER_PORT"; + m_portNames[15] = "FX_PORT"; + u8 r30 = 0; field_0x448[r30++] = &field_0x3f8; field_0x448[r30++] = &field_0x3fa; field_0x448[r30++] = &field_0x3fc; field_0x448[r30++] = &field_0x3fe; field_0x448[r30++] = &field_0x400; - field_0x448[r30++] = &field_0x402; - field_0x448[r30] = &field_0x444; - field_0x464 = 0; - field_0x468 = 7; + field_0x448[r30++] = &m_portNum; + field_0x448[r30] = &m_portVal; + + m_cursorY = 0; + m_cursorMax = 7; field_0x4a0 = 0; field_0x4a4 = 1.0f; field_0x4a8 = 0.5f; @@ -48,65 +57,446 @@ Z2SoundPlayer::Z2SoundPlayer(const char* param_1) : JAWWindow("Player for JAudio field_0x4b0 = 0.0f; field_0x4b4 = 0.0f; field_0x4b8 = 1.0f; - field_0x498 = Z2GetSeqMgr()->getSubBgmHandle(); + + mp_subBgmHandle = Z2GetSeqMgr()->getSubBgmHandle(); } -void Z2SoundPlayer::onDraw(JAWGraphContext*) { +void Z2SoundPlayer::onDraw(JAWGraphContext* graf) { + JAUSoundNameTable* soundTable = JASGlobalInstance::getInstance(); + + int var_r27 = 0; + if (field_0x3ed) { + var_r27 = 2; + } + u8 cursorY = 0; + + graf->color(JUtility::TColor(0, 0x7F, 0xFF, 0xFF), JUtility::TColor(0, 0xFF, 0x7F, 0xFF)); + graf->print(1, cursorY++, "Project: %s", m_name); + + graf->color(0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF); + graf->print(0, m_cursorY + 1, ">"); + + JUtility::TColor sp28(0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF); + JUtility::TColor sp24(0, 0xFF >> (u8)var_r27, 0, 0xFF); + + onDrawSoundItem(graf, soundTable, cursorY++, + sp28, + sp24, + "SEQ NUM ", + 1, 0, field_0x3f8 + ); + + graf->color(sp28); + const char* cateName; + if (soundTable != NULL) { + cateName = soundTable->getGroupName(JAISoundID(0, field_0x3fa & 0xFF, 0)); + } else { + cateName = ""; + } + graf->print(1, cursorY++, "SE CATE %03x %s", field_0x3fa, cateName); + + onDrawSoundItem(graf, soundTable, cursorY++, + sp28, + sp24, + "SE NUM ", + 0, field_0x3fa & 0xFF, field_0x3fc + ); + onDrawSoundItem(graf, soundTable, cursorY++, + sp28, + sp24, + "STRM NUM", + 2, 0, field_0x3fe + ); + + graf->color(sp28); + graf->print(1, cursorY++, "CORE_SPK %03x %s", field_0x400, Z2AudioCS::getName(field_0x400)); + + graf->color(field_0x446 + 0xC0, 0xC0, 0xC0, 0xFF); + graf->print(1, cursorY++, "PORT NUM %03x %s", m_portNum, m_portNames[m_portNum]); + graf->print(1, cursorY++, "PORT VAL %03x", m_portVal); + + graf->color(0, 0x50, 0xC8, 0xFF); + if (field_0x3ee) { + graf->print(1, cursorY, "DOLBY ON\n"); + } + + graf->color(0xC8, 0x50, 0, 0xFF); + if (field_0x3f0) { + graf->print(10, cursorY, "LEVEL SE CALL"); + } + + graf->color(0xFF, 0, 0, 0xFF); + graf->print(0x16, cursorY, "%s", field_0x3ed ? "PAUSE ON" : ""); + + graf->color(0, 0xC8, (field_0x4a0 * 200) / 30, 0xFF); + if (field_0x3ef) { + graf->print(0x16, cursorY, "RESET %d\n", field_0x4a0); + } } -void Z2SoundPlayer::onTrigA(const JUTGamePad&) { +void Z2SoundPlayer::onTrigA(const JUTGamePad& pad) { + switch (m_cursorY) { + case 0: { + JAISoundID sp24(1, 0, (u16)field_0x3f8); + switch (sp24) { + case 0x100000a: + case 0x100000b: + case 0x100000f: + case 0x1000012: + case 0x1000014: + case 0x100001b: + case 0x100001c: + case 0x1000024: + Z2GetSoundMgr()->startSound(sp24, mp_subBgmHandle, NULL); + break; + default: + Z2GetSoundMgr()->startSound(sp24, &field_0x494, NULL); + break; + } + break; + } + case 1: + case 2: + if (!field_0x3f0) { + JAISoundHandle* handle = field_0x48c.getFreeHandle(); + JAISoundID sp20(0, field_0x3fa & 0xFF, (u16)field_0x3fc); + if (handle != NULL) { + Z2GetSoundStarter()->startSound(sp20, handle, NULL); + if (*handle) { + Z2GetSoundStarter()->setPortData(handle, m_portNum, m_portVal, -1); + } + } + } + break; + case 3: + Z2GetSoundMgr()->startSound(JAISoundID(2, 0, (u16)field_0x3fe), &field_0x49c, NULL); + break; + case 4: + if (!field_0x3f0) { + Z2AudioCS::start(field_0x400, 0); + } + break; + case 5: + case 6: + field_0x446 = 64; + if (m_portNum < 9) { + JAISoundHandle* handle = field_0x48c.getFreeHandle(); + JAISoundID sp1C(0, field_0x3fa & 0xFF, (u16)field_0x3fc); + if (handle != NULL) { + Z2GetSoundStarter()->startSound(sp1C, handle, NULL); + if (*handle) { + Z2GetSoundStarter()->setPortData(handle, m_portNum, m_portVal, -1); + } + } + } else { + if (field_0x494) { + Z2GetSoundStarter()->setPortData(&field_0x494, m_portNum, m_portVal, -1); + } + if (mp_subBgmHandle->isSoundAttached()) { + Z2GetSoundStarter()->setPortData(mp_subBgmHandle, m_portNum, m_portVal, -1); + } + } + break; + } } -void Z2SoundPlayer::onTrigB(const JUTGamePad&) { +void Z2SoundPlayer::onTrigB(const JUTGamePad& pad) { + switch (m_cursorY) { + case 0: { + if (field_0x494) { + field_0x494->stop(0); + } + field_0x494.releaseSound(); + + if (mp_subBgmHandle->isSoundAttached()) { + (*mp_subBgmHandle)->stop(); + } + break; + } + case 1: + case 2: { + JAISoundHandle* handle = field_0x48c.getHandleSoundID(JAISoundID(0, field_0x3fa & 0xFF, (u16)field_0x3fc)); + if (handle) { + (*handle)->stop(); + handle->releaseSound(); + } + break; + } + case 3: + if (field_0x49c) { + field_0x49c->stop(); + } + + field_0x49c.releaseSound(); + break; + case 4: + Z2AudioCS::stop(0); + break; + case 5: + case 6: + m_portVal = 0; + field_0x446 = 0; + + if (field_0x494) { + Z2GetSoundStarter()->setPortData(&field_0x494, m_portNum, m_portVal, -1); + } + + if (mp_subBgmHandle->isSoundAttached()) { + Z2GetSoundStarter()->setPortData(mp_subBgmHandle, m_portNum, m_portVal, -1); + } + break; + } } void Z2SoundPlayer::frameWork() { + switch (m_cursorY) { + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (field_0x3ef) { + field_0x4a0++; + + if (Z2GetAudioMgr()->hasReset()) { + Z2GetAudioMgr()->resetRecover(); + field_0x3ef = false; + OS_REPORT("RESET END \n"); + } + } } -void Z2SoundPlayer::onPadProc(const JUTGamePad&) { +void Z2SoundPlayer::onPadProc(const JUTGamePad& pad) { + if (field_0x3f0 && pad.testButton(PAD_BUTTON_A)) { + switch (m_cursorY) { + case 2: { + JAISoundID sp14(0, field_0x3fa & 0xFF, (u16)field_0x3fc); + JAISoundHandle* handle = field_0x48c.getHandleSoundID(sp14); + if (handle == NULL) { + handle = field_0x48c.getFreeHandle(); + } + if (handle != NULL) { + Z2GetAudioMgr()->startLevelSound(sp14, handle, NULL); + } + + if (*handle) { + Z2GetSoundStarter()->setPortData(handle, m_portNum, m_portVal, -1); + } + break; + } + case 4: + Z2AudioCS::startLevel(field_0x400, 0); + break; + } + } } -void Z2SoundPlayer::onTrigX(const JUTGamePad&) { +void Z2SoundPlayer::onTrigX(const JUTGamePad& pad) { + switch (m_cursorY) { + case 0: { + if (field_0x494) { + field_0x494->pause(!field_0x494->isPaused()); + } + if (mp_subBgmHandle->isSoundAttached()) { + (*mp_subBgmHandle)->pause(!(*mp_subBgmHandle)->isPaused()); + } + break; + } + case 1: + case 2: { + JAISoundHandle* handle = field_0x48c.getHandleSoundID(JAISoundID(0, field_0x3fa & 0xFF, (u16)field_0x3fc)); + if (handle) { + (*handle)->pause(!(*handle)->isPaused()); + } + break; + } + case 3: + if (field_0x49c) { + (field_0x49c)->pause(!(field_0x49c)->isPaused()); + } + break; + case 4: + Z2AudioCS::stop(0); + break; + } } -void Z2SoundPlayer::onTrigY(const JUTGamePad&) { - - -} -void Z2SoundPlayer::onTrigZ(const JUTGamePad&) { - - -} -void Z2SoundPlayer::onTrigL(const JUTGamePad&) { - +void Z2SoundPlayer::onTrigY(const JUTGamePad& pad) { + if (!field_0x3ef) { + Z2GetAudioMgr()->resetProcess(30, false); + field_0x3ef = true; + field_0x4a0 = 0; + } } -void Z2SoundPlayer::onKeyLeft(const JUTGamePad&) { - +void Z2SoundPlayer::onTrigZ(const JUTGamePad& pad) { + bool* pvar = &field_0x3f0; + bool newValue = *pvar ^ 1; + *pvar = newValue; } -void Z2SoundPlayer::onKeyRight(const JUTGamePad&) { +void Z2SoundPlayer::onTrigL(const JUTGamePad& pad) { + bool* pvar = &field_0x3ee; + bool newValue = *pvar ^ 1; + *pvar = newValue; + if (field_0x3ee) { + Z2GetAudioMgr()->setOutputMode(2); + } else { + Z2GetAudioMgr()->setOutputMode(1); + } } -void Z2SoundPlayer::onKeyUp(const JUTGamePad&) { +void Z2SoundPlayer::onKeyLeft(const JUTGamePad& pad) { + int moveMax = getCursorMoveMax(pad); + int menuMax = getMenuNumberMax(); + if (moveMax >= menuMax) { + moveMax = 1; + } + + if (*field_0x448[m_cursorY] > moveMax - 1) { + *field_0x448[m_cursorY] -= (s16)moveMax; + } else { + *field_0x448[m_cursorY] = (*field_0x448[m_cursorY] + menuMax) - moveMax; + } + + if (m_cursorY == 1) { + correctSeNumber(); + } } -void Z2SoundPlayer::onKeyDown(const JUTGamePad&) { +void Z2SoundPlayer::onKeyRight(const JUTGamePad& pad) { + int moveMax = getCursorMoveMax(pad); + int menuMax = getMenuNumberMax(); + if (moveMax >= menuMax) { + moveMax = 1; + } + + if (*field_0x448[m_cursorY] < menuMax - moveMax) { + *field_0x448[m_cursorY] += (s16)moveMax; + } else { + *field_0x448[m_cursorY] = (*field_0x448[m_cursorY] + moveMax) - menuMax; + } + + if (m_cursorY == 1) { + correctSeNumber(); + } } -void Z2SoundPlayer::onKeyMenu(const JUTGamePad&) { - +void Z2SoundPlayer::onKeyUp(const JUTGamePad& pad) { + if (m_cursorY != 0) { + m_cursorY--; + } else { + m_cursorY = m_cursorMax - 1; + } } -u32 Z2SoundPlayer::getCursorMoveMax(const JUTGamePad&) { - +void Z2SoundPlayer::onKeyDown(const JUTGamePad& pad) { + if (m_cursorY < m_cursorMax - 1) { + m_cursorY++; + } else { + m_cursorY = 0; + } +} + +void Z2SoundPlayer::onKeyMenu(const JUTGamePad& pad) { + bool* pvar = &field_0x3ed; + bool newValue = *pvar ^ 1; + *pvar = newValue; + + Z2GetSoundMgr()->pauseAllGameSound(field_0x3ed); +} + +u32 Z2SoundPlayer::getCursorMoveMax(const JUTGamePad& pad) { + u32 num = 1; + + if (pad.testButton(PAD_TRIGGER_Z) && pad.testButton(PAD_BUTTON_X)) { + num = 128; + } else if (pad.testButton(PAD_TRIGGER_Z)) { + num = 16; + } else if (pad.testButton(PAD_BUTTON_X)) { + num = 8; + } + + return num; +} + +int Z2SoundPlayer::getMenuNumberMax() { + JAUSoundTable* soundTable = JASGlobalInstance::getInstance(); + JUT_ASSERT(550, soundTable); + + int num = 0; + switch (m_cursorY) { + case 0: + num = soundTable->getNumItems_inGroup(1, 0); + break; + case 1: + num = soundTable->getNumGroups_inSection(0); + break; + case 2: + num = soundTable->getNumItems_inGroup(0, field_0x3fa); + break; + case 3: + num = soundTable->getNumItems_inGroup(2, 0); + break; + case 4: + num = Z2AudioCS::getNumOfSound(); + break; + case 5: + num = 16; + break; + case 6: + num = 128; + break; + } + + return num; +} + +void Z2SoundPlayer::correctSeNumber() { + JAUSoundTable* soundTable = JASGlobalInstance::getInstance(); + JUT_ASSERT(594, soundTable); + + int num = soundTable->getNumItems_inGroup(0, field_0x3fa); + if (num == 0) { + field_0x3fc = 0; + } else if (field_0x3fc >= num) { + field_0x3fc = num - 1; + } +} + +void Z2SoundPlayer::onDrawSoundItem(JAWGraphContext* graf, JAUSoundNameTable* nameTable, int cursorY, + const JUtility::TColor& color0, const JUtility::TColor& color1, + const char* label, u32 sectionID, u32 groupID, u32 waveID) +{ + static const char szNoEntry[] = "(NO ENTRY)"; + + const char* soundName = ""; + if (nameTable != NULL) { + soundName = nameTable->getName(JAISoundID(sectionID, groupID, waveID)); + if (*soundName == 0) { + soundName = szNoEntry; + } + } else { + soundName = ""; + } + + // !@bug comparing strings directly instead of using strcmp + if (soundName == szNoEntry) { + graf->color(color1); + } else { + graf->color(color0); + } + + graf->print(1, cursorY, "%s %03x %s", label, waveID, soundName); } diff --git a/src/Z2AudioLib/Z2TrackView.cpp b/src/Z2AudioLib/Z2TrackView.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Z2AudioLib/Z2WaveArcLoader.cpp b/src/Z2AudioLib/Z2WaveArcLoader.cpp new file mode 100644 index 0000000000..2522f4a877 --- /dev/null +++ b/src/Z2AudioLib/Z2WaveArcLoader.cpp @@ -0,0 +1,335 @@ +#include "Z2AudioLib/Z2WaveArcLoader.h" +#include "JSystem/JAudio2/JAUSectionHeap.h" +#include "JSystem/JAudio2/JASWaveInfo.h" + +#include + +static f32 cStatusBar_X1 = 8.0f; +static f32 cStatusBar_X2 = 16.0f; +static f32 cWaveBar_X1 = 30.0f; +static f32 cWaveBar_X2 = 80.0f; +static f32 cBar_Y = 5.0f; +static f32 cBarHeight = 310.0f; + +static u8 lbl_8074A738 = 10; +static u8 lbl_8074A739 = 23; + +static u32 cWaveArcListSize = 10; + +Z2WaveArcLoader::Z2WaveArcLoader() : + JAWWindow("Z2WaveArcLoader", 420, 365) +{ + setWindowColor(0, 0, 0x50, 0xFF); + + mpWaveBank = NULL; + mpWaveArc = NULL; + mWaveUsedSize = 0; + mTotalUsedSize = 0; + mBankNo = 0; + mArcCount = 0; + field_0x408 = 0; + field_0x40c = 0; + field_0x410 = 0; + field_0x414 = 0; + mIsLoadTail = false; + + checkWaveBank(); + checkWaveArc(); +} + +Z2WaveArcLoader::~Z2WaveArcLoader() {} + +// nonmatching with tree iterator stuff +void Z2WaveArcLoader::onDraw(JAWGraphContext* graf) { + int cursorX = 8; + JASHeap* rootheap = JASWaveArcLoader::getRootHeap(); + u32 aramsize = JASKernel::getAramSize(); + + mWaveUsedSize = 0; + + for (u32 i = 0; i < 255; i++) { + JASWaveBank* bank = JASGlobalInstance::getInstance()->getWaveBankTable().getWaveBank(i); + if (bank != NULL) { + u32 arcCount = bank->getArcCount(); + for (int j = 0; j < arcCount; j++) { + JASWaveArc* arc = bank->getWaveArc(j); + if (arc != NULL && arc->getStatus() == 2) { + mWaveUsedSize += arc->getFileSize(); + } + } + } + } + + u32 otherUsedSize = mTotalUsedSize - mWaveUsedSize; + u32 totalFree = rootheap->getTotalFreeSize(); + u32 linearFreeSize = rootheap->getFreeSize(); + u32 sp54 = totalFree - linearFreeSize; + + graf->color(JUtility::TColor(0x32, 0x96, 0xFF, 0xFF), JUtility::TColor(0xC8, 0xC8, 0xFF, 0xFF)); + graf->print(cursorX, 0, "ARAM STATUS\n"); + + graf->color(0xFF, 0xFF, 0xFF, 0xFF); + graf->print(cursorX, 1, " total used : %8d\n", mTotalUsedSize); + + graf->color(0xFF, 0x40, 0x40, 0xFF); + graf->print(cursorX, 2, " wave used : %8d\n", mWaveUsedSize); + + graf->color(0xFF, 0xFF, 0x40, 0xFF); + graf->print(cursorX, 3, " other used : %8d\n", otherUsedSize); + + graf->color(0x40, 0xFF, 0x40, 0xFF); + graf->print(cursorX, 4, " linear free : %8d\n", linearFreeSize); + + graf->color(0xFF, 0xFF, 0xFF, 0xFF); + graf->print(cursorX, 5, " total free : %8d\n", totalFree); + graf->print(cursorX, 6, " ------------------------\n"); + graf->print(cursorX, 7, " aram size : %8d\n", aramsize); + + graf->color(0xFF, 0xFF, 0x20, 0xFF); + f32 var_f30 = cBar_Y; + f32 var_f31 = var_f30 + (((f32)otherUsedSize / (f32)aramsize) * cBarHeight); + graf->fillBox(JGeometry::TBox2(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31)); + + graf->color(0xFF, 0x20, 0x20, 0xFF); + var_f30 = var_f31; + var_f31 += ((f32)mWaveUsedSize / (f32)aramsize) * cBarHeight; + graf->fillBox(JGeometry::TBox2(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31)); + + graf->color(0x20, 0xFF, 0x20, 0xFF); + var_f30 = var_f31; + var_f31 += ((f32)linearFreeSize / (f32)aramsize) * cBarHeight; + graf->fillBox(JGeometry::TBox2(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31)); + + graf->color(0x20, 0x20, 0xFF, 0xFF); + var_f30 = var_f31; + var_f31 += ((f32)sp54 / (f32)aramsize) * cBarHeight; + graf->fillBox(JGeometry::TBox2(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31)); + + graf->color(0x40, 0x40, 0xFF, 0xFF); + graf->fillBox(JGeometry::TBox2(cWaveBar_X1, cBar_Y, cWaveBar_X2, cBar_Y + cBarHeight)); + + void* pbase = rootheap->getBase(); + u32 heapSize = rootheap->getSize(); + int sp48 = 0; + + mTotalUsedSize = 0; + + for (JSUTreeIterator i = rootheap->getFirstChild(); (int)i != (int)rootheap->getEndChild(); ++i) { + intptr_t sp40 = (char*)i->getBase() - (char*)pbase; + u32 sp3C = i->getSize(); + mTotalUsedSize += sp3C; + + int sp38 = (sp40 * cBarHeight) / heapSize; + int sp34 = (sp3C * cBarHeight) / heapSize; + JGeometry::TBox2 spD0(cWaveBar_X1, cBar_Y + (f32)sp38, cWaveBar_X2, (f32)sp34 + (cBar_Y + (f32)sp38)); + u8 sp9 = 0xFF; + sp9 = sp48 % 2 ? (u8)0xC0 : (u8)0x80; + graf->color(0xFF, sp9, 0x40, 0xFF); + graf->fillBox(spD0); + + if (mpWaveArc != NULL) { + if (mpWaveArc->getHeap() == i.getObject()) { + graf->color(0xFF, 0xFF, 0xFF, 0xFF); + graf->lineWidth(15); + graf->drawFrame(spD0); + } + } + + sp48++; + } + + graf->color(JUtility::TColor(0xC8, 0xC8, 0xFF, 0xFF), JUtility::TColor(0x32, 0x96, 0xFF, 0xFF)); + if (mIsLoadTail) { + graf->print(cursorX, 9, "WAVE BANK LOAD:Tail"); + } else { + graf->print(cursorX, 9, "WAVE BANK LOAD:Linear"); + } + + int var_r26 = lbl_8074A738; + + if (mpWaveBank == NULL) { + graf->color(0x64, 0x64, 0x64, 0xFF); + graf->print(cursorX, var_r26, " ws:%3d Not Registerd", mBankNo); + + graf->color(0xFF, 0xFF, 0xFF, 0xFF); + graf->print(cursorX, var_r26, ">"); + } else { + graf->color(0xFF, 0xFF, 0xFF, 0xFF); + if (field_0x414 < 2) { + graf->print(cursorX, field_0x414 + var_r26, ">"); + } else { + graf->print(cursorX, field_0x414 + (var_r26 + 1), ">"); + } + + graf->print(cursorX, var_r26++, " ws:%3d", mBankNo); + graf->print(cursorX, var_r26++, " aw:%3d-%3d /%3d", field_0x40c, field_0x410, mArcCount - 1); + + graf->color(0xFF, 0xA0, 0x64, 0xFF); + graf->print(cursorX, var_r26++, " aw_status aw_size"); + + graf->color(0xFF, 0xFF, 0xFF, 0xFF); + + for (int i = field_0x40c; i < field_0x410 + 1; i++) { + JASWaveArc* arc = mpWaveBank->getWaveArc(i); + if (arc == NULL) { + break; + } + + switch (arc->getStatus()) { + case 0: + graf->color(0x64, 0x64, 0x64, 0xFF); + graf->print(cursorX, var_r26, "%3d: NOT_LOAD %8d", i, arc->getFileSize()); + break; + case 1: + graf->color(0xFF, 0x64, 0x64, 0xFF); + graf->print(cursorX, var_r26, "%3d: WAIT_LOAD %8d", i, arc->getFileSize()); + break; + case 2: + graf->color(0xFF, 0xFF, 0xC8, 0xFF); + graf->print(cursorX, var_r26, "%3d: LOAD %8d", i, arc->getFileSize()); + break; + } + + var_r26++; + } + } + + var_r26 = lbl_8074A739; + graf->color(0x96, 0x96, 0xE1, 0xFF); + graf->print(cursorX, var_r26++, "-----------------"); + graf->print(cursorX, var_r26++, " A -> LOAD WAVE"); + graf->print(cursorX, var_r26++, " B -> ERASE WAVE"); + graf->print(cursorX, var_r26++, "-----------------"); +} + +void Z2WaveArcLoader::checkWaveBank() { + JAUSectionHeap* sectionHeap = JASGlobalInstance::getInstance(); + const JAUSectionHeap::TSectionHeapData& heapData = sectionHeap->getSectionHeapData(); + const JAUSection::TSectionData& sectionData = sectionHeap->getSectionData(); + + if (sectionData.registeredWaveBankTables.test(mBankNo)) { + mpWaveBank = heapData.waveBankTable.getWaveBank(mBankNo); + mArcCount = mpWaveBank->getArcCount(); + } else { + mpWaveBank = NULL; + mArcCount = 0; + } + + if (mBankNo == 1) { + mIsLoadTail = true; + } else { + mIsLoadTail = false; + } +} + +void Z2WaveArcLoader::checkWaveArc() { + field_0x40c = field_0x408 * cWaveArcListSize; + if (field_0x40c > mArcCount - 1) { + field_0x408--; + field_0x40c = field_0x408 * cWaveArcListSize; + } + + field_0x410 = (field_0x408 + 1) * cWaveArcListSize - 1; + + if (field_0x410 > mArcCount - 1) { + field_0x410 = mArcCount - 1; + } + + if (field_0x414 > 1) { + if ((field_0x40c + field_0x414) - 2 > field_0x410) { + field_0x414 = (field_0x410 - field_0x40c) + 2; + } + + mpWaveArc = mpWaveBank->getWaveArc(field_0x40c + field_0x414 - 2); + } else { + mpWaveArc = NULL; + } +} + +void Z2WaveArcLoader::onKeyUp(const JUTGamePad&) { + if (mpWaveBank == NULL) { + field_0x414 = 0; + } else { + if (field_0x414 != 0) { + field_0x414--; + } else { + field_0x414 = 11; + } + + checkWaveArc(); + } +} + +void Z2WaveArcLoader::onKeyDown(const JUTGamePad&) { + if (mpWaveBank == NULL) { + field_0x414 = 0; + } else { + if (field_0x414 < 11) { + field_0x414++; + } else { + field_0x414 = 0; + } + + checkWaveArc(); + } +} + +void Z2WaveArcLoader::onKeyLeft(const JUTGamePad&) { + if (field_0x414 == 0) { + if (mBankNo != 0) { + mBankNo--; + } else { + mBankNo = 0; + } + + checkWaveBank(); + } else if (mpWaveBank != NULL) { + if (field_0x408 != 0) { + field_0x408--; + } else { + field_0x408 = 0; + } + + checkWaveArc(); + } +} + +void Z2WaveArcLoader::onKeyRight(const JUTGamePad&) { + if (field_0x414 == 0) { + if (mBankNo < 255) { + mBankNo++; + } else { + mBankNo = 255; + } + + checkWaveBank(); + } else if (mpWaveBank != NULL) { + if (field_0x408 < 255) { + field_0x408++; + } else { + field_0x408 = 255; + } + + checkWaveArc(); + } +} + +void Z2WaveArcLoader::onTrigA(const JUTGamePad&) { + if (mpWaveArc != NULL && mpWaveArc->getStatus() == 0) { + if (mIsLoadTail) { + mpWaveArc->loadTail(NULL); + } else { + mpWaveArc->load(NULL); + } + } +} + +void Z2WaveArcLoader::onTrigB(const JUTGamePad&) { + if (mpWaveArc != NULL && mpWaveArc->getStatus() == 2) { + mpWaveArc->erase(); + } +} + +void Z2WaveArcLoader::onTrigZ(const JUTGamePad&) { + mIsLoadTail = !mIsLoadTail; +} diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index 4f106ece22..5e2530bdf3 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -54,6 +54,10 @@ #include "res/Object/Alink.h" #include +#if TARGET_PC +bool dusk::tweaks::FastIronBoots = false; +#endif + static int daAlink_Create(fopAc_ac_c* i_this); static int daAlink_Delete(daAlink_c* i_this); static int daAlink_Execute(daAlink_c* i_this); @@ -7509,6 +7513,11 @@ void daAlink_c::setBlendMoveAnime(f32 i_morf) { f32 sp28 = mpHIO->mMove.m.mFootPositionRatio; BOOL sp24 = checkEventRun(); BOOL sp20 = checkBootsMoveAnime(1); +#if TARGET_PC + if (dusk::tweaks::FastIronBoots) { + sp20 = FALSE; + } +#endif f32 var_f29; @@ -9469,6 +9478,11 @@ void daAlink_c::setStickData() { } else { mHeavySpeedMultiplier = mpHIO->mItem.mIronBoots.m.mInputFactor; } +#if TARGET_PC + if (dusk::tweaks::FastIronBoots) { + mHeavySpeedMultiplier = 1.0f; + } +#endif mStickValue *= mHeavySpeedMultiplier; } else if (checkBootsOrArmorHeavy()) { if (checkZoraWearAbility()) { @@ -9476,6 +9490,11 @@ void daAlink_c::setStickData() { } else { mHeavySpeedMultiplier = mpHIO->mItem.mIronBoots.m.mWaterInputFactor; } +#if TARGET_PC + if (dusk::tweaks::FastIronBoots) { + mHeavySpeedMultiplier = 1.0f; + } +#endif mStickValue *= mHeavySpeedMultiplier; } else if ((checkWolf() && field_0x2fbc == 11 && checkWaterPolygonUnder()) || mGndPolyAtt0 == 11) diff --git a/src/d/actor/d_a_bg_obj.cpp b/src/d/actor/d_a_bg_obj.cpp index 4c7fb4d03e..7d4adb9e47 100644 --- a/src/d/actor/d_a_bg_obj.cpp +++ b/src/d/actor/d_a_bg_obj.cpp @@ -976,7 +976,7 @@ void daBgObj_c::setSe() { temp++; for (; i != 0; i--) { - fopAcM_seStart(this, *temp, 0); + fopAcM_seStart(this, *(BE(u32)*)temp, 0); temp++; } } diff --git a/src/d/actor/d_a_e_fz.cpp b/src/d/actor/d_a_e_fz.cpp index 6fa54a0ffe..a48c4df8f0 100644 --- a/src/d/actor/d_a_e_fz.cpp +++ b/src/d/actor/d_a_e_fz.cpp @@ -3,16 +3,17 @@ * @brief Enemy - Mini Freezard */ -#include "d/dolzel_rel.h" // IWYU pragma: keep +#include "d/dolzel_rel.h" // IWYU pragma: keep -#include "d/actor/d_a_e_fz.h" -#include "f_op/f_op_actor_enemy.h" -#include "d/actor/d_a_mirror.h" -#include "d/actor/d_a_b_yo.h" -#include "d/d_com_inf_game.h" -#include "d/d_item.h" #include "SSystem/SComponent/c_math.h" #include "SSystem/SComponent/c_xyz.h" +#include "d/actor/d_a_b_yo.h" +#include "d/actor/d_a_e_fz.h" +#include "d/actor/d_a_mirror.h" +#include "d/d_com_inf_game.h" +#include "d/d_item.h" +#include "f_op/f_op_actor_enemy.h" + class daE_FZ_HIO_c { public: @@ -42,26 +43,26 @@ namespace { static dCcD_SrcSph cc_fz_src = { { - {0x0, {{0x100, 0x1, 0x0}, {0xd0fbfdff, 0x43}, 0x65}}, // mObj - {dCcD_SE_METAL, 0x0, 0x0, 0x0, 0x0}, // mGObjAt - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x6}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf + {0x0, {{0x100, 0x1, 0x0}, {0xd0fbfdff, 0x43}, 0x65}}, // mObj + {dCcD_SE_METAL, 0x0, 0x0, 0x0, 0x0}, // mGObjAt + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x6}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf { - {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph - } // mSphAttr + {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph + } // mSphAttr }; static dCcD_SrcSph cc_fz_at_src = { { - {0x0, {{0x100, 0x1, 0x1d}, {0x0, 0x0}, 0x0}}, // mObj - {dCcD_SE_METAL, 0x0, 0x0, 0x0, 0x0}, // mGObjAt - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf + {0x0, {{0x100, 0x1, 0x1d}, {0x0, 0x0}, 0x0}}, // mObj + {dCcD_SE_METAL, 0x0, 0x0, 0x0, 0x0}, // mGObjAt + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf { - {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph - } // mSphAttr + {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph + } // mSphAttr }; } // namespace @@ -84,7 +85,7 @@ daE_FZ_HIO_c::daE_FZ_HIO_c() { } s32 daE_FZ_c::draw() { - if (field_0x714 == 2 && !checkItemGet(dItemNo_IRONBALL_e,1)) { + if (field_0x714 == 2 && !checkItemGet(dItemNo_IRONBALL_e, 1)) { return 1; } @@ -100,13 +101,13 @@ s32 daE_FZ_c::draw() { pos.set(current.pos.x, current.pos.y + 10.0f, current.pos.z); field_0x70c = dComIfGd_setShadow(field_0x70c, 1, model, &pos, 300.0f, 0.0f, current.pos.y, - mObjAcch.GetGroundH(), mObjAcch.m_gnd, &tevStr, - 0, 1.0f, &dDlst_shadowControl_c::mSimpleTexObj); + mObjAcch.GetGroundH(), mObjAcch.m_gnd, &tevStr, 0, 1.0f, + &dDlst_shadowControl_c::mSimpleTexObj); return 1; } -static void daE_FZ_Draw(daE_FZ_c* i_this) { - i_this->draw(); +static int daE_FZ_Draw(daE_FZ_c* i_this) { + return i_this->draw(); } void daE_FZ_c::setActionMode(int i_actionMode, int i_actionPhase) { @@ -136,7 +137,7 @@ void daE_FZ_c::mBoundSoundset() { if (speed < 1) speed = 1; - mCreature.startCreatureSound(Z2SE_EN_FZ_BOUND,speed,-1); + mCreature.startCreatureSound(Z2SE_EN_FZ_BOUND, speed, -1); } void daE_FZ_c::deadnextSet(bool param_0) { @@ -150,7 +151,7 @@ void daE_FZ_c::deadnextSet(bool param_0) { } mTgCoSph.ClrTgHit(); - fopAcM_OffStatus(this,0); + fopAcM_OffStatus(this, 0); attention_info.flags &= ~fopAc_AttnFlag_BATTLE_e; mAtSph.OffAtSetBit(); @@ -160,7 +161,7 @@ void daE_FZ_c::deadnextSet(bool param_0) { speedF = 0.0f; field_0x6fc = 0; - setActionMode(ACT_DAMAGE,0); + setActionMode(ACT_DAMAGE, 0); } static u8 data_806C1BA0; @@ -168,178 +169,186 @@ static u8 data_806C1BA0; static daE_FZ_HIO_c l_HIO; void daE_FZ_c::damage_check() { - csXyz s_pos; - cXyz pos; - cXyz pos2; - cXyz pos3; + csXyz s_pos; + cXyz pos; + cXyz pos2; + cXyz pos3; - if (1 < health) { - scale.set(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); - setMidnaBindEffect(this, &mCreature, ¤t.pos, &scale); + if (1 < health) { + scale.set(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); + setMidnaBindEffect(this, &mCreature, ¤t.pos, &scale); - if (field_0x712 == 0) { - pos.set(dComIfGp_getPlayer(0)->current.pos); - mStts.Move(); + if (field_0x712 == 0) { + pos.set(dComIfGp_getPlayer(0)->current.pos); + mStts.Move(); - if (field_0x714 == 3) { - if (mTgCoSph.ChkTgHit()) { - mAtInfo.mpCollider = mTgCoSph.GetTgHitObj(); + if (field_0x714 == 3) { + if (mTgCoSph.ChkTgHit()) { + mAtInfo.mpCollider = mTgCoSph.GetTgHitObj(); - if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_IRON_BALL)) { - deadnextSet(false); - } - } - } else { - if (mTgCoSph.ChkTgHit()) { - mAtInfo.mpCollider = mTgCoSph.GetTgHitObj(); - - if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_40) || mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_BOOMERANG)) { - current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; - f32 tmp_l_hio = l_HIO.field_0x28; - speedF = tmp_l_hio; - field_0x6fc = tmp_l_hio; - mBoundSoundset(); - setActionMode(ACT_DAMAGE,1); - return; - } - - pos2 = current.pos - *mTgCoSph.GetTgHitPosP(); - pos3.set(*mTgCoSph.GetTgHitPosP()); - - s_pos.x = 0; - s_pos.y = pos2.atan2sX_Z(); - s_pos.z = 0; - - if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_SPINNER) || mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_ARROW)) { - current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; - f32 tmp_l_hio = l_HIO.field_0x28; - speedF = tmp_l_hio; - field_0x6fc = tmp_l_hio; - mBoundSoundset(); - dComIfGp_setHitMark(2,this,&pos3,&s_pos,0,AT_TYPE_0); - setActionMode(ACT_DAMAGE,1); - return; - } - - cXyz cStack_54(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); - dComIfGp_particle_set(0x85ba, ¤t.pos, &shape_angle, &cStack_54); - - if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_HOOKSHOT)) { - health -= 20; - - if (1 < health) { - current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; - - f32 tmp_l_hio = l_HIO.field_0x28; - speedF = tmp_l_hio; - field_0x6fc = tmp_l_hio; - mCreature.startCreatureSound(Z2SE_EN_FZ_DAMAGE,0,-1); - - f32 tmp_l_hio2 = l_HIO.field_0x28; - speedF = tmp_l_hio2; - field_0x6fc = tmp_l_hio2; - setActionMode(ACT_DAMAGE,1); - dComIfGp_setHitMark(3,this,&pos3,&s_pos,0,AT_TYPE_0); - return; - } - - deadnextSet(true); - dComIfGp_setHitMark(1,this,&pos3,&s_pos,0,AT_TYPE_0); - return; - } - - if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_IRON_BALL)) { - deadnextSet(false); - mTgCoSph.ClrTgHit(); - dComIfGp_setHitMark(3,this,&pos3,&s_pos,0,AT_TYPE_0); - return; - } - - cc_at_check(this,&mAtInfo); - - if (mAtInfo.mHitStatus == 0) { - dComIfGp_setHitMark(1,this,&pos3,&s_pos,0,AT_TYPE_0); - } else { - dComIfGp_setHitMark(3,this,&pos3,&s_pos,0,AT_TYPE_0); - } - - mLastWallHitAngle = mAtInfo.mHitDirection.y; - setReflectAngle(); - current.angle.y += -32768; - field_0x712 = 10; - - if (1 < health) { - mCreature.startCreatureSound(Z2SE_EN_FZ_DAMAGE,0,-1); - f32 tmp_l_hio = l_HIO.field_0x28; - speedF = tmp_l_hio; - field_0x6fc = tmp_l_hio; - setActionMode(ACT_DAMAGE,1); - return; - } - - deadnextSet(true); - return; - } else { - if (mObjAcch.ChkGroundHit() && mTgCoSph.ChkCoHit()) { - fopAc_ac_c* co_hit_actor = mTgCoSph.GetCoHitAc(); - - if (fopAcM_IsActor(co_hit_actor) && fopAcM_GetName(co_hit_actor) == fpcNm_E_FZ_e) { - pos = current.pos - mTgCoSph.GetCoHitAc()->current.pos; - mTgCoSph.ClrCoHit(); - f32 co_hit_actor_speed = co_hit_actor->speedF; - - if (co_hit_actor_speed > l_HIO.field_0x28 * 0.2f || speedF > l_HIO.field_0x28 * 0.2f) { - pos = current.pos - co_hit_actor->current.pos; - mLastWallHitAngle = pos.atan2sX_Z(); - setReflectAngle(); - - f32 tmp2 = speedF; - f32 tmp = co_hit_actor->speedF; - - if (speedF > tmp) { - co_hit_actor->speedF = tmp2; - static_cast(co_hit_actor)->field_0x6fc = tmp2; - } else { - speedF = tmp; - field_0x6fc = tmp; + if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_IRON_BALL)) { + deadnextSet(false); + } } - - mBoundSoundset(); - setActionMode(ACT_DAMAGE,5); - return; - } - } - } - - if (mAtSph.ChkAtHit()) { - fopAc_ac_c* player = dComIfGp_getPlayer(0); - fopAc_ac_c* at_hit_actor = mAtSph.GetAtHitAc(); - - current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; - - if (player != at_hit_actor) { - mAtSph.ClrAtHit(); } else { - if (mAtSph.ChkAtShieldHit()) { - f32 l_hio_28 = l_HIO.field_0x28; - speedF = l_hio_28; - field_0x6fc = l_hio_28; - setActionMode(ACT_DAMAGE,1); + if (mTgCoSph.ChkTgHit()) { + mAtInfo.mpCollider = mTgCoSph.GetTgHitObj(); - } else { - if (mActionMode != ACT_DAMAGE) { - field_0x712 = 10; - setActionMode(ACT_DAMAGE,3); + if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_40) || + mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_BOOMERANG)) + { + current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; + f32 tmp_l_hio = l_HIO.field_0x28; + speedF = tmp_l_hio; + field_0x6fc = tmp_l_hio; + mBoundSoundset(); + setActionMode(ACT_DAMAGE, 1); + return; + } + + pos2 = current.pos - *mTgCoSph.GetTgHitPosP(); + pos3.set(*mTgCoSph.GetTgHitPosP()); + + s_pos.x = 0; + s_pos.y = pos2.atan2sX_Z(); + s_pos.z = 0; + + if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_SPINNER) || + mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_ARROW)) + { + current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; + f32 tmp_l_hio = l_HIO.field_0x28; + speedF = tmp_l_hio; + field_0x6fc = tmp_l_hio; + mBoundSoundset(); + dComIfGp_setHitMark(2, this, &pos3, &s_pos, 0, AT_TYPE_0); + setActionMode(ACT_DAMAGE, 1); + return; + } + + cXyz cStack_54(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); + dComIfGp_particle_set(0x85ba, ¤t.pos, &shape_angle, &cStack_54); + + if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_HOOKSHOT)) { + health -= 20; + + if (1 < health) { + current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; + + f32 tmp_l_hio = l_HIO.field_0x28; + speedF = tmp_l_hio; + field_0x6fc = tmp_l_hio; + mCreature.startCreatureSound(Z2SE_EN_FZ_DAMAGE, 0, -1); + + f32 tmp_l_hio2 = l_HIO.field_0x28; + speedF = tmp_l_hio2; + field_0x6fc = tmp_l_hio2; + setActionMode(ACT_DAMAGE, 1); + dComIfGp_setHitMark(3, this, &pos3, &s_pos, 0, AT_TYPE_0); + return; + } + + deadnextSet(true); + dComIfGp_setHitMark(1, this, &pos3, &s_pos, 0, AT_TYPE_0); + return; + } + + if (mTgCoSph.GetTgHitObj()->ChkAtType(AT_TYPE_IRON_BALL)) { + deadnextSet(false); + mTgCoSph.ClrTgHit(); + dComIfGp_setHitMark(3, this, &pos3, &s_pos, 0, AT_TYPE_0); + return; + } + + cc_at_check(this, &mAtInfo); + + if (mAtInfo.mHitStatus == 0) { + dComIfGp_setHitMark(1, this, &pos3, &s_pos, 0, AT_TYPE_0); + } else { + dComIfGp_setHitMark(3, this, &pos3, &s_pos, 0, AT_TYPE_0); + } + + mLastWallHitAngle = mAtInfo.mHitDirection.y; + setReflectAngle(); + current.angle.y += -32768; + field_0x712 = 10; + + if (1 < health) { + mCreature.startCreatureSound(Z2SE_EN_FZ_DAMAGE, 0, -1); + f32 tmp_l_hio = l_HIO.field_0x28; + speedF = tmp_l_hio; + field_0x6fc = tmp_l_hio; + setActionMode(ACT_DAMAGE, 1); + return; + } + + deadnextSet(true); + return; + } else { + if (mObjAcch.ChkGroundHit() && mTgCoSph.ChkCoHit()) { + fopAc_ac_c* co_hit_actor = mTgCoSph.GetCoHitAc(); + + if (fopAcM_IsActor(co_hit_actor) && + fopAcM_GetName(co_hit_actor) == fpcNm_E_FZ_e) + { + pos = current.pos - mTgCoSph.GetCoHitAc()->current.pos; + mTgCoSph.ClrCoHit(); + f32 co_hit_actor_speed = co_hit_actor->speedF; + + if (co_hit_actor_speed > l_HIO.field_0x28 * 0.2f || + speedF > l_HIO.field_0x28 * 0.2f) + { + pos = current.pos - co_hit_actor->current.pos; + mLastWallHitAngle = pos.atan2sX_Z(); + setReflectAngle(); + + f32 tmp2 = speedF; + f32 tmp = co_hit_actor->speedF; + + if (speedF > tmp) { + co_hit_actor->speedF = tmp2; + static_cast(co_hit_actor)->field_0x6fc = tmp2; + } else { + speedF = tmp; + field_0x6fc = tmp; + } + + mBoundSoundset(); + setActionMode(ACT_DAMAGE, 5); + return; + } + } + } + + if (mAtSph.ChkAtHit()) { + fopAc_ac_c* player = dComIfGp_getPlayer(0); + fopAc_ac_c* at_hit_actor = mAtSph.GetAtHitAc(); + + current.angle.y = fopAcM_searchPlayerAngleY(this) + 32768; + + if (player != at_hit_actor) { + mAtSph.ClrAtHit(); + } else { + if (mAtSph.ChkAtShieldHit()) { + f32 l_hio_28 = l_HIO.field_0x28; + speedF = l_hio_28; + field_0x6fc = l_hio_28; + setActionMode(ACT_DAMAGE, 1); + + } else { + if (mActionMode != ACT_DAMAGE) { + field_0x712 = 10; + setActionMode(ACT_DAMAGE, 3); + } + } + mBoundSoundset(); + mAtSph.ClrAtHit(); + } + } } - } - mBoundSoundset(); - mAtSph.ClrAtHit(); } - } } - } } - } } bool daE_FZ_c::way_gake_check() { @@ -350,13 +359,13 @@ bool daE_FZ_c::way_gake_check() { return false; } - cMtx_YrotS((MtxP)calc_mtx,current.angle.y); + cMtx_YrotS((MtxP)calc_mtx, current.angle.y); pos.x = 0.0f; pos.y = 300.0f; pos.z = 70.0f; - MtxPosition(&pos,&field_0x6dc); + MtxPosition(&pos, &field_0x6dc); field_0x6dc += current.pos; field_0x6e8.set(field_0x6dc); @@ -374,234 +383,231 @@ bool daE_FZ_c::way_gake_check() { } void daE_FZ_c::executeWait() { - cXyz pos; - cXyz pos2; - s16 angle; - f32 tmp = l_HIO.field_0x14; + cXyz pos; + cXyz pos2; + s16 angle; + f32 tmp = l_HIO.field_0x14; - switch (mActionPhase) { - case 0: - if (fopAcM_wayBgCheck(this,200.0f,50.0f)) { - angle = cM_rndFX(10000.0f) + 32768.0f; - } else { + switch (mActionPhase) { + case 0: + if (fopAcM_wayBgCheck(this, 200.0f, 50.0f)) { + angle = cM_rndFX(10000.0f) + 32768.0f; + } else { + pos2.x = home.pos.x + cM_rndFX(l_HIO.field_0x10); + pos2.y = home.pos.y; + pos2.z = home.pos.z + cM_rndFX(l_HIO.field_0x10); - pos2.x = home.pos.x + cM_rndFX(l_HIO.field_0x10); - pos2.y = home.pos.y; - pos2.z = home.pos.z + cM_rndFX(l_HIO.field_0x10); + pos = pos2 - current.pos; - pos = pos2 - current.pos; + angle = pos.atan2sX_Z() - current.angle.y; - angle = pos.atan2sX_Z() - current.angle.y; - - if (angle > 12288) { - angle = 12288; - } - else { - if (angle < -12288) - angle = -12288; - } - } - - mAngleFromPlayer = current.angle.y + angle; - field_0x710 = l_HIO.field_0x06 + cM_rndFX(l_HIO.field_0x30); - mActionPhase = 1; - case 1: - if (way_gake_check()) { - pos2 = current.pos - home.pos; - angle = pos2.atan2sX_Z(); - mAngleFromPlayer = angle; - current.angle.y = angle; - } - - if (field_0x714 == 4) { - field_0x710 = 10; - speedF = 0.0f; - angle = fopAcM_searchPlayerAngleY(this); - mAngleFromPlayer = angle; - current.angle.y = angle; - tmp = l_HIO.field_0x18; - } - - if (mObjAcch.ChkGroundHit() && dComIfG_Bgsp().GetPolyAtt0(mObjAcch.m_gnd) == 8) { - angle = shape_angle.y - mAngleFromPlayer; - - if (abs(angle) < 512 && field_0x710 == 0) { - cLib_addCalc0(&speedF, 0.1f, 0.1f); + if (angle > 12288) { + angle = 12288; + } else { + if (angle < -12288) + angle = -12288; + } + } + + mAngleFromPlayer = current.angle.y + angle; + field_0x710 = l_HIO.field_0x06 + cM_rndFX(l_HIO.field_0x30); + mActionPhase = 1; + case 1: + if (way_gake_check()) { + pos2 = current.pos - home.pos; + angle = pos2.atan2sX_Z(); + mAngleFromPlayer = angle; + current.angle.y = angle; + } + + if (field_0x714 == 4) { + field_0x710 = 10; + speedF = 0.0f; + angle = fopAcM_searchPlayerAngleY(this); + mAngleFromPlayer = angle; + current.angle.y = angle; + tmp = l_HIO.field_0x18; + } + + if (mObjAcch.ChkGroundHit() && dComIfG_Bgsp().GetPolyAtt0(mObjAcch.m_gnd) == 8) { + angle = shape_angle.y - mAngleFromPlayer; + + if (abs(angle) < 512 && field_0x710 == 0) { + cLib_addCalc0(&speedF, 0.1f, 0.1f); + } + } else { + cLib_addCalc0(&speedF, 0.1f, l_HIO.field_0x2c); + } + + if (field_0x710 == 0 && speedF < 0.2f) { + angle = shape_angle.y - mAngleFromPlayer; + + if (abs(angle) < 512) { + current.angle.y = shape_angle.y; + setActionMode(ACT_MOVE, 0); + } } - } else { - cLib_addCalc0(&speedF,0.1f,l_HIO.field_0x2c); } - if (field_0x710 == 0 && speedF < 0.2f) { - angle = shape_angle.y - mAngleFromPlayer; + cLib_addCalcAngleS2(&shape_angle.y, mAngleFromPlayer, 8, 1280); - if (abs(angle) < 512) { - current.angle.y = shape_angle.y; - setActionMode(ACT_MOVE,0); - } + if (fopAcM_searchPlayerDistance(this) <= tmp && !way_gake_check()) { + if (!fopAcM_otherBgCheck(this, dComIfGp_getPlayer(0))) { + current.angle.y = shape_angle.y; + setActionMode(ACT_ATTACK, 0); + } } - } - - cLib_addCalcAngleS2(&shape_angle.y,mAngleFromPlayer,8,1280); - - if (fopAcM_searchPlayerDistance(this) <= tmp && !way_gake_check()) { - if (!fopAcM_otherBgCheck(this,dComIfGp_getPlayer(0))) { - current.angle.y = shape_angle.y; - setActionMode(ACT_ATTACK,0); - } - } } void daE_FZ_c::executeMove() { switch (mActionPhase) { - case 0: - field_0x710 = l_HIO.field_0x08 + cM_rndFX(l_HIO.field_0x34); - mActionPhase = 1; - case 1: - cLib_addCalcAngleS2(¤t.angle.y,mAngleFromPlayer,8,256); - cLib_addCalc2(&speedF,l_HIO.field_0x1c,1.0f,3.0f); + case 0: + field_0x710 = l_HIO.field_0x08 + cM_rndFX(l_HIO.field_0x34); + mActionPhase = 1; + case 1: + cLib_addCalcAngleS2(¤t.angle.y, mAngleFromPlayer, 8, 256); + cLib_addCalc2(&speedF, l_HIO.field_0x1c, 1.0f, 3.0f); - if (fopAcM_wayBgCheck(this, 200.0f,50.0f) != 0 || field_0x710 == 0) { - setActionMode(ACT_WAIT,0); - } - default: - if (way_gake_check()) { - speedF = 0; - setActionMode(ACT_WAIT,0); - } else { - shape_angle.y = current.angle.y; + if (fopAcM_wayBgCheck(this, 200.0f, 50.0f) != 0 || field_0x710 == 0) { + setActionMode(ACT_WAIT, 0); + } + default: + if (way_gake_check()) { + speedF = 0; + setActionMode(ACT_WAIT, 0); + } else { + shape_angle.y = current.angle.y; - if (fopAcM_searchPlayerDistance(this) <= l_HIO.field_0x14) { - setActionMode(ACT_ATTACK,0); - } + if (fopAcM_searchPlayerDistance(this) <= l_HIO.field_0x14) { + setActionMode(ACT_ATTACK, 0); } + } } } void daE_FZ_c::executeAttack() { switch (mActionPhase) { case 0: - cLib_addCalcAngleS2(¤t.angle.y,fopAcM_searchPlayerAngleY(this),8,0x300); + cLib_addCalcAngleS2(¤t.angle.y, fopAcM_searchPlayerAngleY(this), 8, 0x300); if (way_gake_check() == 0) { - cLib_addCalc2(&speedF,l_HIO.field_0x20,0.7f,1.0f); + cLib_addCalc2(&speedF, l_HIO.field_0x20, 0.7f, 1.0f); } else { speedF = 0.0f; } default: shape_angle.y = current.angle.y; if (!(fopAcM_searchPlayerDistance(this) >= l_HIO.field_0x10)) { - if (fopAcM_otherBgCheck(this,dComIfGp_getPlayer(0)) == 0) { + if (fopAcM_otherBgCheck(this, dComIfGp_getPlayer(0)) == 0) { return; } } } - setActionMode(ACT_WAIT,0); + setActionMode(ACT_WAIT, 0); } void daE_FZ_c::executeDamage() { - cXyz pos; - pos.set(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); - f32 tmp; + cXyz pos; + pos.set(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); + f32 tmp; - switch(mActionPhase) { - case 0: - dComIfGp_particle_set(0x85b8,¤t.pos,&shape_angle,&pos); - dComIfGp_particle_set(0x85b9,¤t.pos,&shape_angle,&pos); + switch (mActionPhase) { + case 0: + dComIfGp_particle_set(0x85b8, ¤t.pos, &shape_angle, &pos); + dComIfGp_particle_set(0x85b9, ¤t.pos, &shape_angle, &pos); - if (field_0x714 != 3) { - field_0x564 = 25; - fopAcM_createItemFromEnemyID(field_0x564,¤t.pos,-1,-1,0,0,0,0); - } else { - if (cM_rnd() < 0.2f) { - fopAcM_createItem(¤t.pos,0,-1,-1,0,0,0); - } - } - fopAcM_delete(this); - break; - case 1: - tmp = l_HIO.field_0x28; - speedF = tmp; - field_0x6fc = tmp; - case 5: - mStts.SetWeight(118); - current.angle.y < 0 ? field_0x704 = 0 : field_0x704 = 1; - mActionPhase = 2; - case 2: - if (mObjAcch.ChkGroundHit() && dComIfG_Bgsp().GetPolyAtt0(mObjAcch.m_gnd) == 8) { - tmp = 0.2f; - } else { - tmp = 1.0f; - } + if (field_0x714 != 3) { + field_0x564 = 25; + fopAcM_createItemFromEnemyID(field_0x564, ¤t.pos, -1, -1, 0, 0, 0, 0); + } else { + if (cM_rnd() < 0.2f) { + fopAcM_createItem(¤t.pos, 0, -1, -1, 0, 0, 0); + } + } + fopAcM_delete(this); + break; + case 1: + tmp = l_HIO.field_0x28; + speedF = tmp; + field_0x6fc = tmp; + case 5: + mStts.SetWeight(118); + current.angle.y < 0 ? field_0x704 = 0 : field_0x704 = 1; + mActionPhase = 2; + case 2: + if (mObjAcch.ChkGroundHit() && dComIfG_Bgsp().GetPolyAtt0(mObjAcch.m_gnd) == 8) { + tmp = 0.2f; + } else { + tmp = 1.0f; + } - cLib_addCalc0(&speedF,0.1f,tmp); + cLib_addCalc0(&speedF, 0.1f, tmp); - if (field_0x704 == 0) { - s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); - shape_angle.y -= value; - } else { - s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); - shape_angle.y += value; - } + if (field_0x704 == 0) { + s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); + shape_angle.y -= value; + } else { + s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); + shape_angle.y += value; + } - if (mObjAcch.ChkWallHit()) { - mLastWallHitAngle = mAcchCir.GetWallAngleY(); - setReflectAngle(); - mBoundSoundset(); - } + if (mObjAcch.ChkWallHit()) { + mLastWallHitAngle = mAcchCir.GetWallAngleY(); + setReflectAngle(); + mBoundSoundset(); + } - if (speedF < 0.3f) { - current.angle.y = shape_angle.y; - mStts.SetWeight(100); - setActionMode(ACT_WAIT,0); - } - break; - case 3: - mAngleFromPlayer = fopAcM_searchPlayerAngleY(this); - if (current.angle.y < 0) { - field_0x704 = 0; - } - else { - field_0x704 = 1; - } - tmp = l_HIO.field_0x24; - speedF = tmp; - field_0x6fc = tmp; - mActionPhase = 4; - case 4: - if (field_0x704 == 0) { - s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); - shape_angle.y -= value; - } - else { - s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); - shape_angle.y += value; - } + if (speedF < 0.3f) { + current.angle.y = shape_angle.y; + mStts.SetWeight(100); + setActionMode(ACT_WAIT, 0); + } + break; + case 3: + mAngleFromPlayer = fopAcM_searchPlayerAngleY(this); + if (current.angle.y < 0) { + field_0x704 = 0; + } else { + field_0x704 = 1; + } + tmp = l_HIO.field_0x24; + speedF = tmp; + field_0x6fc = tmp; + mActionPhase = 4; + case 4: + if (field_0x704 == 0) { + s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); + shape_angle.y -= value; + } else { + s16 value = 4096.0f - (4096.0f / field_0x6fc) * (field_0x6fc - speedF); + shape_angle.y += value; + } - cLib_addCalcAngleS2(¤t.angle.y,mAngleFromPlayer,1,512); - cLib_addCalc0(&speedF,0.1f,0.1f); + cLib_addCalcAngleS2(¤t.angle.y, mAngleFromPlayer, 1, 512); + cLib_addCalc0(&speedF, 0.1f, 0.1f); - if (mObjAcch.ChkWallHit()) { - mLastWallHitAngle = mAcchCir.GetWallAngleY(); - setReflectAngle(); - mBoundSoundset(); - } + if (mObjAcch.ChkWallHit()) { + mLastWallHitAngle = mAcchCir.GetWallAngleY(); + setReflectAngle(); + mBoundSoundset(); + } - if (speedF < 0.2f) { - current.angle.y = shape_angle.y; - setActionMode(ACT_ATTACK,0); + if (speedF < 0.2f) { + current.angle.y = shape_angle.y; + setActionMode(ACT_ATTACK, 0); + } + break; + case 6: + health = 0; + if (field_0x710 == 1 || mObjAcch.ChkGroundHit()) { + mActionPhase = 0; + } } - break; - case 6: - health = 0; - if (field_0x710 == 1 || mObjAcch.ChkGroundHit()) { - mActionPhase = 0; - } - } } void daE_FZ_c::executeRollMove() { - if (fopAcM_SearchByID(fopAcM_GetLinkId(this),&mpBlizzetaActor) == 0 || !mpBlizzetaActor) return; + if (fopAcM_SearchByID(fopAcM_GetLinkId(this), &mpBlizzetaActor) == 0 || !mpBlizzetaActor) + return; u32 model_no = static_cast(mpBlizzetaActor)->getModelNo(); if (model_no < 4 || 6 < model_no) { @@ -625,10 +631,10 @@ void daE_FZ_c::executeRollMove() { field_0x710 = (20 - field_0x715) * 2; case 1: if (field_0x710 == 0) { - cLib_chaseF(&mRadiusBase,1.0f,0.03f); + cLib_chaseF(&mRadiusBase, 1.0f, 0.03f); } - cLib_chaseAngleS(&field_0x704,1024,16); + cLib_chaseAngleS(&field_0x704, 1024, 16); pos = mpBlizzetaActor->current.pos; pos.x += (f32)(mode_rarius * cM_ssin(roll_angle + field_0x715 * 0xccc)); @@ -639,23 +645,24 @@ void daE_FZ_c::executeRollMove() { if (static_cast(mpBlizzetaActor)->getFrizadAttack() == 3) { mActionPhase = 2; speedF = 60.0f; - current.angle.y = cLib_targetAngleY(&static_cast(mpBlizzetaActor)->current.pos,¤t.pos); + current.angle.y = cLib_targetAngleY( + &static_cast(mpBlizzetaActor)->current.pos, ¤t.pos); } break; case 2: - cLib_chaseF(&mRadiusBase,1.0,0.1); - cLib_chaseAngleS(&field_0x704,512,16); + cLib_chaseF(&mRadiusBase, 1.0, 0.1); + cLib_chaseAngleS(&field_0x704, 512, 16); if (mObjAcch.ChkWallHit() || !mObjAcch.ChkGroundHit()) { - setActionMode(ACT_DAMAGE,0); - mCreature.startCreatureSound(Z2SE_EN_FZ_DEATH,0,-1); + setActionMode(ACT_DAMAGE, 0); + mCreature.startCreatureSound(Z2SE_EN_FZ_DEATH, 0, -1); return; } if (mAtSph.ChkAtHit()) { fopAc_ac_c* at_hit_actor = mAtSph.GetAtHitAc(); if ((fopAcM_GetName(at_hit_actor) == fpcNm_ALINK_e) || mAtSph.ChkAtShieldHit()) { - setActionMode(ACT_DAMAGE,0); + setActionMode(ACT_DAMAGE, 0); return; } } @@ -787,26 +794,26 @@ void daE_FZ_c::action() { } void daE_FZ_c::mtx_set() { - mDoMtx_stack_c::transS(current.pos.x,current.pos.y,current.pos.z); - mDoMtx_stack_c::ZXYrotM(shape_angle); - mDoMtx_stack_c::scaleM(l_HIO.field_0x0c,l_HIO.field_0x0c,l_HIO.field_0x0c); - mDoMtx_stack_c::scaleM(mRadiusBase,mRadiusBase,mRadiusBase); - mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle); + mDoMtx_stack_c::scaleM(l_HIO.field_0x0c, l_HIO.field_0x0c, l_HIO.field_0x0c); + mDoMtx_stack_c::scaleM(mRadiusBase, mRadiusBase, mRadiusBase); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); } void daE_FZ_c::cc_set() { cXyz pos; cXyz pos2; - pos.set(0.0f,60.0f,0.0f); - mDoMtx_stack_c::multVec(&pos,&eyePos); + pos.set(0.0f, 60.0f, 0.0f); + mDoMtx_stack_c::multVec(&pos, &eyePos); attention_info.position = eyePos; attention_info.position.y += 25.0f; mDoMtx_stack_c::copy(mpModel->getBaseTRMtx()); - pos.set(0.0f,40.0f,0.0f); - mDoMtx_stack_c::multVec(&pos,&pos2); + pos.set(0.0f, 40.0f, 0.0f); + mDoMtx_stack_c::multVec(&pos, &pos2); mTgCoSph.SetC(pos2); mTgCoSph.SetR(mRadiusBase * 60.0f); @@ -815,8 +822,8 @@ void daE_FZ_c::cc_set() { mDoMtx_stack_c::copy(mpModel->getBaseTRMtx()); - pos.set(0.0f,25.0f,0.0f); - mDoMtx_stack_c::multVec(&pos,&pos2); + pos.set(0.0f, 25.0f, 0.0f); + mDoMtx_stack_c::multVec(&pos, &pos2); mAtSph.SetC(pos2); mAtSph.SetR(mRadiusBase * 40.0f); @@ -826,16 +833,16 @@ void daE_FZ_c::cc_set() { s32 daE_FZ_c::execute() { if (field_0x714 == 2) { - if (checkItemGet(dItemNo_IRONBALL_e,1) == 0) { + if (checkItemGet(dItemNo_IRONBALL_e, 1) == 0) { return 1; } if (attention_info.distances[fopAc_attn_BATTLE_e] == 0) { attention_info.distances[fopAc_attn_BATTLE_e] = 69; - fopAcM_SetGroup(this,2); - #if DEBUG - fopAcM_OnStatus(this,0); - #endif + fopAcM_SetGroup(this, 2); +#if DEBUG + fopAcM_OnStatus(this, 0); +#endif attention_info.flags |= fopAc_AttnFlag_BATTLE_e; } } @@ -849,9 +856,9 @@ s32 daE_FZ_c::execute() { if (field_0x712 != 0) field_0x712 -= 1; - action(); // set current action - mtx_set(); // update model matrix - cc_set(); // update sphere colliders + action(); // set current action + mtx_set(); // update model matrix + cc_set(); // update sphere colliders mCreature.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); @@ -875,8 +882,8 @@ s32 daE_FZ_c::execute() { return 1; } -static void daE_FZ_Execute(daE_FZ_c* i_this) { - i_this->execute(); +static int daE_FZ_Execute(daE_FZ_c* i_this) { + return i_this->execute(); } void daE_FZ_c::demoDelete() { @@ -887,12 +894,12 @@ void daE_FZ_c::demoDelete() { fopAcM_delete(this); } -static BOOL daE_FZ_IsDelete(daE_FZ_c* i_this) { - return TRUE; +static int daE_FZ_IsDelete(daE_FZ_c* i_this) { + return 1; } s32 daE_FZ_c::_delete() { - dComIfG_resDelete(&mPhaseReq,"E_FZ"); + dComIfG_resDelete(&mPhaseReq, "E_FZ"); if (field_0xc21 != 0) { data_806C1BA0 = 0; @@ -905,8 +912,8 @@ s32 daE_FZ_c::_delete() { return 1; } -static void daE_FZ_Delete(daE_FZ_c* i_this) { - i_this->_delete(); +static int daE_FZ_Delete(daE_FZ_c* i_this) { + return i_this->_delete(); } s32 daE_FZ_c::CreateHeap() { @@ -921,122 +928,120 @@ s32 daE_FZ_c::CreateHeap() { } static int useHeapInit(fopAc_ac_c* i_this) { - return static_cast(i_this)->CreateHeap(); + return static_cast(i_this)->CreateHeap(); } s32 daE_FZ_c::create() { - fopAcM_ct(this,daE_FZ_c); + fopAcM_ct(this, daE_FZ_c); - s32 phase = dComIfG_resLoad(&mPhaseReq,"E_FZ"); - if (phase == cPhs_COMPLEATE_e) { - if (!fopAcM_entrySolidHeap(this,useHeapInit,6480)) { - return cPhs_ERROR_e; - } - if (data_806C1BA0 == 0) { - data_806C1BA0 = 1; - field_0xc21 = 1; - l_HIO.field_0x04 = -1; + s32 phase = dComIfG_resLoad(&mPhaseReq, "E_FZ"); + if (phase == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this, useHeapInit, 6480)) { + return cPhs_ERROR_e; + } + if (data_806C1BA0 == 0) { + data_806C1BA0 = 1; + field_0xc21 = 1; + l_HIO.field_0x04 = -1; + } + + attention_info.flags = fopAc_AttnFlag_BATTLE_e; + attention_info.distances[fopAc_attn_BATTLE_e] = 69; + + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_SetMin(this, -200.0f, -200.0f, -200.0f); + fopAcM_SetMax(this, 200.0f, 200.0f, 200.0f); + + mStts.Init(100, 0, this); + health = 80; + field_0x560 = 80; + + field_0x714 = fopAcM_GetParam(this); + field_0x715 = fopAcM_GetParam(this) >> 8; + + if (field_0x714 == 255) + field_0x714 = 0; + + if (field_0x714 == 1 || field_0x714 == 3) { + speed.y = cM_rndFX(10.0f) + 30.0f; + f32 rng = cM_rndFX(1.0f); + speedF = rng + 4.0f; + field_0x6fc = rng + 4.0f; + if (field_0x714 == 1) { + fopAcM_OnStatus(this, fopAcStts_UNK_0x4000_e); + } + } + + mObjAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, + fopAcM_GetSpeed_p(this), 0, 0); + + if (field_0x714 == 3) { + mAcchCir.SetWall(35.0f, 70.0f); + } else { + mAcchCir.SetWall(20.0f, 60.0f); + } + + mObjAcch.CrrPos(dComIfG_Bgsp()); + + mTgCoSph.Set(cc_fz_src); + mTgCoSph.SetStts(&mStts); + + mAtSph.Set(cc_fz_at_src); + mAtSph.SetStts(&mStts); + + mCreature.init(¤t.pos, &eyePos, 3, 1); + mCreature.setEnemyName("E_fz"); + + mAtInfo.mpSound = &mCreature; + mAtInfo.mPowerType = 1; + + gravity = -5.0f; + + shape_angle.z = 0; + shape_angle.x = 0; + + s16 random = cM_rndFX(10000.0f); + shape_angle.y = random; + current.angle.y = random; + + field_0x670.set(current.pos); + + for (int i = 0; i < 4; i++) { + field_0x67c[i].set(current.pos); + } + + if (field_0x714 == 2 && !checkItemGet(dItemNo_IRONBALL_e, 1)) { + attention_info.distances[fopAc_attn_BATTLE_e] = 0; + fopAcM_SetGroup(this, 0); + fopAcM_OffStatus(this, 0); + attention_info.flags &= ~fopAc_AttnFlag_BATTLE_e; + } + + if (field_0x714 == 3) { + mRadiusBase = 0.0f; + attention_info.flags &= ~fopAc_AttnFlag_BATTLE_e; + mAtSph.SetAtType(AT_TYPE_CSTATUE_SWING); + mAtSph.SetAtSpl(dCcG_At_Spl_UNK_1); + setActionMode(ACT_ROLLMOVE, 0); + } else { + mAtSph.SetAtMtrl(dCcD_MTRL_ICE); + mRadiusBase = 1.0f; + cM_rnd() < 0.5f ? setActionMode(ACT_WAIT, 0) : setActionMode(ACT_MOVE, 0); + } + + mtx_set(); } - attention_info.flags = fopAc_AttnFlag_BATTLE_e; - attention_info.distances[fopAc_attn_BATTLE_e] = 69; - - fopAcM_SetMtx(this,mpModel->getBaseTRMtx()); - fopAcM_SetMin(this,-200.0f,-200.0f,-200.0f); - fopAcM_SetMax(this,200.0f,200.0f,200.0f); - - mStts.Init(100,0,this); - health = 80; - field_0x560 = 80; - - field_0x714 = fopAcM_GetParam(this); - field_0x715 = fopAcM_GetParam(this) >> 8; - - if (field_0x714 == 255) - field_0x714 = 0; - - if (field_0x714 == 1 || field_0x714 == 3) { - speed.y = cM_rndFX(10.0f) + 30.0f; - f32 rng = cM_rndFX(1.0f); - speedF = rng + 4.0f; - field_0x6fc = rng + 4.0f; - if (field_0x714 == 1) { - fopAcM_OnStatus(this,fopAcStts_UNK_0x4000_e); - } - } - - mObjAcch.Set(fopAcM_GetPosition_p(this),fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, fopAcM_GetSpeed_p(this), 0, 0); - - if (field_0x714 == 3) { - mAcchCir.SetWall(35.0f,70.0f); - } - else { - mAcchCir.SetWall(20.0f,60.0f); - } - - mObjAcch.CrrPos(dComIfG_Bgsp()); - - mTgCoSph.Set(cc_fz_src); - mTgCoSph.SetStts(&mStts); - - mAtSph.Set(cc_fz_at_src); - mAtSph.SetStts(&mStts); - - mCreature.init(¤t.pos,&eyePos,3,1); - mCreature.setEnemyName("E_fz"); - - mAtInfo.mpSound = &mCreature; - mAtInfo.mPowerType = 1; - - gravity = -5.0f; - - shape_angle.z = 0; - shape_angle.x = 0; - - s16 random = cM_rndFX(10000.0f); - shape_angle.y = random; - current.angle.y = random; - - field_0x670.set(current.pos); - - for (int i = 0; i < 4; i++) { - field_0x67c[i].set(current.pos); - } - - if (field_0x714 == 2 && !checkItemGet(dItemNo_IRONBALL_e,1)) { - attention_info.distances[fopAc_attn_BATTLE_e] = 0; - fopAcM_SetGroup(this,0); - fopAcM_OffStatus(this,0); - attention_info.flags &= ~fopAc_AttnFlag_BATTLE_e; - } - - if (field_0x714 == 3) { - mRadiusBase = 0.0f; - attention_info.flags &= ~fopAc_AttnFlag_BATTLE_e; - mAtSph.SetAtType(AT_TYPE_CSTATUE_SWING); - mAtSph.SetAtSpl(dCcG_At_Spl_UNK_1); - setActionMode(ACT_ROLLMOVE,0); - } else { - mAtSph.SetAtMtrl(dCcD_MTRL_ICE); - mRadiusBase = 1.0f; - cM_rnd() < 0.5f ? setActionMode(ACT_WAIT,0) : setActionMode(ACT_MOVE,0); - } - - mtx_set(); - } - - return phase; + return phase; } -static void daE_FZ_Create(daE_FZ_c* i_this) { - i_this->create(); +static int daE_FZ_Create(daE_FZ_c* i_this) { + return i_this->create(); } static actor_method_class l_daE_FZ_Method = { - (process_method_func)daE_FZ_Create, - (process_method_func)daE_FZ_Delete, - (process_method_func)daE_FZ_Execute, - (process_method_func)daE_FZ_IsDelete, + (process_method_func)daE_FZ_Create, (process_method_func)daE_FZ_Delete, + (process_method_func)daE_FZ_Execute, (process_method_func)daE_FZ_IsDelete, (process_method_func)daE_FZ_Draw, }; diff --git a/src/d/actor/d_a_e_oc.cpp b/src/d/actor/d_a_e_oc.cpp index 01f282b0ea..6f0a55f12a 100644 --- a/src/d/actor/d_a_e_oc.cpp +++ b/src/d/actor/d_a_e_oc.cpp @@ -189,8 +189,8 @@ int daE_OC_c::draw() { return 1; } -static void daE_OC_Draw(daE_OC_c* i_this) { - i_this->draw(); +static int daE_OC_Draw(daE_OC_c* i_this) { + return i_this->draw(); } daE_OC_c* E_OC_n::m_battle_oc; @@ -2639,12 +2639,12 @@ int daE_OC_c::execute() { return 1; } -static void daE_OC_Execute(daE_OC_c* i_this) { - i_this->execute(); +static int daE_OC_Execute(daE_OC_c* i_this) { + return i_this->execute(); } -static BOOL daE_OC_IsDelete(daE_OC_c* param_0) { - return TRUE; +static int daE_OC_IsDelete(daE_OC_c* param_0) { + return 1; } int daE_OC_c::_delete() { @@ -2662,9 +2662,9 @@ int daE_OC_c::_delete() { return 1; } -static void daE_OC_Delete(daE_OC_c* i_this) { +static int daE_OC_Delete(daE_OC_c* i_this) { fopAcM_RegisterDeleteID(i_this, "E_OC"); - i_this->_delete(); + return i_this->_delete(); } int daE_OC_c::CreateHeap() { @@ -2833,8 +2833,8 @@ cPhs_Step daE_OC_c::create() { return phase; } -static void daE_OC_Create(daE_OC_c* i_this) { - i_this->create(); +static int daE_OC_Create(daE_OC_c* i_this) { + return i_this->create(); } static actor_method_class l_daE_OC_Method = { diff --git a/src/d/actor/d_a_e_ws.cpp b/src/d/actor/d_a_e_ws.cpp index 2be149e917..bb5835776f 100644 --- a/src/d/actor/d_a_e_ws.cpp +++ b/src/d/actor/d_a_e_ws.cpp @@ -10,6 +10,10 @@ #include #include "f_op/f_op_actor_enemy.h" +#define PLAYER_NOT_FOUND 0 +#define PLAYER_TARGET 1 +#define PLAYER_NEAR 2 + class daE_WS_HIO_c : public JORReflexible { public: daE_WS_HIO_c(); @@ -28,6 +32,7 @@ public: /* 0x24 */ u8 debug_ON; }; + namespace { static dCcD_SrcSph cc_ws_src = { { @@ -66,13 +71,27 @@ daE_WS_HIO_c::daE_WS_HIO_c() { attack_speed = 10.0f; } +#if DEBUG +void daE_WS_HIO_c::genMessage(JORMContext* ctx) { + ctx->genLabel("スタルウォーーーーーーーール", 0x80000001); + ctx->genSlider("基本サイズ", &base_size, 0.0f, 5.0f); + ctx->genSlider("サーチ角度", &search_angle, 0.0f, 30000.0f); + ctx->genSlider("攻撃速度", &attack_speed, 0.0f, 100.0f); + ctx->genSlider("移動範囲", &move_range, 0.0f, 1000.0f); + ctx->genSlider("サーチ範囲", &search_range, 0.0f, 1000.0f); + ctx->genSlider("サーチY上下範囲", &search_y_range, 0.0f, 1000.0f); + ctx->genSlider("地面までの距離", &dist_to_ground, 0.0f, 1000.0f); + ctx->genCheckBox("デバック表示", &debug_ON, 0x1); +} +#endif + int daE_WS_c::draw() { - J3DModel* model_p = mpModelMorf->getModel(); + J3DModel* model = mAnm_p->getModel(); g_env_light.settingTevStruct(0, ¤t.pos, &tevStr); - g_env_light.setLightTevColorType_MAJI(model_p, &tevStr); + g_env_light.setLightTevColorType_MAJI(model, &tevStr); if (mDownColor) { - J3DModelData* modelData_p = model_p->getModelData(); + J3DModelData* modelData_p = model->getModelData(); for (u16 i = 0; i < modelData_p->getMaterialNum(); i++) { J3DMaterial* material_p = modelData_p->getMaterialNodePointer(i); material_p->getTevColor(0)->r = mDownColor; @@ -81,48 +100,48 @@ int daE_WS_c::draw() { } } - mpModelMorf->entryDL(); + mAnm_p->entryDL(); cXyz sp8; sp8.set(current.pos.x, 100.0f + current.pos.y, current.pos.z); - mShadowId = dComIfGd_setShadow(mShadowId, 1, model_p, &sp8, 400.0f, 0.0f, current.pos.y, mAcch.GetGroundH(), mAcch.m_gnd, &tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + mShadowId = dComIfGd_setShadow(mShadowId, 1, model, &sp8, 400.0f, 0.0f, current.pos.y, mAcch.GetGroundH(), mAcch.m_gnd, &tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); return 1; } -static int daE_WS_Draw(daE_WS_c* a_this) { - return a_this->draw(); +static int daE_WS_Draw(daE_WS_c* i_this) { + return i_this->draw(); } void daE_WS_c::setBck(int i_anm, u8 i_mode, f32 i_morf, f32 i_speed) { - mpModelMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_WS", i_anm), i_mode, i_morf, i_speed, 0.0f, -1.0f); + mAnm_p->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_WS", i_anm), i_mode, i_morf, i_speed, 0.0f, -1.0f); } void daE_WS_c::setFootSound() { - if (mpModelMorf->getAnm() == dComIfG_getObjectRes("E_WS", 7)) { - if (mpModelMorf->checkFrame(0.0f) || - mpModelMorf->checkFrame(4.5f) || - mpModelMorf->checkFrame(7.5f) || - mpModelMorf->checkFrame(9.0f) || - mpModelMorf->checkFrame(13.5f) || - mpModelMorf->checkFrame(16.0f) || - mpModelMorf->checkFrame(19.0f) || - mpModelMorf->checkFrame(23.5f) || - mpModelMorf->checkFrame(25.0f) || - mpModelMorf->checkFrame(28.0f) || - mpModelMorf->checkFrame(32.5f) || - mpModelMorf->checkFrame(36.0f) || - mpModelMorf->checkFrame(39.5f)) + if (mAnm_p->getAnm() == dComIfG_getObjectRes("E_WS", 7)) { + if (mAnm_p->checkFrame(0.0f) || + mAnm_p->checkFrame(4.5f) || + mAnm_p->checkFrame(7.5f) || + mAnm_p->checkFrame(9.0f) || + mAnm_p->checkFrame(13.5f) || + mAnm_p->checkFrame(16.0f) || + mAnm_p->checkFrame(19.0f) || + mAnm_p->checkFrame(23.5f) || + mAnm_p->checkFrame(25.0f) || + mAnm_p->checkFrame(28.0f) || + mAnm_p->checkFrame(32.5f) || + mAnm_p->checkFrame(36.0f) || + mAnm_p->checkFrame(39.5f)) { mSound.startCreatureSound(Z2SE_EN_WS_FOOTNOTE, 0, -1); } - } else if (mpModelMorf->getAnm() == dComIfG_getObjectRes("E_WS", 8)) { - if (mpModelMorf->checkFrame(0.5f) || - mpModelMorf->checkFrame(6.0f) || - mpModelMorf->checkFrame(11.0f) || - mpModelMorf->checkFrame(16.0f) || - mpModelMorf->checkFrame(21.0f) || - mpModelMorf->checkFrame(26.5f) || - mpModelMorf->checkFrame(31.0f)) + } else if (mAnm_p->getAnm() == dComIfG_getObjectRes("E_WS", 8)) { + if (mAnm_p->checkFrame(0.5f) || + mAnm_p->checkFrame(6.0f) || + mAnm_p->checkFrame(11.0f) || + mAnm_p->checkFrame(16.0f) || + mAnm_p->checkFrame(21.0f) || + mAnm_p->checkFrame(26.5f) || + mAnm_p->checkFrame(31.0f)) { mSound.startCreatureSound(Z2SE_EN_WS_FOOTNOTE, 0, -1); } @@ -141,13 +160,13 @@ f32 daE_WS_c::calcTargetDist(cXyz i_basePos, cXyz i_targetPos) { } s16 daE_WS_c::calcTargetAngle(cXyz i_basePos, cXyz i_targetPos) { - cXyz sp1C; - cXyz sp10 = i_targetPos - i_basePos; + cXyz mae; + cXyz ato = i_targetPos - i_basePos; - mDoMtx_stack_c::XrotS(-field_0x668.x); - mDoMtx_stack_c::YrotM(-field_0x668.y); - mDoMtx_stack_c::multVec(&sp10, &sp1C); - return cM_atan2s(sp1C.x, sp1C.z); + mDoMtx_stack_c::XrotS(-mTargetWallAngle.x); + mDoMtx_stack_c::YrotM(-mTargetWallAngle.y); + mDoMtx_stack_c::multVec(&ato, &mae); + return cM_atan2s(mae.x, mae.z); } static u8 hio_set; @@ -171,13 +190,13 @@ int daE_WS_c::checkPlayerPos() { dComIfGp_checkPlayerStatus1(0, 0x2000000) || dComIfGp_checkPlayerStatus1(0, 0x10000) || calcTargetDist(current.pos, player_pos) < 150.0f) && - checkInSearchRange(player_pos, field_0x65c) && checkInSearchRange(current.pos, field_0x65c)) + checkInSearchRange(player_pos, mHomePos) && checkInSearchRange(current.pos, mHomePos)) { dBgS_GndChk gndchk; cXyz gndpos; mDoMtx_stack_c::transS(current.pos); - mDoMtx_stack_c::ZXYrotM(field_0x66e); + mDoMtx_stack_c::ZXYrotM(mWallAngle); mDoMtx_stack_c::ZXYrotM(shape_angle); mDoMtx_stack_c::transM(0.0f, 100.0f, 0.0f); mDoMtx_stack_c::multVecZero(&gndpos); @@ -187,17 +206,17 @@ int daE_WS_c::checkPlayerPos() { if (current.pos.y - gndpos.y > l_HIO.dist_to_ground) { // Return 1 if walltula is looking towards player if (cLib_distanceAngleS(shape_angle.y, calcTargetAngle(current.pos, player_pos)) < l_HIO.search_angle) { - return 1; + return PLAYER_TARGET; } // otherwise return 2 if player is near the walltula if (calcTargetDist(current.pos, player_pos) < 150.0f) { - return 2; + return PLAYER_NEAR; } } } - return 0; + return PLAYER_NOT_FOUND; } bool daE_WS_c::checkAttackEnd() { @@ -205,17 +224,17 @@ bool daE_WS_c::checkAttackEnd() { mDoMtx_stack_c::copy(daPy_getLinkPlayerActorClass()->getModelJointMtx(0)); mDoMtx_stack_c::multVecZero(&player_pos); - BOOL r30 = false; + BOOL checkPlayerNear = FALSE; if ( daPy_getPlayerActorClass()->checkClimbMove() || dComIfGp_checkPlayerStatus1(0, 0x02000000) || dComIfGp_checkPlayerStatus1(0, 0x10000) || calcTargetDist(current.pos, player_pos) < 200.0f ) { - r30 = true; + checkPlayerNear = TRUE; } - if (!r30 || - !checkInSearchRange(current.pos, field_0x65c) || + if (!checkPlayerNear || + !checkInSearchRange(current.pos, mHomePos) || checkBeforeBg(shape_angle.y) ) { @@ -228,41 +247,41 @@ bool daE_WS_c::checkAttackEnd() { } void daE_WS_c::executeWait() { - int temp_r3 = checkPlayerPos(); - if (temp_r3 == 1) { + int playerCheck = checkPlayerPos(); + if (playerCheck == PLAYER_TARGET) { setActionMode(ACTION_ATTACK_e); return; } - if (temp_r3 == 2 && mMode != 3 && mMode != 4) { + if (playerCheck == PLAYER_NEAR && mMode != 3 && mMode != 4) { mMode = 2; } switch (mMode) { case 0: - mMoveWaitTimer = 50.0f + cM_rndF(50.0f); + mWaitTimer = 50.0f + cM_rndF(50.0f); setBck(9, 2, 3.0f, 1.0f); mMode = 1; /* fallthrough */ case 1: - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { mMode = 2; } break; case 2: speedF = 0.0f; - field_0x690 = 0; - mTargetAngle = shape_angle.y + cM_rndFX(32768.0f); + mIsReturnHome = 0; + mTargetAngle = shape_angle.y + cM_rndFX(32768.0f); // random turn up to ±180° - if (temp_r3 == 2) { - mTargetStep = 0x200; + if (playerCheck == PLAYER_NEAR) { + mStepAngle = 0x200; setBck(8, 2, 3.0f, 2.4f); } else { - if (calcTargetDist(current.pos, field_0x65c) >= l_HIO.move_range) { - mTargetAngle = calcTargetAngle(current.pos, field_0x65c); - field_0x690 = 1; + if (calcTargetDist(current.pos, mHomePos) >= l_HIO.move_range) { + mTargetAngle = calcTargetAngle(current.pos, mHomePos); + mIsReturnHome = 1; } - mTargetStep = 0x100; + mStepAngle = 0x100; setBck(8, 2, 3.0f, 1.2f); } @@ -271,37 +290,37 @@ void daE_WS_c::executeWait() { case 3: setFootSound(); - if (cLib_chaseAngleS(&shape_angle.y, mTargetAngle, mTargetStep)) { + if (cLib_chaseAngleS(&shape_angle.y, mTargetAngle, mStepAngle)) { mMode = 4; - mMoveWaitTimer = 10; + mWaitTimer = 10; setBck(9, 2, 3.0f, 1.0f); } break; case 4: - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { mMode = 5; } break; case 5: mMode = 6; speedF = 3.0f; - mMoveWaitTimer = 20.0f + cM_rndF(10.0f); + mWaitTimer = 20.0f + cM_rndF(10.0f); setBck(7, 2, 3.0f, 1.0f); /* fallthrough */ case 6: setFootSound(); - if (field_0x690 == 0) { - if (calcTargetDist(current.pos, field_0x65c) >= l_HIO.move_range) { - mMoveWaitTimer = 0; + if (mIsReturnHome == 0) { + if (calcTargetDist(current.pos, mHomePos) >= l_HIO.move_range) { + mWaitTimer = 0; } } if (checkBeforeBg(shape_angle.y)) { - mMoveWaitTimer = 0; + mWaitTimer = 0; } - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { speedF = 0.0f; mMode = 0; } @@ -333,11 +352,11 @@ void daE_WS_c::executeAttack() { mMode = 2; setBck(10, 2, 3.0f, 1.0f); mSound.startCreatureVoice(Z2SE_EN_WS_V_YOKOKU, -1); - mMoveWaitTimer = 10; + mWaitTimer = 10; } break; case 2: - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { speedF = l_HIO.attack_speed * mBodyScale; setBck(7, 2, 3.0f, 3.0f); mMode = 3; @@ -352,20 +371,20 @@ void daE_WS_c::executeAttack() { setFootSound(); cLib_chaseAngleS(&shape_angle.y, calcTargetAngle(current.pos, player_pos), 0x400); - BOOL r28 = false; + BOOL checkAttackStart = FALSE; if (checkBeforeBg(shape_angle.y)) { - r28 = true; + checkAttackStart = TRUE; } if (mCcSph.ChkAtHit()) { - cCcD_Obj* r27 = mCcSph.GetAtHitObj(); - if (fopAcM_GetName(dCc_GetAc(r27->GetAc())) == fpcNm_ALINK_e) { - r28 = true; + cCcD_Obj* hitObj = mCcSph.GetAtHitObj(); + if (fopAcM_GetName(dCc_GetAc(hitObj->GetAc())) == fpcNm_ALINK_e) { + checkAttackStart = TRUE; } } - if (!checkInSearchRange(current.pos, field_0x65c)) { - r28 = true; + if (!checkInSearchRange(current.pos, mHomePos)) { + checkAttackStart = TRUE; } - if (r28) { + if (checkAttackStart) { mMode = 4; speedF = 0.0f; setBck(4, 0, 3.0f, 1.0f); @@ -378,11 +397,11 @@ void daE_WS_c::executeAttack() { break; } case 4: - if (mpModelMorf->checkFrame(7.5f)) { + if (mAnm_p->checkFrame(7.5f)) { mSound.startCreatureVoice(Z2SE_EN_WS_V_ATTACK, -1); } - if (mpModelMorf->isStop()) { + if (mAnm_p->isStop()) { setActionMode(ACTION_WAIT_e); } /* fallthrough */ @@ -408,9 +427,9 @@ void daE_WS_c::executeDown() { mSound.startCreatureVoice(Z2SE_EN_WS_V_DAMAGE, -1); /* fallthrough */ case 1: - if (mpModelMorf->isStop()) { - mAcchCir.SetWall(0.0f, 4.0f); - current.angle.y = field_0x668.y; + if (mAnm_p->isStop()) { + mBgc.SetWall(0.0f, 4.0f); + current.angle.y = mTargetWallAngle.y; setBck(6, 0, 3.0f, 0.0f); mSound.startCreatureVoice(Z2SE_EN_WS_V_DEATH, -1); speedF = 5.0f; @@ -433,7 +452,7 @@ void daE_WS_c::executeDown() { speedF = 3.0f + cM_rndF(2.0f); speed.y = 12.0f; mMode = 3; - mMoveWaitTimer = 30; + mWaitTimer = 30; setBck(6, 0, 5.0f, 1.0f); mSound.startCreatureSound(Z2SE_CM_BODYFALL_S, 0, -1); } @@ -467,8 +486,8 @@ void daE_WS_c::executeDown() { case 4: cLib_addCalc2(&mDownColor, -20.0f, 1.0f, 0.4f); - if (mpModelMorf->isStop()) { - mMoveWaitTimer = 15; + if (mAnm_p->isStop()) { + mWaitTimer = 15; mMode = 5; return; } @@ -476,12 +495,12 @@ void daE_WS_c::executeDown() { case 5: cLib_addCalc2(&mDownColor, -20.0f, 1.0f, 0.4f); - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { fopAcM_delete(this); fopAcM_createDisappear(this, ¤t.pos, 7, 0, 7); - if (mSwbit != 0xFF && !dComIfGs_isSwitch(mSwbit, fopAcM_GetRoomNo(this))) { - dComIfGs_onSwitch(mSwbit, fopAcM_GetRoomNo(this)); + if (bitSw != 0xFF && !dComIfGs_isSwitch(bitSw, fopAcM_GetRoomNo(this))) { + dComIfGs_onSwitch(bitSw, fopAcM_GetRoomNo(this)); } } break; @@ -497,36 +516,36 @@ void daE_WS_c::executeWindDown() { mCcSph.OffTgSetBit(); mCcBokkuriSph.OffTgSetBit(); - mAcchCir.SetWall(0.0f, 4.0f); + mBgc.SetWall(0.0f, 4.0f); mMode = 1; setBck(7, 2, 3.0f, 1.0f); mSound.startCreatureVoice(Z2SE_EN_WS_V_DAMAGE, -1); - mMoveWaitTimer = 5; + mWaitTimer = 5; mAcch.SetGroundUpY(20.0f); attention_info.flags = 0; speed.y = 0.0f; speedF = 5.0f; - current.angle.y = field_0x668.y; - mTargetStep = -0x800; + current.angle.y = mTargetWallAngle.y; + mStepAngle = -0x800; break; case 1: - shape_angle.y += mTargetStep; - cLib_chaseAngleS(&field_0x66e.y, 0, 0x400); - cLib_chaseAngleS(&field_0x66e.x, 0, 0x400); + shape_angle.y += mStepAngle; + cLib_chaseAngleS(&mWallAngle.y, 0, 0x400); + cLib_chaseAngleS(&mWallAngle.x, 0, 0x400); shape_angle.x += 0x800; shape_angle.z += 0x800; speed.y = 30.0f; - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { mMode = 2; gravity = -3.0f; } break; case 2: - shape_angle.y += mTargetStep; - cLib_chaseAngleS(&field_0x66e.y, 0, 0x400); - cLib_chaseAngleS(&field_0x66e.x, 0, 0x400); + shape_angle.y += mStepAngle; + cLib_chaseAngleS(&mWallAngle.y, 0, 0x400); + cLib_chaseAngleS(&mWallAngle.x, 0, 0x400); cLib_chaseAngleS(&shape_angle.x, -0x8000, 0x400); cLib_chaseAngleS(&shape_angle.z, 0, 0x400); @@ -534,15 +553,15 @@ void daE_WS_c::executeWindDown() { speedF = 3.0f + cM_rndF(2.0f); speed.y = 12.0f; mMode = 3; - mMoveWaitTimer = 30; + mWaitTimer = 30; setBck(6, 0, 5.0f, 1.0f); mSound.startCreatureVoice(Z2SE_EN_WS_V_DEATH, -1); mSound.startCreatureSound(Z2SE_CM_BODYFALL_S, 0, -1); } break; case 3: - shape_angle.y += mTargetStep; - cLib_chaseAngleS(&mTargetStep, 0, 0x80); + shape_angle.y += mStepAngle; + cLib_chaseAngleS(&mStepAngle, 0, 0x80); cLib_chaseAngleS(&shape_angle.x, -0x8000, 0x400); cLib_chaseAngleS(&shape_angle.z, 0, 0x400); @@ -556,23 +575,23 @@ void daE_WS_c::executeWindDown() { break; case 4: cLib_addCalc2(&mDownColor, -20.0f, 1.0f, 0.4f); - shape_angle.y += mTargetStep; - cLib_chaseAngleS(&mTargetStep, 0, 0x80); - shape_angle.y += mTargetStep; + shape_angle.y += mStepAngle; + cLib_chaseAngleS(&mStepAngle, 0, 0x80); + shape_angle.y += mStepAngle; - if (mpModelMorf->isStop()) { - mMoveWaitTimer = 15; + if (mAnm_p->isStop()) { + mWaitTimer = 15; mMode = 5; } break; case 5: cLib_addCalc2(&mDownColor, -20.0f, 1.0f, 0.4f); - if (mMoveWaitTimer == 0) { + if (mWaitTimer == 0) { fopAcM_delete(this); fopAcM_createDisappear(this, ¤t.pos, 7, 0, 7); - if (mSwbit != 0xFF && !dComIfGs_isSwitch(mSwbit, fopAcM_GetRoomNo(this))) { - dComIfGs_onSwitch(mSwbit, fopAcM_GetRoomNo(this)); + if (bitSw != 0xFF && !dComIfGs_isSwitch(bitSw, fopAcM_GetRoomNo(this))) { + dComIfGs_onSwitch(bitSw, fopAcM_GetRoomNo(this)); } } break; @@ -653,47 +672,47 @@ void daE_WS_c::action() { mSound.setLinkSearch(field_0x566); if (mAction != ACTION_DOWN_e && mAction != ACTION_WIND_DOWN_e) { - cXyz sp14; - mDoMtx_stack_c::YrotS(field_0x668.y); - mDoMtx_stack_c::XrotM(field_0x668.x); + cXyz ato; + mDoMtx_stack_c::YrotS(mTargetWallAngle.y); + mDoMtx_stack_c::XrotM(mTargetWallAngle.x); mDoMtx_stack_c::YrotM(current.angle.y); - cXyz sp8(0.0f, 0.0f, speedF); - mDoMtx_stack_c::multVec(&sp8, &sp14); - speed = sp14; + cXyz mae(0.0f, 0.0f, speedF); + mDoMtx_stack_c::multVec(&mae, &ato); + speed = ato; current.pos += speed; } else { fopAcM_posMoveF(this, NULL); } mAcch.CrrPos(dComIfG_Bgsp()); - mpModelMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); + mAnm_p->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); } void daE_WS_c::mtx_set() { mDoMtx_stack_c::transS(current.pos); - mDoMtx_stack_c::ZXYrotM(field_0x66e); + mDoMtx_stack_c::ZXYrotM(mWallAngle); mDoMtx_stack_c::ZXYrotM(shape_angle); mDoMtx_stack_c::scaleM(mBodyScale, mBodyScale, mBodyScale); - J3DModel* model_p = mpModelMorf->getModel(); + J3DModel* model_p = mAnm_p->getModel(); model_p->setBaseTRMtx(mDoMtx_stack_c::get()); - mpModelMorf->modelCalc(); + mAnm_p->modelCalc(); } void daE_WS_c::cc_set() { cXyz mae; cXyz ato; - J3DModel* model_p = mpModelMorf->getModel(); + J3DModel* model = mAnm_p->getModel(); - mDoMtx_stack_c::YrotS(field_0x668.y); - mDoMtx_stack_c::XrotM(field_0x668.x); + mDoMtx_stack_c::YrotS(mTargetWallAngle.y); + mDoMtx_stack_c::XrotM(mTargetWallAngle.x); mae.set(0.0f, 15.0f + nREG_F(10), 0.0f); mDoMtx_stack_c::multVec(&mae, &ato); attention_info.position = current.pos + ato; attention_info.position.y += 90.0f * mBodyScale; - MTXCopy(model_p->getAnmMtx(1), mDoMtx_stack_c::get()); + MTXCopy(model->getAnmMtx(1), mDoMtx_stack_c::get()); mae.set(-15.0f + nREG_F(5), -10.0f + nREG_F(6), nREG_F(7)); mDoMtx_stack_c::multVec(&mae, &eyePos); @@ -707,8 +726,8 @@ void daE_WS_c::cc_set() { } int daE_WS_c::execute() { - if (mMoveWaitTimer != 0) { - mMoveWaitTimer--; + if (mWaitTimer != 0) { + mWaitTimer--; } if (mInvulnerabilityTimer != 0) { @@ -725,8 +744,8 @@ int daE_WS_c::execute() { return 1; } -static int daE_WS_Execute(daE_WS_c* a_this) { - return a_this->execute(); +static int daE_WS_Execute(daE_WS_c* i_this) { + return i_this->execute(); } void daE_WS_c::checkInitialWall() { @@ -739,7 +758,7 @@ void daE_WS_c::checkInitialWall() { linchk.Set(¤t.pos, &endpos, NULL); if (dComIfG_Bgsp().LineCross(&linchk)) { - if (field_0x691 == 0 && dComIfG_Bgsp().GetWallCode(linchk) != 1 && dComIfG_Bgsp().GetWallCode(linchk) != 4) { + if (arg0 == 0 && dComIfG_Bgsp().GetWallCode(linchk) != 1 && dComIfG_Bgsp().GetWallCode(linchk) != 4) { return; } @@ -749,9 +768,9 @@ void daE_WS_c::checkInitialWall() { dComIfG_Bgsp().GetTriPla(linchk, &tri); cXyz* tri_np = tri.GetNP(); - field_0x668.y = cM_atan2s(tri_np->x, tri_np->z); - field_0x668.x = cM_atan2s(tri_np->absXZ(), tri_np->y); - field_0x66e = field_0x668; + mTargetWallAngle.y = cM_atan2s(tri_np->x, tri_np->z); + mTargetWallAngle.x = cM_atan2s(tri_np->absXZ(), tri_np->y); + mWallAngle = mTargetWallAngle; return; } } @@ -759,8 +778,8 @@ void daE_WS_c::checkInitialWall() { bool daE_WS_c::checkBeforeBg(s16 i_angle) { dBgS_LinChk linchk; - cXyz sp68; - cXyz sp5C; + cXyz mae; + cXyz ato; cXyz endpos; cXyz startpos; @@ -768,56 +787,56 @@ bool daE_WS_c::checkBeforeBg(s16 i_angle) { return false; } - mDoMtx_stack_c::YrotS(field_0x668.y); - mDoMtx_stack_c::XrotM(field_0x668.x); + mDoMtx_stack_c::YrotS(mTargetWallAngle.y); + mDoMtx_stack_c::XrotM(mTargetWallAngle.x); mDoMtx_stack_c::YrotM(i_angle); - sp68.set(0.0f, 50.0f * mBodyScale, 0.0f); - mDoMtx_stack_c::multVec(&sp68, &startpos); + mae.set(0.0f, 50.0f * mBodyScale, 0.0f); + mDoMtx_stack_c::multVec(&mae, &startpos); startpos += current.pos; - mDoMtx_stack_c::YrotS(field_0x668.y); - mDoMtx_stack_c::XrotM(field_0x668.x); + mDoMtx_stack_c::YrotS(mTargetWallAngle.y); + mDoMtx_stack_c::XrotM(mTargetWallAngle.x); mDoMtx_stack_c::YrotM(i_angle); - sp68.set(0.0f, 0.0f, 50.0f * mBodyScale); - mDoMtx_stack_c::multVec(&sp68, &sp5C); + mae.set(0.0f, 0.0f, 50.0f * mBodyScale); + mDoMtx_stack_c::multVec(&mae, &ato); - sp68.set(sp5C.x, 0.0f, sp5C.z); - endpos = startpos + sp68; + mae.set(ato.x, 0.0f, ato.z); + endpos = startpos + mae; linchk.Set(&startpos, &endpos, NULL); if (dComIfG_Bgsp().LineCross(&linchk)) { return 1; } - if (sp5C.y > 0.0f) { - sp68.set(0.0f, 50.0f * mBodyScale, 0.0f); + if (ato.y > 0.0f) { + mae.set(0.0f, 50.0f * mBodyScale, 0.0f); } else { - sp68.set(0.0f, -l_HIO.dist_to_ground, 0.0f); + mae.set(0.0f, -l_HIO.dist_to_ground, 0.0f); } - endpos = startpos + sp68; + endpos = startpos + mae; linchk.Set(&startpos, &endpos, NULL); if (dComIfG_Bgsp().LineCross(&linchk)) { return true; } - mDoMtx_stack_c::YrotS(field_0x668.y); - mDoMtx_stack_c::XrotM(field_0x668.x); + mDoMtx_stack_c::YrotS(mTargetWallAngle.y); + mDoMtx_stack_c::XrotM(mTargetWallAngle.x); mDoMtx_stack_c::YrotM(i_angle); - sp68.set(0.0f, 50.0f * mBodyScale, 100.0f * mBodyScale); - mDoMtx_stack_c::multVec(&sp68, &sp5C); - startpos = current.pos + sp5C; + mae.set(0.0f, 50.0f * mBodyScale, 100.0f * mBodyScale); + mDoMtx_stack_c::multVec(&mae, &ato); + startpos = current.pos + ato; cXyz sp38(0.0f, -40.0f * mBodyScale, 100.0f * mBodyScale); - mDoMtx_stack_c::multVec(&sp38, &sp5C); - endpos = current.pos + sp5C; + mDoMtx_stack_c::multVec(&sp38, &ato); + endpos = current.pos + ato; linchk.Set(&startpos, &endpos, NULL); if (!dComIfG_Bgsp().LineCross(&linchk)) { return true; } - if (field_0x691 == 0 && dComIfG_Bgsp().GetWallCode(linchk) != 1 && dComIfG_Bgsp().GetWallCode(linchk) != 4) { + if (arg0 == 0 && dComIfG_Bgsp().GetWallCode(linchk) != 1 && dComIfG_Bgsp().GetWallCode(linchk) != 4) { return true; } @@ -825,7 +844,7 @@ bool daE_WS_c::checkBeforeBg(s16 i_angle) { dComIfG_Bgsp().GetTriPla(linchk, &tri); cXyz* tri_np = tri.GetNP(); - cLib_chaseAngleS(&field_0x66e.y, cM_atan2s(tri_np->x, tri_np->z), 0x100); + cLib_chaseAngleS(&mWallAngle.y, cM_atan2s(tri_np->x, tri_np->z), 0x100); checkWall(); return false; } @@ -834,7 +853,7 @@ bool daE_WS_c::checkWall() { cXyz startpos; cXyz endpos; mDoMtx_stack_c::transS(current.pos); - mDoMtx_stack_c::ZXYrotM(field_0x66e); + mDoMtx_stack_c::ZXYrotM(mWallAngle); mDoMtx_stack_c::ZXYrotM(shape_angle); mDoMtx_stack_c::transM(0.0f, 100.0f, 0.0f); @@ -846,7 +865,7 @@ bool daE_WS_c::checkWall() { dBgS_LinChk linchk; linchk.Set(&startpos, &endpos, NULL); if (dComIfG_Bgsp().LineCross(&linchk)) { - if (field_0x691 == 0 && dComIfG_Bgsp().GetWallCode(linchk) != 1 && dComIfG_Bgsp().GetWallCode(linchk) != 4) { + if (arg0 == 0 && dComIfG_Bgsp().GetWallCode(linchk) != 1 && dComIfG_Bgsp().GetWallCode(linchk) != 4) { return false; } @@ -856,8 +875,8 @@ bool daE_WS_c::checkWall() { dComIfG_Bgsp().GetTriPla(linchk, &tri); cXyz* tri_np = tri.GetNP(); - field_0x668.y = cM_atan2s(tri_np->x, tri_np->z); - field_0x668.x = cM_atan2s(tri_np->absXZ(), tri_np->y); + mTargetWallAngle.y = cM_atan2s(tri_np->x, tri_np->z); + mTargetWallAngle.x = cM_atan2s(tri_np->absXZ(), tri_np->y); return true; } @@ -871,8 +890,8 @@ static int daE_WS_IsDelete(daE_WS_c* a_this) { int daE_WS_c::_delete() { dComIfG_resDelete(&mPhase, "E_WS"); - if (mHIOInit) { - hio_set = false; + if (mHioSet) { + hio_set = FALSE; mDoHIO_DELETE_CHILD(l_HIO.id); } @@ -883,24 +902,25 @@ int daE_WS_c::_delete() { return 1; } -static int daE_WS_Delete(daE_WS_c* a_this) { - return a_this->_delete(); +static int daE_WS_Delete(daE_WS_c* i_this) { + fopAcM_RegisterDeleteID(i_this, "E_WS"); + return i_this->_delete(); } int daE_WS_c::CreateHeap() { J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("E_WS", 0xD); JUT_ASSERT(1401, modelData != NULL); - mpModelMorf = JKR_NEW mDoExt_McaMorfSO(modelData, NULL, NULL, (J3DAnmTransform*)dComIfG_getObjectRes("E_WS", 7), 0, 1.0f, 0, -1, &mSound, 0x80000, 0x11000084); - if (mpModelMorf == NULL || mpModelMorf->getModel() == NULL) { + mAnm_p = JKR_NEW mDoExt_McaMorfSO(modelData, NULL, NULL, (J3DAnmTransform*)dComIfG_getObjectRes("E_WS", 7), 0, 1.0f, 0, -1, &mSound, 0x80000, 0x11000084); + if (mAnm_p == NULL || mAnm_p->getModel() == NULL) { return 0; } return 1; } -static int useHeapInit(fopAc_ac_c* i_this) { - return ((daE_WS_c*)i_this)->CreateHeap(); +static int useHeapInit(fopAc_ac_c* actor) { + return ((daE_WS_c*)actor)->CreateHeap(); } int daE_WS_c::create() { @@ -910,8 +930,8 @@ int daE_WS_c::create() { if (phase_state == cPhs_COMPLEATE_e) { OS_REPORT("E_WS PARAM %x\n", fopAcM_GetParam(this)); - mSwbit = (fopAcM_GetParam(this) & 0xFF00) >> 8; - if (mSwbit != 0xFF && dComIfGs_isSwitch(mSwbit, fopAcM_GetRoomNo(this))) { + bitSw = (fopAcM_GetParam(this) & 0xFF00) >> 8; + if (bitSw != 0xFF && dComIfGs_isSwitch(bitSw, fopAcM_GetRoomNo(this))) { OS_REPORT("E_WS やられ後なので再セットしません\n"); return cPhs_ERROR_e; } @@ -922,13 +942,13 @@ int daE_WS_c::create() { if (!hio_set) { hio_set = true; - mHIOInit = true; + mHioSet = true; l_HIO.id = mDoHIO_CREATE_CHILD("スタルウォール", &l_HIO); } - field_0x691 = fopAcM_GetParam(this); - if (field_0x691 == 0xFF) { - field_0x691 = 0; + arg0 = fopAcM_GetParam(this); + if (arg0 == 0xFF) { + arg0 = 0; } if (((fopAcM_GetParam(this) & 0xFF0000) >> 0x10) == 1) { @@ -938,12 +958,12 @@ int daE_WS_c::create() { } attention_info.flags = fopAc_AttnFlag_BATTLE_e; - fopAcM_SetMtx(this, mpModelMorf->getModel()->getBaseTRMtx()); + fopAcM_SetMtx(this, mAnm_p->getModel()->getBaseTRMtx()); fopAcM_SetMin(this, -200.0f, -200.0f, -200.0f); fopAcM_SetMax(this, 200.0f, 200.0f, 200.0f); - mAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, fopAcM_GetSpeed_p(this), NULL, NULL); - mAcchCir.SetWall(0.0f, 0.0f); + mAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mBgc, fopAcM_GetSpeed_p(this), NULL, NULL); + mBgc.SetWall(0.0f, 0.0f); health = 10; field_0x560 = 10; @@ -963,7 +983,7 @@ int daE_WS_c::create() { setActionMode(ACTION_WAIT_e); checkInitialWall(); - field_0x65c = current.pos; + mHomePos = current.pos; speed.y = 0.0f; gravity = 0.0f; mtx_set(); @@ -972,8 +992,8 @@ int daE_WS_c::create() { return phase_state; } -static int daE_WS_Create(daE_WS_c* a_this) { - return a_this->create(); +static int daE_WS_Create(daE_WS_c* i_this) { + return i_this->create(); } static actor_method_class l_daE_WS_Method = { diff --git a/src/d/actor/d_a_e_zs.cpp b/src/d/actor/d_a_e_zs.cpp index 46a1050855..cd57ffdd51 100644 --- a/src/d/actor/d_a_e_zs.cpp +++ b/src/d/actor/d_a_e_zs.cpp @@ -495,8 +495,8 @@ int daE_ZS_c::CreateHeap() { return 1; } -static void useHeapInit(fopAc_ac_c* i_this) { - static_cast(i_this)->CreateHeap(); +static int useHeapInit(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); } int daE_ZS_c::create() { @@ -504,7 +504,7 @@ int daE_ZS_c::create() { int phase = dComIfG_resLoad(&mPhase, "E_ZS"); if (phase == cPhs_COMPLEATE_e) { OS_REPORT("E_ZS PARAM %x\n", fopAcM_GetParam(this)); - if (!fopAcM_entrySolidHeap(this, (heapCallbackFunc)useHeapInit, 0xFC0)) { + if (!fopAcM_entrySolidHeap(this, useHeapInit, 0xFC0)) { return cPhs_ERROR_e; } diff --git a/src/d/actor/d_a_grass.cpp b/src/d/actor/d_a_grass.cpp index 1668386edf..f04d5cfcd2 100644 --- a/src/d/actor/d_a_grass.cpp +++ b/src/d/actor/d_a_grass.cpp @@ -80,12 +80,7 @@ void daGrass_c::deleteGrass() { } } -dGrass_packet_c::~dGrass_packet_c() { -#if TARGET_PC - GXDestroyTexObj(&mTexObj_l_M_kusa05_RGBATEX); - GXDestroyTexObj(&mTexObj_l_M_Hijiki00TEX); -#endif -} +dGrass_packet_c::~dGrass_packet_c() {} void daGrass_c::executeGrass() { if (m_grass != NULL) { diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index c1c5e4b297..a3b48f1098 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -268,9 +268,9 @@ void daMant_packet_c::draw() { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_CLR_RGB, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0); - GXSETARRAY(GX_VA_POS, this->getPos(), sizeof(mPos[0]), 12); - GXSETARRAY(GX_VA_NRM, this->getNrm(), sizeof(mNrm[0]), 12); - GXSETARRAY(GX_VA_TEX0, &l_texCoord, sizeof(l_texCoord), 8); + GXSETARRAY(GX_VA_POS, this->getPos(), sizeof(mPos[0]), 12, true); + GXSETARRAY(GX_VA_NRM, this->getNrm(), sizeof(mNrm[0]), 12, true); + GXSETARRAY(GX_VA_TEX0, &l_texCoord, sizeof(l_texCoord), 8, false); // TODO: set to true when converted to float literals GXSetZCompLoc(0); GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); diff --git a/src/d/actor/d_a_midna.cpp b/src/d/actor/d_a_midna.cpp index cbbf1915e2..88a5bb38bb 100644 --- a/src/d/actor/d_a_midna.cpp +++ b/src/d/actor/d_a_midna.cpp @@ -1834,12 +1834,12 @@ void daMidna_c::setBckAnime(J3DAnmTransform* i_bck, int i_attr, f32 i_morf) { } } else { u8* buf = mBckHeap[0].getBuffer(); - if (*(u32*)(buf + 0x1c) == 0xffffffff) { + if (*(BE(u32)*)(buf + 0x1c) == 0xffffffff) { offStateFlg1(FLG1_UNK_800); bas = NULL; } else { onStateFlg1(FLG1_UNK_800); - bas = mBckHeap[0].getBuffer() + *(u32*)(buf + 0x1c); + bas = mBckHeap[0].getBuffer() + *(BE(u32)*)(buf + 0x1c); } } diff --git a/src/d/actor/d_a_myna.cpp b/src/d/actor/d_a_myna.cpp index af26d5e3a2..b23845a922 100644 --- a/src/d/actor/d_a_myna.cpp +++ b/src/d/actor/d_a_myna.cpp @@ -74,9 +74,9 @@ static char* l_bckFileNameTBL[] = { static char* l_btpFileNameTBL[] = {"MYNA.btp"}; -static void createHeapCallBack(fopAc_ac_c* i_this) { +static int createHeapCallBack(fopAc_ac_c* i_this) { daMyna_c* a_this = static_cast(i_this); - a_this->createHeap(); + return a_this->createHeap(); } static int jntNodeCallBack(J3DJoint* i_jnt, int param_1) { @@ -339,7 +339,7 @@ int daMyna_c::create() { return phase; } - if (!fopAcM_entrySolidHeap(this, (heapCallbackFunc)&createHeapCallBack, 0x21F0)) { + if (!fopAcM_entrySolidHeap(this, createHeapCallBack, 0x21F0)) { return cPhs_ERROR_e; } diff --git a/src/d/actor/d_a_npc_sola.cpp b/src/d/actor/d_a_npc_sola.cpp index 49568095bc..a8fb79593c 100644 --- a/src/d/actor/d_a_npc_sola.cpp +++ b/src/d/actor/d_a_npc_sola.cpp @@ -194,14 +194,13 @@ int daNpc_solA_c::Execute() { return execute(); } -void daNpc_solA_c::Draw() { +int daNpc_solA_c::Draw() { if (mpMatAnm[0] != NULL) { J3DModelData* mdlData_p = mpMorf[0]->getModel()->getModelData(); mdlData_p->getMaterialNodePointer(getEyeballMaterialNo())->setMaterialAnm(mpMatAnm[0]); } - draw(FALSE, FALSE, mpHIO->m.common.real_shadow_size, NULL, 100.0f, FALSE, FALSE, - FALSE); - return; + + return draw(FALSE, FALSE, mpHIO->m.common.real_shadow_size, NULL, 100.0f, FALSE, FALSE, FALSE); } BOOL daNpc_solA_c::createHeapCallBack(fopAc_ac_c* a_this) { @@ -481,12 +480,12 @@ static int daNpc_solA_Execute(void* param_0) { return static_cast(param_0)->Execute(); } -static void daNpc_solA_Draw(void* param_0) { +static int daNpc_solA_Draw(void* param_0) { return static_cast(param_0)->Draw(); } -static BOOL daNpc_solA_IsDelete(void* param_0) { - return TRUE; +static int daNpc_solA_IsDelete(void* param_0) { + return 1; } static actor_method_class daNpc_solA_MethodTable = { diff --git a/src/d/actor/d_a_npc_tk.cpp b/src/d/actor/d_a_npc_tk.cpp index c31c0c052c..0349f8ebc0 100644 --- a/src/d/actor/d_a_npc_tk.cpp +++ b/src/d/actor/d_a_npc_tk.cpp @@ -2014,7 +2014,7 @@ void daNPC_TK_c::executeWolfPerch() { mWolfPathData = dPath_GetRoomPath(mpPath1->m_nextID, fopAcM_GetRoomNo(this)); JUT_ASSERT(2498, mWolfPathData != NULL); - field_0x6ea = mWolfPathData->field_0x6; + field_0x6ea = mWolfPathData->swbit; field_0x6e8 = mWolfPathData->field_0x4; field_0x6e9 = mWolfPathData->field_0x7; field_0x6d0.Init(mWolfPathData); @@ -2518,7 +2518,7 @@ void daNPC_TK_c::executeResistanceDemo() { 0x200, 0x10); shape_angle.x = -current.angle.x; - cLib_addCalcAngleS(¤t.angle.y, cLib_targetAngleY((Vec*)¤t, &posWithOffset), 8, + cLib_addCalcAngleS(¤t.angle.y, cLib_targetAngleY(¤t.pos, &posWithOffset), 8, 0x400, 0x10); shape_angle.y = current.angle.y; diff --git a/src/d/actor/d_a_obj_Y_taihou.cpp b/src/d/actor/d_a_obj_Y_taihou.cpp index ab9d2bf4cf..61f96a12ab 100644 --- a/src/d/actor/d_a_obj_Y_taihou.cpp +++ b/src/d/actor/d_a_obj_Y_taihou.cpp @@ -356,21 +356,21 @@ int daObjYtaihou_c::Delete() { return 1; } -static void daObjYtaihou_create1st(daObjYtaihou_c* i_this) { +static int daObjYtaihou_create1st(daObjYtaihou_c* i_this) { fopAcM_ct(i_this, daObjYtaihou_c); - i_this->create1st(); + return i_this->create1st(); } -static void daObjYtaihou_MoveBGDelete(daObjYtaihou_c* i_this) { - i_this->MoveBGDelete(); +static int daObjYtaihou_MoveBGDelete(daObjYtaihou_c* i_this) { + return i_this->MoveBGDelete(); } -static void daObjYtaihou_MoveBGExecute(daObjYtaihou_c* i_this) { - i_this->MoveBGExecute(); +static int daObjYtaihou_MoveBGExecute(daObjYtaihou_c* i_this) { + return i_this->MoveBGExecute(); } -static void daObjYtaihou_MoveBGDraw(daObjYtaihou_c* i_this) { - i_this->Draw(); +static int daObjYtaihou_MoveBGDraw(daObjYtaihou_c* i_this) { + return i_this->Draw(); } static actor_method_class daObjYtaihou_METHODS = { diff --git a/src/d/actor/d_a_obj_brg.cpp b/src/d/actor/d_a_obj_brg.cpp index b2acca8f98..64dd01ee45 100644 --- a/src/d/actor/d_a_obj_brg.cpp +++ b/src/d/actor/d_a_obj_brg.cpp @@ -16,6 +16,8 @@ #include "f_op/f_op_camera_mng.h" #include +#include "dusk/logging.h" + static void ride_call_back(dBgW* i_bgw, fopAc_ac_c* i_bgActor, fopAc_ac_c* i_rideActor) { obj_brg_class* a_this = (obj_brg_class*)i_bgActor; @@ -1794,6 +1796,10 @@ static int daObj_Brg_Create(fopAc_ac_c* i_this) { cXyz(334.0f, 85.0f, -16054.0f), cXyz(334.0f, 150.0f, -16270.0f), cXyz(334.0f, 216.0f, -16485.0f), +#ifdef TARGET_PC + // Avoids out-of-bounds index (n=22) + cXyz(0.f, 0.f, 0.f), +#endif }; for (brno = 0; brno < a_this->field_0xb1ea; brno++) { diff --git a/src/d/actor/d_a_obj_fan.cpp b/src/d/actor/d_a_obj_fan.cpp index bf221bd8aa..dfe413c5b9 100644 --- a/src/d/actor/d_a_obj_fan.cpp +++ b/src/d/actor/d_a_obj_fan.cpp @@ -310,9 +310,9 @@ int daObjFan_c::Delete() { return 1; } -static void daObjFan_create1st(daObjFan_c* param_0) { +static int daObjFan_create1st(daObjFan_c* param_0) { fopAcM_ct(param_0, daObjFan_c); - param_0->create1st(); + return param_0->create1st(); } static int daObjFan_MoveBGDelete(daObjFan_c* param_0) { diff --git a/src/d/actor/d_a_obj_flag.cpp b/src/d/actor/d_a_obj_flag.cpp index 9e4d238fed..b3f55ff1d2 100644 --- a/src/d/actor/d_a_obj_flag.cpp +++ b/src/d/actor/d_a_obj_flag.cpp @@ -16,7 +16,7 @@ daObjFlag_c::M_attrs const daObjFlag_c::M_attr = { }; void daObjFlag_c::create_init() { - field_0x5dc = (*(u32*)dComIfG_getObjectRes(daSetBgObj_c::getArcName(this), "spec.dat")) & 0xffff; + field_0x5dc = (*(BE(u32)*)dComIfG_getObjectRes(daSetBgObj_c::getArcName(this), "spec.dat")) & 0xffff; mPos = cXyz(current.pos.x, current.pos.y + field_0x5dc, current.pos.z); mFlagJoints[0].mRv = (short)(cM_rnd() * 65535.0f); mFlagJoints[1].mRv = (short)(cM_rnd() * 65535.0f); diff --git a/src/d/actor/d_a_obj_flag2.cpp b/src/d/actor/d_a_obj_flag2.cpp index b4f89cd39a..4741f4d5a3 100644 --- a/src/d/actor/d_a_obj_flag2.cpp +++ b/src/d/actor/d_a_obj_flag2.cpp @@ -274,9 +274,9 @@ void FlagCloth_c::draw() { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_CLR_RGB, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0); - GXSETARRAY(GX_VA_POS, getPos(), sizeof(mPositions), sizeof(cXyz)); - GXSETARRAY(GX_VA_NRM, getNormal(), sizeof(mNormals), sizeof(cXyz)); - GXSETARRAY(GX_VA_TEX0, mpTexCoord, sizeof(mpTexCoord), 8); + GXSETARRAY(GX_VA_POS, getPos(), sizeof(mPositions), sizeof(cXyz), true); + GXSETARRAY(GX_VA_NRM, getNormal(), sizeof(mNormals), sizeof(cXyz), true); + GXSETARRAY(GX_VA_TEX0, mpTexCoord, sizeof(l_texCoord), 8, true); GXSetZCompLoc(GX_FALSE); GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GXLoadTexObj(&mTexObj, GX_TEXMAP0); @@ -304,7 +304,7 @@ void FlagCloth_c::draw() { GXSetClipMode(GX_CLIP_ENABLE); GXSetCullMode(GX_CULL_BACK); GXCallDisplayList(l_pennant_flagDL, 0x80); - GXSETARRAY(GX_VA_NRM, getNormalBack(), sizeof(mNormalBacks), sizeof(cXyz)); + GXSETARRAY(GX_VA_NRM, getNormalBack(), sizeof(mNormalBacks), sizeof(cXyz), true); GXSetCullMode(GX_CULL_FRONT); GXCallDisplayList(l_pennant_flagDL, 0x80); J3DShape::resetVcdVatCache(); diff --git a/src/d/actor/d_a_obj_flag3.cpp b/src/d/actor/d_a_obj_flag3.cpp index 7337a4b97d..fc696db1ab 100644 --- a/src/d/actor/d_a_obj_flag3.cpp +++ b/src/d/actor/d_a_obj_flag3.cpp @@ -233,9 +233,9 @@ inline void FlagCloth2_c::draw() { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_CLR_RGB, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0); - GXSETARRAY(GX_VA_POS, getPos(), sizeof(mPositions), sizeof(cXyz)); - GXSETARRAY(GX_VA_NRM, getNormal(), sizeof(mNormals), sizeof(cXyz)); - GXSETARRAY(GX_VA_TEX0, mTexCoord, sizeof(mTexCoord), 8); + GXSETARRAY(GX_VA_POS, getPos(), sizeof(mPositions), sizeof(cXyz), true); + GXSETARRAY(GX_VA_NRM, getNormal(), sizeof(mNormals), sizeof(cXyz), true); + GXSETARRAY(GX_VA_TEX0, mTexCoord, sizeof(mTexCoord), 8, true); GXSetZCompLoc(GX_FALSE); GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GXLoadTexObj(&mTexObj, GX_TEXMAP0); @@ -276,7 +276,7 @@ inline void FlagCloth2_c::draw() { GXEnd(); } - GXSETARRAY(GX_VA_NRM, getNormalBack(), sizeof(mNormalBacks), sizeof(cXyz)); + GXSETARRAY(GX_VA_NRM, getNormalBack(), sizeof(mNormalBacks), sizeof(cXyz), true); GXSetCullMode(GX_CULL_FRONT); for (int i = 0; i < 5; i++) { diff --git a/src/d/actor/d_a_obj_inobone.cpp b/src/d/actor/d_a_obj_inobone.cpp index d73c5e5f9f..2076405828 100644 --- a/src/d/actor/d_a_obj_inobone.cpp +++ b/src/d/actor/d_a_obj_inobone.cpp @@ -89,8 +89,8 @@ static void* s_boar_sub(void* i_actor, void* i_data) { return NULL; } -static void CheckCreateHeap(fopAc_ac_c* i_this) { - static_cast(i_this)->CreateHeap(); +static int CheckCreateHeap(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); } void daObjIBone_c::initBaseMtx() { @@ -150,7 +150,7 @@ int daObjIBone_c::create() { int result = dComIfG_resLoad(&mPhase, l_arcName); if (result == cPhs_COMPLEATE_e) { - if (!fopAcM_entrySolidHeap(this, (heapCallbackFunc)CheckCreateHeap, 0x860)) { + if (!fopAcM_entrySolidHeap(this, CheckCreateHeap, 0x860)) { return cPhs_ERROR_e; } else if (!Create()) { return cPhs_ERROR_e; diff --git a/src/d/actor/d_a_obj_stick.cpp b/src/d/actor/d_a_obj_stick.cpp index 2e448c1579..d6aa8d1e22 100644 --- a/src/d/actor/d_a_obj_stick.cpp +++ b/src/d/actor/d_a_obj_stick.cpp @@ -198,24 +198,24 @@ void daObj_Stick_c::setMtx() { mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); } -static u32 daObj_Stick_Create(void* i_this) { +static int daObj_Stick_Create(void* i_this) { return static_cast(i_this)->create(); } -static void daObj_Stick_Delete(void* param_0) { - static_cast(param_0)->Delete(); +static int daObj_Stick_Delete(void* param_0) { + return static_cast(param_0)->Delete(); } -static void daObj_Stick_Execute(void* param_0) { - static_cast(param_0)->Execute(); +static int daObj_Stick_Execute(void* param_0) { + return static_cast(param_0)->Execute(); } -static void daObj_Stick_Draw(void* param_0) { - static_cast(param_0)->Draw(); +static int daObj_Stick_Draw(void* param_0) { + return static_cast(param_0)->Draw(); } -static BOOL daObj_Stick_IsDelete(void* param_0) { - return TRUE; +static int daObj_Stick_IsDelete(void* param_0) { + return 1; } static actor_method_class daObj_Stick_MethodTable = { diff --git a/src/d/actor/d_a_obj_stone.cpp b/src/d/actor/d_a_obj_stone.cpp index 5cf5716873..f74adf12a7 100644 --- a/src/d/actor/d_a_obj_stone.cpp +++ b/src/d/actor/d_a_obj_stone.cpp @@ -126,7 +126,7 @@ static f32 bound(cXyz* param_0, cBgS_PolyInfo const& param_1, f32 param_2) { cXyz pos; f32 abs = param_0->abs(); - C_VECReflect(param_0, (Vec*)&plane, &pos); + C_VECReflect(param_0, &plane.mNormal, &pos); *param_0 = pos * abs * param_2; return param_0->absXZ(); diff --git a/src/d/actor/d_a_peru.cpp b/src/d/actor/d_a_peru.cpp index 7d2a7c39bb..b02c740c06 100644 --- a/src/d/actor/d_a_peru.cpp +++ b/src/d/actor/d_a_peru.cpp @@ -59,7 +59,7 @@ static daNpcT_motionAnmData_c l_motionAnmData[11] = { static daNpcT_MotionSeqMngr_c::sequenceStepData_c l_faceMotionSequenceData[20] = { {1, -1, 1}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, {2, -1, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, {0, -1, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, {3, -1, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, - {4, -1, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, + {4, -1, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, }; static daNpcT_MotionSeqMngr_c::sequenceStepData_c l_motionSequenceData[40] = { diff --git a/src/d/actor/d_a_tag_magne.cpp b/src/d/actor/d_a_tag_magne.cpp index 8b47511eeb..ca74c0655a 100644 --- a/src/d/actor/d_a_tag_magne.cpp +++ b/src/d/actor/d_a_tag_magne.cpp @@ -44,15 +44,15 @@ int daTagMagne_c::_delete() { return 1; } -static void daTagMagne_Delete(daTagMagne_c* i_this) { +static int daTagMagne_Delete(daTagMagne_c* i_this) { int id = fopAcM_GetID(i_this); - i_this->_delete(); + return i_this->_delete(); } -static void daTagMagne_Create(fopAc_ac_c* i_this) { +static int daTagMagne_Create(fopAc_ac_c* i_this) { daTagMagne_c* magne = static_cast(i_this); int id = fopAcM_GetID(i_this); - magne->create(); + return magne->create(); } static actor_method_class l_daTagMagne_Method = { diff --git a/src/d/actor/d_a_tag_sppath.cpp b/src/d/actor/d_a_tag_sppath.cpp index 81fbe04184..9fdb00fe55 100644 --- a/src/d/actor/d_a_tag_sppath.cpp +++ b/src/d/actor/d_a_tag_sppath.cpp @@ -189,7 +189,7 @@ int daTagSppath_c::execute() { } if (mpBestPath->field_0x4 == 0) { - if (mpBestPath->field_0x6 == 0xff || fopAcM_isSwitch(this, mpBestPath->field_0x6) == 0) { + if (mpBestPath->swbit == 0xff || fopAcM_isSwitch(this, mpBestPath->swbit) == 0) { field_0x6e8 = 1; } else { field_0x6e8 = 2; diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 13bc1ad251..762b1e02e9 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -5,8 +5,14 @@ #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "SSystem/SComponent/c_counter.h" +#if TARGET_PC +const u16 l_J_Ohana00_64TEX__width = 64; +const u16 l_J_Ohana00_64TEX__height = 64; +#else const u16 l_J_Ohana00_64TEX__width = 63; const u16 l_J_Ohana00_64TEX__height = 63; +#endif + #include "assets/l_J_Ohana00_64TEX.h" static u8 l_flowerPos[708] = { @@ -72,8 +78,8 @@ static u8 l_flowerNormal[180] = { 0x46, 0x54, 0x0D, 0x3C, 0x4B, 0xEE, 0x80, 0x3F, 0x7F, 0xF5, 0xF9, 0x3C, 0x49, 0x81, 0xBF, }; -static u8 l_flowerColor[8] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xB2, 0xB2, 0xB2, 0xFF, +static GXColor l_flowerColor[2] = { + {0xFF, 0xFF, 0xFF, 0xFF}, {0xB2, 0xB2, 0xB2, 0xFF} }; static u8 l_flowerTexCoord[] = { @@ -108,8 +114,14 @@ l_matDL__d_a_grass(l_J_Ohana00_64TEX) #include "assets/l_matLight4DL.h" l_matLight4DL(l_J_Ohana00_64TEX) +#if TARGET_PC +const u16 l_J_Ohana01_64128_0419TEX__width = 64; +const u16 l_J_Ohana01_64128_0419TEX__height = 128; +#else const u16 l_J_Ohana01_64128_0419TEX__width = 63; const u16 l_J_Ohana01_64128_0419TEX__height = 127; +#endif + #include "assets/l_J_Ohana01_64128_0419TEX.h" static u8 l_flowerPos2[1224] = { @@ -213,8 +225,8 @@ static u8 l_flowerNormal2[288] = { 0x3B, 0x76, 0x7B, 0x1C, 0x3B, 0x99, 0x6B, 0x76, 0x3F, 0x7F, 0xF5, 0xF9, 0xBC, 0x8A, 0x1D, 0xFC, }; -static u8 l_flowerColor2[8] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB2, 0xFF, +static GXColor l_flowerColor2[2] = { + {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xB2, 0xFF} }; static u8 l_flowerTexCoord2[] = { @@ -509,6 +521,16 @@ dFlower_packet_c::dFlower_packet_c() { unused += 0x2000; } +#if TARGET_PC + GXInitTexObj(&mTexObj_l_J_Ohana00_64TEX, l_J_Ohana00_64TEX, + l_J_Ohana00_64TEX__width, l_J_Ohana00_64TEX__height, GX_TF_CMPR, GX_MIRROR, GX_MIRROR, GX_FALSE + ); + + GXInitTexObj(&mTexObj_l_J_Ohana01_64128_0419TEX, l_J_Ohana01_64128_0419TEX, + l_J_Ohana01_64128_0419TEX__width, l_J_Ohana01_64128_0419TEX__height, GX_TF_CMPR, GX_MIRROR, GX_MIRROR, GX_FALSE + ); +#endif + m_deleteRoom = &dFlower_packet_c::deleteRoom; #if AVOID_UB @@ -531,10 +553,10 @@ void dFlower_packet_c::draw() { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); - GXSETARRAY(GX_VA_POS, &l_flowerPos, sizeof(l_flowerPos), 0xC); - GXSETARRAY(GX_VA_NRM, &l_flowerNormal, sizeof(l_flowerNormal), 0xC); - GXSETARRAY(GX_VA_CLR0, &l_flowerColor, sizeof(l_flowerColor), 4); - GXSETARRAY(GX_VA_TEX0, &l_flowerTexCoord, sizeof(l_flowerTexCoord), 8); + GXSETARRAY(GX_VA_POS, &l_flowerPos, sizeof(l_flowerPos), 0xC, false); + GXSETARRAY(GX_VA_NRM, &l_flowerNormal, sizeof(l_flowerNormal), 0xC, false); + GXSETARRAY(GX_VA_CLR0, &l_flowerColor, sizeof(l_flowerColor), 4, false); + GXSETARRAY(GX_VA_TEX0, &l_flowerTexCoord, sizeof(l_flowerTexCoord), 8, false); GXColor sp64; dFlower_room_c* sp5C = m_room; @@ -615,6 +637,10 @@ void dFlower_packet_c::draw() { GXLoadPosMtxImm(sp44->m_modelMtx, 0); GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); +#if TARGET_PC + GXLoadTexObj(&mTexObj_l_J_Ohana00_64TEX, GX_TEXMAP0); +#endif + if (!cLib_checkBit(sp44->m_state, 8)) { GXCallDisplayList(&l_J_hana00DL, 0x140); } else { @@ -626,10 +652,10 @@ void dFlower_packet_c::draw() { sp5C++; } - GXSETARRAY(GX_VA_POS, mp_pos, sizeof(l_flowerPos2), 0xC); - GXSETARRAY(GX_VA_NRM, &l_flowerNormal2, sizeof(l_flowerNormal2), 0xC); - GXSETARRAY(GX_VA_CLR0, mp_colors, sizeof(l_flowerColor2), 4); - GXSETARRAY(GX_VA_TEX0, mp_texCoords, sizeof(l_flowerTexCoord2), 8); + GXSETARRAY(GX_VA_POS, mp_pos, sizeof(l_flowerPos2), 0xC, true); + GXSETARRAY(GX_VA_NRM, &l_flowerNormal2, sizeof(l_flowerNormal2), 0xC, false); + GXSETARRAY(GX_VA_CLR0, mp_colors, sizeof(l_flowerColor2), 4, true); + GXSETARRAY(GX_VA_TEX0, mp_texCoords, sizeof(l_flowerTexCoord2), 8, true); sp5C = m_room; @@ -757,6 +783,10 @@ void dFlower_packet_c::draw() { GXLoadPosMtxImm(sp34->m_modelMtx, 0); GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); +#if TARGET_PC + GXLoadTexObj(&mTexObj_l_J_Ohana01_64128_0419TEX, GX_TEXMAP0); +#endif + if (!cLib_checkBit(sp34->m_state, 8)) { if (!cLib_checkBit(sp34->m_state, 0x10)) { GXCallDisplayList(mp_Jhana01DL, m_Jhana01DL_size); diff --git a/src/d/actor/d_grass.inc b/src/d/actor/d_grass.inc index 2078e917ad..6351cc75fc 100644 --- a/src/d/actor/d_grass.inc +++ b/src/d/actor/d_grass.inc @@ -536,10 +536,10 @@ void dGrass_packet_c::draw() { GXSetVtxDescv(l_vtxDescList); GXSetVtxAttrFmtv(GX_VTXFMT0, l_vtxAttrFmtList); - GXSETARRAY(GX_VA_POS, mp_pos, sizeof(l_pos), sizeof(Vec)); - GXSETARRAY(GX_VA_NRM, mp_normal, sizeof(l_normal), sizeof(Vec)); - GXSETARRAY(GX_VA_CLR0, mp_colors, sizeof(l_color), sizeof(GXColor)); - GXSETARRAY(GX_VA_TEX0, mp_texCoords, sizeof(l_texCoord), 8); + GXSETARRAY(GX_VA_POS, mp_pos, sizeof(l_pos), sizeof(Vec), true); + GXSETARRAY(GX_VA_NRM, mp_normal, sizeof(l_normal), sizeof(Vec), true); + GXSETARRAY(GX_VA_CLR0, mp_colors, sizeof(l_color), sizeof(GXColor), true); + GXSETARRAY(GX_VA_TEX0, mp_texCoords, sizeof(l_texCoord), 8, true); GXColorS10 spA0 = {0, 0, 0, 0}; GXColorS10 sp98 = {0, 0, 0, 0}; diff --git a/src/d/d_bg_parts.cpp b/src/d/d_bg_parts.cpp index 930c3f63b1..3c378bf325 100644 --- a/src/d/d_bg_parts.cpp +++ b/src/d/d_bg_parts.cpp @@ -106,7 +106,7 @@ void dBgp_c::modelMaterial_c::set(J3DModelData* i_modelData, J3DMaterial* i_mate void dBgp_c::model_c::create(J3DModelData* i_modelData, Mtx i_mtx) { const void* binary = i_modelData->getBinary(); - mId = *(u32*)((char*)binary + 0x1C); + mId = *(BE(u32)*)((char*)binary + 0x1C); if (mId != 0xFFFF) { addShare(mId); } diff --git a/src/d/d_camera.cpp b/src/d/d_camera.cpp index ce2c7c169a..a5efef9bfa 100644 --- a/src/d/d_camera.cpp +++ b/src/d/d_camera.cpp @@ -10532,6 +10532,10 @@ int dCamera_c::StartShake(s32 i_length, u8* i_pattern, s32 i_flags, cXyz i_pos) #define PATTERN_LENGTH_MAX 4 #endif + #if TARGET_PC + *(u32*)i_pattern = BSWAP32(*(u32*)i_pattern); + #endif + if (i_length < 0 || i_length > PATTERN_LENGTH_MAX << 3) { OS_REPORT("camera: shake: too long data\n"); i_length = PATTERN_LENGTH_MAX << 3; diff --git a/src/d/d_cursor_mng.cpp b/src/d/d_cursor_mng.cpp index 0d3fd4345e..230b4e740e 100644 --- a/src/d/d_cursor_mng.cpp +++ b/src/d/d_cursor_mng.cpp @@ -318,7 +318,7 @@ void dCsr_mng_c::bloObj_c::calcPaneObjNum(J2DPane* i_pane) { } JSUTreeIterator iter = i_pane->getPaneTree()->getFirstChild(); - while (iter != NULL) { + while (iter) { calcPaneObjNum(*iter); ++iter; } @@ -334,7 +334,7 @@ void dCsr_mng_c::bloObj_c::createPaneObj(paneObj_c** i_panes, J2DPane* i_pane) { } JSUTreeIterator iter = i_pane->getPaneTree()->getFirstChild(); - while (iter != NULL) { + while (iter) { createPaneObj(i_panes, *iter); ++iter; } diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index ee6b01f9fd..ede33efd65 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1402,7 +1402,11 @@ void dDlst_shadowControl_c::init() { for (int i = 0; i < 2; i++) { u16 size = l_realImageSize[i]; +#ifdef TARGET_PC + u32 buffer_size = 0x20; // No need to allocate memory for texture +#else u32 buffer_size = GXGetTexBufferSize(size, size, 5, GX_DISABLE, 0); +#endif field_0x15ef0[i] = JKR_NEW_ARRAY_ARGS(u8, buffer_size, 0x20); GXInitTexObj(&field_0x15eb0[i], field_0x15ef0[i], size, size, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_DISABLE); @@ -1516,7 +1520,7 @@ void dDlst_shadowControl_c::draw(Mtx param_0) { dKy_GxFog_set(); GXSetChanCtrl(GX_ALPHA0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); - GXSETARRAY(GX_VA_POS, l_shadowVolPos, sizeof(l_shadowVolPos), sizeof(l_shadowVolPos[0])); + GXSETARRAY(GX_VA_POS, l_shadowVolPos, sizeof(l_shadowVolPos), sizeof(l_shadowVolPos[0]), true); GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_POS, GX_TEXMTX0); GXSetNumTevStages(1); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); @@ -1548,7 +1552,7 @@ void dDlst_shadowControl_c::draw(Mtx param_0) { GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB8, 0); - GXSETARRAY(GX_VA_POS, l_simpleShadowPos, sizeof(l_simpleShadowPos), sizeof(l_simpleShadowPos[0])); + GXSETARRAY(GX_VA_POS, l_simpleShadowPos, sizeof(l_simpleShadowPos), sizeof(l_simpleShadowPos[0]), true); GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); @@ -1636,7 +1640,7 @@ int dDlst_shadowControl_c::setReal(u32 param_1, s8 param_2, J3DModel* param_3, c u32 rv = pdVar12->set(mNextID, param_3, param_4, param_5, param_6, param_7, dVar17, dVar16); if (!rv) { return 0; - } + } mRealNum++; if (pdVar10 == NULL) { if (pdVar11 == NULL) { @@ -1860,6 +1864,12 @@ int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base void dDlst_list_c::draw(dDlst_base_c** p_start, dDlst_base_c** p_end) { for (; p_start < p_end; p_start++) { dDlst_base_c* dlst = *p_start; + +#if DEBUG && TARGET_PC + char buf[64]; + snprintf(buf, sizeof(buf), "%s::draw()", typeid(dlst).name()); + GXScopedDebugGroup scope(buf); +#endif dlst->draw(); } } diff --git a/src/d/d_map.cpp b/src/d/d_map.cpp index 76289d52dd..46b0bbf742 100644 --- a/src/d/d_map.cpp +++ b/src/d/d_map.cpp @@ -341,7 +341,6 @@ inline u8 twoValueLineInterpolation(u8 param_0, u8 param_1, f32 param_2) { } void renderingAmap_c::draw() { - #if REQUIRES_GX_LINES f32 tmp = ((f32)(g_Counter.mCounter0 % dMap_HIO_prm_res_dst_s::m_res->field_0x1aa) / (f32)dMap_HIO_prm_res_dst_s::m_res->field_0x1aa); tmp = tmp; @@ -376,8 +375,7 @@ void renderingAmap_c::draw() { dMap_HIO_prm_res_dst_s::m_res->field_0x1a7, tmp); setAmapPaletteColor(0x2E, temp_r31, temp_r30, temp_r29, temp_r28); - renderingDAmap_c::draw(); - #endif + GX_DEBUG_GROUP(renderingDAmap_c::draw); } int renderingAmap_c::getDispType() const { @@ -1099,7 +1097,7 @@ void dMap_c::resCopy() { } } -dMap_c::dMap_c(int param_0, int param_1, int param_2, int param_3) { +dMap_c::dMap_c(int width, int height, int param_2, int param_3) { m_res_src = NULL; m_res = NULL; mResTIMG = NULL; @@ -1171,8 +1169,8 @@ dMap_c::dMap_c(int param_0, int param_1, int param_2, int param_3) { resCopy(); - mTexSizeX = param_0; - mTexSizeY = param_1; + mTexSizeX = width; + mTexSizeY = height; if (dMap_HIO_prm_res_dst_s::m_res->field_0x1ae > 0) { field_0x74 = dMap_HIO_prm_res_dst_s::m_res->field_0x1b0 / 6; @@ -1182,12 +1180,23 @@ dMap_c::dMap_c(int param_0, int param_1, int param_2, int param_3) { mImage_p = JKR_NEW_ARRAY_ARGS(u8, buffer_size, 0x20); JUT_ASSERT(2638, mImage_p != NULL); + +#ifdef TARGET_PC + // Increase map render resolution + renderingDAmap_c::init(mImage_p, mTexSizeX * 4, mTexSizeY * 4, mTexSizeX, mTexSizeY); +#else renderingDAmap_c::init(mImage_p, mTexSizeX, mTexSizeY, mTexSizeX, mTexSizeY); +#endif mResTIMG = JKR_NEW_ARGS (0x20) ResTIMG; JUT_ASSERT(2647, mResTIMG != NULL); +#ifdef TARGET_PC + // Increase map render resolution + makeResTIMG(mResTIMG, mTexSizeX * 4, mTexSizeY * 4, mImage_p, (u8*)m_res, 0x33); +#else makeResTIMG(mResTIMG, mTexSizeX, mTexSizeY, mImage_p, (u8*)m_res, 0x33); +#endif } #if DEBUG diff --git a/src/d/d_map_path.cpp b/src/d/d_map_path.cpp index 47f0f1e43c..b5ecee95b3 100644 --- a/src/d/d_map_path.cpp +++ b/src/d/d_map_path.cpp @@ -292,11 +292,22 @@ void dDrawPath_c::rendering(dDrawPath_c::floor_class const* p_floor) { } } +#ifdef TARGET_PC +static u32 getRoomPosArraySize(const dDrawPath_c::room_class* room) { + if (room->mpFloor == NULL || room->mpFloatData == NULL || room->mFloorNum == 0) { + return 0; + } + const dDrawPath_c::group_class* firstGroup = room->mpFloor[0].mpGroup; + JUT_ASSERT(0, firstGroup != NULL); + JUT_ASSERT(0, (const u8*)firstGroup >= (const u8*)room->mpFloatData); + return (const u8*)firstGroup - (const u8*)room->mpFloatData; +} +#endif + void dDrawPath_c::rendering(dDrawPath_c::room_class const* room) { JUT_ASSERT(1043, room != NULL); if (room != NULL) { - // TODO: FILL IN SIZE. - GXSETARRAY(GX_VA_POS, room->mpFloatData, 0, 8); + GXSetArray(GX_VA_POS, room->mpFloatData, getRoomPosArraySize(room), 8, false); floor_class* floor = room->mpFloor; if (floor != NULL) { @@ -346,13 +357,11 @@ void dRenderingMap_c::makeResTIMG(ResTIMG* p_image, u16 width, u16 height, u8* p void dRenderingMap_c::renderingMap() { preRenderingMap(); if (isDrawPath()) { - #if REQUIRES_GX_LINES preDrawPath(); beforeDrawPath(); drawPath(); afterDrawPath(); postDrawPath(); - #endif } postRenderingMap(); } @@ -446,7 +455,7 @@ dMpath_n::dTexObjAggregate_c dMpath_n::m_texObjAgg; * make the map look worse for extra speed in the emulator, especially in large * areas such as hyrule field. */ -// #define HYRULE_FIELD_SPEEDHACK +#define HYRULE_FIELD_SPEEDHACK void dRenderingFDAmap_c::renderingDecoration(dDrawPath_c::line_class const* p_line) { s32 width = getDecorationLineWidth(p_line->field_0x1); @@ -473,7 +482,6 @@ void dRenderingFDAmap_c::renderingDecoration(dDrawPath_c::line_class const* p_li GXSetTevColor(GX_TEVREG1, lineColor); for (int i = 0; i < data_num; i++) { -#if REQUIRES_GX_LINES #ifndef HYRULE_FIELD_SPEEDHACK if (i < data_num - 1) { GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); @@ -494,7 +502,7 @@ void dRenderingFDAmap_c::renderingDecoration(dDrawPath_c::line_class const* p_li GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA); GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); #endif -#endif + GXBegin(GX_POINTS, GX_VTXFMT0, 1); GXPosition1x16(data_p[0]); GXTexCoord2f32(0, 0); diff --git a/src/d/d_map_path_dmap.cpp b/src/d/d_map_path_dmap.cpp index cd76155327..f2a41e8fd3 100644 --- a/src/d/d_map_path_dmap.cpp +++ b/src/d/d_map_path_dmap.cpp @@ -617,10 +617,7 @@ bool renderingDAmap_c::isSwitch(dDrawPath_c::group_class const* i_group) { } void renderingDAmap_c::draw() { -#if !TARGET_PC - // Currently breaks Aurora. renderingMap(); -#endif mIsDraw = true; } @@ -851,7 +848,7 @@ void renderingPlusDoor_c::drawDoorCommon(stage_tgsc_data_class const* i_doorData GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB565, 0); - GXSETARRAY(GX_VA_TEX0, (void*)l_tex0, sizeof(l_tex0), 2); + GXSETARRAY(GX_VA_TEX0, l_tex0, sizeof(l_tex0), 2, true); setTevSettingIntensityTextureToCI(); @@ -1010,7 +1007,7 @@ void renderingPlusDoorAndCursor_c::drawTreasure() { GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB565, 0); - GXSETARRAY(GX_VA_TEX0, (void*)l_iconTex0, sizeof(l_iconTex0), 2); + GXSETARRAY(GX_VA_TEX0, l_iconTex0, sizeof(l_iconTex0), 2, true); setTevSettingIntensityTextureToCI(); @@ -1084,7 +1081,7 @@ void renderingPlusDoorAndCursor_c::drawTreasureAfterPlayer() { GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB565, 0); - GXSETARRAY(GX_VA_TEX0, (void*)l_iconTex0, sizeof(l_iconTex0), 2); + GXSETARRAY(GX_VA_TEX0, l_iconTex0, sizeof(l_iconTex0), 2, true); setTevSettingIntensityTextureToCI(); diff --git a/src/d/d_menu_dmap_map.cpp b/src/d/d_menu_dmap_map.cpp index 0754bf7e35..8b345fbcbd 100644 --- a/src/d/d_menu_dmap_map.cpp +++ b/src/d/d_menu_dmap_map.cpp @@ -300,16 +300,25 @@ void dMenu_DmapMap_c::_delete() { } } -void dMenu_DmapMap_c::setTexture(u16 param_0, u16 param_1, u16 param_2, u16 param_3) { +void dMenu_DmapMap_c::setTexture(u16 width, u16 height, u16 param_2, u16 param_3) { +#ifdef TARGET_PC + // Increase map render resolution + width *= 2; + height *= 2; +#endif for (int lp1 = 0; lp1 < 2; lp1++) { - u32 var_r27 = GXGetTexBufferSize(param_0, param_1, 9, 0, 0); - mMapImage_p[lp1] = JKR_NEW_ARRAY_ARGS(u8, var_r27, 0x20); +#ifdef TARGET_PC + u32 sz = 0x20; // No need to allocate memory for texture +#else + u32 sz = GXGetTexBufferSize(width, height, 9, 0, 0); +#endif + mMapImage_p[lp1] = JKR_NEW_ARRAY_ARGS(u8, sz, 0x20); JUT_ASSERT(1672, mMapImage_p[lp1] != NULL); - mRend[lp1].init(mMapImage_p[lp1], param_0, param_1, param_2, param_3); + mRend[lp1].init(mMapImage_p[lp1], width, height, param_2, param_3); mResTIMG[lp1] = JKR_NEW_ARGS (0x20) ResTIMG; JUT_ASSERT(1687, mResTIMG[lp1] != NULL); - mRend[lp1].makeResTIMG(mResTIMG[lp1], param_0, param_1, mMapImage_p[lp1], (u8*)dMdm_HIO_prm_res_dst_s::m_res, 30); + mRend[lp1].makeResTIMG(mResTIMG[lp1], width, height, mMapImage_p[lp1], (u8*)dMdm_HIO_prm_res_dst_s::m_res, 30); } } @@ -929,7 +938,7 @@ f32 dMenu_StageMapCtrl_c::m_zoomCenterMinZ; f32 dMenu_StageMapCtrl_c::m_zoomCenterMaxZ; -void dMenu_StageMapCtrl_c::_create(u16 param_0, u16 param_1, u16 param_2, u16 param_3, +void dMenu_StageMapCtrl_c::_create(u16 width, u16 height, u16 param_2, u16 param_3, s8 param_4, void* param_5) { field_0xe6 = dComIfGp_roomControl_getStayNo(); field_0xe7 = param_4; @@ -946,7 +955,7 @@ void dMenu_StageMapCtrl_c::_create(u16 param_0, u16 param_1, u16 param_2, u16 pa field_0x98 = param_3; f32 var_f26 = field_0x98 > field_0x94 ? field_0x98 : field_0x94; - dMenu_DmapMap_c::_create(param_0, param_1, param_2, param_3, param_5); + dMenu_DmapMap_c::_create(width, height, param_2, param_3, param_5); getInitDispCenter(&field_0x9c, &field_0xa0); field_0xa4 = field_0x9c; diff --git a/src/d/d_menu_fmap.cpp b/src/d/d_menu_fmap.cpp index c8969f2ac3..851e22b7c7 100644 --- a/src/d/d_menu_fmap.cpp +++ b/src/d/d_menu_fmap.cpp @@ -2278,7 +2278,7 @@ void dMenu_Fmap_c::decodeFieldMapData() { dMenuMapCommon_c::Stage_c* stage_data = (dMenuMapCommon_c::Stage_c*)(field_data + mpFieldDat->mStageDataOffset); mDataNumMax = stage_data->mCount; - mAllTitleName = *(u16*)(field_data + 0x16); + mAllTitleName = *(BE(u16)*)(field_data + 0x16); setTitleName(mAllTitleName); dMenu_Fmap_field_region_data_c::data* regions = region_data->mData; char tex_path[20]; diff --git a/src/d/d_menu_fmap_map.cpp b/src/d/d_menu_fmap_map.cpp index fbbd9267e5..2c5b1cea8e 100644 --- a/src/d/d_menu_fmap_map.cpp +++ b/src/d/d_menu_fmap_map.cpp @@ -657,9 +657,19 @@ const GXColor* dMenu_FmapMap_c::getColor(int param_0) { } void dMenu_FmapMap_c::setTexture(u16 i_width, u16 i_height, u16 param_2, u16 param_3) { +#ifdef TARGET_PC + // Increase map render resolution + i_width *= 2; + i_height *= 2; +#endif + mMapImage_p = NULL; mResTIMG = NULL; +#ifdef TARGET_PC + int size = 0x20; // No need to allocate memory for texture +#else int size = GXGetTexBufferSize(i_width, i_height, GX_TF_C8, 0, 0); +#endif mMapImage_p = JKR_NEW_ARRAY_ARGS(u8, size, 0x20); init(mMapImage_p, i_width, i_height, param_2, param_3); mResTIMG = JKR_NEW_ARGS (0x20) ResTIMG; diff --git a/src/d/d_menu_ring.cpp b/src/d/d_menu_ring.cpp index cad04d6ab6..3949adffed 100644 --- a/src/d/d_menu_ring.cpp +++ b/src/d/d_menu_ring.cpp @@ -1262,10 +1262,8 @@ void dMenu_Ring_c::drawItem() { (g_ringHIO.mItemAlphaMin + fVar16 * (g_ringHIO.mItemAlphaMax - g_ringHIO.mItemAlphaMin)); for (int i = 0; i < mItemsTotal; i++) { if (i != mCurrentSlot || (mStatus != STATUS_WAIT && mStatus != STATUS_EXPLAIN && mStatus != STATUS_EXPLAIN_FORCE)) { - #if REQUIRES_GX_LINES J2DDrawFrame(mItemSlotPosX[i] - 24.0f + mCenterPosX, mItemSlotPosY[i] - 24.0f + mCenterPosY, 48.0f, 48.0f, g_ringHIO.mItemFrame[g_ringHIO.UNSELECT_FRAME], 6); - #endif f32 fVar17 = 1.0f; if (i != mCurrentSlot) { fVar17 = ringAlpha / 255.0f; @@ -1308,10 +1306,8 @@ void dMenu_Ring_c::drawItem() { void dMenu_Ring_c::drawItem2() { s32 idx = mCurrentSlot; if (mStatus == STATUS_WAIT || mStatus == STATUS_EXPLAIN || mStatus == STATUS_EXPLAIN_FORCE) { - #if REQUIRES_GX_LINES J2DDrawFrame(mItemSlotPosX[idx] - 24.0f + mCenterPosX, mItemSlotPosY[idx] - 24.0f + mCenterPosY, 48.0f, 48.0f, g_ringHIO.mItemFrame[g_ringHIO.SELECT_FRAME], 6); - #endif for (int i = 0; i < 3; i++) { if (mpItemTex[idx][i] != NULL) { diff --git a/src/d/d_meter2_info.cpp b/src/d/d_meter2_info.cpp index 61cf7ae5ee..3e8d2601c1 100644 --- a/src/d/d_meter2_info.cpp +++ b/src/d/d_meter2_info.cpp @@ -11,6 +11,8 @@ #include "d/d_meter_map.h" #include "d/d_msg_class.h" #include "d/d_msg_object.h" +#include "d/d_meter_HIO.h" + #include enum ITEMICON_RES_FILE_ID { @@ -362,19 +364,18 @@ void dMeter2Info_c::getString(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_ } JMSMesgInfo_c* bmg_inf = (JMSMesgInfo_c*)(msgRes + sizeof(bmg_header_t)); - u8* bmg_data = (u8*)bmg_inf + bmg_inf->header.size + sizeof(bmg_section_t); // pointer to start of message data + u8* bmg_data = (u8*)bmg_inf + bmg_inf->header.size; + u8* string_data = bmg_data + sizeof(bmg_section_t); // pointer to start of message data char* string_ptr = NULL; for (u16 i = 0; i < bmg_inf->entry_num; i++) { - u8* entry = ((u8*)bmg_inf + (i * sizeof(JMSMesgEntry_c))); - // check if i_stringID equals the message entry "Message ID" - if (i_stringID == *(BE(u16)*)(entry + 0x14)) { - string_ptr = (char*)(bmg_data + *(BE(u32)*)(entry + 0x10)); // use entry "String Offset" to get string pointer + if (i_stringID == bmg_inf->entries[i].message_id) { + string_ptr = (char*)(string_data + bmg_inf->entries[i].string_offset); // use entry "String Offset" to get string pointer strcpy(o_string, string_ptr); if (i_msgEntry != NULL) { - memcpy(i_msgEntry, entry + 0x10, sizeof(JMSMesgEntry_c)); + memcpy(i_msgEntry, &bmg_inf->entries[i], sizeof(JMSMesgEntry_c)); } return; @@ -508,6 +509,10 @@ void dMeter2Info_c::getStringKanji(u32 i_stringID, char* o_string, JMSMesgEntry_ } } +static void dummyString() { + OS_REPORT("レボ用ID=====>%d, %d\n"); +} + f32 dMeter2Info_c::getStringLength(J2DTextBox* i_textbox, char* i_string) { f32 str_width = 0.0f; f32 str_len = 0.0f; @@ -1003,6 +1008,104 @@ s16 dMeter2Info_c::get4thTexture(u8 i_itemType) { } void dMeter2Info_c::set1stColor(u8 i_itemType, J2DPicture* i_pic) { + // TODO: probably some way to rectify this for both versions + #if VERSION == VERSION_SHIELD_DEBUG + static JUtility::TColor const black_color[37] = { + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x60, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0xC0, 0x00), + JUtility::TColor(0xA0, 0x60, 0x00, 0x00), JUtility::TColor(0xA0, 0x00, 0x00, 0x00), JUtility::TColor(0x40, 0x00, 0x60, 0x00), + JUtility::TColor(0xE0, 0x00, 0x00, 0x00), JUtility::TColor(0x40, 0x40, 0x40, 0x00), JUtility::TColor(0x6E, 0x6E, 0x64, 0x00), + JUtility::TColor(0x32, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x7F, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x7F, 0x00), + JUtility::TColor(0xAF, 0x9B, 0x6E, 0x00), JUtility::TColor(0xAA, 0x9B, 0x6E, 0x00), JUtility::TColor(0x55, 0x37, 0x14, 0x00), + JUtility::TColor(0x6E, 0x6E, 0x6E, 0x00), JUtility::TColor(0x6E, 0x6E, 0x6E, 0x00), JUtility::TColor(0xFF, 0x58, 0x00, 0x00), + JUtility::TColor(0x6C, 0x3E, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x32, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x7F, 0x00), JUtility::TColor(0x00, 0x7F, 0x00, 0x00), JUtility::TColor(0x55, 0x37, 0x14, 0x00), + JUtility::TColor(0x00, 0x00, 0x22, 0x00), JUtility::TColor(0x2B, 0x18, 0x22, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x46, 0x46, 0x41, 0x00), JUtility::TColor(0x46, 0x46, 0x41, 0x00), JUtility::TColor(0x46, 0x46, 0x41, 0x00), + JUtility::TColor(0x46, 0x46, 0x41, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), + }; + + static JUtility::TColor const white_color[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0x60, 0xFF, 0x00, 0xFF), JUtility::TColor(0x00, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0x00, 0xFF), JUtility::TColor(0xFF, 0x80, 0x80, 0xFF), JUtility::TColor(0xBE, 0x40, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xC0, 0x00, 0xFF), JUtility::TColor(0xC0, 0xC0, 0xC0, 0xFF), JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xD2, 0xAA, 0xFF), JUtility::TColor(0xEF, 0xF5, 0xC9, 0xFF), JUtility::TColor(0xB0, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xF0, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xF0, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xD7, 0xFF), + JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xC2, 0xFF), + JUtility::TColor(0xFF, 0x9D, 0x00, 0xFF), JUtility::TColor(0xC8, 0xC8, 0xC8, 0xFF), JUtility::TColor(0xFF, 0xD2, 0xAA, 0xFF), + JUtility::TColor(0xB0, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xEF, 0xF5, 0xC9, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xD7, 0xFF), + JUtility::TColor(0xD7, 0xCF, 0xF5, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x33, 0xFF), JUtility::TColor(0xC8, 0xC8, 0xC8, 0xFF), + JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), + JUtility::TColor(0xF5, 0xF5, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_lu[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), + JUtility::TColor(0xFF, 0x78, 0xAF, 0xFF), JUtility::TColor(0x5C, 0xB4, 0x16, 0xFF), JUtility::TColor(0xA4, 0xFF, 0x00, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x00, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0x78, 0xAF, 0xFF), + JUtility::TColor(0xA4, 0xFF, 0x00, 0xFF), JUtility::TColor(0x5C, 0xB4, 0x16, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x00, 0xFF), + JUtility::TColor(0xC9, 0xB4, 0xFF, 0xFF), JUtility::TColor(0x3C, 0x0A, 0x00, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), JUtility::TColor(0xFF, 0xA0, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_ru[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), + JUtility::TColor(0xFF, 0xFF, 0x73, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x2A, 0xFF), JUtility::TColor(0x98, 0xFF, 0x00, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x73, 0xFF), + JUtility::TColor(0x98, 0xFF, 0x00, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x2A, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0x39, 0xFF), JUtility::TColor(0xFF, 0xFF, 0x00, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0x00), JUtility::TColor(0xFF, 0xA0, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_ld[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0x78, 0x6E, 0x3C, 0xFF), + JUtility::TColor(0xFF, 0x00, 0x00, 0xFF), JUtility::TColor(0x3C, 0x32, 0x50, 0xFF), JUtility::TColor(0x00, 0x00, 0x74, 0xFF), + JUtility::TColor(0xFA, 0xC8, 0x9B, 0xFF), JUtility::TColor(0xFA, 0xC8, 0x9B, 0xFF), JUtility::TColor(0x46, 0x87, 0x00, 0xFF), + JUtility::TColor(0x5A, 0xB4, 0xB4, 0xFF), JUtility::TColor(0x5A, 0xB4, 0xB4, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0xFF, 0x00, 0x00, 0xFF), + JUtility::TColor(0x00, 0x00, 0x74, 0xFF), JUtility::TColor(0x3C, 0x32, 0x50, 0xFF), JUtility::TColor(0x46, 0x87, 0x00, 0xFF), + JUtility::TColor(0x3C, 0x32, 0x50, 0x49), JUtility::TColor(0xFF, 0xFF, 0x00, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), + JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), + JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0xE0, 0x00, 0xE0, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_rd[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0x78, 0x6E, 0x3C, 0xFF), + JUtility::TColor(0xFF, 0x96, 0x00, 0xFF), JUtility::TColor(0x55, 0x42, 0x00, 0xFF), JUtility::TColor(0x61, 0x48, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xAA, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xAA, 0xFF), JUtility::TColor(0xAF, 0x91, 0x23, 0xFF), + JUtility::TColor(0xE6, 0xFA, 0xFF, 0xFF), JUtility::TColor(0xE6, 0xFA, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0xFF, 0x96, 0x00, 0xFF), + JUtility::TColor(0x61, 0x48, 0xFF, 0xFF), JUtility::TColor(0x55, 0x42, 0x00, 0xFF), JUtility::TColor(0xAF, 0x91, 0x23, 0xFF), + JUtility::TColor(0x3C, 0x09, 0x4E, 0xFF), JUtility::TColor(0xBA, 0x98, 0x00, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), + JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0x00, 0x00, 0x00, 0xFF), + JUtility::TColor(0x00, 0x00, 0x00, 0xFF), JUtility::TColor(0xE0, 0x00, 0xE0, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + #else static GXColor const black_color[37] = { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x60, 0x00, 0x00}, {0x00, 0x00, 0xC0, 0x00}, {0xA0, 0x60, 0x00, 0x00}, {0xA0, 0x00, 0x00, 0x00}, {0x40, 0x00, 0x60, 0x00}, @@ -1098,6 +1201,7 @@ void dMeter2Info_c::set1stColor(u8 i_itemType, J2DPicture* i_pic) { {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF, 0xFF}, }; + #endif i_pic->setBlackWhite(*(JUtility::TColor*)&black_color[i_itemType], *(JUtility::TColor*)&white_color[i_itemType]); @@ -1108,6 +1212,104 @@ void dMeter2Info_c::set1stColor(u8 i_itemType, J2DPicture* i_pic) { } void dMeter2Info_c::set2ndColor(u8 i_itemType, J2DPicture* i_pic) { + // TODO: probably some way to rectify this for both versions + #if VERSION == VERSION_SHIELD_DEBUG + static JUtility::TColor const black_color[37] = { + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x86, 0xD4, 0x00), JUtility::TColor(0xE6, 0x1E, 0xFF, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), JUtility::TColor(0x00, 0x00, 0x00, 0x00), + JUtility::TColor(0x00, 0x00, 0x00, 0x00), + }; + + static JUtility::TColor const white_color[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xF5, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xC8, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_lu[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0x00, 0x00, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_ru[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0x00, 0xFF, 0xFF, 0x58), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x58), JUtility::TColor(0xFF, 0xFF, 0xFF, 0x58), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0x58), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_ld[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + + static JUtility::TColor const vertex_color_rd[37] = { + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xCD, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xCD, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + JUtility::TColor(0xFF, 0xFF, 0xFF, 0xFF), + }; + #else static GXColor const black_color[37] = { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, @@ -1203,6 +1405,7 @@ void dMeter2Info_c::set2ndColor(u8 i_itemType, J2DPicture* i_pic) { {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF, 0xFF}, }; + #endif i_pic->setBlackWhite(*(JUtility::TColor*)&black_color[i_itemType], *(JUtility::TColor*)&white_color[i_itemType]); @@ -1235,6 +1438,8 @@ void dMeter2Info_c::set3rdColor(u8 i_itemType, J2DPicture* i_pic) { } void dMeter2Info_c::set4thColor(u8 i_itemType, J2DPicture* i_pic) { + UNUSED(i_itemType); + i_pic->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); i_pic->setCornerColor( JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), @@ -1443,6 +1648,18 @@ u8 dMeter2Info_getPixel(f32 i_posX, f32 i_posY, f32 param_2, f32 param_3, f32 i_ return (var_r24 & 0x7000) != 0; } +bool dMeter2Info_isNextStage(const char* i_name, s16 i_roomNo, s16 i_point, s16 i_layer) { + if (strcmp(dComIfGp_getNextStageName(), i_name) == 0 + && dComIfGp_getNextStageRoomNo() == i_roomNo + && dComIfGp_getNextStagePoint() == i_point + && dComIfGp_getNextStageLayer() == i_layer + ) { + return true; + } + + return false; +} + void dMeter2Info_setCloth(u8 i_clothId, bool i_offItemBit) { switch (i_clothId) { case dItemNo_WEAR_CASUAL_e: @@ -1586,6 +1803,7 @@ u8 dMeter2Info_getNewLetterNum() { } int dMeter2Info_setNewLetterSender() { + int ret = 0; u8 check = 0; for (int i = 0; i < 0x40; i++) { @@ -1593,10 +1811,9 @@ int dMeter2Info_setNewLetterSender() { u16 letterEvent = dMenu_Letter::getLetterEventFlag(i); if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[letterEvent])) { if (check == 0) { - u16 letterName = dMenu_Letter::getLetterName(i); - dMsgObject_c::setLetterNameID(letterName); + dMsgObject_setLetterNameID(dMenu_Letter::getLetterName(i)); } else { - dMsgObject_c::setLetterNameID(0); + dMsgObject_setLetterNameID(0); return 0; } check++; @@ -1604,7 +1821,7 @@ int dMeter2Info_setNewLetterSender() { } } - return 0; + return ret; } int dMeter2Info_recieveLetter() { @@ -1636,6 +1853,33 @@ int dMeter2Info_recieveLetter() { return rv; } +#if WIDESCREEN_SUPPORT +f32 dMeter2Info_getWide2DPosX(f32* param_0) { + J2DOrthoGraph graf(0.0f, 0.0f, 640.0f, 456.0f, -1.0f, 1.0f); + graf.setOrtho(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), -1.0f, 1.0f); + JGeometry::TBox2* bounds = graf.getBounds(); + const JGeometry::TBox2* ortho = graf.getOrtho(); + + f32 var_f31 = 304.0f; + f32 var_f30 = 608.0f / (ortho->f.x - ortho->i.x); + f32 var_f29 = *param_0 - var_f31; + *param_0 = var_f29 * var_f30 + var_f31; + return *param_0; +} + +void dMeter2Info_onWide2D() { + g_ringHIO.updateOnWide(); + g_drawHIO.updateOnWide(); +} + +void dMeter2Info_offWide2D() { + g_ringHIO.updateOffWide(); + g_drawHIO.updateOffWide(); +} +#endif + +void dMeter2Info_set2DVibrationT() {} + void dMeter2Info_set2DVibration() {} void dMeter2Info_set2DVibrationM() {} diff --git a/src/d/d_meter_map.cpp b/src/d/d_meter_map.cpp index 1e0f7e397d..7e55d899fd 100644 --- a/src/d/d_meter_map.cpp +++ b/src/d/d_meter_map.cpp @@ -302,12 +302,12 @@ bool dMeterMap_c::isEventRunCheck() { f32 dMeterMap_c::getMapDispEdgeLeftX_Layout() { #if (PLATFORM_WII || PLATFORM_SHIELD) if (mDoGph_gInf_c::isWide()) { - return g_meter_mapHIO.mWideBottomLeftX + field_0x28; + return g_meter_mapHIO.mWideBottomLeftX + mSlidePositionOffset; } - return g_meter_mapHIO.mNormalBottomLeftX + field_0x28; + return g_meter_mapHIO.mNormalBottomLeftX + mSlidePositionOffset; #else - return field_0x28 + 35; + return mSlidePositionOffset + 35; #endif } @@ -349,14 +349,14 @@ s16 dMeterMap_c::getDispPosOutSide_OffsetX() { void dMeterMap_c::setDispPosInsideFlg_SE_On() { if (isEnableDispMapAndMapDispSizeTypeNo()) { dComIfGp_mapShow(); - field_0x2d = 1; + mMapIsInside = 1; field_0x2e = 7; } } void dMeterMap_c::setDispPosOutsideFlg_SE_On() { dComIfGp_mapHide(); - field_0x2d = 0; + mMapIsInside = 0; field_0x2e = 7; } @@ -456,44 +456,44 @@ void dMeterMap_c::_create(J2DScreen* unused) { field_0x2a = 0; if (dComIfGp_checkMapShow()) { - field_0x2d = 1; + mMapIsInside = 1; if (!isEnableDispMapAndMapDispSizeTypeNo()) { - field_0x2d = 0; + mMapIsInside = 0; } if (!isMapOpenCheck()) { - field_0x2d = 0; + mMapIsInside = 0; } } else { - field_0x2d = 0; + mMapIsInside = 0; } - if (field_0x2d != 0) { - field_0x2d = 1; - field_0x28 = getDispPosInside_OffsetX(); + if (mMapIsInside != 0) { + mMapIsInside = 1; + mSlidePositionOffset = getDispPosInside_OffsetX(); dMeter2Info_setMapStatus(1); } else { - field_0x2d = 0; - field_0x28 = getDispPosOutSide_OffsetX(); + mMapIsInside = 0; + mSlidePositionOffset = getDispPosOutSide_OffsetX(); dMeter2Info_setMapStatus(0); } field_0x2e = 0; - field_0x28 = 0; + mSlidePositionOffset = 0; field_0x30 = 0; /* dSv_event_flag_c::M_085 - Twilight Hyrule Field - Midna dialogue right before Boss Bug's Tear of Light appears */ field_0x2b = dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[118]); } void dMeterMap_c::setDispPosOutSide() { - field_0x2d = 0; - field_0x28 = getDispPosOutSide_OffsetX(); + mMapIsInside = 0; + mSlidePositionOffset = getDispPosOutSide_OffsetX(); } void dMeterMap_c::setDispPosInSide() { - field_0x2d = 1; - field_0x28 = getDispPosInside_OffsetX(); + mMapIsInside = 1; + mSlidePositionOffset = getDispPosInside_OffsetX(); } void dMeterMap_c::_delete() { @@ -506,7 +506,7 @@ void dMeterMap_c::_delete() { } if (isEnableDispMapAndMapDispSizeTypeNo()) { - if (field_0x2d != 0) { + if (mMapIsInside != 0) { dComIfGp_mapShow(); } else { dComIfGp_mapHide(); @@ -548,16 +548,16 @@ void dMeterMap_c::_move(u32 param_0) { ctrlShowMap(); } - if (field_0x2d != 0) { - if (field_0x28 != getDispPosInside_OffsetX()) { - if (!cLib_addCalcAngleS(&field_0x28, getDispPosInside_OffsetX(), 2, 60, 10)) { + if (mMapIsInside != 0) { + if (mSlidePositionOffset != getDispPosInside_OffsetX()) { + if (!cLib_addCalcAngleS(&mSlidePositionOffset, getDispPosInside_OffsetX(), 2, 60, 10)) { #if DEBUG cLib_checkBit((int)field_0x2e, 4); #endif } } } else { - cLib_addCalcAngleS(&field_0x28, getDispPosOutSide_OffsetX(), 2, 60, 10); + cLib_addCalcAngleS(&mSlidePositionOffset, getDispPosOutSide_OffsetX(), 2, 60, 10); } Vec map_pos = dMapInfo_n::getMapPlayerPos(); @@ -579,8 +579,8 @@ void dMeterMap_c::_move(u32 param_0) { mSizeH = (s16)sizeH; #endif - field_0x18 = field_0x28 + getMapDispEdgeLeftX_Layout(); - field_0x1c = getMapDispEdgeBottomY_Layout() - mSizeH; + mDrawPosX = mSlidePositionOffset + getMapDispEdgeLeftX_Layout(); + mDrawPosY = getMapDispEdgeBottomY_Layout() - mSizeH; mMap->_move(map_pos.x, map_pos.z, stayNo, map_pos.y); field_0x30 = dComIfGp_event_runCheck(); @@ -593,6 +593,14 @@ void dMeterMap_c::_draw() { dComIfGd_set2DOpa(this); } #else +#if TARGET_PC + // Optimization: don't draw map if it's off-screen/invisible. + // Especially useful in debug builds on Hyrule field etc., it's slow! + if ((!mMapIsInside && mSlidePositionOffset == getDispPosOutSide_OffsetX()) || mMapAlpha == 0) { + return; + } +#endif + mMap->_draw(); dComIfGd_set2DOpa(this); #endif @@ -609,8 +617,8 @@ void dMeterMap_c::draw() { graf->setup2D(); f32 sizeX = mSizeW; f32 sizeY = mSizeH; - f32 tmp2 = field_0x18; - f32 tmp3 = field_0x1c; + f32 drawPosX = mDrawPosX; + f32 drawPosY = mDrawPosY; u8 alpha = mMapAlpha; #if DEBUG @@ -620,7 +628,7 @@ void dMeterMap_c::draw() { #endif mMapJ2DPicture->setAlpha(alpha); - mMapJ2DPicture->draw(tmp2, tmp3, sizeX, sizeY, false, false, false); + mMapJ2DPicture->draw(drawPosX, drawPosY, sizeX, sizeY, false, false, false); mMapJ2DPicture->calcMtx(); } } @@ -640,7 +648,7 @@ void dMeterMap_c::ctrlShowMap() { dMeter2Info_getPauseStatus() == 2 || dMeter2Info_getPauseStatus() == 6) { #if !DEBUG - if (dMeter2Info_getMapStatus() == 0 && field_0x2d == 0) { + if (dMeter2Info_getMapStatus() == 0 && mMapIsInside == 0) { setDispPosInsideFlg_SE_On(); Z2GetAudioMgr()->seStart(Z2SE_SY_MAP_OPEN_S, NULL, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0); @@ -653,7 +661,7 @@ void dMeterMap_c::ctrlShowMap() { #if DEBUG dMeter2Info_getMapStatus() == 0 && #else - dMeter2Info_getMapStatus() == 1 && field_0x2d != 0 && + dMeter2Info_getMapStatus() == 1 && mMapIsInside != 0 && #endif isFmapScreen() ) { @@ -690,7 +698,7 @@ void dMeterMap_c::ctrlShowMap() { dMeter2Info_resetPauseStatus(); if (isDmapScreen()) { #if !DEBUG - if (dMeter2Info_getMapStatus() == 0 && field_0x2d == 0) { + if (dMeter2Info_getMapStatus() == 0 && mMapIsInside == 0) { setDispPosInsideFlg_SE_On(); Z2GetAudioMgr()->seStart(Z2SE_SY_MAP_OPEN_S, NULL, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0); @@ -703,7 +711,7 @@ void dMeterMap_c::ctrlShowMap() { #if DEBUG dMeter2Info_getMapStatus() == 0 #else - dMeter2Info_getMapStatus() == 1 && field_0x2d != 0 + dMeter2Info_getMapStatus() == 1 && mMapIsInside != 0 #endif ) { dMeter2Info_setMapStatus(6); diff --git a/src/d/d_msg_object.cpp b/src/d/d_msg_object.cpp index 9a8f6d594a..8836acff10 100644 --- a/src/d/d_msg_object.cpp +++ b/src/d/d_msg_object.cpp @@ -656,7 +656,7 @@ void dMsgObject_c::setMessageIndexDemo(u32 revoMsgIndex, bool param_2) { u32 dMsgObject_c::getMessageIndex(u32 param_0) { u32 i = 0; JMSMesgInfo_c* pMsg = (JMSMesgInfo_c*)((char*)mpMsgDt + 0x20); - u32 msgIndexCount = *((u16*)((char*)mpMsgDt + 0x28)); + u32 msgIndexCount = *((BE(u16)*)((char*)mpMsgDt + 0x28)); int rv; for (; i < msgIndexCount; i++) { if (pMsg->entries[i].message_id == param_0) { @@ -683,12 +683,12 @@ u32 dMsgObject_c::getRevoMessageIndex(u32 param_1) { JUT_ASSERT(1916, groupID==s_groupID || groupID == 0) changeGroup(groupID); pMsg = (JMSMesgInfo_c*)((char*)mpMsgDt + 0x20); - msgIndexCount = *((u16*)((char*)mpMsgDt + 0x28)); + msgIndexCount = *((BE(u16)*)((char*)mpMsgDt + 0x28)); for (; i < msgIndexCount; i++) { if (pMsg->entries[i].message_id == param_1) { s8* ptr = (s8*)pMsg + pMsg->header.size + pMsg->entries[i].string_offset + 8; if (ptr[0] == 26 && ptr[2] == 3 && (s8)ptr[4] == 0) { - rv = pMsg->entries[*(int*)(ptr + 5)].message_id; + rv = pMsg->entries[*(BE(int)*)(ptr + 5)].message_id; } else { rv = param_1; } @@ -706,7 +706,7 @@ u32 dMsgObject_c::getRevoMessageIndex(u32 param_1) { u32 dMsgObject_c::getMessageIndexAlways(u32 param_0) { u32 i = 0; JMSMesgInfo_c* pMsg = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); - u32 msgIndexCount = *((u16*)((char*)mpMsgRes + 0x28)); + u32 msgIndexCount = *((BE(u16)*)((char*)mpMsgRes + 0x28)); int rv; for (; i < msgIndexCount; i++) { if (pMsg->entries[i].message_id == param_0) { diff --git a/src/d/d_path.cpp b/src/d/d_path.cpp index a01cfdc8a6..b1fa3b7891 100644 --- a/src/d/d_path.cpp +++ b/src/d/d_path.cpp @@ -8,7 +8,38 @@ #include "d/d_path.h" #include "d/d_com_inf_game.h" -dPnt* dPath_GetPnt(dPath const* path, int pnt_index) { +#if DEBUG +#include "d/d_debug_viewer.h" +#endif + +class dPath_HIO : public JORReflexible { +public: + dPath_HIO() {} + ~dPath_HIO(); + + void genMessage(JORMContext* mctx) { + mctx->genCheckBox("デバッグ表示", &flags, 2); + mctx->genSlider("部屋番号", &roomNo, -2, 64); + mctx->genLabel("-3=現在プレイヤーのいる部屋, -2=旧常駐、-1=常駐", 0); + } + + void Ct() { + flags = 0; + roomNo = -3; + } + + int GetRoomNo() { return roomNo; } + bool ChkDispLine() { return flags & 2; } + + /* 0x4 */ s8 id; + /* 0x6 */ u16 flags; + /* 0x8 */ s16 roomNo; +}; + +dPnt* dPath_GetPnt(const dPath* path, int pnt_index) { + JUT_ASSERT(27, path != NULL); + JUT_ASSERT(28, 0 <= pnt_index && pnt_index < path->m_num); + if (path == NULL || path->m_points == NULL || pnt_index < 0 || pnt_index >= path->m_num) { return NULL; } @@ -17,116 +48,212 @@ dPnt* dPath_GetPnt(dPath const* path, int pnt_index) { } dPath* dPath_GetRoomPath(int path_index, int room_no) { - dStage_dPath_c* path; + dStage_dPath_c* pd; if (room_no == -1) { - path = dComIfGp_getStage()->getPath2Inf(); + dStage_dt_c* stage = dComIfGp_getStage(); + pd = stage->getPath2Inf(); } else { + JUT_ASSERT(58, 0 <= room_no && room_no < 64); dStage_roomDt_c* roomDt = dComIfGp_roomControl_getStatusRoomDt(room_no); if (roomDt == NULL) { return NULL; } - path = roomDt->getPath2Inf(); + pd = roomDt->getPath2Inf(); } - if (path == NULL || path_index < 0 || path_index >= path->m_num) { + if (pd == NULL || path_index < 0 || path_index >= pd->num) { return NULL; } - return &path->m_path[path_index]; + return &pd->m_path[path_index]; } -dPath* dPath_GetNextRoomPath(dPath const* p_path, int room_no) { - dStage_dPath_c* path; +dPath* dPath_GetNextRoomPath(const dPath* path, int room_no) { + dStage_dPath_c* pd; if (room_no == -1) { - path = dComIfGp_getStage()->getPath2Inf(); + dStage_dt_c* stage = dComIfGp_getStage(); + pd = stage->getPath2Inf(); } else { dStage_roomDt_c* roomDt = dComIfGp_roomControl_getStatusRoomDt(room_no); if (roomDt == NULL) { return NULL; } - path = roomDt->getPath2Inf(); + pd = roomDt->getPath2Inf(); } - int next_id = p_path->m_nextID; - if (path == NULL || next_id == 0xFFFF) { + int next_id = path->m_nextID; + if (pd == NULL || next_id == 0xFFFF) { return NULL; } - if (next_id < 0 || next_id >= path->m_num) { + JUT_ASSERT(111, 0 <= next_id && next_id < pd->num); + if (next_id < 0 || next_id >= pd->num) { return NULL; } - return &path->m_path[next_id]; + return &pd->m_path[next_id]; } #if !PLATFORM_GCN // Fakematch due to differing return type on non-GCN platforms -int dPath_GetPolyRoomPathVec(cBgS_PolyInfo const& poly, cXyz* p_pathVec, int* param_2) { +int dPath_GetPolyRoomPathVec(const cBgS_PolyInfo& polyinfo, cXyz* vec, int* param_2) #else -u8 dPath_GetPolyRoomPathVec(cBgS_PolyInfo const& poly, cXyz* p_pathVec, int* param_2) { +u8 dPath_GetPolyRoomPathVec(const cBgS_PolyInfo& polyinfo, cXyz* vec, int* param_2) #endif - int roomId = dComIfG_Bgsp().GetRoomId(poly); - int roomPathId = dComIfG_Bgsp().GetRoomPathId(poly); +{ + int room_no = dComIfG_Bgsp().GetRoomId(polyinfo); + int path_idx = dComIfG_Bgsp().GetRoomPathId(polyinfo); - p_pathVec->x = 0.0f; - p_pathVec->y = 0.0f; - p_pathVec->z = 0.0f; + vec->x = 0.0f; + vec->y = 0.0f; + vec->z = 0.0f; *param_2 = 0; - if (roomId == -1) { + if (room_no == -1) { return 0; } - dPath* path = dPath_GetRoomPath(roomPathId, roomId); + dPath* path = dPath_GetRoomPath(path_idx, room_no); if (path == NULL) { return 0; } - if (path->field_0x6 != 0xFF && dComIfGs_isSwitch(path->field_0x6, roomId)) { + if (path->swbit != 0xFF && dComIfGs_isSwitch(path->swbit, room_no)) { return 0; } - int pnt_no = dComIfG_Bgsp().GetRoomPathPntNo(poly); + int pnt_no = dComIfG_Bgsp().GetRoomPathPntNo(polyinfo); if (pnt_no == 0xFF || pnt_no < 0 || pnt_no >= path->m_num) { return 0; } - dPnt* pnt_start = path->m_points; - dPnt* pnt_end = &pnt_start[pnt_no]; + dPnt* pnt_end = &path->m_points[pnt_no]; dPnt* pnt_begin; if (pnt_no == path->m_num - 1) { - pnt_begin = pnt_start; + pnt_begin = path->m_points; } else { - pnt_begin = &pnt_start[pnt_no + 1]; + pnt_begin = &path->m_points[pnt_no + 1]; } - p_pathVec->x = pnt_begin->m_position.x - pnt_end->m_position.x; - p_pathVec->y = pnt_begin->m_position.y - pnt_end->m_position.y; - p_pathVec->z = pnt_begin->m_position.z - pnt_end->m_position.z; + vec->x = pnt_begin->m_position.x - pnt_end->m_position.x; + vec->y = pnt_begin->m_position.y - pnt_end->m_position.y; + vec->z = pnt_begin->m_position.z - pnt_end->m_position.z; *param_2 = path->field_0x4; return 1; } +#if DEBUG +dPath_HIO::~dPath_HIO() {} + +static dPath_HIO s_hio; +#endif + #if VERSION == VERSION_SHIELD_DEBUG void dPath_Ct() { #if DEBUG + s_hio.Ct(); + s_hio.id = mDoHIO_CREATE_CHILD("レール", &s_hio); #endif } void dPath_Dt() { - #if DEBUG - #endif + mDoHIO_DELETE_CHILD(s_hio.id); } void dPath_Move() {} void dPath_Draw() { #if DEBUG + if (s_hio.ChkDispLine()) { + static int start_counter; + int counter = start_counter / 20; + dStage_dPath_c* pd; + + int hio_roomNo = s_hio.GetRoomNo(); + if (hio_roomNo == -3) { + int roomNo = dComIfGp_roomControl_getStayNo(); + dStage_roomDt_c* roomDt = dComIfGp_roomControl_getStatusRoomDt(roomNo); + if (roomDt == NULL) { + return; + } + + pd = roomDt->getPath2Inf(); + } else if (hio_roomNo == -2) { + pd = dComIfGp_getStage()->getPathInf(); + } else if (hio_roomNo == -1) { + pd = dComIfGp_getStage()->getPath2Inf(); + } else { + dStage_roomDt_c* roomDt = dComIfGp_roomControl_getStatusRoomDt(hio_roomNo); + if (roomDt == NULL) { + return; + } + + pd = roomDt->getPath2Inf(); + } + + if (pd != NULL) { + dPath* path = pd->m_path; + for (int i = 0; i < pd->num; i++) { + if (path->m_num >= 1) { + dPnt* pnt = path->m_points; + cXyz start_pos; + cXyz end_pos; + + for (int j = 0; j < path->m_num - 1; j++) { + start_pos.set(pnt[0].m_position); + end_pos.set(pnt[1].m_position); + + if (counter == 0) { + dDbVw_drawLineOpa(start_pos, end_pos, (GXColor){0xFF, 0xFF, 0xFF, 0xFF}, TRUE, 12); + } else { + dDbVw_drawLineOpa(start_pos, end_pos, (GXColor){0xFF, 0, 0, 0xFF}, TRUE, 12); + } + + counter++; + if (counter >= 8) { + counter = 0; + } + + pnt++; + } + + if (dPath_ChkClose(path)) { + start_pos.set(pnt[0].m_position); + end_pos.set(path[1].m_points->m_position); + + if (counter == 0) { + dDbVw_drawLineOpa(start_pos, end_pos, (GXColor){0xFF, 0xFF, 0xFF, 0xFF}, TRUE, 12); + } else { + dDbVw_drawLineOpa(start_pos, end_pos, (GXColor){0xFF, 0, 0, 0xFF}, TRUE, 12); + } + + counter++; + if (counter >= 8) { + counter = 0; + } + } + } + + path++; + } + } + + start_counter--; + if (start_counter < 0) { + start_counter = 160; + } + } #endif } + +static void dummy() { + cXyz pos; + GXColor color; + dDbVw_drawSphereOpa(pos, 0.0f, color, 0); +} #endif diff --git a/src/d/d_resorce.cpp b/src/d/d_resorce.cpp index 1dce982025..ab21e140c0 100644 --- a/src/d/d_resorce.cpp +++ b/src/d/d_resorce.cpp @@ -20,6 +20,8 @@ #include #include +#include "dusk/logging.h" + #ifndef __MWERKS__ #include "dusk/extras.h" #endif diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 53f610267f..057bcdf4ff 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -22,6 +22,7 @@ #include #include +#include "dusk/logging.h" #include "dusk/string.hpp" #if TARGET_PC #include @@ -391,6 +392,16 @@ static void dummy1(dStage_roomControl_c* roomControl) { } JKRExpHeap* dStage_roomControl_c::createMemoryBlock(int i_blockIdx, u32 i_heapSize) { + #if TARGET_PC + // Cave of Ordeals crashes around floor 29 due to no free heap space + // Increasing the size here avoids that, though its ugly. maybe TODO a better fix + if (strcmp(dComIfGp_getStartStageName(), "D_SB01") == 0) { + u32 prev = i_heapSize; + i_heapSize *= 2; + DuskLog.warn("Doubling heap size for D_SB01... ({}) -> ({})", prev, i_heapSize); + } + #endif + if (mMemoryBlock[i_blockIdx] == NULL) { mMemoryBlock[i_blockIdx] = JKRCreateExpHeap(i_heapSize, mDoExt_getArchiveHeap(), false); JKRHEAP_NAMEF(mMemoryBlock[i_blockIdx], "Room control memory block %d", i_blockIdx); @@ -2136,7 +2147,7 @@ static int dStage_pathInfoInit(dStage_dt_c* i_stage, void* i_data, int entryNum, i_stage->setPathInfo(path_c); - for (int i = 0; i < path_c->m_num; i++) { + for (int i = 0; i < path_c->num; i++) { #if TARGET_PC path->m_points.setBase(i_stage->getPntInf()->m_pnt_offset); #else @@ -2165,7 +2176,7 @@ static int dStage_rpatInfoInit(dStage_dt_c* i_stage, void* i_data, int i_num, vo dPath* pPath = pStagePath->m_path; i_stage->setPath2Info(pStagePath); - for (s32 i = 0; i < pStagePath->m_num; pPath++, i++, (void)0) { + for (s32 i = 0; i < pStagePath->num; pPath++, i++, (void)0) { #if TARGET_PC pPath->m_points.setBase(i_stage->getPnt2Inf()->m_pnt_offset); #else diff --git a/src/d/d_vib_pattern.cpp b/src/d/d_vib_pattern.cpp index d8263b45bd..6c06016cf5 100644 --- a/src/d/d_vib_pattern.cpp +++ b/src/d/d_vib_pattern.cpp @@ -59,3 +59,30 @@ const vib_pattern dVibration_c::CQ_patt[VIBMODE_Q_MAX] = { /* VIBMODE_Q_POWER8 */ {4, 32, 0x6B6D6B6D}, /* VIBMODE_Q_HORSE */ {0, 27, 0x20201000}, }; + +const char* shock_names[VIBMODE_S_MAX] = { + "VIBMODE_S_CUSTOM", + "VIBMODE_S_POWER1", + "VIBMODE_S_POWER2", + "VIBMODE_S_POWER3", + "VIBMODE_S_POWER4", + "VIBMODE_S_POWER5", + "VIBMODE_S_POWER6", + "VIBMODE_S_POWER7", + "VIBMODE_S_POWER8", + "VIBMODE_S_DOKUTT", + "VIBMODE_S_FOR2D", +}; + +const char* quake_names[VIBMODE_Q_MAX] = { + "VIBMODE_Q_CUSTOM", + "VIBMODE_Q_POWER1", + "VIBMODE_Q_POWER2", + "VIBMODE_Q_POWER3", + "VIBMODE_Q_POWER4", + "VIBMODE_Q_POWER5", + "VIBMODE_Q_POWER6", + "VIBMODE_Q_POWER7", + "VIBMODE_Q_POWER8", + "VIBMODE_Q_HORSE", +}; diff --git a/src/d/d_vibration.cpp b/src/d/d_vibration.cpp index 70a1a04779..a145ae878c 100644 --- a/src/d/d_vibration.cpp +++ b/src/d/d_vibration.cpp @@ -5,6 +5,7 @@ #include "f_op/f_op_camera_mng.h" #include "m_Do/m_Do_controller_pad.h" #include "SSystem/SComponent/c_math.h" +#include "d/d_s_play.h" #include #define RESET_FRAME -99 @@ -21,6 +22,13 @@ u16* makedata(u16* data, u32 pattern, s32 length) { data[1] = pattern >> 16; data[2] = pattern; data[3] = 0; + +#if TARGET_PC + data[0] = BSWAP16(data[0]); + data[1] = BSWAP16(data[1]); + data[2] = BSWAP16(data[2]); +#endif + return data; } @@ -31,27 +39,30 @@ s32 rollshift(u32 pattern, s32 length, s32 index) { #else index %= length; #endif - return (pattern >> index) | (pattern << (length - index)); + u32 var_r31 = pattern; + return (var_r31 >> index) | (var_r31 << (length - index)); } u32 makebits(u32 bits, s32 length, s32 numbits) { + bits &= (-1 << (32 - length)); + u32 mask = bits; s32 i; - u32 mask = bits & (-1 << (32 - length)); - bits = mask; for (i = length; i < numbits; i += length) { - bits = mask | (bits >> length); + mask = bits | (mask >> length); } - return bits; + return mask; } u32 randombit(s32 rounds, s32 length) { u32 value = 0; + int i; - for (int i = 0; i < rounds; i++) { + for (i = 0; i < rounds; i++) { value |= 0x40000000 >> (u32)(length * cM_rnd()); } + return value; } }; @@ -70,10 +81,13 @@ int dVibration_c::Run() { mMotor.mQuake.field_0x0 |= 1; } - mMotor.mQuake.mFrame = RESET_FRAME; - mMotor.mShock.mFrame = RESET_FRAME; + mMotor.mShock.mFrame = mMotor.mQuake.mFrame = RESET_FRAME; } + #if DEBUG + testShake(); + #endif + if ((mCamera.mShock.field_0x0 & 1) && mCamera.mShock.mFrame != RESET_FRAME) { mCamera.mShock.mFrame = 0; mCamera.mShock.mVibMode = VIBMODE_S_NONE; @@ -85,6 +99,8 @@ int dVibration_c::Run() { } if (mCamera.mShock.mFrame == 0 || mCamera.mQuake.mFrame == 0) { + s32 pattern; + u32 sp1C = 0; u32 rumble = 0; if (mCamera.mShock.mVibMode == VIBMODE_S_NONE || (mCamera.mShock.field_0x0 & 1)) { mCamera.mShock.mFrame = RESET_FRAME; @@ -104,7 +120,7 @@ int dVibration_c::Run() { rumble |= RUMBLE_QUAKE; } - s32 length, pattern, bits, flags; + s32 length, bits, flags; switch (rumble) { case RUMBLE_SHOCK: length = mCamera.mShock.mLength; @@ -119,6 +135,12 @@ int dVibration_c::Run() { if (dComIfGp_getCamera(0) != NULL && dComIfGp_getCamera(0)->field_0x22f == 0x47) { dCam_getBody()->StartShake(length, (u8*)&pattern, flags, mCamera.mShock.mPos.norm()); } + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: start camera(%d) %x %d\n", mFrame, rumble, pattern, length); + } + #endif break; case RUMBLE_QUAKE: length = mCamera.mQuake.mLength; @@ -133,11 +155,18 @@ int dVibration_c::Run() { if (dComIfGp_getCamera(0) != NULL && dComIfGp_getCamera(0)->field_0x22f == 0x47) { dCam_getBody()->StartShake(length, (u8*)&pattern, flags, mCamera.mQuake.mPos.norm()); } + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: start camera(%d) %x %d\n", mFrame, rumble, pattern, length); + } + #endif break; case RUMBLE_SHOCK | RUMBLE_QUAKE: pattern = mCamera.mShock.mPattern << mCamera.mShock.mFrame; length = mCamera.mShock.mLength - mCamera.mShock.mFrame; - pattern |= rollshift(makebits(mCamera.mQuake.mPattern, mCamera.mQuake.mLength, length), length, mFrame); + sp1C = makebits(mCamera.mQuake.mPattern, mCamera.mQuake.mLength, length); + pattern |= rollshift(sp1C, length, mFrame); pattern |= randombit(mCamera.mShock.mRounds > mCamera.mQuake.mRounds ? mCamera.mShock.mRounds : mCamera.mQuake.mRounds, length); flags = mCamera.mShock.mFlags | mCamera.mQuake.mFlags; @@ -149,13 +178,24 @@ int dVibration_c::Run() { dCam_getBody()->StartShake(length, (u8*)&pattern, flags, cXyz(mCamera.mShock.mPos + mCamera.mQuake.mPos).norm()); } - mCamera.mQuake.mFrame = 0; - mCamera.mShock.mFrame = 0; + mCamera.mShock.mFrame = mCamera.mQuake.mFrame = 0; + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: start camera(%d) %x %d\n", mFrame, rumble, pattern, length); + } + #endif break; default: if (dComIfGp_getCamera(0) != NULL && dComIfGp_getCamera(0)->field_0x22f == 0x47) { dCam_getBody()->StopShake(); } + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: stop camera\n", mFrame); + } + #endif break; } } @@ -171,6 +211,7 @@ int dVibration_c::Run() { } if (mMotor.mShock.mFrame == 0 || mMotor.mQuake.mFrame == 0) { + s32 sp14 = 0; u32 rumble = 0; if (mMotor.mShock.mVibMode == VIBMODE_S_NONE || (mMotor.mShock.field_0x0 & 1)) { mMotor.mShock.mFrame = RESET_FRAME; @@ -199,39 +240,64 @@ int dVibration_c::Run() { pattern = mMotor.mShock.mPattern; pattern |= randombit(mMotor.mShock.mRounds, length); mMotor.mShock.mStopFrame = length; - mDoCPd_c::startMotorWave(PAD_1, makedata(data, pattern, length), JUTGamePad::CRumble::VAL_0, 60); + mDoCPd_c::startMotorWave(PAD_1, (u8*)makedata(data, pattern, length), JUTGamePad::CRumble::VAL_0, 60); + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: start motor (%d) %x %d\n", mFrame, rumble, pattern, length); + } + #endif break; case RUMBLE_QUAKE: length = mMotor.mQuake.mLength; pattern = rollshift(mMotor.mQuake.mPattern, length, mFrame); pattern |= randombit(mMotor.mQuake.mRounds, length); mMotor.mQuake.mStopFrame = INT_MAX; - mDoCPd_c::startMotorWave(PAD_1, makedata(data, pattern, length), JUTGamePad::CRumble::VAL_1, 60); + + OS_REPORT("d_vibration mDoCPd_c::startMotorWave\n"); + + mDoCPd_c::startMotorWave(PAD_1, (u8*)makedata(data, pattern, length), JUTGamePad::CRumble::VAL_1, 60); + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: start motor (%d) %x %d\n", mFrame, rumble, pattern, length); + } + #endif break; case RUMBLE_SHOCK | RUMBLE_QUAKE: pattern = mMotor.mShock.mPattern << mMotor.mShock.mFrame; length = mMotor.mShock.mLength - mMotor.mShock.mFrame; - pattern |= rollshift(makebits(mMotor.mQuake.mPattern, mMotor.mQuake.mLength, length), length, mFrame); + sp14 = makebits(mMotor.mQuake.mPattern, mMotor.mQuake.mLength, length); + pattern |= rollshift(sp14, length, mFrame); pattern |= randombit(mMotor.mShock.mRounds > mMotor.mQuake.mRounds ? mMotor.mShock.mRounds : mMotor.mQuake.mRounds, length); mMotor.mQuake.mStopFrame = length; mMotor.mShock.mStopFrame = length; - mMotor.mQuake.mFrame = 0; - mMotor.mShock.mFrame = 0; - mDoCPd_c::startMotorWave(PAD_1, makedata(data, pattern, length), JUTGamePad::CRumble::VAL_0, 60); + mMotor.mShock.mFrame = mMotor.mQuake.mFrame = 0; + + mDoCPd_c::startMotorWave(PAD_1, (u8*)makedata(data, pattern, length), JUTGamePad::CRumble::VAL_0, 60); + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: start motor (%d) %x %d\n", mFrame, rumble, pattern, length); + } + #endif break; default: mDoCPd_c::stopMotorWave(PAD_1); mDoCPd_c::stopMotor(PAD_1); - mMotor.mQuake.mStopFrame = RESET_FRAME; - mMotor.mShock.mStopFrame = RESET_FRAME; + mMotor.mShock.mStopFrame = mMotor.mQuake.mStopFrame = RESET_FRAME; + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: stop motor\n", mFrame); + } + #endif break; } } - mCamera.mQuake.field_0x0 = 0; - mCamera.mShock.field_0x0 = 0; - mMotor.mQuake.field_0x0 = 0; - mMotor.mShock.field_0x0 = 0; + mCamera.mShock.field_0x0 = mCamera.mQuake.field_0x0 = 0; + mMotor.mShock.field_0x0 = mMotor.mQuake.field_0x0 = 0; if (mCamera.mShock.mFrame >= 0) { mCamera.mShock.mFrame++; @@ -259,9 +325,22 @@ int dVibration_c::Run() { if (mMotor.mQuake.mFrame >= 930) { mMotor.mQuake.mFrame = 0; + + #if DEBUG + if (mVibTest.m_displayDbg & 0x8000) { + OS_REPORT("vibration: %06d: stop motor @ limit restart\n", mFrame); + } + #endif } else if (mMotor.mQuake.mFrame >= 900) { mDoCPd_c::stopMotorWave(PAD_1); mDoCPd_c::stopMotor(PAD_1); + + #if DEBUG + if ((mVibTest.m_displayDbg & 0x8000) && mMotor.mQuake.mFrame == 900) { + OS_REPORT("vibration: %06d: stop motor @ limit\n", mFrame); + } + #endif + mMotor.mQuake.mFrame++; } else if (mMotor.mQuake.mFrame >= 0) { mMotor.mQuake.mFrame++; @@ -297,6 +376,12 @@ bool dVibration_c::StartShock(int i_vibmode, int i_flags, cXyz i_pos) { ret = true; } + #if DEBUG + if ((mVibTest.m_displayDbg & 0x8000) && ret) { + OS_REPORT("vibration: %06d: start shock %d %d\n", mFrame, i_vibmode, i_flags); + } + #endif + return ret; } @@ -322,6 +407,12 @@ bool dVibration_c::StartQuake(int i_vibmode, int i_flags, cXyz i_pos) { ret = true; } + #if DEBUG + if ((mVibTest.m_displayDbg & 0x8000) && ret) { + OS_REPORT("vibration: %06d: start quake %d %d\n", mFrame, i_vibmode, i_flags); + } + #endif + return ret; } @@ -354,6 +445,12 @@ bool dVibration_c::StartQuake(const u8* i_pattern, int i_rounds, int i_flags, cX ret = true; } + #if DEBUG + if ((mVibTest.m_displayDbg & 0x8000) && ret) { + OS_REPORT("vibration: %06d: start quake %x %d %d\n", mFrame, bits, i_rounds, i_flags); + } + #endif + return ret; } @@ -374,9 +471,114 @@ int dVibration_c::StopQuake(int i_flags) { ret = TRUE; } + #if DEBUG + if ((mVibTest.m_displayDbg & 0x8000) && ret) { + OS_REPORT("vibration: %06d: stop quake %d\n", mFrame, i_flags); + } + #endif + return ret; } +#if DEBUG +int dVibration_c::testShake() { + int var_r29, var_r28; + int ret = FALSE; + s32 cam_bits, cam_len, cam_rounds; + s32 motor_bits, motor_len, motor_rounds; + + switch (mVibTest.field_0x10) { + case 10: + if (mVibTest.m_vibswitch >= 1 && mVibTest.m_vibswitch < 100) { + var_r29 = mVibTest.m_vibswitch; + cam_bits = CS_patt[var_r29].bits; + cam_len = CS_patt[var_r29].length; + cam_rounds = CS_patt[var_r29].rounds; + + motor_bits = MS_patt[var_r29].bits; + motor_len = MS_patt[var_r29].length; + motor_rounds = MS_patt[var_r29].rounds; + + OS_REPORT("vibration: TEST C b %x l %d r %d\n", cam_bits, cam_len, cam_rounds); + OS_REPORT("(SHOCK) m %2d M b %x l %d r %d\n", motor_bits, motor_len, motor_rounds); + } else { + motor_bits = cam_bits = (mVibTest.m_pattern << 0x10) | mVibTest.m_pattern2; + motor_len = cam_len = mVibTest.m_length; + motor_rounds = cam_rounds = mVibTest.m_randombit; + } + + if (mVibTest.field_0xa & 0x7E) { + mCamera.mShock.mVibMode = 0; + mCamera.mShock.mFrame = 0; + mCamera.mShock.mFlags = mVibTest.field_0xa; + mCamera.mShock.mPos = cXyz(0.0f, 1.0f, 0.0f); + mCamera.mShock.mPattern = cam_bits; + mCamera.mShock.mLength = cam_len; + mCamera.mShock.mRounds = cam_rounds; + } + + if (mVibTest.field_0xa & 1) { + mMotor.mShock.mVibMode = 0; + mMotor.mShock.mFrame = 0; + mMotor.mShock.mPattern = motor_bits; + mMotor.mShock.mLength = motor_len; + mMotor.mShock.mRounds = motor_rounds; + } + + mVibTest.field_0x10 = 0; + ret = TRUE; + break; + case 20: + if (mVibTest.m_vibswitch >= 100 && mVibTest.m_vibswitch < 200) { + var_r28 = mVibTest.m_vibswitch - 100; + cam_bits = CQ_patt[var_r28].bits; + cam_len = CQ_patt[var_r28].length; + cam_rounds = CQ_patt[var_r28].rounds; + + motor_bits = MQ_patt[var_r28].bits; + motor_len = MQ_patt[var_r28].length; + motor_rounds = MQ_patt[var_r28].rounds; + + OS_REPORT("vibration: TEST C b %x l %d r %d\n", cam_bits, cam_len, cam_rounds); + OS_REPORT("(QUAKE) m %2d M b %x l %d r %d\n", motor_bits, motor_len, motor_rounds); + } else { + motor_bits = cam_bits = (mVibTest.m_pattern << 0x10) | mVibTest.m_pattern2; + motor_len = cam_len = mVibTest.m_length; + motor_rounds = cam_rounds = mVibTest.m_randombit; + } + + if (mVibTest.field_0xa & 0x7E) { + mCamera.mQuake.mVibMode = 0; + mCamera.mQuake.mFrame = 0; + mCamera.mQuake.mFlags = mVibTest.field_0xa; + mCamera.mQuake.mPos = cXyz(0.0f, 1.0f, 0.0f); + mCamera.mQuake.mPattern = cam_bits; + mCamera.mQuake.mLength = cam_len; + mCamera.mQuake.mRounds = cam_rounds; + } + + if (mVibTest.field_0xa & 1) { + mMotor.mQuake.mVibMode = 0; + mMotor.mQuake.mFrame = 0; + mMotor.mQuake.mPattern = motor_bits; + mMotor.mQuake.mLength = motor_len; + mMotor.mQuake.mRounds = motor_rounds; + } + + mVibTest.field_0x10 = 0; + ret = TRUE; + break; + case 21: + OS_REPORT("vibration: TEST STOP\n"); + StopQuake(0x1F); + mVibTest.field_0x10 = 0; + break; + } + + return ret; +} +#endif + void dVibration_c::Kill() { mDoCPd_c::stopMotorWaveHard(PAD_1); mDoCPd_c::stopMotorHard(PAD_1); @@ -388,30 +590,18 @@ bool dVibration_c::CheckQuake() { } void dVibration_c::setDefault() { - mMotor.mShock.mVibMode = VIBMODE_S_NONE; - mCamera.mShock.mVibMode = VIBMODE_S_NONE; - mMotor.mQuake.mVibMode = VIBMODE_Q_NONE; - mCamera.mQuake.mVibMode = VIBMODE_Q_NONE; - mMotor.mShock.field_0x0 = 0; - mCamera.mShock.field_0x0 = 0; - mMotor.mQuake.field_0x0 = 0; - mCamera.mQuake.field_0x0 = 0; - mMotor.mShock.mPattern = 0; - mCamera.mShock.mPattern = 0; - mMotor.mQuake.mPattern = 0; - mCamera.mQuake.mPattern = 0; - mMotor.mShock.mLength = 0; - mCamera.mShock.mLength = 0; - mMotor.mQuake.mLength = 0; - mCamera.mQuake.mLength = 0; - mMotor.mShock.mRounds = 0; - mCamera.mShock.mRounds = 0; - mMotor.mQuake.mRounds = 0; - mCamera.mQuake.mRounds = 0; - mMotor.mShock.mFrame = RESET_FRAME; - mCamera.mShock.mFrame = RESET_FRAME; - mMotor.mQuake.mFrame = RESET_FRAME; - mCamera.mQuake.mFrame = RESET_FRAME; + mCamera.mShock.mVibMode = mMotor.mShock.mVibMode = VIBMODE_S_NONE; + mCamera.mQuake.mVibMode = mMotor.mQuake.mVibMode = VIBMODE_Q_NONE; + mCamera.mShock.field_0x0 = mMotor.mShock.field_0x0 = 0; + mCamera.mQuake.field_0x0 = mMotor.mQuake.field_0x0 = 0; + mCamera.mShock.mPattern = mMotor.mShock.mPattern = 0; + mCamera.mQuake.mPattern = mMotor.mQuake.mPattern = 0; + mCamera.mShock.mLength = mMotor.mShock.mLength = 0; + mCamera.mQuake.mLength = mMotor.mQuake.mLength = 0; + mCamera.mShock.mRounds = mMotor.mShock.mRounds = 0; + mCamera.mQuake.mRounds = mMotor.mQuake.mRounds = 0; + mCamera.mShock.mFrame = mMotor.mShock.mFrame = RESET_FRAME; + mCamera.mQuake.mFrame = mMotor.mQuake.mFrame = RESET_FRAME; mMotor.mShock.mStopFrame = RESET_FRAME; mMotor.mQuake.mStopFrame = RESET_FRAME; mMode = MODE_WAIT; @@ -421,6 +611,10 @@ void dVibration_c::setDefault() { void dVibration_c::Init() { Kill(); setDefault(); + + #if DEBUG + mVibTest.Init(); + #endif } void dVibration_c::Pause() { @@ -430,10 +624,8 @@ void dVibration_c::Pause() { mDoCPd_c::stopMotorHard(PAD_1); } - mMotor.mShock.mVibMode = VIBMODE_S_NONE; - mCamera.mShock.mVibMode = VIBMODE_S_NONE; - mMotor.mShock.mFrame = RESET_FRAME; - mCamera.mShock.mFrame = RESET_FRAME; + mCamera.mShock.mVibMode = mMotor.mShock.mVibMode = VIBMODE_S_NONE; + mCamera.mShock.mFrame = mMotor.mShock.mFrame = RESET_FRAME; if (mCamera.mQuake.mVibMode != VIBMODE_Q_NONE) { mCamera.mQuake.mFrame = 0; @@ -449,3 +641,133 @@ void dVibration_c::Pause() { void dVibration_c::Remove() { Kill(); } + +#if DEBUG +void dVibTest_c::setDefault() { + m_pattern = m_pattern2 = 0; + field_0xa = 0; + field_0x10 = 0; + m_randombit = 0; + m_vibswitch = 0; + m_displayDbg = 0; + m_length = 32; +} + +dVibTest_c::dVibTest_c() { + setDefault(); + id = mDoHIO_CREATE_CHILD("振動処理", this); +} + +dVibTest_c::~dVibTest_c() { + mDoHIO_DELETE_CHILD(id); +} + +void dVibTest_c::Init() { + setDefault(); +} + +void dVibTest_c::genMessage(JORMContext* mctx) { + int i; + + mctx->genLabel("- パターン", 0, 0); + mctx->genCheckBox(" ", &m_pattern, 0x8000, 0, NULL, 10, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x4000, 0, NULL, 0x1e, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x2000, 0, NULL, 0x32, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x1000, 0, NULL, 0x46, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x800, 0, NULL, 0x5a, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x400, 0, NULL, 0x6e, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x200, 0, NULL, 0x82, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x100, 0, NULL, 0x96, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x80, 0, NULL, 0xaa, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x40, 0, NULL, 0xbe, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x20, 0, NULL, 0xd2, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 0x10, 0, NULL, 0xe6, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 8, 0, NULL, 0xfa, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 4, 0, NULL, 0x10e, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 2, 0, NULL, 0x122, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern, 1, 0, NULL, 0x136, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x8000, 0, NULL, 0x14a, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x4000, 0, NULL, 0x15e, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x2000, 0, NULL, 0x172, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x1000, 0, NULL, 0x186, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x800, 0, NULL, 0x19a, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x400, 0, NULL, 0x1ae, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x200, 0, NULL, 0x1c2, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x100, 0, NULL, 0x1d6, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x80, 0, NULL, 0x1ea, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x40, 0, NULL, 0x1fe, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x20, 0, NULL, 0x212, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 0x10, 0, NULL, 0x226, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 8, 0, NULL, 0x23a, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 4, 0, NULL, 0x24e, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 2, 0, NULL, 0x262, 0x14, 0x14, 0x14); + mctx->genCheckBox(" ", &m_pattern2, 1, 0, NULL, 0x276, 0x14, 0x14, 0x14); + + mctx->genLabel("-", 0, 0); + mctx->startComboBox("振動切替", &m_vibswitch, 0x130); + for (i = 0; i < 11; i++) { + mctx->genComboBoxItem(shock_names[i], i); + } + for (i = 0; i < 10; i++) { + mctx->genComboBoxItem(quake_names[i], i + 100); + } + mctx->endComboBox(); + + mctx->genLabel("- VIBMODE_S_* は衝撃型用、VIBMODE_Q_* は地震型用です", 0); + mctx->genLabel("-", 0); + + mctx->genLabel("- タイプ", 0); + mctx->genCheckBox("振動パック", &field_0xa, 1, 0); + mctx->genCheckBox("座標揺れ", &field_0xa, 2, 0); + mctx->genCheckBox("座標揺れ(強)", &field_0xa, 0x40, 0); + mctx->genCheckBox("画角揺れ", &field_0xa, 4, 0); + mctx->genCheckBox("Z揺れ", &field_0xa, 8, 0); + mctx->genCheckBox("ブラー", &field_0xa, 0x10, 0); + + mctx->genLabel("-", 0); + mctx->genSlider("長さ", &m_length, 0, 0x20); + mctx->genSlider("ランダムビット", &m_randombit, 0, 0x20); + + mctx->genLabel("-", 0); + mctx->genButton("衝撃型揺れ開始", 0x12d, 0); + mctx->genButton("地震型揺れ開始", 0x12e, 0); + mctx->genButton("地震型揺れ停止", 0x12f, 0); + + mctx->genLabel("-", 0, 0); + mctx->genCheckBox(" デバッグ表示", &m_displayDbg, 0x8000); + + mctx->genLabel("-", 0, 0); + mctx->genLabel("-", 0, 0); + mctx->genButton("揺れ実験(強)", 0x131, 0); + mctx->genButton("揺れ実験(中)", 0x132, 0); + mctx->genButton("揺れ実験(弱)", 0x133, 0); + + mctx->genLabel("-", 0, 0); + mctx->genLabel("-", 0, 0); +} + +void dVibTest_c::listenPropertyEvent(const JORPropertyEvent* event) { + JORReflexible::listenPropertyEvent(event); + + switch ((int)event->id) { + case 0x12D: + field_0x10 = 10; + break; + case 0x12E: + field_0x10 = 20; + break; + case 0x12F: + field_0x10 = 21; + break; + case 0x131: + dComIfGp_getVibration().StartShock(XREG_S(1) + 8, 0x1F, cXyz(0.0f, 1.0f, 0.0f)); + break; + case 0x132: + dComIfGp_getVibration().StartShock(XREG_S(2) + 4, 0x1F, cXyz(0.0f, 1.0f, 0.0f)); + break; + case 0x133: + dComIfGp_getVibration().StartShock(XREG_S(3) + 2, 0x1F, cXyz(0.0f, 1.0f, 0.0f)); + break; + } +} +#endif diff --git a/src/dusk/OSThread.cpp b/src/dusk/OSThread.cpp index 322d33a331..ea9c568eef 100644 --- a/src/dusk/OSThread.cpp +++ b/src/dusk/OSThread.cpp @@ -23,6 +23,8 @@ #if _WIN32 #define WIN32_LEAN_AND_MEAN 1 #include +#elif __APPLE__ +#include #endif // ============================================================================ @@ -682,6 +684,8 @@ void OSSetCurrentThreadName(const char* name) { if (!SUCCEEDED(result)) { CRASH("OSSetThreadName: SetThreadDescription failed"); } +#elif __APPLE__ + pthread_setname_np(name); #endif } diff --git a/src/dusk/audio/DuskDsp.cpp b/src/dusk/audio/DuskDsp.cpp index 2b26ea478c..7b9401d394 100644 --- a/src/dusk/audio/DuskDsp.cpp +++ b/src/dusk/audio/DuskDsp.cpp @@ -254,7 +254,7 @@ static int ReadChannelSamplesChunk( renderData + skipSamples, static_cast(renderSize - skipSamples * sizeof(u16))); - assert(channel.mSamplePosition % channel.mSamplesPerBlock == 0 || channel.mSamplesLeft == 0); + assert(curSamplePosition % channel.mSamplesPerBlock == 0 || channel.mSamplesLeft == 0); return static_cast(renderSamples - skipSamples); } diff --git a/src/dusk/imgui/ImGuiConsole.cpp b/src/dusk/imgui/ImGuiConsole.cpp index cc8b758cb7..60ba229ead 100644 --- a/src/dusk/imgui/ImGuiConsole.cpp +++ b/src/dusk/imgui/ImGuiConsole.cpp @@ -174,6 +174,7 @@ namespace dusk { void ImGuiConsole::draw() { if (CheckMenuViewToggle(ImGuiKey_F1, m_isHidden)) { + m_menuTools.afterDraw(); return; } @@ -187,6 +188,8 @@ namespace dusk { ImGui::EndMainMenuBar(); } + + m_menuTools.afterDraw(); } bool ImGuiConsole::CheckMenuViewToggle(ImGuiKey key, bool& active) { diff --git a/src/dusk/imgui/ImGuiHeapOverlay.cpp b/src/dusk/imgui/ImGuiHeapOverlay.cpp index 588857cedb..62d1d9f48c 100644 --- a/src/dusk/imgui/ImGuiHeapOverlay.cpp +++ b/src/dusk/imgui/ImGuiHeapOverlay.cpp @@ -1,14 +1,25 @@ #include #include -#include "JSystem/JFramework/JFWSystem.h" -#include "JSystem/JKernel/JKRHeap.h" -#include "imgui.h" #include "ImGuiConsole.hpp" #include "ImGuiMenuTools.hpp" +#include "JSystem/JFramework/JFWSystem.h" +#include "JSystem/JKernel/JKRExpHeap.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "absl/container/flat_hash_map.h" +#include "imgui.h" + +struct OpenHeapData { + bool Safe; + bool HeapCheckRan; + bool HeapCheckFailed; +}; + +static absl::flat_hash_map OpenHeapWindows; namespace dusk { static void DrawTableCore(); + void ShowHeapDetailed(JKRHeap* heap, OpenHeapData& data, bool& open); void ImGuiMenuTools::ShowHeapOverlay() { if (!ImGuiConsole::CheckMenuViewToggle(ImGuiKey_F4, m_showHeapOverlay)) { @@ -16,9 +27,13 @@ namespace dusk { } if (ImGui::Begin("Heaps", &m_showHeapOverlay)) { + for (auto& x : OpenHeapWindows) { + x.second.Safe = false; + } + if (ImGui::BeginTable( "heaps", - 5, + 6, ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) { DrawTableCore(); @@ -28,6 +43,19 @@ namespace dusk { } ImGui::End(); + + std::vector closeQueue; + for (auto& [heap, safe] : OpenHeapWindows) { + auto open = true; + ShowHeapDetailed(heap, safe, open); + if (!open) { + closeQueue.push_back(heap); + } + } + + for (auto toRemove : closeQueue) { + OpenHeapWindows.erase(toRemove); + } } static void DrawHeap(JKRHeap* heap, int depth = 0); @@ -44,6 +72,7 @@ namespace dusk { ImGui::TextUnformatted("Total"); ImGui::TableNextColumn(); ImGui::TextUnformatted("Type"); + ImGui::TableNextColumn(); DrawHeap(reinterpret_cast(JFWSystem::rootHeap)); } @@ -70,8 +99,15 @@ namespace dusk { static void DrawHeap(JKRHeap* heap, const int depth) { ImGui::TableNextRow(); + char idBuf[32]; + snprintf(idBuf, sizeof(idBuf), "%p", heap); + ImGui::PushID(idBuf); ImGui::TableNextColumn(); + if (OpenHeapWindows.find(heap) != OpenHeapWindows.end()) { + OpenHeapWindows[heap].Safe = true; + } + auto indentSize = depth * 16; if (indentSize != 0) ImGui::Indent(indentSize); @@ -103,9 +139,134 @@ namespace dusk { auto typeString = GetHeapType(heap); ImGui::TextUnformatted(typeString.data(), typeString.data() + 4); + ImGui::TableNextColumn(); + if (ImGui::Button("View")) { + OpenHeapWindows[heap].Safe = true; + } + const JSUTree& tree = heap->getHeapTree(); for (JSUTreeIterator iter(tree.getFirstChild()); iter != tree.getEndChild(); ++iter) { DrawHeap(*iter, depth + 1); } + + ImGui::PopID(); + } + + struct MemBlockPair { + JKRExpHeap::CMemBlock* block; + bool used; + + auto& operator->() { + return block; + } + }; + + static std::vector FindAllHeapBlocks(JKRExpHeap* heap) { + std::vector result; + + for (JKRExpHeap::CMemBlock* b = heap->getFreeHead(); b; b = b->getNextBlock()) { + result.push_back({b, false}); + } + + for (JKRExpHeap::CMemBlock* b = heap->getUsedHead(); b; b = b->getNextBlock()) { + result.push_back({b, true}); + } + + std::ranges::sort(result, [](auto a, auto b) { return a.block < b.block; }); + + return result; + } + + void ShowHeapDetailed(JKRHeap* heap, OpenHeapData& data, bool& open) { + char title[128]; + const char* name = data.Safe ? heap->getName() : "INVALID"; + snprintf(title, sizeof(title), "Heap %s##%p", heap->getName(), static_cast(heap)); + + if (!ImGui::Begin(name, &open)) { + ImGui::End(); + return; + } + + if (!data.Safe) { + ImGui::TextUnformatted("Heap no longer exists"); + ImGui::End(); + return; + } + + heap->lock(); + + ImGui::Text("Name: %s", heap->getName()); + const auto size = BytesToString(heap->getSize()); + const auto freeSize = BytesToString(heap->getFreeSize()); + ImGui::Text("Size: %08X (%s), free: %08X (%s)", heap->getSize(), size.c_str(), heap->getFreeSize(), freeSize.c_str()); + + if (ImGui::Button("Check")) { + data.HeapCheckFailed = !heap->check(); + data.HeapCheckRan = true; + } + + if (data.HeapCheckFailed) { + ImGui::SameLine(); + ImColor red = IM_COL32(0xFF, 0, 0, 0xFF); + ImGui::TextColored(red, "Heap check failed"); + } else if (data.HeapCheckRan) { + ImGui::SameLine(); + ImColor red = IM_COL32(0, 0xFF, 0, 0xFF); + ImGui::TextColored(red, "Heap check passed"); + } + + if (heap->getHeapType() == 'EXPH') { + auto expHeap = dynamic_cast(heap); + + ImGui::SeparatorText("Blocks"); + + if (ImGui::BeginTable("Blocks", 5, ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) { + ImGui::TableSetupColumn("Start", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("End", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Size"); + ImGui::TableSetupColumn("Allocated", ImGuiTableColumnFlags_WidthFixed, ImGui::CalcTextSize("Allocated").x); + ImGui::TableSetupColumn("IsValid", ImGuiTableColumnFlags_WidthFixed, ImGui::CalcTextSize("IsValid").x); + ImGui::TableHeadersRow(); + + const auto blocks = FindAllHeapBlocks(expHeap); + + for (auto block : blocks) { + assert(block->getSize() != 0); + ImGui::TableNextRow(); + + if (block.used) { + ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, IM_COL32(0xFF, 0, 0, 0x44)); + } else { + ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, IM_COL32(0, 0xFF, 0, 0x44)); + } + + char bufId[32]; + snprintf(bufId, sizeof(bufId), "%p", block); + ImGui::PushID(bufId); + ImGui::TableNextColumn(); + ImGui::Text("%08X", (u32)((uintptr_t)block.block - (uintptr_t)expHeap->getStartAddr())); + ImGui::TableNextColumn(); + ImGui::Text("%08X", (u32)((uintptr_t)block.block + block->getSize() - (uintptr_t)expHeap->getStartAddr())); + ImGui::TableNextColumn(); + auto sizeNice = BytesToString(block->getSize()); + ImGui::Text("%08X (%s)", block->getSize(), sizeNice.c_str()); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(block.used ? "True" : "False"); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(block->isValid() ? "True" : "False"); + if (block->isValid() != block.used) { + ImGui::SameLine(); + ImGui::TextUnformatted("(!!!)"); + } + ImGui::PopID(); + } + + ImGui::EndTable(); + } + } + + ImGui::End(); + + heap->unlock(); } } diff --git a/src/dusk/imgui/ImGuiMapLoader.cpp b/src/dusk/imgui/ImGuiMapLoader.cpp index 89ab6aa120..8d11c0673b 100644 --- a/src/dusk/imgui/ImGuiMapLoader.cpp +++ b/src/dusk/imgui/ImGuiMapLoader.cpp @@ -5,6 +5,7 @@ #include "ImGuiConsole.hpp" #include "ImGuiMenuTools.hpp" #include "dusk/map_loader_definitions.h" +#include "fmt/format.h" namespace dusk { void ImGuiMenuTools::ShowMapLoader() { diff --git a/src/dusk/imgui/ImGuiMenuGame.cpp b/src/dusk/imgui/ImGuiMenuGame.cpp index e4ff609ccb..7b90dcb5b5 100644 --- a/src/dusk/imgui/ImGuiMenuGame.cpp +++ b/src/dusk/imgui/ImGuiMenuGame.cpp @@ -7,6 +7,7 @@ #include #include "JSystem/JUtility/JUTGamePad.h" +#include "d/actor/d_a_alink.h" #include "dusk/audio/DuskAudioSystem.h" #include "m_Do/m_Do_audio.h" #include "m_Do/m_Do_controller_pad.h" @@ -23,12 +24,20 @@ namespace dusk { ImGui::Separator(); if (ImGui::BeginMenu("Graphics")) { + if (ImGui::MenuItem("Toggle Fullscreen", "F11")) { + m_graphicsSettings.m_fullscreen = !m_graphicsSettings.m_fullscreen; + VISetWindowFullscreen(m_graphicsSettings.m_fullscreen); + } + + ImGui::Separator(); + ImGui::Checkbox("Native Bloom", &m_graphicsSettings.m_enableBloom); ImGui::Checkbox("Water Projection Offset", &m_graphicsSettings.m_waterProjectionOffset); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Adds GC-specific -0.01 transS offset\n" "that causes ~6px ghost artifacts in water reflections"); } + ImGui::EndMenu(); } @@ -67,6 +76,11 @@ namespace dusk { ImGui::EndMenu(); } + if (ImGui::BeginMenu("Tweaks")) { + ImGui::MenuItem("Fast iron boots", nullptr, &tweaks::FastIronBoots); + ImGui::EndMenu(); + } + ImGui::EndMenu(); } @@ -76,6 +90,11 @@ namespace dusk { if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_R)) { JUTGamePad::C3ButtonReset::sResetSwitchPushing = true; } + + if (ImGui::IsKeyPressed(ImGuiKey_F11)) { + m_graphicsSettings.m_fullscreen = !m_graphicsSettings.m_fullscreen; + VISetWindowFullscreen(m_graphicsSettings.m_fullscreen); + } } static void drawVirtualStick(const char* id, const ImVec2& stick) { @@ -102,17 +121,38 @@ namespace dusk { return; } - // if pending for an input mapping, check to set new input - if (m_controllerConfig.m_pendingMapping != nullptr) { + // if pending for a button mapping, check to set new input + if (m_controllerConfig.m_pendingButtonMapping != nullptr) { s32 nativeButton = PADGetNativeButtonPressed(m_controllerConfig.m_pendingPort); if (nativeButton != -1) { - m_controllerConfig.m_pendingMapping->nativeButton = nativeButton; - m_controllerConfig.m_pendingMapping = nullptr; + m_controllerConfig.m_pendingButtonMapping->nativeButton = nativeButton; + m_controllerConfig.m_pendingButtonMapping = nullptr; m_controllerConfig.m_pendingPort = -1; PADBlockInput(false); } } + // if pending for an axis mapping, check to set new input + if (m_controllerConfig.m_pendingAxisMapping != nullptr) { + auto nativeAxis = PADGetNativeAxisPulled(m_controllerConfig.m_pendingPort); + if (nativeAxis.nativeAxis != -1) { + m_controllerConfig.m_pendingAxisMapping->nativeAxis = nativeAxis; + m_controllerConfig.m_pendingAxisMapping->nativeButton = -1; + m_controllerConfig.m_pendingAxisMapping = nullptr; + m_controllerConfig.m_pendingPort = -1; + PADBlockInput(false); + } else { + auto nativeButton = PADGetNativeButtonPressed(m_controllerConfig.m_pendingPort); + if (nativeButton != -1) { + m_controllerConfig.m_pendingAxisMapping->nativeAxis = {-1, AXIS_SIGN_POSITIVE}; + m_controllerConfig.m_pendingAxisMapping->nativeButton = nativeButton; + m_controllerConfig.m_pendingAxisMapping = nullptr; + m_controllerConfig.m_pendingPort = -1; + PADBlockInput(false); + } + } + } + ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize; @@ -136,10 +176,12 @@ namespace dusk { ImGui::EndTabBar(); // if tab is changed while waiting for input, cancel pending - if (m_controllerConfig.m_pendingMapping != nullptr && + if ((m_controllerConfig.m_pendingButtonMapping != nullptr || + m_controllerConfig.m_pendingAxisMapping != nullptr) && m_controllerConfig.m_pendingPort != m_controllerConfig.m_selectedPort) { - m_controllerConfig.m_pendingMapping = nullptr; + m_controllerConfig.m_pendingButtonMapping = nullptr; + m_controllerConfig.m_pendingAxisMapping = nullptr; m_controllerConfig.m_pendingPort = -1; PADBlockInput(false); } @@ -197,34 +239,78 @@ namespace dusk { } // buttons panel - constexpr float buttonSize = 40; + constexpr float uiButtonSize = 40; ImGuiBeginGroupPanel("Buttons", ImVec2(150, 20)); u32 buttonCount; - PADButtonMapping* mappingList = PADGetButtonMappings(m_controllerConfig.m_selectedPort, &buttonCount); - if (mappingList != nullptr) { + PADButtonMapping* btnMappingList = PADGetButtonMappings(m_controllerConfig.m_selectedPort, &buttonCount); + if (btnMappingList != nullptr) { for (int i = 0; i < buttonCount; i++) { - const char* btnName = PADGetButtonName(mappingList[i].padButton); + const char* btnName = PADGetButtonName(btnMappingList[i].padButton); ImVec2 len = ImGui::CalcTextSize(btnName); ImVec2 pos = ImGui::GetCursorPos(); ImGui::SetCursorPosY(pos.y + len.y / 4); - ImGui::SetCursorPosX(pos.x + abs(len.x - buttonSize)); + ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize)); ImGui::Text("%s", btnName); ImGui::SameLine(); ImGui::SetCursorPosY(pos.y); - bool pressed = ImGui::Button(m_controllerConfig.m_isReading && m_controllerConfig.m_pendingMapping == &mappingList[i] - ? fmt::format("Press a Key...##{}", btnName).c_str() - : fmt::format("{0}##-{1}", PADGetNativeButtonName(mappingList[i].nativeButton), i).c_str(), + std::string dispName; + if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingButtonMapping == &btnMappingList[i]) { + dispName = fmt::format("Press a Key...##{}", btnName); + } else { + dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(btnMappingList[i].nativeButton), i); + } + bool pressed = ImGui::Button(dispName.c_str(), ImVec2(100.0f, 20.0f)); if (pressed) { m_controllerConfig.m_isReading = true; m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort; - m_controllerConfig.m_pendingMapping = &mappingList[i]; + m_controllerConfig.m_pendingButtonMapping = &btnMappingList[i]; + PADBlockInput(true); + } + } + } + + ImGuiEndGroupPanel(); + ImGui::SameLine(); + + uint32_t axisCount; + PADAxisMapping* axisMappingList = PADGetAxisMappings(m_controllerConfig.m_selectedPort, &axisCount); + + ImGuiBeginGroupPanel("Triggers", ImVec2(150, 20)); + + PADAxis triggers[] = {PAD_AXIS_TRIGGER_L, PAD_AXIS_TRIGGER_R}; + if (axisMappingList != nullptr) { + for (PADAxis trigger : triggers) { + const char* axisName = PADGetAxisName(axisMappingList[trigger].padAxis); + ImVec2 len = ImGui::CalcTextSize(axisName); + ImVec2 pos = ImGui::GetCursorPos(); + + ImGui::SetCursorPosY(pos.y + len.y / 4); + ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize)); + ImGui::Text("%s", axisName); + ImGui::SameLine(); + + ImGui::SetCursorPosY(pos.y); + + std::string dispName; + if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingAxisMapping == &axisMappingList[trigger]) { + dispName = fmt::format("Press a Key...##{}", axisName); + } else { + dispName = fmt::format("{0}##-{1}", PADGetNativeAxisName(axisMappingList[trigger].nativeAxis), trigger); + } + bool pressed = ImGui::Button(dispName.c_str(), + ImVec2(100.0f, 20.0f)); + + if (pressed) { + m_controllerConfig.m_isReading = true; + m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort; + m_controllerConfig.m_pendingAxisMapping = &axisMappingList[trigger]; PADBlockInput(true); } } @@ -235,32 +321,52 @@ namespace dusk { int port = m_controllerConfig.m_selectedPort; - const char* stickDirections[] = { - "Up", - "Down", - "Left", - "Right", - }; - // main stick panel ImGuiBeginGroupPanel("Control Stick", ImVec2(150, 20)); drawVirtualStick("##mainStick", ImVec2{ mDoCPd_c::getStickX(port), mDoCPd_c::getStickY(port) }); - { - for (int i = 0; i < 4; i++) { - const char* label = stickDirections[i]; + if (axisMappingList != nullptr) { + const PADAxis lStickAxes[] = {PAD_AXIS_LEFT_Y_POS, PAD_AXIS_LEFT_Y_NEG, PAD_AXIS_LEFT_X_NEG, PAD_AXIS_LEFT_X_POS}; + for (auto axis : lStickAxes) { + const char* label = PADGetAxisDirectionLabel(axis); ImVec2 len = ImGui::CalcTextSize(label); ImVec2 pos = ImGui::GetCursorPos(); ImGui::SetCursorPosY(pos.y + len.y / 4); - ImGui::SetCursorPosX(pos.x + abs(len.x - buttonSize)); + ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize)); ImGui::Text("%s", label); ImGui::SameLine(); ImGui::SetCursorPosY(pos.y); - bool pressed = ImGui::Button(fmt::format("Temp##{}", label).c_str(), ImVec2(100.0f, 20.0f)); + std::string dispName; + if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingAxisMapping == &axisMappingList[axis]) { + dispName = fmt::format("Press a Key...##{}", label); + } else { + if (axisMappingList[axis].nativeAxis.nativeAxis != -1) { + const char* signStr; + if (axis == PAD_AXIS_TRIGGER_L || axis == PAD_AXIS_TRIGGER_R) { + signStr = ""; + } else if (axisMappingList[axis].nativeAxis.sign == AXIS_SIGN_POSITIVE) { + signStr = "+"; + } else { + signStr = "-"; + } + dispName = fmt::format("{0}{1}##-{2}", PADGetNativeAxisName(axisMappingList[axis].nativeAxis), signStr, axis); + } else { + assert(axisMappingList[axis].nativeButton != -1); + dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(axisMappingList[axis].nativeButton), axis); + } + } + bool pressed = ImGui::Button(dispName.c_str(), ImVec2(100.0f, 20.0f)); + + if (pressed) { + m_controllerConfig.m_isReading = true; + m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort; + m_controllerConfig.m_pendingAxisMapping = &axisMappingList[axis]; + PADBlockInput(true); + } } } @@ -284,20 +390,47 @@ namespace dusk { drawVirtualStick("##subStick", ImVec2{ mDoCPd_c::getSubStickX(port), mDoCPd_c::getSubStickY(port) }); - { - for (int i = 0; i < 4; i++) { - const char* label = stickDirections[i]; + if (axisMappingList != nullptr) { + const PADAxis rStickAxes[] = {PAD_AXIS_RIGHT_Y_POS, PAD_AXIS_RIGHT_Y_NEG, PAD_AXIS_RIGHT_X_NEG, PAD_AXIS_RIGHT_X_POS}; + for (auto axis : rStickAxes) { + const char* label = PADGetAxisDirectionLabel(axisMappingList[axis].padAxis); ImVec2 len = ImGui::CalcTextSize(label); ImVec2 pos = ImGui::GetCursorPos(); ImGui::SetCursorPosY(pos.y + len.y / 4); - ImGui::SetCursorPosX(pos.x + abs(len.x - buttonSize)); + ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize)); ImGui::Text("%s", label); ImGui::SameLine(); ImGui::SetCursorPosY(pos.y); - bool pressed = ImGui::Button(fmt::format("Temp##sub{}", label).c_str(), ImVec2(100.0f, 20.0f)); + std::string dispName; + if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingAxisMapping == &axisMappingList[axis]) { + dispName = fmt::format("Press a Key...##sub{}", label); + } else { + if (axisMappingList[axis].nativeAxis.nativeAxis != -1) { + const char* signStr; + if (axis == PAD_AXIS_TRIGGER_L || axis == PAD_AXIS_TRIGGER_R) { + signStr = ""; + } else if (axisMappingList[axis].nativeAxis.sign == AXIS_SIGN_POSITIVE) { + signStr = "+"; + } else { + signStr = "-"; + } + dispName = fmt::format("{0}{1}##-{2}", PADGetNativeAxisName(axisMappingList[axis].nativeAxis), signStr, axis); + } else { + assert(axisMappingList[axis].nativeButton != -1); + dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(axisMappingList[axis].nativeButton), axis); + } + } + bool pressed = ImGui::Button(fmt::format("{0}##sub{1}", dispName, label).c_str(), ImVec2(100.0f, 20.0f)); + + if (pressed) { + m_controllerConfig.m_isReading = true; + m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort; + m_controllerConfig.m_pendingAxisMapping = &axisMappingList[axis]; + PADBlockInput(true); + } } } diff --git a/src/dusk/imgui/ImGuiMenuGame.hpp b/src/dusk/imgui/ImGuiMenuGame.hpp index 35e7e397aa..ad6a7140ec 100644 --- a/src/dusk/imgui/ImGuiMenuGame.hpp +++ b/src/dusk/imgui/ImGuiMenuGame.hpp @@ -30,13 +30,15 @@ namespace dusk { struct { int m_selectedPort = 0; bool m_isReading = false; - PADButtonMapping* m_pendingMapping = nullptr; + PADButtonMapping* m_pendingButtonMapping = nullptr; + PADAxisMapping* m_pendingAxisMapping = nullptr; int m_pendingPort = -1; } m_controllerConfig; struct { bool m_enableBloom = 1; bool m_waterProjectionOffset = false; + bool m_fullscreen = false; } m_graphicsSettings; bool m_showControllerConfig = false; diff --git a/src/dusk/imgui/ImGuiMenuTools.cpp b/src/dusk/imgui/ImGuiMenuTools.cpp index e77941af52..40bb3fa1ec 100644 --- a/src/dusk/imgui/ImGuiMenuTools.cpp +++ b/src/dusk/imgui/ImGuiMenuTools.cpp @@ -25,8 +25,7 @@ namespace dusk { if (ImGui::BeginMenu("Collision View")) { ImGui::Checkbox("Enable Terrain view", &m_collisionViewSettings.m_enableTerrainView); - // can't use wireframe atm because aurora doesn't support GX_LINES - //ImGui::Checkbox("Enable wireframe view", &m_collisionViewSettings.m_enableWireframe); + ImGui::Checkbox("Enable wireframe view", &m_collisionViewSettings.m_enableWireframe); ImGui::SliderFloat("Opacity##terrain", &m_collisionViewSettings.m_terrainViewOpacity, 0.0f, 100.0f); ImGui::SliderFloat("Draw Range", &m_collisionViewSettings.m_drawRange, 0.0f, 1000.0f); ImGui::Separator(); @@ -46,6 +45,7 @@ namespace dusk { ImGui::MenuItem("Player Info", nullptr, &m_showPlayerInfo); ImGui::MenuItem("Save Editor", nullptr, &m_showSaveEditor); ImGui::MenuItem("Audio Debug", "F7", &m_showAudioDebug); + ImGui::MenuItem("OSReport Force", nullptr, &OSReportReallyForceEnable); ImGui::EndMenu(); } @@ -124,10 +124,13 @@ namespace dusk { BytesToString(stats->lastIndexSize))); ImGuiStringViewText(fmt::format(FMT_STRING("Storage size: {}\n"), BytesToString(stats->lastStorageSize))); + ImGuiStringViewText(fmt::format(FMT_STRING("Tex upload size: {}\n"), + BytesToString(stats->lastTextureUploadSize))); ImGuiStringViewText(fmt::format( FMT_STRING("Total: {}\n"), BytesToString(stats->lastVertSize + stats->lastUniformSize + - stats->lastIndexSize + stats->lastStorageSize))); + stats->lastIndexSize + stats->lastStorageSize + + stats->lastTextureUploadSize))); } ImGui::End(); } @@ -189,4 +192,4 @@ namespace dusk { ImGui::End(); } -} \ No newline at end of file +} diff --git a/src/dusk/imgui/ImGuiMenuTools.hpp b/src/dusk/imgui/ImGuiMenuTools.hpp index 35703d8aa2..66c820dd78 100644 --- a/src/dusk/imgui/ImGuiMenuTools.hpp +++ b/src/dusk/imgui/ImGuiMenuTools.hpp @@ -23,6 +23,7 @@ namespace dusk { ImGuiMenuTools(); void draw(); + void afterDraw(); void ShowDebugOverlay(); void ShowCameraOverlay(); diff --git a/src/dusk/imgui/ImGuiStubLog.cpp b/src/dusk/imgui/ImGuiStubLog.cpp index 5f77dccd38..d8638da297 100644 --- a/src/dusk/imgui/ImGuiStubLog.cpp +++ b/src/dusk/imgui/ImGuiStubLog.cpp @@ -36,18 +36,20 @@ namespace dusk { std::lock_guard lock(StubLogMutex); + if (StubLogBuffer.size() > 1024 * 1024) { + DuskLog.warn("Stub log FULL. Dropping logs!"); + return; + } + LineOffsets.push_back(StubLogBuffer.size()); const auto levelName = LogLevelName(level); StubLogBuffer.appendf("[%s | %s] %s\n", levelName, module, message); } - static void ClearPastFrame(); - void ImGuiMenuTools::ShowStubLog() { std::lock_guard lock(StubLogMutex); if (!ImGuiConsole::CheckMenuViewToggle(ImGuiKey_F5, m_showStubLog)) { - ClearPastFrame(); return; } @@ -78,7 +80,6 @@ namespace dusk { } ImGui::End(); - ClearPastFrame(); } void ClearPastFrame() { @@ -88,4 +89,10 @@ namespace dusk { StubLogBuffer.clear(); LineOffsets.clear(); } + + void ImGuiMenuTools::afterDraw() { + std::lock_guard lock(StubLogMutex); + + ClearPastFrame(); + } } diff --git a/src/dusk/main.cpp b/src/dusk/main.cpp index 4155482488..7d19325f8f 100644 --- a/src/dusk/main.cpp +++ b/src/dusk/main.cpp @@ -3,6 +3,8 @@ #include #endif +#include + int game_main(int argc, char* argv[]); void WindowsSetupConsole(); diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index a7829bdb50..d744d048ba 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -1738,8 +1738,6 @@ void mDoExt_McaMorfSO::setAnm(J3DAnmTransform* i_anm, int i_attr, f32 i_morf, f3 setLoopFrame(getFrame()); setMorf(i_morf); - STUB_RET(); - if (mpSound != NULL) { if (i_anm != NULL) { mpBas = static_cast(i_anm)->getBas(); @@ -2385,8 +2383,8 @@ void mDoExt_3DlineMat0_c::draw() { int var_r26 = (field_0x14 << 1) & 0xFFFF; for (int i = 0; i < field_0x10; i++) { - GXSETARRAY(GX_VA_POS, field_0x18->field_0x8[field_0x16], sizeof(cXyz) * var_r26, sizeof(cXyz)); - GXSETARRAY(GX_VA_NRM, field_0x18->field_0x10[field_0x16], 3 * var_r26, 3); + GXSETARRAY(GX_VA_POS, field_0x18->field_0x8[field_0x16], sizeof(cXyz) * var_r26, sizeof(cXyz), true); + GXSETARRAY(GX_VA_NRM, field_0x18->field_0x10[field_0x16], 3 * var_r26, 3, true); GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, var_r26); for (u16 j = 0; j < (u16)var_r26; j++) { @@ -2701,11 +2699,11 @@ void mDoExt_3DlineMat1_c::draw() { mDoExt_3Dline_c* lines = mpLines; u16 vert_num = field_0x34 << 1; for (s32 i = 0; i < mNumLines; i++) { - GXSETARRAY(GX_VA_POS, lines->field_0x8[mIsDrawn], vert_num * sizeof(cXyz), sizeof(cXyz)); + GXSETARRAY(GX_VA_POS, lines->field_0x8[mIsDrawn], vert_num * sizeof(cXyz), sizeof(cXyz), true); GXSETARRAY(GX_VA_NRM, lines->field_0x10[mIsDrawn], vert_num * sizeof(mDoExt_3Dline_field_0x10_c), - sizeof(mDoExt_3Dline_field_0x10_c)); - GXSETARRAY(GX_VA_TEX0, lines->field_0x18[mIsDrawn], vert_num * sizeof(cXy), sizeof(cXy)); + sizeof(mDoExt_3Dline_field_0x10_c), true); + GXSETARRAY(GX_VA_TEX0, lines->field_0x18[mIsDrawn], vert_num * sizeof(cXy), sizeof(cXy), true); GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, vert_num); u16 j = 0; @@ -3038,7 +3036,7 @@ mDoExt_cube8pPacket::mDoExt_cube8pPacket(cXyz* i_points, const GXColor& i_color) } void drawCube(MtxP mtx, cXyz* pos, const GXColor& color) { - GXSETARRAY(GX_VA_POS, pos, sizeof(*pos), sizeof(*pos)); + GXSETARRAY(GX_VA_POS, pos, sizeof(cXyz) * 8, sizeof(cXyz), true); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); @@ -3117,7 +3115,7 @@ mDoExt_quadPacket::mDoExt_quadPacket(cXyz* i_points, const GXColor& i_color, u8 } void mDoExt_quadPacket::draw() { - GXSETARRAY(GX_VA_POS, mPoints, sizeof(mPoints), sizeof(cXyz)); + GXSETARRAY(GX_VA_POS, mPoints, sizeof(mPoints), sizeof(cXyz), true); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); @@ -3169,7 +3167,7 @@ mDoExt_trianglePacket::mDoExt_trianglePacket(cXyz* i_points, const GXColor& i_co void mDoExt_trianglePacket::draw() { j3dSys.reinitGX(); - GXSETARRAY(GX_VA_POS, mPoints, sizeof(mPoints), sizeof(cXyz)); + GXSETARRAY(GX_VA_POS, mPoints, sizeof(mPoints), sizeof(cXyz), true); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 94ba2fe6ce..5c321f207f 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -319,11 +319,11 @@ void mDoGph_gInf_c::create() { m_fullFrameBufferTex = (char*)m_fullFrameBufferTimg + sizeof(ResTIMG); #endif - mFrameBufferTimg = createTimg(FB_WIDTH / 2, FB_HEIGHT / 2, 6); + mFrameBufferTimg = createTimg(FB_WIDTH / 2, FB_HEIGHT / 2, GX_TF_RGBA8); JUT_ASSERT(374, mFrameBufferTimg != NULL); mFrameBufferTex = (char*)mFrameBufferTimg + sizeof(ResTIMG); - mZbufferTimg = createTimg(FB_WIDTH / 2, FB_HEIGHT / 2, 3); + mZbufferTimg = createTimg(FB_WIDTH / 2, FB_HEIGHT / 2, GX_TF_IA8); JUT_ASSERT(381, mZbufferTimg != NULL); mZbufferTex = (char*)mZbufferTimg + sizeof(ResTIMG); @@ -1139,7 +1139,11 @@ void mDoGph_drawFilterQuad(s8 param_0, s8 param_1) { void mDoGph_gInf_c::bloom_c::create() { if (m_buffer == NULL) { - u32 size = GXGetTexBufferSize(FB_WIDTH / 2, FB_HEIGHT / 2, 6, GX_FALSE, 0); +#ifdef TARGET_PC + u32 size = 0x20; // No need to allocate memory for texture +#else + u32 size = GXGetTexBufferSize(FB_WIDTH / 2, FB_HEIGHT / 2, GX_TF_RGBA8, GX_FALSE, 0); +#endif m_buffer = mDoExt_getArchiveHeap()->alloc(size, -32); JUT_ASSERT(1621, m_buffer != NULL); @@ -1653,7 +1657,7 @@ int mDoGph_Painter() { #endif dComIfGp_setCurrentGrafPort(&ortho); - dComIfGd_drawCopy2D(); + GX_DEBUG_GROUP(dComIfGd_drawCopy2D); #if DEBUG // "↓↓↓↓↓↓↓↓↓↓ CPU time measuring start ↓↓↓↓↓↓↓↓↓↓" @@ -2166,25 +2170,25 @@ int mDoGph_Painter() { JPADrawInfo draw_info3(m5, 0.0f, FB_HEIGHT, 0.0f, FB_WIDTH); if (!dComIfGp_isPauseFlag()) { - dComIfGp_particle_draw2Dback(&draw_info3); + GX_DEBUG_GROUP(dComIfGp_particle_draw2Dback, &draw_info3); } - dComIfGp_particle_draw2DmenuBack(&draw_info3); + GX_DEBUG_GROUP(dComIfGp_particle_draw2DmenuBack, &draw_info3); ortho.setPort(); - dComIfGd_draw2DOpa(); - drawItem3D(); + GX_DEBUG_GROUP(dComIfGd_draw2DOpa); + GX_DEBUG_GROUP(drawItem3D); ortho.setPort(); #if DEBUG captureScreenSetPort(); #endif - dComIfGd_draw2DOpaTop(); - dComIfGd_draw2DXlu(); + GX_DEBUG_GROUP(dComIfGd_draw2DOpaTop); + GX_DEBUG_GROUP(dComIfGd_draw2DXlu); - if (!dComIfGp_isPauseFlag()) { - dComIfGp_particle_draw2Dfore(&draw_info3); + if (dComIfGp_isPauseFlag()) { + GX_DEBUG_GROUP(dComIfGp_particle_draw2Dfore, &draw_info3); } #if DEBUG @@ -2197,7 +2201,7 @@ int mDoGph_Painter() { mDoGph_gInf_c::calcFade(); } - dComIfGp_particle_draw2DmenuFore(&draw_info3); + GX_DEBUG_GROUP(dComIfGp_particle_draw2DmenuFore, &draw_info3); j3dSys.setViewMtx(m4); } else { // No camera window active — still draw 2D display lists diff --git a/src/m_Do/m_Do_machine.cpp b/src/m_Do/m_Do_machine.cpp index f50c8a6fdb..d5258b6f98 100644 --- a/src/m_Do/m_Do_machine.cpp +++ b/src/m_Do/m_Do_machine.cpp @@ -29,6 +29,10 @@ #include "DynamicLink.h" #include "os_report.h" +#if TARGET_PC +#include +#endif + #if !PLATFORM_GCN #include #include @@ -991,6 +995,11 @@ int mDoMch_Create() { GXSetVerifyCallback((GXVerifyCallback)&myGXVerifyCallback); #endif JKRDvdRipper::setSZSBufferSize(0x4000); +#if TARGET_PC + JKRHeap* dvdHeap = JKRCreateExpHeap(0x10000, NULL, false); + assert(dvdHeap != NULL); + JKRDvdRipper::setHeap(dvdHeap); +#endif JKRDvdAramRipper::setSZSBufferSize(0x4000); JKRAram::setSZSBufferSize(0x2000); mDoDvdThd::create(OSGetThreadPriority(OSGetCurrentThread()) - 2); diff --git a/src/m_Do/m_Do_printf.cpp b/src/m_Do/m_Do_printf.cpp index f4ef1fad00..3cacece77d 100644 --- a/src/m_Do/m_Do_printf.cpp +++ b/src/m_Do/m_Do_printf.cpp @@ -21,6 +21,10 @@ u8 __OSReport_System_disable; u8 __OSReport_enable; +#if TARGET_PC +bool dusk::OSReportReallyForceEnable = false; +#endif + #ifdef __GEKKO__ asm void OSSwitchFiberEx(__REGISTER u32 param_0, __REGISTER u32 param_1, __REGISTER u32 param_2, __REGISTER u32 param_3, __REGISTER u32 code, __REGISTER u32 stack) { nofralloc @@ -153,6 +157,9 @@ void mDoPrintf_vprintf_Thread(char const* fmt, va_list args) { #endif vprintf(fmt, args); + if (dusk::OSReportReallyForceEnable) { + fflush(stdout); + } #if DEBUG if (thread != NULL) { @@ -170,12 +177,16 @@ void mDoPrintf_vprintf(char const* fmt, va_list args) { #if DEBUG mDoPrintf_vprintf_Thread(fmt, args); #else +#if !TARGET_PC u8* stackPtr = (u8*)OSGetStackPointer(); if (stackPtr < (u8*)currentThread->stackEnd + 0xA00 || stackPtr > currentThread->stackBase) { mDoPrintf_vprintf_Interrupt(fmt, args); } else { +#endif mDoPrintf_vprintf_Thread(fmt, args); +#if !TARGET_PC } +#endif #endif } } @@ -184,7 +195,11 @@ void mDoPrintf_VReport(const char* fmt, va_list args) { if (!print_initialized) { OSReportInit(); } +#if TARGET_PC + if (dusk::OSReportReallyForceEnable || __OSReport_enable || !__OSReport_disable) { +#else if (__OSReport_enable || !__OSReport_disable) { +#endif OSThread* currentThread = mDoExt_GetCurrentRunningThread(); if (__OSReport_MonopolyThread == NULL || __OSReport_MonopolyThread == currentThread) { mDoPrintf_vprintf(fmt, args);