old school demo effects test timing
Publié : jeu. 19/avr./2018 15:07
				
				Bonjour, 
après mes tests sur comment "timer" des effets graphiques dans une démo / cracktro en utilisant les fichiers musique modules protrekkr et V2M , place à FMOD
je me suis permis de rassembler pas mal de codes d'ici où là, avec les remerciement qui vont avec,
external libs :
- FMODex-min
- MP3D
- Directx9 : dll à avoir dans windows\system32 ou dans le dossier de l'exe
lien vers l'archive contenant tout ce qui peut être utile, si pas envie de vous prendre la tête il y a l'exe, vous pouvez l'envoyer sur virustotal celui ça ne me dérange pas il n'y a pas de routines d'indétection qui pourrait ensuite être distribuées.
https://drive.google.com/file/d/1gqxiKd ... vhfcC/view
ok sous PB 5.42 LTS , problème avec le shader HL_SL sous 5.62 (unicode ?)
les textes des scrolltexts ne veulent rien dire et ne sont là que pour test et ...y'a pas de fin donc [ESC]
			après mes tests sur comment "timer" des effets graphiques dans une démo / cracktro en utilisant les fichiers musique modules protrekkr et V2M , place à FMOD
je me suis permis de rassembler pas mal de codes d'ici où là, avec les remerciement qui vont avec,
external libs :
- FMODex-min
- MP3D
- Directx9 : dll à avoir dans windows\system32 ou dans le dossier de l'exe
lien vers l'archive contenant tout ce qui peut être utile, si pas envie de vous prendre la tête il y a l'exe, vous pouvez l'envoyer sur virustotal celui ça ne me dérange pas il n'y a pas de routines d'indétection qui pourrait ensuite être distribuées.
https://drive.google.com/file/d/1gqxiKd ... vhfcC/view
ok sous PB 5.42 LTS , problème avec le shader HL_SL sous 5.62 (unicode ?)
les textes des scrolltexts ne veulent rien dire et ne sont là que pour test et ...y'a pas de fin donc [ESC]
Code : Tout sélectionner
; greetz JohnJohnSHERMAN for fmod oscillo wave 
; inc. for shader DirectX HLSL code slightly modded by my fingers
; Falsam for FMOD_DataSectionLoadSound() function
IncludeFile "fmodex-min.pbi"
#FMOD_OPENMEMORY  = $00000800
Enumeration
  #rightbar
  #leftbar
  #Mainform
  #Wave
  #spectrum
  #rambo
EndEnumeration
;----------------Init variables globales --------------------------------------
Global fmodsystem.i, Channel.i, i.i, j.i, Max.i, Position.i, YCurrentWave.i, YOldWave.i, Angle.f
Global Dim Sounds(1)
Global Dim Plasma.i(1)
Global Dim WaveArray.f(1024) ; Array for Waves --------------------------------------
u=0                          ; manual timer :)
Structure FMOD_CREATESOUNDEXINFO
  cbsize.i      
  length.i       
  params.i[32]   
EndStructure
;-----------------------------------------------------------------------------
;----------------Init Display, Scroll, Rasters, Fonts, Sprites----------------
EP_InitFXLib()
MP_Graphics3DWindow(150,50,1024,768,"",#PB_Window_BorderLess  )
EP_Init2DStars(200,7,1.3,0,0,1024,768)
EP_2DStarsColor(1,RGB(255,0,0))
EP_2DStarsColor(2,RGB(0,255,0))
EP_CatchFont32(1,?font,?endfont)
EP_CatchFont32(2,?font2, ?endfont2)
EP_CatchFont32(3,?font3, ?endfont3)
ramb=MP_CatchSprite(?rambo,?rambo-?endrambo)
decrunch=MP_CatchSprite(?decrunch,?decrunch-?enddecrunch)
InitSprite()
InitKeyboard()
EP_FastRasterBar(0,RGB(40,140,250),32)                        ; blue1
EP_FastRasterBar(1,RGB(73,51,140),32)                         ; purple
EP_FastRasterBar(3,RGB(73,51,140),32,210,2,0,2)               ; blue moving
                                                              ;EP_SetRasterSinAdd(3,8.5)
EP_FastRasterBar(4,RGB(40,140,250),32,100,2,0,2)              ; purple moving
EP_FastRasterBar(5,RGB(40,140,250),32,130,3,0,1)              ; blue2
EP_FastRasterBar(6,RGB(73,51,140),32,130,3,0,2)               ; red
EP_SetScrollText(1, "         .....Another JMG new Prod @2017.... blue sky and yellow sun"+
                    "....................take a look.....let's add some colour .........."+
                    "...........ahhh   ok  ! ..........some move now ? .............., alright.............    is it better  ? ... "+
                    "sure ........so.....what's going on there ? ...........")
EP_Create32Scroll(1, 1, 1, 480)
EP_SetScroll32Speed(1, 8)
EP_SetScrollText(2,"    ohhh   what ??!!       Another scrolling text sinus ! very pretty effect ! ..FIRE ! ")
EP_Create32Scroll(2, 2, 2,400, 20,1025)
EP_SetScroll32Speed(2, 4)
EP_SetSinScroll32(2, 0, 2, 170, -4) 
EP_SetScrollText(3,"  Well Well Well ..........what a beautiful oldschool character font.....does it come from Amstrad ??  ")
EP_Create32Scroll(3, 3, 3, 700)
EP_SetScroll32Speed(3, 8)
EP_SetScrollText(4,"  hey......look ! ..............it's   Rambo !! ................     wow wow wow !   a turning Rambo !"+
                   "                                                       "+
                   "                                     a rambo cube With turning texture too !!! .."+
                   "                               what about a plamsa shader texture ? ")
EP_Create32Scroll(4, 4, 2, 20)
EP_SetScroll32Speed(4, 8)
;----------------Init Spectrum stuff -----------------------------------------
CanvasGadget(#spectrum, 240, 150, 540, 330)
;------------------------------Init 3DCube---------------------------------------------
camera=MP_CreateCamera()
cube=MP_CreateCube()
Texture =  MP_CatchTexture(?rambo,?endrambo)
MP_PositionEntity (cube,0,-1.8,8)
;------------------------------Init Plasma Shader---------------------------------------------
Plasma  = MP_CreateBackBufferTexture()
shader5FX.s = PeekS(?sh2,?sh2end-?sh2)
Plasma(1) = MP_CreateMyShader(shader5FX)
Post_FX = 1
;-----------------------------------------------------------------------------
;----------------Procedures---------------------------------------------------
Procedure GoScroll2()
  
  
  EP_Move32Scroll(2)
  
  
EndProcedure
Procedure EndScroll2()
  
  EP_Close32Scroll(2)
  
EndProcedure
Procedure GoScroll1()
  
  
  EP_Move32Scroll(1)
  
  
EndProcedure
Procedure EndScroll1()
  
  EP_Close32Scroll(1)
  
EndProcedure
Procedure GoScroll3()
  
  
  EP_Move32Scroll(3)
  
  
EndProcedure
Procedure EndScroll3()
  
  EP_Close32Scroll(3)
  
EndProcedure
Procedure GoScroll4()
  
  
  EP_Move32Scroll(4)
  
  
EndProcedure
Procedure EndScroll4()
  
  EP_Close32Scroll(4)
  
EndProcedure
Procedure StopRaster1()
  
  EP_CloseRasterBar(0)
  EP_CloseRasterBar(1)
  
EndProcedure
Procedure StopRaster2()
  
  EP_CloseRasterBar(3)
  EP_CloseRasterBar(4)
  
EndProcedure
Procedure StopRaster3()
  
  EP_CloseRasterBar(5)
  EP_CloseRasterBar(6)
  
EndProcedure
Procedure StopSpectrum()
  
  
  StopDrawing()
  
EndProcedure
Procedure FMOD_DataSectionLoadSound(SoundId, SoundLocStart, SoundLocEnd)   
  Protected exinfo.FMOD_CREATESOUNDEXINFO
  
  exinfo\cbSize = SizeOf(FMOD_CREATESOUNDEXINFO)
  exinfo\Length = SoundLocEnd - SoundLocStart 
  
  FMOD_System_CreateStream(FmodSystem, SoundLocStart, #FMOD_SOFTWARE | #FMOD_OPENMEMORY, @exinfo, @Sounds(SoundId))
EndProcedure
;----------------Init sound First Part-------------------------------------------------
first:
FMOD_System_Create(@fmodsystem)
FMOD_System_Init(fmodsystem, 32, #FMOD_INIT_NORMAL, 0)
FMOD_DataSectionLoadSound(0, ?ams, ?endams)
FMOD_System_PlaySound(fmodsystem, #FMOD_CHANNEL_FREE, Sounds(0), 0, @channel)
;------------------------------First Screen Décrunch-------------------------------------
Repeat
  event=WindowEvent()  
  MP_DrawSprite(decrunch,300,150)
  u=u+1
  
  
  
  If Post_FX > 0
    MP_ShaderSetVar_f (Plasma(Post_FX),"time",MP_ElapsedMicroseconds()/100000 )   
    MP_SetTechniqueMyShader (Plasma(Post_FX),"PostProcess")   
    MP_UseBackbufferShader(Plasma, Plasma(Post_FX)) 
  EndIf
  
  If Post_FX > 0
    MP_RenderToTexture( Plasma )
    MP_TextureToBackBuffer (Plasma)
  EndIf
  
  
  ;Debug u
  
  MP_Flip ()
  
Until u=700
MP_FreeSprite(decrunch)
FMOD_Channel_Stop(Channel)
FMOD_System_Release(fmodsystem)
;----------------Init sound Second Part-------------------------------------------------
second:
FMOD_System_Create(@fmodsystem)
FMOD_System_Init(fmodsystem, 32, #FMOD_INIT_NORMAL, 0)
FMOD_DataSectionLoadSound(1, ?File, ?EndFile)
FMOD_System_PlaySound(fmodsystem, #FMOD_CHANNEL_FREE, Sounds(1), 0, @channel) ; GO Sound and Go Diego !!!
;---------------------MainLoop-------------------------------------------------------------------MainLoop----------------------------------------------
Repeat
  
  
  event=WindowEvent()         
  
  FMOD_Channel_GetWaveData(Channel, WaveArray(), 1024, 0)
  FMOD_Channel_GetPosition(channel, @pos, #FMOD_TIMEUNIT_MS)
  
  
  
  GoScroll1() 
  
  
  
  
  
  
  ;-----------------Go Starfield------------------------------------------------
  EP_2DStarsDraw()           
  ;-----------------------------------------------------------------------------
  
  
  
  
  ;-----------------------------Tests Position & Events------------------------
  
  If pos > 10000
    EP_DisplayRasterBar(0,30)
    EP_DisplayRasterBar(1,740) ;   display rasters 1
    
    
  EndIf
  
  
  
  
  
  If pos > 13000
    StopRaster1()
    
    
    EP_DisplayRasterBar(5,10) ;   display rasters 2 
    EP_DisplayRasterBar(6,760) 
    
  EndIf
  
  
  
  If pos > 22000  ; go scrolltext 
    GoScroll2()
    
  EndIf
  
  ;----------------- Display Spectrum--------------------------------------  
  
  If pos >38500 
    
    StartDrawing(CanvasOutput(#spectrum))
    
    
    DrawingMode(#PB_2DDrawing_Transparent) 
    Box(0, 0, 1026, 400,0) 
    
    
    DrawingMode(#PB_2DDrawing_Default)
    For i=1 To 1024
      YOldWave=(WaveArray(i-1)+1)*250
      YCurrentWave=(WaveArray(i)+1)*250
      LineXY(i-1,YOldWave,i,YCurrentWave,RGB(0,200,50))
      LineXY(i-1,YOldWave+1,i,YCurrentWave+1,RGB(0,90,50))
      LineXY(i-1,YOldWave-1,i,YCurrentWave-1,RGB(0,110,50))
    Next 
    
    StopDrawing()  
    
    
  EndIf  
  
  ;-----------------------------------------------------------------------------  
  
  If pos >39000
    EndScroll1()  ; stop tout le bordel et start scroll 3
    EndScroll2()
    GoScroll3()
  EndIf
  
  
  
  If pos > 48000 
    GoScroll4()
    MP_DrawSprite(ramb,430 , 490) ; Display my old friend Rambo
  EndIf
  
  If pos > 55000
    MP_TurnSprite(ramb,1)
  EndIf
  
  
  If pos > 58000
    MP_FreeSprite(ramb)
    MP_EntitySetTexture (cube, Texture) 
    MP_TurnEntity (cube,2,0.8,0.8)
  EndIf
  
  
  If pos > 65000
    Angle.f + 1.5
    MP_RotateTexture (Texture , Angle)
  EndIf
  
  
  If pos > 73000
    
    EndScroll3()
    EndScroll4()
    
    
    If Post_FX > 0
      MP_ShaderSetVar_f (Plasma(Post_FX),"time",MP_ElapsedMicroseconds()/100000 )   
      MP_SetTechniqueMyShader (Plasma(Post_FX),"PostProcess")   
      MP_UseBackbufferShader(Plasma, Plasma(Post_FX)) 
    EndIf
    
    If Post_FX > 0
      MP_RenderToTexture( Plasma )
      MP_TextureToBackBuffer (Plasma)
      MP_EntitySetTexture (cube, Plasma)
    EndIf
  EndIf
  
  
  
  MP_RenderWorld() 
  MP_Flip () 
  
  
Until GetAsyncKeyState_(#VK_ESCAPE)
FMOD_Channel_Stop(Channel)
FMOD_System_Release(fmodsystem)
End
;-------------- useful stuff 
DataSection
  ams:
  IncludeBinary "ams.mp3"
  endams:
  File:
  IncludeBinary "spit.mp3"
  EndFile:
  font:
  IncludeBinary "fnt1.png"
  endfont:
  font2:
  IncludeBinary "fnt2.bmp"
  endfont2:
  font3:
  IncludeBinary "fnt3.bmp"
  endfont3:
  rambo:
  IncludeBinary "rambo.bmp"
  endrambo:
  decrunch:
  IncludeBinary "decrunch.png"
  enddecrunch:
  sh2:
  Data.q $2E33205350202F2F,$6F69737265762030,$6F6C660A0D0A0D6E,$6F73657220327461,$3D206E6F6974756C
  Data.q $372C343230317B20,$6C660A0D3B7D3836,$656D69742074616F,$6F6C660A0D0A0D3B,$6853794D20347461
  Data.q $6F6C662872656461,$2078655420327461,$4F4F43584554203A,$4F43203A20294452,$0A0D7B0A0D524F4C
  Data.q $74616F6C66202020,$3B726F6C6F432034,$662020200A0D0A0D,$3D20782074616F6C,$2A20782E78655420
  Data.q $74756C6F73657220,$0D3B20782E6E6F69,$616F6C662020200A,$6554203D20792074,$6572202A20792E78
  Data.q $6E6F6974756C6F73,$200A0D0A0D3B792E,$2074616F6C662020,$78203D2030766F6D,$7328736F632B792B
  Data.q $29656D6974286E69,$3030312A292E322A,$2F78286E69732B2E,$312A292E3030313D,$200A0D3B2E303030
  Data.q $2074616F6C662020,$79203D2031766F6D,$6F73657220202F20,$792E6E6F6974756C,$2032392E30202F20
  Data.q $0D3B656D6974202B,$616F6C662020200A,$3D2032766F6D2074,$657220202F207820,$6E6F6974756C6F73
  Data.q $322E30202F20782E,$662020200A0D3B20,$2031632074616F6C,$697328736261203D,$742B31766F6D286E
  Data.q $2B2E322F29656D69,$2D2E322F32766F6D,$766F6D2D31766F6D,$3B29656D69742B32,$6F6C662020200A0D
  Data.q $203D203263207461,$286E697328736261,$6D286E69732B3163,$303030312F30766F,$656D69742B2E3030
  Data.q $2F79286E69732B29,$656D69742B2E3034,$7828286E69732B29,$303030312F29792B,$29292E332A292E30
  Data.q $6C662020200A0D3B,$3D2033632074616F,$736F632873626120,$28736F632B326328,$766F6D2B31766F6D
  Data.q $69732B2932632B32,$2B2932766F6D286E,$30312F78286E6973,$2929292E30303030,$65722020200A0D3B
  Data.q $6C6F43206E727574,$6F6C66203D20726F,$2C31632028347461,$2E312C33632C3263,$0A0D7D0A0D3B2930
  Data.q $2D2D2D202F2F0A0D,$2D2D2D2D2D2D2D2D,$2D2D2D2D2D2D2D2D,$2D2D2D2D2D2D2D2D,$2D2D2D2D2D2D2D2D
  Data.q $2D2D2D2D2D2D2D2D,$56202F2F0A0D2D2D,$6853207865747265,$0A0D0A0D72656461,$5620746375727473
  Data.q $0D5455504E495F53,$202020200A0D7B0A,$70203374616F6C66,$096E6F697469736F,$495449534F50203A
  Data.q $2020200A0D3B4E4F,$203274616F6C6620,$3065727574786574,$54203A2020202020,$3044524F4F435845
  Data.q $0D0A0D3B7D0A0D3B,$207463757274730A,$555054554F5F5356,$20200A0D7B0A0D54,$74616F6C66202020
  Data.q $7469736F70682034,$4F50203A206E6F69,$0D3B4E4F49544953,$6C6620202020200A,$786574203274616F
  Data.q $3A20203065727574,$524F4F4358455420,$0D3B7D0A0D3B3044,$554F5F53560A0D0A,$76796D2054555054
  Data.q $4E495F5356202873,$29204E4920545550,$2020200A0D7B0A0D,$5054554F5F535620,$0D3B54554F205455
  Data.q $4F202020200A0D0A,$69736F70682E5455,$66203D206E6F6974,$4E49283474616F6C,$6F697469736F702E
  Data.q $2E4E492C20782E6E,$6E6F697469736F70,$702E4E492C20792E,$2E6E6F697469736F,$0A0D3B2931202C7A
  Data.q $2E54554F20202020,$3065727574786574,$65742E4E49203D20,$0D3B306572757478,$746572202020200A
  Data.q $3B54554F206E7275,$202F2F0A0D7D0A0D,$2D2D2D2D2D2D2D2D,$2D2D2D2D2D2D2D2D,$2D2D2D2D2D2D2D2D
  Data.q $2D2D2D2D2D2D2D2D,$2D2D2D2D2D2D2D2D,$0D0A0D2D2D2D2D2D,$71696E686365740A,$5074736F50206575
  Data.q $0A0D737365636F72,$70202020200A0D7B,$0A0D317020737361,$200A0D7B20202020,$2F2F202020202020
  Data.q $6E69746867694C20,$65757254203D2067,$20202020200A0D3B,$7865747265562020,$3D20726564616853
  Data.q $656C69706D6F6320,$20305F335F737620,$0D3B29287376796D,$202020202020200A,$68536C6578695020
  Data.q $63203D2072656461,$7020656C69706D6F,$794D20305F335F73,$2928726564616853,$7D202020200A0D3B
  Data.b $0D,$0A,$0D,$0A,$7D
  sh2end:
EndDataSection     
; EndPB 
; PB 5.42 x86