From 5c93ad530782bf551c43fe9e9677fa7161700793 Mon Sep 17 00:00:00 2001 From: TomCube <121310847+yomcube@users.noreply.github.com> Date: Sun, 30 Nov 2025 17:54:14 -0600 Subject: [PATCH 1/2] dCoin_c 91.44% --- compile_flags.txt | 4 +++ include/game/bases/d_coin.hpp | 16 ++++++++++++ slices/wiimj2d.json | 9 +++++++ source/dol/bases/d_coin.cpp | 48 +++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 compile_flags.txt create mode 100644 include/game/bases/d_coin.hpp create mode 100644 source/dol/bases/d_coin.cpp 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..f20f757c --- /dev/null +++ b/include/game/bases/d_coin.hpp @@ -0,0 +1,16 @@ +#pragma once +#include + +class dCoin_c { +public: + static int execute(); +protected: + static s16 m_shapeAngle[3]; + static s16 m_h_shapeAngle[3]; + 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..d586b7c3 --- /dev/null +++ b/source/dol/bases/d_coin.cpp @@ -0,0 +1,48 @@ +#include +#include + +int dCoin_c::execute() { + static u8 l_h_block_time[] = {12, 8, 8, 8}; + static 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[1] = (m_ptn_no << 10) & 0x3FC00; + m_frame += 1; + + if ((u8)m_shapeAngle[1] >= 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[1] = m_h_shapeAngle[1] + 0x3fff & 0xc000; + } + + m_h_ptn_time = l_h_block_time[m_h_ptn_no]; + } + + if (m_h_ptn_no != 0) { + m_h_shapeAngle[1] = m_h_shapeAngle[1] + 0x2aa; + } + + m_b_ptn_time = m_b_ptn_time + -1; + if (m_b_ptn_time == 0) { + m_b_ptn_no = 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; +} \ No newline at end of file From dfff01f0cb7a64850c10b0c22d3ea4388050a073 Mon Sep 17 00:00:00 2001 From: TomCube <121310847+yomcube@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:42:10 -0600 Subject: [PATCH 2/2] Match d_coin.cpp --- include/game/bases/d_coin.hpp | 7 ++++--- source/dol/bases/d_coin.cpp | 32 +++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/game/bases/d_coin.hpp b/include/game/bases/d_coin.hpp index f20f757c..db5443ed 100644 --- a/include/game/bases/d_coin.hpp +++ b/include/game/bases/d_coin.hpp @@ -1,12 +1,13 @@ #pragma once +#include #include class dCoin_c { public: static int execute(); -protected: - static s16 m_shapeAngle[3]; - static s16 m_h_shapeAngle[3]; +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; diff --git a/source/dol/bases/d_coin.cpp b/source/dol/bases/d_coin.cpp index d586b7c3..3c0afa51 100644 --- a/source/dol/bases/d_coin.cpp +++ b/source/dol/bases/d_coin.cpp @@ -1,9 +1,19 @@ +#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 u8 l_h_block_time[] = {12, 8, 8, 8}; - static u8 l_b_block_time[] = {50, 6, 6, 6}; + 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; @@ -11,10 +21,10 @@ int dCoin_c::execute() { m_ptn_no -= 4; } - m_shapeAngle[1] = (m_ptn_no << 10) & 0x3FC00; - m_frame += 1; + m_shapeAngle.y = m_frame << 10; + m_frame++; - if ((u8)m_shapeAngle[1] >= 0x40) { + if (m_frame >= 0x40) { m_frame = 0; } @@ -24,25 +34,25 @@ int dCoin_c::execute() { m_h_ptn_no += 1; if (m_h_ptn_no >= 4) { m_h_ptn_no = 0; - m_h_shapeAngle[1] = m_h_shapeAngle[1] + 0x3fff & 0xc000; + 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[1] = m_h_shapeAngle[1] + 0x2aa; + m_h_shapeAngle.y += 0x2aa; } - m_b_ptn_time = m_b_ptn_time + -1; + m_b_ptn_time -= 1; if (m_b_ptn_time == 0) { - m_b_ptn_no = m_b_ptn_no + 1; + 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; -} \ No newline at end of file +}