GB: Add audio processing
Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
+3
-4
@@ -8,11 +8,10 @@ project(RP2040_GB C CXX)
|
|||||||
# Initialize the Raspberry Pi Pico SDK
|
# Initialize the Raspberry Pi Pico SDK
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
add_executable(RP2040_GB src/main.c src/rom.c src/mk_ili9225.c)
|
add_executable(RP2040_GB src/main.c src/rom.c src/mk_ili9225.c ext/minigb_apu/minigb_apu.c)
|
||||||
target_include_directories(RP2040_GB PRIVATE inc)
|
target_include_directories(RP2040_GB PRIVATE inc ext/minigb_apu)
|
||||||
target_link_libraries(RP2040_GB
|
target_link_libraries(RP2040_GB
|
||||||
pico_stdlib pico_stdio pico_bootrom pico_multicore pico_stdio
|
pico_stdlib pico_stdio pico_bootrom pico_multicore pico_stdio pico_multicore
|
||||||
pico_multicore
|
|
||||||
hardware_clocks hardware_pio hardware_vreg hardware_pio
|
hardware_clocks hardware_pio hardware_vreg hardware_pio
|
||||||
hardware_sync hardware_pll hardware_spi hardware_irq hardware_dma
|
hardware_sync hardware_pll hardware_spi hardware_irq hardware_dma
|
||||||
pico_binary_info)
|
pico_binary_info)
|
||||||
|
|||||||
+4
-1
@@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "hedley.h"
|
||||||
|
#include "minigb_apu.h"
|
||||||
|
|
||||||
#include <stdint.h> /* Required for int types */
|
#include <stdint.h> /* Required for int types */
|
||||||
#include <string.h> /* Required for memset */
|
#include <string.h> /* Required for memset */
|
||||||
#include <time.h> /* Required for tm struct */
|
#include <time.h> /* Required for tm struct */
|
||||||
@@ -3371,7 +3374,7 @@ void __gb_step_cpu(struct gb_s *gb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check serial transmission. */
|
/* Check serial transmission. */
|
||||||
if(gb->gb_reg.SC & SERIAL_SC_TX_START)
|
if(HEDLEY_UNLIKELY(gb->gb_reg.SC & SERIAL_SC_TX_START))
|
||||||
{
|
{
|
||||||
/* If new transfer, call TX function. */
|
/* If new transfer, call TX function. */
|
||||||
if(gb->counter.serial_count == 0 && gb->gb_serial_tx != NULL)
|
if(gb->counter.serial_count == 0 && gb->gb_serial_tx != NULL)
|
||||||
|
|||||||
+18
-7
@@ -1,8 +1,10 @@
|
|||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
#define ENABLE_LCD 1
|
#define ENABLE_LCD 1
|
||||||
#define ENABLE_SOUND 0
|
#define ENABLE_SOUND 1
|
||||||
|
#define ENABLE_HIPASS 0
|
||||||
#define USE_DMA 0
|
#define USE_DMA 0
|
||||||
|
//#define AUDIO_SAMPLE_RATE 8000.0
|
||||||
|
//#define AUDIO_NSAMPLES 268
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reducing VSYNC calculation to lower multiple.
|
* Reducing VSYNC calculation to lower multiple.
|
||||||
@@ -16,6 +18,7 @@
|
|||||||
|
|
||||||
/* C Headers */
|
/* C Headers */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* RP2040 Headers */
|
/* RP2040 Headers */
|
||||||
@@ -29,7 +32,6 @@
|
|||||||
#include <pico/stdio.h>
|
#include <pico/stdio.h>
|
||||||
#include <pico/stdlib.h>
|
#include <pico/stdlib.h>
|
||||||
#include <pico/multicore.h>
|
#include <pico/multicore.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/* Project headers */
|
/* Project headers */
|
||||||
#include "hedley.h"
|
#include "hedley.h"
|
||||||
@@ -310,10 +312,10 @@ int main(void)
|
|||||||
gpio_set_slew_rate(GPIO_SDA, GPIO_SLEW_RATE_FAST);
|
gpio_set_slew_rate(GPIO_SDA, GPIO_SLEW_RATE_FAST);
|
||||||
|
|
||||||
/* Set SPI clock to use high frequency. */
|
/* Set SPI clock to use high frequency. */
|
||||||
//clock_configure(clk_peri, 0,
|
clock_configure(clk_peri, 0,
|
||||||
// CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLK_SYS,
|
CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLK_SYS,
|
||||||
// 125 * 1000 * 1000, 125 * 1000 * 1000);
|
125 * 1000 * 1000, 125 * 1000 * 1000);
|
||||||
spi_init(spi0, 24*1000*1000);
|
spi_init(spi0, 32*1000*1000);
|
||||||
spi_set_format(spi0, 16, SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST);
|
spi_set_format(spi0, 16, SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST);
|
||||||
|
|
||||||
/* Start Core1, which processes requests to the LCD. */
|
/* Start Core1, which processes requests to the LCD. */
|
||||||
@@ -335,12 +337,18 @@ int main(void)
|
|||||||
gb_init_lcd(&gb, &lcd_draw_line);
|
gb_init_lcd(&gb, &lcd_draw_line);
|
||||||
//gb.direct.interlace = 1;
|
//gb.direct.interlace = 1;
|
||||||
#endif
|
#endif
|
||||||
|
#if ENABLE_SOUND
|
||||||
|
audio_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
uint_fast32_t frames = 0;
|
uint_fast32_t frames = 0;
|
||||||
uint64_t start_time = time_us_64();
|
uint64_t start_time = time_us_64();
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
int input;
|
int input;
|
||||||
|
#if ENABLE_SOUND
|
||||||
|
static float stream[AUDIO_NSAMPLES];
|
||||||
|
#endif
|
||||||
|
|
||||||
gb.gb_frame = 0;
|
gb.gb_frame = 0;
|
||||||
|
|
||||||
@@ -350,6 +358,9 @@ int main(void)
|
|||||||
} while(HEDLEY_LIKELY(gb.gb_frame == 0));
|
} while(HEDLEY_LIKELY(gb.gb_frame == 0));
|
||||||
|
|
||||||
frames++;
|
frames++;
|
||||||
|
#if ENABLE_SOUND
|
||||||
|
audio_callback(NULL, stream, AUDIO_NSAMPLES);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Required since we do not know whether a button remains
|
/* Required since we do not know whether a button remains
|
||||||
* pressed over a serial connection. */
|
* pressed over a serial connection. */
|
||||||
|
|||||||
Reference in New Issue
Block a user