diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 00000000..2f50b1fc --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,4 @@ +-I +include +-I +include/lib diff --git a/include/game/bases/d_coin.hpp b/include/game/bases/d_coin.hpp new file mode 100644 index 00000000..db5443ed --- /dev/null +++ b/include/game/bases/d_coin.hpp @@ -0,0 +1,17 @@ +#pragma once +#include +#include + +class dCoin_c { +public: + static int execute(); +private: + static mAng3_c m_shapeAngle; + static mAng3_c m_h_shapeAngle; + static u8 m_frame; + static u8 m_ptn_no; + static u8 m_h_ptn_no; + static u8 m_h_ptn_time; + static u8 m_b_ptn_no; + static u8 m_b_ptn_time; +}; diff --git a/slices/wiimj2d.json b/slices/wiimj2d.json index 2cf1a16d..6c0149ff 100644 --- a/slices/wiimj2d.json +++ b/slices/wiimj2d.json @@ -205,6 +205,15 @@ ".sdata2": "0xf80-0xfa0" } }, + { + "source": "dol/bases/d_coin.cpp", + "memoryRanges": { + ".text": "0x87750-0x87870", + ".ctors": "0xc8-0xcc", + ".sbss": "0x2c0-0x2d8", + ".sdata2": "0xfa0-0xfa8" + } + }, { "source": "dol/bases/d_cd.cpp", "memoryRanges": { diff --git a/source/dol/bases/d_coin.cpp b/source/dol/bases/d_coin.cpp new file mode 100644 index 00000000..3c0afa51 --- /dev/null +++ b/source/dol/bases/d_coin.cpp @@ -0,0 +1,58 @@ +#include "game/mLib/m_angle.hpp" +#include +#include + +mAng3_c dCoin_c::m_shapeAngle; +mAng3_c dCoin_c::m_h_shapeAngle; +u8 dCoin_c::m_frame; +u8 dCoin_c::m_ptn_no; +u8 dCoin_c::m_h_ptn_no; +u8 dCoin_c::m_h_ptn_time; +u8 dCoin_c::m_b_ptn_no; +u8 dCoin_c::m_b_ptn_time; + +int dCoin_c::execute() { + static const u8 l_h_block_time[] = {12, 8, 8, 8}; + static const u8 l_b_block_time[] = {50, 6, 6, 6}; + + m_ptn_no = (m_frame >> 3) & 0xFF; + + if (m_ptn_no >= 4) { + m_ptn_no -= 4; + } + + m_shapeAngle.y = m_frame << 10; + m_frame++; + + if (m_frame >= 0x40) { + m_frame = 0; + } + + m_h_ptn_time -= 1; + + if (m_h_ptn_time == 0) { + m_h_ptn_no += 1; + if (m_h_ptn_no >= 4) { + m_h_ptn_no = 0; + m_h_shapeAngle.y = ((s16)m_h_shapeAngle.y + 0x3fff) & 0xc000; + } + + m_h_ptn_time = l_h_block_time[m_h_ptn_no]; + } + + if (m_h_ptn_no != 0) { + m_h_shapeAngle.y += 0x2aa; + } + + m_b_ptn_time -= 1; + if (m_b_ptn_time == 0) { + m_b_ptn_no += 1; + if (m_b_ptn_no >= 4) { + m_b_ptn_no = 0; + } + + m_b_ptn_time = l_b_block_time[m_b_ptn_no]; + } + + return 1; +}