test: update test_audio to use main game music engine
This commit is contained in:
+6
-47
@@ -1,59 +1,18 @@
|
||||
#include <gb/gb.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define N_C5 0x706
|
||||
#define N_E5 0x739
|
||||
#define N_G5 0x759
|
||||
#define N_REST 0x000
|
||||
|
||||
const uint16_t arp[16] = {
|
||||
N_C5, N_REST, N_E5, N_REST, N_G5, N_REST, N_E5, N_REST,
|
||||
N_C5, N_REST, N_E5, N_REST, N_G5, N_REST, N_E5, N_REST
|
||||
};
|
||||
|
||||
static uint8_t tick = 0;
|
||||
static uint8_t frame_counter = 0;
|
||||
|
||||
void init_music() {
|
||||
NR52_REG = 0x00;
|
||||
NR52_REG = 0x80;
|
||||
NR50_REG = 0x77;
|
||||
NR51_REG = 0xFF;
|
||||
}
|
||||
|
||||
void update_music() {
|
||||
if (frame_counter == 0) {
|
||||
uint16_t f1 = arp[tick];
|
||||
if (f1 == N_REST) {
|
||||
NR11_REG = 0x00;
|
||||
NR12_REG = 0x00;
|
||||
NR13_REG = 0x00;
|
||||
NR14_REG = 0x80;
|
||||
} else {
|
||||
NR10_REG = 0x00;
|
||||
NR11_REG = 0x80;
|
||||
NR12_REG = 0xF2;
|
||||
NR13_REG = (uint8_t)(f1 & 0xFF);
|
||||
NR14_REG = 0x80 | ((f1 >> 8) & 0x07);
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick >= 16) tick = 0;
|
||||
|
||||
frame_counter = 15; // Lento
|
||||
} else {
|
||||
frame_counter--;
|
||||
}
|
||||
}
|
||||
#include "music.h"
|
||||
|
||||
void main() {
|
||||
printf(" AUDIO TEST 2\n\n");
|
||||
printf(" Tracker Test in Esecuzione...\n");
|
||||
printf(" AUDIO TEST MICE!\n\n");
|
||||
printf(" Soundtrack in Loop...\n");
|
||||
|
||||
init_music();
|
||||
|
||||
while(1) {
|
||||
update_music();
|
||||
wait_vbl_done();
|
||||
|
||||
uint8_t keys = joypad();
|
||||
// Optional test logic for SFX could go here if needed.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user