-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
396 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
#ifndef _CMOVIEPLAYER | ||
#define _CMOVIEPLAYER | ||
|
||
#include "Kyoto/CDvdFile.hpp" | ||
#include "types.h" | ||
|
||
class CMoviePlayer { | ||
public: | ||
static void SetSfxVolume(uchar); | ||
static void SetSfxVolume(uchar); | ||
|
||
CMoviePlayer(const char*, float, bool, bool); | ||
~CMoviePlayer(); | ||
CMoviePlayer(const char*, float, bool, bool); | ||
~CMoviePlayer(); | ||
|
||
void Update(float); | ||
bool DrawVideo() const; | ||
void Update(float); | ||
bool DrawVideo() const; | ||
|
||
private: | ||
char x0_pad[0x100]; | ||
private: | ||
CDvdFile x0_movieFile; | ||
uint x84_; | ||
uint x88_; | ||
uint x8c_; | ||
uchar x90_; | ||
uint x94_; | ||
uint x98_; | ||
uint x9c_; | ||
uint xa0_; | ||
uint xa4_; | ||
uint xa8_; | ||
// char x0_pad[0x100]; | ||
}; | ||
|
||
#endif // _CMOVIEPLAYER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#include <Kyoto/Graphics/CGX.hpp> | ||
#include <Kyoto/Graphics/CMoviePlayer.hpp> | ||
#include <Kyoto/Graphics/CTexture.hpp> | ||
|
||
const char skInterlacePattern[32] = { | ||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
}; | ||
|
||
static void MyTHPGXRestore() { | ||
CGX::SetZMode(TRUE, GX_ALWAYS, FALSE); | ||
CGX::SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET); | ||
CGX::SetNumTexGens(1); | ||
CGX::SetNumChans(0); | ||
CGX::SetNumTevStages(1); | ||
CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); | ||
CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); | ||
} | ||
|
||
static void MyTHPGXYuv2RgbSetup(bool r29, bool r30) { | ||
GXVtxDescList attr[3] = { | ||
{GX_VA_POS, GX_DIRECT}, | ||
{GX_VA_TEX0, GX_DIRECT}, | ||
{GX_VA_NULL, GX_NONE}, | ||
}; | ||
CGX::SetZMode(TRUE, GX_ALWAYS, FALSE); | ||
CGX::SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR); | ||
CGX::SetNumChans(0); | ||
CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, FALSE, GX_PTIDENTITY); | ||
CGX::SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, FALSE, GX_PTIDENTITY); | ||
|
||
if (r30) { | ||
CGX::SetNumTexGens(2); | ||
CGX::SetNumTevStages(4); | ||
} else { | ||
CGX::SetNumTexGens(3); | ||
CGX::SetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_POS, GX_TEXMTX0, FALSE, GX_PTIDENTITY); | ||
|
||
float n = r29 ? 0.25f : 0.f; | ||
float mtx[8] = {0.125f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.25f, n}; | ||
GXLoadTexMtxImm((MtxPtr)mtx, GX_TEXMTX0, GX_MTX2x4); | ||
GXTexObj obj; | ||
GXInitTexObj(&obj, skInterlacePattern, 8, 4, GX_TF_I8, GX_REPEAT, GX_REPEAT, FALSE); | ||
GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, FALSE, FALSE, GX_ANISO_1); | ||
GXLoadTexObj(&obj, GX_TEXMAP3); | ||
CTexture::InvalidateTexmap(GX_TEXMAP3); | ||
CGX::SetTevOrder(GX_TEVSTAGE4, GX_TEXCOORD2, GX_TEXMAP3, GX_COLOR_NULL); | ||
CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE4); | ||
CGX::SetTevColorIn(GX_TEVSTAGE4, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); | ||
CGX::SetTevAlphaIn(GX_TEVSTAGE4, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA); | ||
CGX::SetAlphaCompare(GX_LESS, 128, GX_AOP_AND, GX_ALWAYS, 0); | ||
CGX::SetNumTevStages(5); | ||
} | ||
|
||
CGX::SetVtxDescv(attr); | ||
GXSetColorUpdate(TRUE); | ||
GXSetAlphaUpdate(FALSE); | ||
GXInvalidateTexAll(); | ||
GXSetVtxAttrFmt(GX_VTXFMT7, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); | ||
GXSetVtxAttrFmt(GX_VTXFMT7, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0); | ||
CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL); | ||
CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_C0); | ||
CGX::SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, false, GX_TEVPREV); | ||
CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_A0); | ||
CGX::SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, false, GX_TEVPREV); | ||
CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0); | ||
CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A); | ||
CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP2, GX_COLOR_NULL); | ||
CGX::SetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_CPREV); | ||
CGX::SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_2, false, GX_TEVPREV); | ||
CGX::SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_APREV); | ||
CGX::SetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, false, GX_TEVPREV); | ||
CGX::SetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K1); | ||
CGX::SetTevKAlphaSel(GX_TEVSTAGE1, GX_TEV_KASEL_K1_A); | ||
CGX::SetTevOrder(GX_TEVSTAGE2, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); | ||
CGX::SetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_TEXC, GX_CC_ONE, GX_CC_CPREV); | ||
CGX::SetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); | ||
CGX::SetTevAlphaIn(GX_TEVSTAGE2, GX_CA_TEXA, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV); | ||
CGX::SetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); | ||
CGX::SetTevOrder(GX_TEVSTAGE3, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); | ||
CGX::SetTevColorIn(GX_TEVSTAGE3, GX_CC_APREV, GX_CC_CPREV, GX_CC_KONST, GX_CC_ZERO); | ||
CGX::SetTevColorOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); | ||
CGX::SetTevAlphaIn(GX_TEVSTAGE3, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); | ||
CGX::SetTevAlphaOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); | ||
CGX::SetTevKColorSel(GX_TEVSTAGE3, GX_TEV_KCSEL_K2); | ||
GXSetTevColorS10(GX_TEVREG0, (GXColorS10){-90, 0, -114, 135}); | ||
CGX::SetTevKColor(GX_KCOLOR0, (GXColor){0, 0, 226, 88}); | ||
CGX::SetTevKColor(GX_KCOLOR1, (GXColor){179, 0, 0, 182}); | ||
CGX::SetTevKColor(GX_KCOLOR2, (GXColor){255, 0, 255, 128}); | ||
} | ||
|
||
static void MyTHPYuv2RgbTextureSetup(void* y, void* u, void* v, ushort width, ushort height) { | ||
GXTexObj yTex; | ||
GXInitTexObj(&yTex, y, width, height, GX_TF_I8, GX_CLAMP, GX_CLAMP, FALSE); | ||
GXInitTexObjLOD(&yTex, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, FALSE, FALSE, GX_ANISO_1); | ||
GXLoadTexObj(&yTex, GX_TEXMAP0); | ||
|
||
GXTexObj uTex; | ||
GXInitTexObj(&uTex, u, width / 2, height / 2, GX_TF_I8, GX_CLAMP, GX_CLAMP, FALSE); | ||
GXInitTexObjLOD(&uTex, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, FALSE, FALSE, GX_ANISO_1); | ||
GXLoadTexObj(&uTex, GX_TEXMAP1); | ||
|
||
GXTexObj vTex; | ||
GXInitTexObj(&vTex, v, (s16)(width / 2), height / 2, GX_TF_I8, GX_CLAMP, GX_CLAMP, FALSE); | ||
GXInitTexObjLOD(&vTex, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, FALSE, FALSE, GX_ANISO_1); | ||
GXLoadTexObj(&vTex, GX_TEXMAP2); | ||
|
||
CTexture::InvalidateTexmap(GX_TEXMAP0); | ||
CTexture::InvalidateTexmap(GX_TEXMAP1); | ||
CTexture::InvalidateTexmap(GX_TEXMAP2); | ||
} | ||
|
||
CMoviePlayer::CMoviePlayer(const char* filepath, float fps, bool a, bool b) | ||
: x0_movieFile(filepath) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include "Kyoto/Alloc/CMemory.hpp" | ||
#include "Kyoto/Graphics/CCubeModel.hpp" | ||
#include "Kyoto/Graphics/CCubeSurface.hpp" | ||
#include "Kyoto/Math/CAABox.hpp" | ||
#include "Kyoto/Math/CVector2f.hpp" | ||
#include "dolphin/os/OSCache.h" | ||
#include "dolphin/types.h" | ||
#include <Kyoto/Graphics/CModel.hpp> | ||
|
||
#include <Kyoto/Graphics/CGraphics.hpp> | ||
#include <Kyoto/IObjectStore.hpp> | ||
|
||
uint CModel::sTotalMemory = 0; | ||
CModel* CModel::sThisFrameList = nullptr; | ||
CModel* CModel::sOneFrameList = nullptr; | ||
CModel* CModel::sTwoFrameList = nullptr; | ||
|
||
static uchar* MemoryFromPartData(uchar** dataCur, int** secSizeCur) { | ||
uchar* ret = **secSizeCur != 0 ? *dataCur : nullptr; | ||
(*dataCur) += **secSizeCur; | ||
(*secSizeCur)++; | ||
return ret; | ||
} | ||
|
||
CModel::CModel(const rstl::auto_ptr< uchar >& data, int length, IObjectStore& store) | ||
: x0_data(data) | ||
, x4_dataLen(length) | ||
, x28_modelInstance(nullptr) | ||
, x2c_currentMatxIdx(0) | ||
, x2e_lastMaterialFrame(0) | ||
, x30_prev(nullptr) | ||
, x34_next(sThisFrameList) | ||
, x38_lastFrame(CGraphics::GetFrameCounter() - 2) { | ||
|
||
uint sectionSizeStart = 0x2c; | ||
uchar* dataPtr = data.get(); | ||
uint flags = *(uint*)(dataPtr + 8); | ||
if (*(uint*)(dataPtr + 4) == 1) { | ||
sectionSizeStart = 0x28; | ||
} | ||
|
||
int* secSizeCur = (int*)(dataPtr + sectionSizeStart); | ||
uint numMatSets = 1; | ||
if (*(uint*)(dataPtr + 4) > 1) { | ||
numMatSets = *(uint*)(dataPtr + 0x28); | ||
} | ||
uchar* dataCur = dataPtr + (((sectionSizeStart + *(uint*)(dataPtr + 0x24) * 4) + 31) & ~31); | ||
x18_matSets.reserve(numMatSets); | ||
for (uint i = 0; i < numMatSets; ++i) { | ||
x18_matSets.push_back(SShader(MemoryFromPartData(&dataCur, &secSizeCur))); | ||
SShader& shader = x18_matSets.back(); | ||
CCubeModel::MakeTexturesFromMats(shader.x10_data, shader.x0_textures, store, true); | ||
x4_dataLen += shader.x0_textures.size() * 12; | ||
} | ||
|
||
CVector3f* positions = reinterpret_cast< CVector3f* >(MemoryFromPartData(&dataCur, &secSizeCur)); | ||
CVector3f* normals = reinterpret_cast< CVector3f* >(MemoryFromPartData(&dataCur, &secSizeCur)); | ||
uint* vtxColors = reinterpret_cast< uint* >(MemoryFromPartData(&dataCur, &secSizeCur)); | ||
CVector2f* floatUvs = reinterpret_cast< CVector2f* >(MemoryFromPartData(&dataCur, &secSizeCur)); | ||
ushort* shortUvs = nullptr; | ||
if ((flags >> 2) & 1) { | ||
shortUvs = reinterpret_cast< ushort* >(MemoryFromPartData(&dataCur, &secSizeCur)); | ||
} | ||
|
||
uint* surfaceInfo = reinterpret_cast< uint* >(MemoryFromPartData(&dataCur, &secSizeCur)); | ||
uint surfaceCount = *surfaceInfo; | ||
x8_surfaces.reserve(surfaceCount); | ||
|
||
for (int i = 0; i < surfaceCount; ++i) { | ||
x8_surfaces.push_back( | ||
reinterpret_cast< CCubeSurface* >(MemoryFromPartData(&dataCur, &secSizeCur))); | ||
} | ||
|
||
SShader& shader = x18_matSets.front(); | ||
const CAABox* box = reinterpret_cast< const CAABox* >(dataPtr + 8); | ||
x28_modelInstance = | ||
rs_new CCubeModel(&x8_surfaces, &shader.x0_textures, shader.x10_data, positions, normals, | ||
vtxColors, floatUvs, shortUvs, *box, (flags >> 1) & 1, true, -1); | ||
sThisFrameList = this; | ||
if (x34_next != nullptr) { | ||
x34_next->x30_prev = this; | ||
} | ||
x4_dataLen += x8_surfaces.size() * 4; | ||
sTotalMemory += x4_dataLen; | ||
DCFlushRange(x0_data.get(), x4_dataLen); | ||
} |
Oops, something went wrong.