Skip to content

Commit

Permalink
Replaced DirectMovie commands with another library (BlitzMovie).
Browse files Browse the repository at this point in the history
This will hopefully fix the crashes that some users had relating to the incompability of DirectMovie.It's also worth to mention that the audio is seperated from the video. There are 2 reasons for this: The first reason is that some people had problems with the audio either during or after the video or general audio problems happened during the playing of the avi file. The other reason is because the BlitzMovie plugin doesn't has a command to check if the movie is finished playing (it technically has, but it either is for a different purpose or it is broken), so the audio file is determining when the program can continue without the user having any need to press a button to continue.
  • Loading branch information
ENDSHN committed May 23, 2017
1 parent aa1da06 commit 73c6792
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 5 deletions.
26 changes: 26 additions & 0 deletions BlitzMovie.decls
@@ -0,0 +1,26 @@
;BlitzMovie 1.3 (C) Harriman Software 2004, 2005
.lib "BlitzMovie.dll"

BlitzMovie_Open%(strName$):"_BLITZMOVIE_Open@4"
BlitzMovie_Close():"_BLITZMOVIE_Close@0"
BlitzMovie_GetWidth%():"_BLITZMOVIE_GetWidth@0"
BlitzMovie_GetHeight%():"_BLITZMOVIE_GetHeight@0"
BlitzMovie_GetPixel%(offset%):"_BLITZMOVIE_GetPixel@4"
BlitzMovie_Play%():"_BLITZMOVIE_Play@0"
BlitzMovie_Stop%():"_BLITZMOVIE_Stop@0"

; Direct3D7 specific stuff (much faster than the software versions)
BlitzMovie_OpenD3D%(strName$, device%, ddraw%):"_BLITZMOVIE_OpenD3D@12"
BlitzMovie_DrawD3D%(x%, y%, width%, height%):"_BLITZMOVIE_DrawD3D@16"

; new stuff for 1.2
BlitzMovie_MuteAudio%():"_BLITZMOVIE_MuteAudio@0"
BlitzMovie_SetVolume%(volume%):"_BLITZMOVIE_SetVolume@4"
BlitzMovie_IsPlaying%():"_BLITZMOVIE_IsPlaying@0"

; new stuff for 1.3
BlitzMovie_OpenDecodeToImage%(strName$, buffer%, looping%):"_BLITZMOVIE_OpenDecodeToImage@12"
BlitzMovie_OpenDecodeToTexture%(strName$, buffer%, looping%):"_BLITZMOVIE_OpenDecodeToTexture@12"
BlitzMovie_Pause%():"_BLITZMOVIE_Pause@0"


Binary file added BlitzMovie.dll
Binary file not shown.
Binary file modified GFX/menu/startup.avi
Binary file not shown.
Binary file added GFX/menu/startup.ogg
Binary file not shown.
86 changes: 81 additions & 5 deletions Main.bb
Expand Up @@ -11243,15 +11243,91 @@ End Function
Function PlayStartupVideos()

If GetINIInt("options.ini","options","play startup video")=0 Then Return
Local SplashScreenVideo = OpenMovie("GFX\menu\startup.avi")
FlushKeys()

Local Cam = CreateCamera()
CameraClsMode Cam, 0, 1
Local Quad = CreateQuad()
Local Texture = CreateTexture(2048, 2048, 256 Or 16 Or 32)
EntityTexture Quad, Texture
EntityFX Quad, 1
CameraRange Cam, 0.01, 100
TranslateEntity Cam, 1.0 / 2048 ,-1.0 / 2048 ,-1.0
EntityParent Quad, Cam, 1

Local moviefile$ = "GFX\menu\startup"
BlitzMovie_Open(moviefile$+".avi") ;Get movie size
Local moview = BlitzMovie_GetWidth()
Local movieh = BlitzMovie_GetHeight()
BlitzMovie_Close()

Local ScaledGraphicHeight%
Local Ratio# = Float(RealGraphicWidth)/Float(RealGraphicHeight)
If Ratio>1.76 And Ratio<1.78
ScaledGraphicHeight = RealGraphicHeight
DebugLog "Not Scaled"
Else
ScaledGraphicHeight% = RealGraphicWidth/Ratio
DebugLog "Scaled: "+ScaledGraphicHeight
EndIf

Local image = CreateImage(moview, movieh)
Local SplashScreenVideo = BlitzMovie_OpenDecodeToImage(moviefile$+".avi", image, False)
SplashScreenVideo = BlitzMovie_Play()
Local SplashScreenAudio = StreamSound_Strict(moviefile$+".ogg",SFXVolume,0)

Repeat
Cls
DrawMovie SplashScreenVideo,0,0,GraphicWidth,GraphicHeight
ProjectImage(image, RealGraphicWidth, ScaledGraphicHeight, Quad, Texture)
Flip
Until ((Not MoviePlaying(SplashScreenVideo)) Or GetKey())
CloseMovie SplashScreenVideo
Until (GetKey() Or (Not IsStreamPlaying_Strict(SplashScreenAudio)))
StopStream_Strict(SplashScreenAudio)
BlitzMovie_Stop()
BlitzMovie_Close()
FreeTexture Texture
FreeEntity Quad
FreeEntity Cam
Cls
Flip

End Function

Function ProjectImage(img, w#, h#, Quad%, Texture%)

Local img_w# = ImageWidth(img)
Local img_h# = ImageHeight(img)
If img_w > 2048 Then img_w = 2048
If img_h > 2048 Then img_h = 2048
If img_w < 1 Then img_w = 1
If img_h < 1 Then img_h = 1

If w > 2048 Then w = 2048
If h > 2048 Then h = 2048
If w < 1 Then w = 1
If h < 1 Then h = 1

Local w_rel# = w# / img_w#
Local h_rel# = h# / img_h#
Local g_rel# = 2048.0 / Float(RealGraphicWidth)
Local dst_x = 1024 - (img_w / 2.0)
Local dst_y = 1024 - (img_h / 2.0)
CopyRect 0, 0, img_w, img_h, dst_x, dst_y, ImageBuffer(img), TextureBuffer(Texture)
ScaleEntity Quad, w_rel * g_rel, h_rel * g_rel, 0.0001
RenderWorld()

End Function

Function CreateQuad()

mesh = CreateMesh()
surf = CreateSurface(mesh)
v0 = AddVertex(surf,-1.0, 1.0, 0, 0, 0)
v1 = AddVertex(surf, 1.0, 1.0, 0, 1, 0)
v2 = AddVertex(surf, 1.0,-1.0, 0, 1, 1)
v3 = AddVertex(surf,-1.0,-1.0, 0, 0, 1)
AddTriangle(surf, v0, v1, v2)
AddTriangle(surf, v0, v2, v3)
UpdateNormals mesh
Return mesh

End Function

Expand Down

0 comments on commit 73c6792

Please sign in to comment.