Continue csfml

This commit is contained in:
Miloslav Číž 2020-10-25 19:05:57 +01:00
parent f83e079b36
commit 8b0e095272

View File

@ -181,20 +181,28 @@ void SFG_playSound(uint8_t soundIndex, uint8_t volume)
} }
sfInputStream soundStream;
uint64_t soundPos = 0; uint64_t soundPos = 0;
sfInt64 soundRead(void* data, sfInt64 size, void* userData) sfSoundStream *sound;
#define AUDIO_BUFFER_SIZE (SFG_SFX_SAMPLE_COUNT * 2)
int16_t audioBuffer[AUDIO_BUFFER_SIZE];
sfBool soundFill(sfSoundStreamChunk *data, void *userdata)
{ {
soundPos += size;
printf("sasa\n");
return size; data->samples = audioBuffer;
data->sampleCount = AUDIO_BUFFER_SIZE;
return sfTrue;
} }
sfInt64 soundSize(void* userData) void soundSeek(sfTime t, void *userData)
{ {
return 100;
} }
int main() int main()
@ -204,16 +212,18 @@ int main()
clock = sfClock_create(); clock = sfClock_create();
sfClock_restart(clock); sfClock_restart(clock);
SFG_init(); SFG_init();
for (int i = 0; i < AUDIO_BUFFER_SIZE; ++i)
audioBuffer[i] = SFG_getNextMusicSample() * 64;
sound = sfSoundStream_create( soundFill,soundSeek ,1,8000,0);
sfSoundStream_play(sound);
for (int i = 0; i < 256; ++i) // precompute RGB palette for (int i = 0; i < 256; ++i) // precompute RGB palette
{ {
uint16_t col565 = paletteRGB565[i]; uint16_t col565 = paletteRGB565[i];
@ -234,7 +244,6 @@ int main()
sfWindow_setVerticalSyncEnabled((sfWindow *) window,sfFalse); sfWindow_setVerticalSyncEnabled((sfWindow *) window,sfFalse);
uint32_t lastAudioUpdate = 0;
while (sfRenderWindow_isOpen(window)) while (sfRenderWindow_isOpen(window))
{ {