Skip to content

Commit

Permalink
Some more BINK progress
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Dec 29, 2023
1 parent ee5dd04 commit 738033a
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 42 deletions.
100 changes: 94 additions & 6 deletions OpenJPOG/Source/ABINKMoviePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

TOSHI_NAMESPACE_USING

static U32 s_iPlayForegroundFast = 0;

ABINKMoviePlayer::ABINKMoviePlayer()
{
m_bHasMovieStopped = TTRUE;
Expand All @@ -14,20 +16,101 @@ ABINKMoviePlayer::ABINKMoviePlayer()
SetFrameReady(TFALSE);
}

TBOOL ABINKMoviePlayer::RenderToFrameBuffer()
TBOOL ABINKMoviePlayer::InitializeMoviePlayer()
{
return TBOOL();
HRESULT hResult = DirectSoundCreate(NULL, &m_pDirectSound, NULL);
if (FAILED(hResult)) {
m_pDirectSound = NULL;
}
else {
BinkSoundUseDirectSound(m_pDirectSound);
}
return TTRUE;
}

TBOOL ABINKMoviePlayer::RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iUnk, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY)
TBOOL ABINKMoviePlayer::ShutdownMoviePlayer()
{
if (a_iDestHeigth == a_iUnk) {
BinkCopyToBufferRect(m_hBink, a_pDest, a_iDestPitch, a_iDestHeigth,
a_iDestX, a_iDestY, a_iSrcX, a_iSrcY, m_hBink->Width, m_hBink->Height, BINKCOPYALL | BINKNOSKIP | BINKSURFACE32A);
if (m_bIsBINKInitialized) {
FreeAudioResource();
FreeVideoResource();
m_bIsBINKInitialized = TFALSE;
SetFrameReady(TFALSE);
}
return TFALSE;
}

TBOOL ABINKMoviePlayer::Update(TFLOAT a_fDeltaTime)
{
if (!m_bHasMovieStopped && m_hBink) {
BinkService(m_hBink);
if (BinkWait(m_hBink)) {
BinkSleep(500);
return TFALSE;
}
RenderToFrameBuffer();
}
return TFALSE;
}

TBOOL ABINKMoviePlayer::RenderToTexture(TTextureResource* a_pTexture)
{
if (m_hBink) {
m_iWidth = m_hBink->Width;
m_iHeight = m_hBink->Height;
if (a_pTexture && !m_bHasMovieStopped) {
if (s_iPlayForegroundFast) {
BinkDoFrame(m_hBink);
BinkNextFrame(m_hBink);
return FALSE;
}
m_iFrameCount++;
// TODO: Do some Texture stuff
BinkDoFrame(m_hBink);
if (m_iFrameCount == m_hBink->Frames) {

}
}
}
return TBOOL();
}

TBOOL ABINKMoviePlayer::RenderToFrameBuffer()
{
if (!m_bHasMovieStopped && !m_bRenderingTiles) {
RenderToTiles();
m_bRenderingTiles = TTRUE;
}
return TFALSE;
}

TBOOL ABINKMoviePlayer::RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iDestWidth, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY)
{
BinkCopyToBufferRect(m_hBink, a_pDest, a_iDestPitch, a_iDestHeigth,
a_iDestX, a_iDestY, a_iSrcX, a_iSrcY, m_hBink->Width, m_hBink->Height, BINKCOPYALL | BINKNOSKIP | BINKSURFACE32A);
TPBYTE pBuf = a_pDest + a_iDestX + a_iDestY * a_iDestWidth;

if (a_iDestHeigth == a_iDestWidth) {
// I think this ignores alpha?
for (TINT i = 0; i < a_iDestHeigth; i++) {
for (TINT j = 0; j < a_iDestWidth; j++) {
*pBuf = *pBuf | 0xFF000000;
}
pBuf += a_iDestPitch * 4;
}
}
else if (a_iDestHeigth != a_iDestWidth && a_iDestHeigth - a_iDestWidth >= 0) {
// I think this ignores alpha?
for (TINT i = 0; i < a_iDestWidth; i++) {
for (TINT j = 0; j < a_iDestWidth; j++) {
*pBuf = *pBuf | 0xFF000000;
}
pBuf += a_iDestPitch * 4;
}
}

return TFALSE;
}

void ABINKMoviePlayer::BinkSleep(TINT a_iMicroseconds)
{
static S32 s_iTotalSleep = 0;
Expand Down Expand Up @@ -58,3 +141,8 @@ void ABINKMoviePlayer::BinkSleep(TINT a_iMicroseconds)
s_iTotalSleep %= 1000;
}
}

TBOOL ABINKMoviePlayer::RenderToTiles()
{
return TBOOL();
}
47 changes: 12 additions & 35 deletions OpenJPOG/Source/ABINKMoviePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,16 @@ class ABINKMoviePlayer : public AMoviePlayer
public:
ABINKMoviePlayer();

virtual TBOOL InitializeMoviePlayer()
{
HRESULT hResult = DirectSoundCreate(NULL, &m_pDirectSound, NULL);
if (FAILED(hResult)) {
m_pDirectSound = NULL;
}
else {
BinkSoundUseDirectSound(m_pDirectSound);
}
return TTRUE;
}
virtual TBOOL InitializeMoviePlayer();

virtual TBOOL ShutdownMoviePlayer()
{
if (m_bIsBINKInitialized) {
FreeAudioResource();
FreeVideoResource();
m_bIsBINKInitialized = TFALSE;
SetFrameReady(TFALSE);
}
return TFALSE;
}
virtual TBOOL ShutdownMoviePlayer();

virtual TBOOL Update(TFLOAT a_fDeltaTime)
{

if (m_bIsBINKInitialized && m_hBink) {
BinkService(m_hBink);
if (BinkWait(m_hBink) != 0) {
BinkSleep(500);
return TFALSE;
}
RenderToFrameBuffer();
}
return TFALSE;
}
virtual TBOOL Update(TFLOAT a_fDeltaTime);

virtual TBOOL RenderToTexture(TTextureResource *a_pTexture);

virtual TBOOL RenderToFrameBuffer();
virtual TBOOL RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iUnk, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY);
virtual TBOOL RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iSourceHeigth, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY);

virtual TBOOL FreeVideoResource()
{
Expand All @@ -66,6 +37,7 @@ class ABINKMoviePlayer : public AMoviePlayer
}

void BinkSleep(TINT a_iMicroseconds);
TBOOL RenderToTiles();

private:

Expand All @@ -82,9 +54,14 @@ class ABINKMoviePlayer : public AMoviePlayer
private:
TBOOL m_bHasMovieStopped; // 0x210
TBOOL m_bIsBINKInitialized; // 0x211
TBOOL m_bDrawingFrame; // 0x213
TBOOL m_bRenderingTiles; // 0x214
HBINK m_hBink; // 0x218
TINT m_iFrameCount; // 0x220
TINT m_iFrameBufferWidth; // 0x224
TINT m_iFrameBufferHeight; // 0x228
TINT m_iWidth; // 0x22C
TINT m_iHeight; // 0x230
TPBYTE m_pFrameBufferBits; // 0x234
LPDIRECTSOUND m_pDirectSound; // 0x278
};
Expand Down
1 change: 0 additions & 1 deletion OpenJPOG/Source/AMoviePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class AMoviePlayer
return TFALSE;
}

// Probably a spelling mistake from the devs (Bit)
virtual TBOOL Render_BackBufferBlit()
{
return TFALSE;
Expand Down

0 comments on commit 738033a

Please sign in to comment.