Page 1 of 1

How to use includeBinary() ?

Posted: Fri Mar 08, 2024 2:30 pm
by rootuid
I have some code which plays some music

Code: Select all

InitSound()
LoadMusic(1,"b.it")
  
If InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Sprite system can't be initialized", 0)
  End
EndIf

If OpenScreen(1920, 1200, 32, "Sprite")
  PlayMusic(1)
  Repeat

    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
Else
  MessageRequester("Error", "Can't open creen !", 0)
EndIf
Now I want to embed the music into the final executable, but how?
I thought by using a DataSection would be the answer

Code: Select all

DataSection
    song:
    IncludeBinary "b.it"
  EndDataSection 
When I double click on IncludeBinary() I can see it has the contents of b.it.

but how do I reference the label 'song' in LoadMusic() ? I tried LoadMusic(1,?song) but LoadMusic() wants the second param to be a string

Re: How to use includeBinary() ?

Posted: Fri Mar 08, 2024 2:42 pm
by Fred

Re: How to use includeBinary() ?

Posted: Fri Mar 08, 2024 2:48 pm
by rootuid
Many thanks Fred, I got it working!