Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compile_flags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-I
include
-I
include/lib
17 changes: 17 additions & 0 deletions include/game/bases/d_coin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include <game/mLib/m_angle.hpp>
#include <types.h>

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;
};
9 changes: 9 additions & 0 deletions slices/wiimj2d.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
58 changes: 58 additions & 0 deletions source/dol/bases/d_coin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "game/mLib/m_angle.hpp"
#include <game/bases/d_coin.hpp>
#include <types.h>

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;
}