Skip to content

Commit

Permalink
work on d_a_movie_player (#2246)
Browse files Browse the repository at this point in the history
* work on d_a_movie_player

* d_a_demo_item mostly done
  • Loading branch information
TakaRikka authored Nov 11, 2024
1 parent ffd6b94 commit 650e1c4
Show file tree
Hide file tree
Showing 13 changed files with 3,982 additions and 2,006 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ def MatchingFor(*versions):
ActorRel(NonMatching, "d_a_mant"),
ActorRel(NonMatching, "d_a_mg_fshop"),
ActorRel(Matching, "d_a_mirror"),
ActorRel(NonMatching, "d_a_movie_player"),
ActorRel(NonMatching, "d_a_movie_player", extra_cflags=["-O3,p"]),
ActorRel(NonMatching, "d_a_myna"),
ActorRel(NonMatching, "d_a_ni"),
ActorRel(NonMatching, "d_a_npc_aru"),
Expand Down
5 changes: 5 additions & 0 deletions include/JSystem/JFramework/JFWDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class JFWDisplay {
mFrameRate = 0;
}

void setFrameRate(u16 rate) {
mFrameRate = rate;
mTickRate = 0;
}

void setDrawDoneMethod(EDrawDone drawDone) { mDrawDoneMethod = drawDone; }
void setFader(JUTFader* fader) { mFader = fader; }
JUTFader* getFader() const { return mFader; }
Expand Down
57 changes: 51 additions & 6 deletions include/d/actor/d_a_demo_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define D_A_DEMO_ITEM_H

#include "f_op/f_op_actor_mng.h"
#include "d/actor/d_a_itembase.h"
#include "d/d_particle.h"

/**
* @ingroup actors-unsorted
Expand All @@ -11,10 +13,16 @@
* @details
*
*/
class daDitem_c : public fopAc_ac_c {
class daDitem_c : public daItemBase_c {
public:
/* 804DFBCC */ bool __CreateHeap();
/* 804DFBD4 */ void CreateInit();
enum Action_e {
ACTION_START_e,
ACTION_EVENT_e,
ACTION_WAIT_LIGHT_END_e,
ACTION_END_e,
};

/* 804DFBD4 */ int CreateInit();
/* 804DFC98 */ void action();
/* 804DFD10 */ void actionStart();
/* 804E00DC */ void actionEvent();
Expand All @@ -29,15 +37,52 @@ class daDitem_c : public fopAc_ac_c {
/* 804E1098 */ void initEffectLight();
/* 804E10D0 */ void settingEffectLight();
/* 804E111C */ void set_mtx();
/* 804E11D4 */ void setTevStr();
/* 804E122C */ void setListStart();
/* 804E1230 */ void draw_WOOD_STICK();

/* 804E122C */ virtual void setListStart();
/* 804E11D4 */ virtual void setTevStr();
/* 804DFBCC */ virtual int __CreateHeap();

inline int Delete();
inline int create();
inline int execute();
inline int draw();

void setAction(u8 i_action) { mAction = i_action; }

u32 chkArgFlag(u8 i_flag) { return field_0x93d & i_flag; }

private:
/* 0x568 */ u8 field_0x568[0x9c8 - 0x568];
/* 0x92C */ cXyz field_0x92c;
/* 0x938 */ f32 field_0x938;
/* 0x93C */ u8 field_0x93c;
/* 0x93D */ u8 field_0x93d;
/* 0x93E */ u8 field_0x93e;
/* 0x93F */ u8 mSetLightEff;
/* 0x940 */ f32 mLightStrength;
/* 0x944 */ u8 field_0x944[0x948 - 0x944];
/* 0x948 */ LIGHT_INFLUENCE mLight;
/* 0x968 */ u8 mAction;
/* 0x969 */ u8 field_0x969;
/* 0x96A */ u8 mParticleAlpha;
/* 0x96C */ dPa_followEcallBack field_0x96c;
/* 0x980 */ dPa_followEcallBack field_0x980;
/* 0x994 */ JPABaseEmitter* field_0x994;
/* 0x998 */ JPABaseEmitter* field_0x998;
/* 0x99C */ cXyz field_0x99c;
/* 0x9A8 */ Z2SoundObjSimple mSound;
};

STATIC_ASSERT(sizeof(daDitem_c) == 0x9c8);

namespace daDitem_prm {
inline u8 getFlag(daDitem_c* i_this) {
return (fopAcM_GetParam(i_this) >> 0x10) & 0xFF;
}

inline u8 getNo(daDitem_c* i_this) {
return fopAcM_GetParam(i_this) & 0xFF;
}
};

#endif /* D_A_DEMO_ITEM_H */
241 changes: 221 additions & 20 deletions include/d/actor/d_a_movie_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,105 @@
#define D_A_MOVIE_PLAYER_H

#include "f_op/f_op_actor.h"
#include "d/d_drawlist.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef u8 THPSample;
typedef s16 THPCoeff;
typedef f32 THPQuantTab[64];

typedef struct _THPHuffmanTab {
u8 quick[32];
u8 increment[32];
u8* Vij;
s32 maxCode[18];
s32 valPtr[18];
u8 Vij1;
u8 pad[11];
} THPHuffmanTab;

typedef struct _THPComponent {
u8 quantizationTableSelector;
u8 DCTableSelector;
u8 ACTableSelector;
THPCoeff predDC;
} THPComponent;

typedef struct _THPFileInfo {
THPQuantTab quantTabs[3];
THPHuffmanTab huffmanTabs[4];
THPComponent components[3];
u16 xPixelSize;
u16 yPixelSize;
u16 MCUsPerRow;
u16 decompressedY;
u8* c;
u32 currByte;
u32 cnt;
u8 validHuffmanTabs;
u8 RST;
u16 nMCU;
u16 currMCU;
u8* dLC[3];
} THPFileInfo;

typedef struct THPAudioRecordHeader {
u32 offsetNextChannel;
u32 sampleSize;
s16 lCoef[8][2];
s16 rCoef[8][2];
s16 lYn1;
s16 lYn2;
s16 rYn1;
s16 rYn2;
} THPAudioRecordHeader;

typedef struct THPAudioDecodeInfo {
u8* encodeData;
u32 offsetNibbles;
u8 predictor;
u8 scale;
s16 yn1;
s16 yn2;
} THPAudioDecodeInfo;

static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag);
static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info);
static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr);

s32 __THPAudioGetNewSample(THPAudioDecodeInfo*);
void __THPAudioInitialize(THPAudioDecodeInfo*, u8*);

static void __THPSetupBuffers(void);
static u8 __THPReadFrameHeader(void);
static u8 __THPReadScaneHeader(void);
static u8 __THPReadQuantizationTable(void);
static u8 __THPReadHuffmanTableSpecification(void);
static void __THPHuffGenerateSizeTable(void);
static void __THPHuffGenerateCodeTable(void);
static void __THPHuffGenerateDecoderTables(u8 tabIndex);
static void __THPRestartDefinition(void);
static void __THPPrepBitStream(void);
static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV);
static void __THPGQRRestore(void);
static void __THPDecompressiMCURow512x448(void);
static void __THPDecompressiMCURow640x480(void);
static void __THPDecompressiMCURowNxN(void);
static void __THPInverseDCTNoYPos(THPCoeff* in, u32 xPos);
static void __THPHuffDecodeDCTCompY(THPFileInfo* info, THPCoeff* block);
static void __THPHuffDecodeDCTCompU(THPFileInfo* info, THPCoeff* block);
static void __THPHuffDecodeDCTCompV(THPFileInfo* info, THPCoeff* block);

static void __THPInverseDCTY8(THPCoeff* in, u32 xPos);
static void __THPGQRSetup();
static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h);

#ifdef __cplusplus
}
#endif

/**
* @ingroup actors-unsorted
Expand All @@ -15,43 +114,145 @@ class daMP_c : public fopAc_ac_c {
public:
/* 80031AD0 */ static int daMP_c_THPPlayerPlay();
/* 80031B24 */ static void daMP_c_THPPlayerPause();
/* 80031A78 */ static int daMP_c_Get_MovieRestFrame();
/* 80031A78 */ static u32 daMP_c_Get_MovieRestFrame();
/* 80031AA4 */ static void daMP_c_Set_PercentMovieVolume(f32);
/* 80878BB8 */ void daMP_c_Get_arg_demoNo();
/* 80878C04 */ void daMP_c_Get_arg_movieNo();
/* 80878C28 */ void daMP_c_Init();
/* 80878D64 */ void daMP_c_Finish();
/* 80878D94 */ void daMP_c_Main();
/* 80878DD8 */ void daMP_c_Draw();
/* 80878E60 */ void daMP_c_Callback_Init(fopAc_ac_c*);
/* 80878ED4 */ daMP_c();
/* 80878F18 */ void daMP_c_Callback_Finish(daMP_c*);
/* 80878F38 */ void daMP_c_Callback_Main(daMP_c*);
/* 80878F70 */ void daMP_c_Callback_Draw(daMP_c*);
/* 80878BB8 */ int daMP_c_Get_arg_demoNo();
/* 80878C04 */ int daMP_c_Get_arg_movieNo();
/* 80878C28 */ int daMP_c_Init();
/* 80878D64 */ int daMP_c_Finish();
/* 80878D94 */ int daMP_c_Main();
/* 80878DD8 */ int daMP_c_Draw();
/* 80878ED4 */ daMP_c() {}

/* 80878E60 */ static int daMP_c_Callback_Init(fopAc_ac_c*);
/* 80878F18 */ static int daMP_c_Callback_Finish(daMP_c*);
/* 80878F38 */ static int daMP_c_Callback_Main(daMP_c*);
/* 80878F70 */ static int daMP_c_Callback_Draw(daMP_c*);

static daMP_c* m_myObj;

private:
/* 0x568 */ int (*mpGetMovieRestFrame)(void);
/* 0x568 */ u32 (*mpGetMovieRestFrame)(void);
/* 0x56C */ void (*mpSetPercentMovieVol)(f32);
/* 0x570 */ int (*mpTHPGetTotalFrame)(void);
/* 0x570 */ u32 (*mpTHPGetTotalFrame)(void);
/* 0x574 */ int (*mpTHPPlay)(void);
/* 0x578 */ void (*mpTHPStop)(void);
/* 0x57C */ int (*mpTHPPause)(void);
};

STATIC_ASSERT(sizeof(daMP_c) == 0x580);

struct daMP_THPReadBuffer {};
struct daMP_THPReadBuffer {
/* 0x00 */ void* m00;
/* 0x04 */ s32 m04;
};

class daMP_Dlst_base_c {
class daMP_Dlst_base_c : public dDlst_base_c {
public:
/* 80878DB8 */ void draw();
/* 80878FD8 */ daMP_Dlst_base_c();
/* 80878FD8 */ daMP_Dlst_base_c() {}

/* 80878DB8 */ virtual void draw();
};

struct THPVideoInfo {
/* 0x00 */ u32 field_0x0;
/* 0x04 */ u32 field_0x4;
/* 0x08 */ u8 field_0x8[0x0C - 0x08];
};

struct THPAudioInfo {
/* 0x00 */ u8 field_0x0[0xC - 0x0];
/* 0x0C */ u32 field_0xc;
};

// made up
struct daMP_Player_c {
/* 0x000 */ DVDFileInfo mFileInfo;
/* 0x03C */ char* field_0x3c;
/* 0x040 */ int field_0x40;
/* 0x044 */ int field_0x44;
/* 0x048 */ int field_0x48;
/* 0x04C */ f32 field_0x4c;
/* 0x050 */ u32 mTotalFrames;
/* 0x054 */ int field_0x54;
/* 0x058 */ int field_0x58;
/* 0x05C */ int field_0x5c;
/* 0x060 */ int field_0x60;
/* 0x064 */ int field_0x64;
/* 0x068 */ u8 field_0x68[0x06C - 0x068];
struct {
u32 _0;
u8 _4;
u8 _5[0x14 - 0x5];
} /* 0x06C */ field_0x6c; // not sure if this is right
/* 0x080 */ THPVideoInfo mVideoInfo;
/* 0x08C */ THPAudioInfo mAudioInfo;
/* 0x09C */ int field_0x9c;
/* 0x0A0 */ int field_0xa0;
/* 0x0A4 */ u8 mState;
/* 0x0A5 */ u8 field_0xa5;
/* 0x0A6 */ u8 field_0xa6;
/* 0x0A7 */ u8 field_0xa7;
/* 0x0A8 */ int field_0xa8;
/* 0x0AC */ int field_0xac;
/* 0x0B0 */ int field_0xb0;
/* 0x0B4 */ int field_0xb4;
/* 0x0B8 */ int field_0xb8;
/* 0x0BC */ int field_0xbc;
/* 0x0C0 */ int field_0xc0;
/* 0x0C4 */ u8 field_0xC4[0x0C8 - 0x0C4];
/* 0x0C8 */ s64 field_0xc8;
/* 0x0D0 */ int field_0xd0;
/* 0x0D4 */ int field_0xd4;
/* 0x0D8 */ int field_0xd8;
/* 0x0DC */ f32 field_0xdc;
/* 0x0E0 */ f32 field_0xe0;
/* 0x0E4 */ f32 field_0xe4;
/* 0x0E8 */ int field_0xe8;
/* 0x0EC */ int field_0xec;
/* 0x0F0 */ int field_0xf0;
/* 0x0F4 */ int field_0xf4;
/* 0x0F8 */ int field_0xf8;
/* 0x0FC */ int field_0xfc;
/* 0x100 */ int field_0x100;
/* 0x104 */ u8 field_0x104[0x10C - 0x104];
/* 0x10C */ int field_0x10c;
/* 0x110 */ u8 field_0x110[0x118 - 0x110];
/* 0x118 */ int field_0x118;
/* 0x11C */ u8 field_0x11C[0x124 - 0x11C];
/* 0x124 */ int field_0x124;
/* 0x128 */ u8 field_0x128[0x130 - 0x128];
/* 0x130 */ int field_0x130;
/* 0x134 */ u8 field_0x134[0x13C - 0x134];
/* 0x13C */ int field_0x13c;
/* 0x140 */ u8 field_0x140[0x148 - 0x140];
/* 0x148 */ int field_0x148;
/* 0x14C */ u8 field_0x14C[0x154 - 0x14C];
/* 0x154 */ int field_0x154;
/* 0x158 */ u8 field_0x158[0x160 - 0x158];
/* 0x160 */ int field_0x160;
/* 0x164 */ u8 field_0x164[0x16C - 0x164];
/* 0x16C */ int field_0x16c;
/* 0x170 */ u8 field_0x170[0x178 - 0x170];
/* 0x178 */ int field_0x178;
/* 0x17C */ int field_0x17c;
/* 0x180 */ int field_0x180;
/* 0x184 */ u8 field_0x184[0x1A8 - 0x184];
/* 0x1A8 */ int field_0x1a8;
/* 0x1AC */ int field_0x1ac;
/* 0x1B0 */ int field_0x1b0;
/* 0x1B4 */ int field_0x1b4;
/* 0x1B8 */ int field_0x1b8;
/* 0x1BC */ int field_0x1bc;
/* 0x1C0 */ int field_0x1c0;
/* 0x1C4 */ int field_0x1c4;
/* 0x1C8 */ int field_0x1c8;
};

struct THPVideoInfo {};
inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) {
return *(s32*)readBuf->m00;
}

struct THPAudioInfo {};
void daMP_PrepareReady(int);

#endif /* D_A_MOVIE_PLAYER_H */
1 change: 1 addition & 0 deletions include/d/d_a_itembase_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
class fopAc_ac_c;

int CheckFieldItemCreateHeap(fopAc_ac_c* actor);
int CheckItemCreateHeap(fopAc_ac_c* i_this);

#endif /* D_A_D_A_ITEMBASE_STATIC_H */
1 change: 1 addition & 0 deletions include/d/d_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@ int isArrow(u8);
int addBombCount(u8, u8);
BOOL isBottleItem(u8 item_no);
u8 check_itemno(int i_itemNo);
BOOL isInsect(u8 i_itemNo);

#endif /* D_D_ITEM_H */
Loading

0 comments on commit 650e1c4

Please sign in to comment.