gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/sms/wav_sample/src/samptest.c
1 #include <gbdk/platform.h>
2
3 #include <stdio.h>
4 #include <stdint.h>
5 #include <stdbool.h>
6
7 #include "sample_player.h"
8
9 #include "cowbell_8bit_pcm_unsigned.h"
10 #include "risset_drum_8bit_pcm_unsigned.h"
11
12 uint8_t joy = 0, old_joy;
13 inline void PROCESS_INPUT(void) {
14 old_joy = joy, joy = joypad();
15 }
16 inline uint8_t KEY_PRESSED(uint8_t key) {
17 return ((joy & ~old_joy) & key);
18 }
19
20 void main(void) {
21 puts("PRESS A/B TO PLAY\n");
22 uint8_t bank_save;
23 while (true) {
24 PROCESS_INPUT();
25
26 if (KEY_PRESSED(J_A)) {
27 bank_save = CURRENT_BANK;
28 SWITCH_ROM(BANK(cowbell_8bit_pcm_unsigned));
29 play_sample(cowbell_8bit_pcm_unsigned, sizeof(cowbell_8bit_pcm_unsigned));
30 cut_sample(SFX_CH_1 | SFX_CH_2 | SFX_CH_3);
31 SWITCH_ROM(bank_save);
32
33 } else if (KEY_PRESSED(J_B)) {
34 bank_save = CURRENT_BANK;
35 SWITCH_ROM(BANK(risset_drum_8bit_pcm_unsigned));
36 play_sample(risset_drum_8bit_pcm_unsigned, sizeof(risset_drum_8bit_pcm_unsigned));
37 cut_sample(SFX_CH_1 | SFX_CH_2 | SFX_CH_3);
38 SWITCH_ROM(bank_save);
39 }
40 vsync();
41 }
42 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.