Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bank parameter for music export #2202

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/studio/screens/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ static void onExport_music(Console* console, const char* type, const char* name,
bool error = true;

if(params.id >= 0 && params.id < MUSIC_TRACKS)
error = studioExportMusic(console->studio, params.id, filename) == NULL;
error = studioExportMusic(console->studio, params.id, params.bank, filename) == NULL;

onFileExported(console, filename, !error);
}
Expand Down
15 changes: 12 additions & 3 deletions src/studio/studio.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const char* studioExportSfx(Studio* studio, s32 index, const char* filename)
return NULL;
}

const char* studioExportMusic(Studio* studio, s32 track, const char* filename)
const char* studioExportMusic(Studio* studio, s32 track, s32 bank, const char* filename)
{
tic_mem* tic = studio->tic;

Expand All @@ -333,15 +333,24 @@ const char* studioExportMusic(Studio* studio, s32 track, const char* filename)
#if TIC80_SAMPLE_CHANNELS == 2
wave_enable_stereo();
#endif

#if defined(TIC80_PRO)
// chained = true in CLI. Set to false if want to use unchained
bool chained = studio->bank.chained;
if(chained)
memset(studio->bank.indexes, bank, sizeof studio->bank.indexes);
else
for(s32 i = 0; i < COUNT_OF(BankModes); i++)
if(BankModes[i] == TIC_MUSIC_MODE)
studio->bank.indexes[i] = bank;
#endif
const tic_sfx* sfx = getSfxSrc(studio);
const tic_music* music = getMusicSrc(studio);

sfx2ram(tic->ram, sfx);
music2ram(tic->ram, music);

const tic_music_state* state = &tic->ram->music_state;
const Music* editor = studio->banks.music[studio->bank.index.music];
const Music* editor = studio->banks.music[bank];

tic_api_music(tic, track, -1, -1, false, editor->sustain, -1, -1);

Expand Down
2 changes: 1 addition & 1 deletion src/studio/studio.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ const StudioConfig* getConfig(Studio* studio);
struct Start* getStartScreen(Studio* studio);
struct Sprite* getSpriteEditor(Studio* studio);

const char* studioExportMusic(Studio* studio, s32 track, const char* filename);
const char* studioExportMusic(Studio* studio, s32 track, s32 bank, const char* filename);
const char* studioExportSfx(Studio* studio, s32 sfx, const char* filename);

tic_mem* getMemory(Studio* studio);
Expand Down