Browse Source

test: update test_audio to use main game music engine

master
Matteo Benedetto 3 days ago
parent
commit
1e594aa02b
  1. 6
      Makefile
  2. 53
      test_audio.c

6
Makefile

@ -8,12 +8,16 @@ SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
TARGET = maze.gb
AUDIO_TARGET = test_audio.gb
all: $(TARGET)
all: $(TARGET) $(AUDIO_TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
$(AUDIO_TARGET): test_audio.c $(OBJ_DIR)/music.o
$(CC) $(CFLAGS) -o $(AUDIO_TARGET) test_audio.c $(OBJ_DIR)/music.o
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) -c -o $@ $<

53
test_audio.c

@ -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.
}
}

Loading…
Cancel
Save