kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
add sound to sms and pce emus
rodzic
53657f2aac
commit
99ff03ea62
Plik binarny nie jest wyświetlany.
|
|
@ -19,8 +19,8 @@ include(pico_sdk_import.cmake)
|
||||||
#set(TARGET picovcs)
|
#set(TARGET picovcs)
|
||||||
#set(TARGET picogb)
|
#set(TARGET picogb)
|
||||||
#set(TARGET picopce)
|
#set(TARGET picopce)
|
||||||
#set(TARGET picosms)
|
set(TARGET picosms)
|
||||||
set(TARGET picogen)
|
#set(TARGET picogen)
|
||||||
|
|
||||||
#set(TARGET pico5200)
|
#set(TARGET pico5200)
|
||||||
|
|
||||||
|
|
|
||||||
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
|
@ -24,7 +24,7 @@ bool show_fps = true;
|
||||||
bool limit_fps = true;
|
bool limit_fps = true;
|
||||||
bool interlace = true;
|
bool interlace = true;
|
||||||
bool frameskip = true;
|
bool frameskip = true;
|
||||||
int z80_enable_mode = 2;
|
static int z80_enable_mode = 2;
|
||||||
bool sn76489_enabled = true;
|
bool sn76489_enabled = true;
|
||||||
extern unsigned short button_state[3];
|
extern unsigned short button_state[3];
|
||||||
|
|
||||||
|
|
@ -126,8 +126,8 @@ void gen_Step(void) {
|
||||||
ym2612_clock = 0;
|
ym2612_clock = 0;
|
||||||
ym2612_index = 0;
|
ym2612_index = 0;
|
||||||
scan_line = 0;
|
scan_line = 0;
|
||||||
//if (z80_enable_mode == 1)
|
if (z80_enable_mode == 1)
|
||||||
//z80_run(lines_per_frame * VDP_CYCLES_PER_LINE);
|
z80_run(lines_per_frame * VDP_CYCLES_PER_LINE);
|
||||||
|
|
||||||
//printf("m(%x)\n", frame);
|
//printf("m(%x)\n", frame);
|
||||||
while (scan_line < lines_per_frame) {
|
while (scan_line < lines_per_frame) {
|
||||||
|
|
@ -249,6 +249,8 @@ void gen_Step(void) {
|
||||||
|
|
||||||
void SND_Process(void *stream, int len) {
|
void SND_Process(void *stream, int len) {
|
||||||
if (audio_enabled) {
|
if (audio_enabled) {
|
||||||
|
//if ( (z80_enable_mode == 3) && (system_clock == 0) )
|
||||||
|
// z80_run(262 * VDP_CYCLES_PER_LINE);
|
||||||
ym2612_run(262 * VDP_CYCLES_PER_LINE);
|
ym2612_run(262 * VDP_CYCLES_PER_LINE);
|
||||||
gwenesis_SN76489_run(262 * VDP_CYCLES_PER_LINE);
|
gwenesis_SN76489_run(262 * VDP_CYCLES_PER_LINE);
|
||||||
audio_sample * snd_buf = (audio_sample *)stream;
|
audio_sample * snd_buf = (audio_sample *)stream;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "pce-go/pce-go.h"
|
#include "pce-go/pce-go.h"
|
||||||
#include "pce-go/pce.h"
|
#include "pce-go/pce.h"
|
||||||
|
#include <pce-go/psg.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "flash_t.h"
|
#include "flash_t.h"
|
||||||
|
|
@ -16,6 +17,11 @@ void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define AUDIO_SAMPLE_RATE 22050
|
||||||
|
#define AUDIO_BUFFER_LENGTH (AUDIO_SAMPLE_RATE / 60 + 1)
|
||||||
|
|
||||||
|
alignas(4) int audio_buffer[AUDIO_BUFFER_LENGTH];
|
||||||
|
|
||||||
|
|
||||||
void pce_Init(void)
|
void pce_Init(void)
|
||||||
{
|
{
|
||||||
|
|
@ -40,13 +46,10 @@ void pce_Start(char * filename)
|
||||||
|
|
||||||
int size = flash_load(filename);
|
int size = flash_load(filename);
|
||||||
PalettePCE(0);
|
PalettePCE(0);
|
||||||
InitPCE(22050, false, (const void *)flash_start, (size_t)size);
|
InitPCE(AUDIO_SAMPLE_RATE, true, (const void *)flash_start, (size_t)size);
|
||||||
|
|
||||||
#ifdef SOUND_PRESENT
|
|
||||||
#ifdef HAS_SND
|
#ifdef HAS_SND
|
||||||
emu_sndInit();
|
emu_sndInit();
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
emu_printf("pce_Start done");
|
emu_printf("pce_Start done");
|
||||||
|
|
@ -77,12 +80,16 @@ void pce_Step(void) {
|
||||||
|
|
||||||
PCE.Joypad.regs[0] = buttons;
|
PCE.Joypad.regs[0] = buttons;
|
||||||
|
|
||||||
//psg_update((int16_t *) audio_buffer, AUDIO_BUFFER_LENGTH, 0xff);
|
|
||||||
//i2s_dma_write(&i2s_config, (const int16_t *) audio_buffer);
|
|
||||||
|
|
||||||
//emu_DrawVsync();
|
//emu_DrawVsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SND_Process(void *stream, int len) {
|
void SND_Process(void *stream, int len) {
|
||||||
// psg_update((int16*)stream, 0, len);
|
int16_t * buf = (int16_t *) audio_buffer;
|
||||||
|
psg_update(buf, AUDIO_BUFFER_LENGTH, 0xff);
|
||||||
|
audio_sample * snd_buf = (audio_sample *)stream;
|
||||||
|
for (int h = 0; h < len*2; h += 2) {
|
||||||
|
int16_t s1 = buf[h]>>8;
|
||||||
|
int16_t s2 = buf[h+1]>>8;
|
||||||
|
*snd_buf++ = ((s1+s2)/2)+128;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,8 +169,11 @@ void * emu_LineBuffer(int line)
|
||||||
#include "AudioPlaySystem.h"
|
#include "AudioPlaySystem.h"
|
||||||
AudioPlaySystem mymixer;
|
AudioPlaySystem mymixer;
|
||||||
|
|
||||||
|
#define AUDIO_SAMPLE_RATE 22050
|
||||||
|
#define AUDIO_BUFFER_LENGTH (AUDIO_SAMPLE_RATE / 60 + 1)
|
||||||
|
|
||||||
void emu_sndInit() {
|
void emu_sndInit() {
|
||||||
tft.begin_audio(256, mymixer.snd_Mixer);
|
tft.begin_audio(AUDIO_BUFFER_LENGTH*2, mymixer.snd_Mixer);
|
||||||
mymixer.start();
|
mymixer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,12 +114,9 @@ void sms_Start(char * filename)
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_SND
|
#ifdef HAS_SND
|
||||||
#ifdef SOUND_PRESENT
|
|
||||||
system_init(22050);
|
system_init(22050);
|
||||||
emu_sndInit();
|
emu_sndInit();
|
||||||
#else
|
sms.use_fm = true;
|
||||||
system_init(0);
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
system_init(0);
|
system_init(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -150,20 +147,26 @@ void sms_Step(void)
|
||||||
input.pad[0] |= INPUT_BUTTON2;
|
input.pad[0] |= INPUT_BUTTON2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(check_key(KEY_DEL)) input.system |= INPUT_HARD_RESET;
|
//if (k & MASK_KEY_USER4) input.system |= INPUT_HARD_RESET;
|
||||||
// if(check_key(KEY_TAB)) input.system |= (IS_GG) ? INPUT_HARD_RESET : INPUT_SOFT_RESET;
|
//if (k & MASK_KEY_USER1) input.system |= (IS_GG) ? INPUT_HARD_RESET : INPUT_SOFT_RESET;
|
||||||
if (k & MASK_KEY_USER2) input.system |= (IS_GG) ? INPUT_START : INPUT_PAUSE;
|
if (k & MASK_KEY_USER1) input.pad[0] |= INPUT_BUTTON2;
|
||||||
|
//if (k & MASK_KEY_USER2) input.system |= (IS_GG) ? INPUT_START : INPUT_PAUSE;
|
||||||
|
|
||||||
sms_frame(0);
|
sms_frame(0);
|
||||||
//emu_printi(emu_FrameSkip());
|
|
||||||
|
|
||||||
emu_DrawVsync();
|
emu_DrawVsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SND_Process(void *stream, int len) {
|
|
||||||
#ifdef SOUND_PRESENT
|
|
||||||
#ifdef HAS_SND
|
#ifdef HAS_SND
|
||||||
// audio_play_sample(stream, 0, len);
|
static int16 sndl[512];
|
||||||
|
static int16 sndr[512];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void SND_Process(void *stream, int len) {
|
||||||
|
#ifdef HAS_SND
|
||||||
|
audio_sample * snd_buf = (audio_sample *)stream;
|
||||||
|
audio_play_sample(&sndl[0], &sndr[0], len);
|
||||||
|
for (int i = 0; i< len; i++ )
|
||||||
|
*snd_buf++ = ((sndl[i]>>8)+(sndr[i]>>8))/2+128;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#define VID_FRAME_SKIP 0x0
|
#define VID_FRAME_SKIP 0x0
|
||||||
#define TFT_VBUFFER_YCROP 0
|
#define TFT_VBUFFER_YCROP 0
|
||||||
#define SINGLELINE_RENDERING 1
|
#define SINGLELINE_RENDERING 1
|
||||||
//#define CUSTOM_SND 1
|
#define CUSTOM_SND 1
|
||||||
//#define TIMER_REND 1
|
//#define TIMER_REND 1
|
||||||
#define EXTRA_HEAP 0x10
|
#define EXTRA_HEAP 0x10
|
||||||
#define FILEBROWSER
|
#define FILEBROWSER
|
||||||
|
|
|
||||||
|
|
@ -322,9 +322,9 @@ void * emu_LineBuffer(int line)
|
||||||
#ifdef HAS_SND
|
#ifdef HAS_SND
|
||||||
#include "AudioPlaySystem.h"
|
#include "AudioPlaySystem.h"
|
||||||
AudioPlaySystem mymixer;
|
AudioPlaySystem mymixer;
|
||||||
|
#define AUDIO_BUFFER_LEN (22050/50)
|
||||||
void emu_sndInit() {
|
void emu_sndInit() {
|
||||||
tft.begin_audio(256, mymixer.snd_Mixer);
|
tft.begin_audio(AUDIO_BUFFER_LEN*2, mymixer.snd_Mixer);
|
||||||
mymixer.start();
|
mymixer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,8 @@
|
||||||
|
|
||||||
#define FLASH_STORE_START 0x100000
|
#define FLASH_STORE_START 0x100000
|
||||||
|
|
||||||
|
#ifdef HAS_USBPIO
|
||||||
|
//#undef HAS_SND
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue