Skip to content

Commit

Permalink
simplify play sample hidden entries
Browse files Browse the repository at this point in the history
  • Loading branch information
xesf committed Oct 20, 2024
1 parent 2f2bf23 commit a382265
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ void game_introduction() {
if (!hqr_get_entry_alloc(&menu_samples, HQR_RESSOURCE, HQR_MENU_SAMPLES)) {
printf("Error: Couldn't load palette %d\n", HQR_MENU_SAMPLES);
}
i32 sample_hidden_index = 0;
u8 *sample_ptr = NULL;
u32 entry_size = hqr_get_hidden_entry_ptr(&sample_ptr, menu_samples, 0);
sample_play_ptr(HQR_MENU_SAMPLES * 100 + sample_hidden_index, sample_ptr, entry_size, 22050, 0, 0);
sample_play_hidden(HQR_MENU_SAMPLES, 0, menu_samples, 22050, 0, 0);
sample_play_hidden(HQR_MENU_SAMPLES, 1, menu_samples, 22050, 0, 0);
memory_free(menu_samples);
}

Expand Down
7 changes: 7 additions & 0 deletions src/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ void sample_play(i32 index, i32 frequency, i32 repeat, i32 pan) {
memory_free(sample_ptr);
}

void sample_play_hidden(i32 index, i32 hidden_index, u8* menu_samples, i32 frequency, i32 repeat, i32 pan) {
i32 sample_hidden_index = 0;
u8 *sample_ptr = NULL;
u32 entry_size = hqr_get_hidden_entry_ptr(&sample_ptr, menu_samples, 0);
sample_play_ptr(index * 100 + hidden_index, sample_ptr, entry_size, 22050, 0, 0);
}

void sample_play_ptr(i32 index, u8* sample_ptr, i32 sample_size, i32 frequency, i32 repeat, i32 pan) {
sample_play_position(index, sample_ptr, sample_size, frequency, repeat, 0, 0, 0, -1, 0, 0, 0);
}
Expand Down
1 change: 1 addition & 0 deletions src/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void sample_init();
i32 sample_is_playing(i32 index);

void sample_play(i32 index, i32 frequency, i32 repeat, i32 pan);
void sample_play_hidden(i32 index, i32 hidden_index, u8* menu_samples, i32 frequency, i32 repeat, i32 pan);
void sample_play_ptr(i32 index, u8* sample_ptr, i32 sample_size, i32 frequency, i32 repeat, i32 pan);
void sample_play_position(i32 index, u8* sample_ptr, i32 sample_size, i32 frequency, i32 repeat, i32 x, i32 y, i32 z, i32 actor_index, i32 hero_x, i32 hero_y, i32 hero_z);
void sample_pause();
Expand Down

0 comments on commit a382265

Please sign in to comment.