More audio stuff

This commit is contained in:
meepingsnesroms
2018-09-25 12:55:59 -07:00
parent b27a66c773
commit 678e5b08ac
4 changed files with 9 additions and 7 deletions

View File

@@ -259,6 +259,7 @@ void retro_run(void)
//TODO make mouse cursor
}
audio_batch_cb(palmAudio, AUDIO_SAMPLES);
video_cb(palmFramebuffer, screenWidth, screenHeight, screenWidth * sizeof(uint16_t));
}

View File

@@ -40,7 +40,7 @@ sd_card_t palmSdCard;
misc_hw_t palmMisc;
uint16_t palmFramebuffer[160 * (160 + 60)];//really 160*160, the extra pixels are the silkscreened digitizer area
uint16_t* palmExtendedFramebuffer;
int16_t palmAudio[AUDIO_SAMPLES];
int16_t palmAudio[AUDIO_SAMPLES * 2];
uint32_t palmAudioSampleIndex;
uint32_t palmSpecialFeatures;
double palmCrystalCycles;//how many cycles before toggling the 32.768 kHz crystal
@@ -95,7 +95,7 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec
memset(palmExtendedFramebuffer, 0x00, 320 * 320 * sizeof(uint16_t));
//add 320*320 silkscreen image later, 2xBRZ should be able to make 320*320 version of the 160*160 silkscreen
}
memset(palmAudio, 0x00, AUDIO_SAMPLES * sizeof(int16_t));
memset(palmAudio, 0x00, AUDIO_SAMPLES * 2 * sizeof(int16_t));
m68328Reset();
sed1376Reset();
ads7846Reset();

View File

@@ -10,8 +10,8 @@ extern "C" {
#include <stdarg.h>
#include <stdio.h>
//#include "memoryAccess.h"//for size macros
#include "specs/emuFeatureRegistersSpec.h"
#include "memoryAccess.h"//for size macros
#include "specs/emuFeatureRegistersSpec.h"//for feature names
//to enable degguging define EMU_DEBUG, all options below do nothing unless EMU_DEBUG is defined
//to enable sandbox debugging define EMU_SANDBOX

View File

@@ -622,7 +622,7 @@ static inline uint16_t getCurrentSpeakerSample(){
static inline void samplePwmXClk32(){
//call every clk32, adds samples to audio buffer
if(palmAudioSampleIndex < AUDIO_SAMPLES){
if(palmAudioSampleIndex < AUDIO_SAMPLES * 2){
double dutyCycle;
uint16_t firstLowSample;
uint8_t audioMode = registerArrayRead8(PCR) >> 2 & 0x03;
@@ -656,8 +656,9 @@ static inline void samplePwmXClk32(){
//add samples to audio buffer
firstLowSample = dutyCycle * AUDIO_DUTY_CYCLE_SIZE;
for(uint16_t count = 0; count < AUDIO_DUTY_CYCLE_SIZE; count++){
palmAudio[palmAudioSampleIndex] = (count < firstLowSample) ? 32767 : -32768;
palmAudioSampleIndex++;
palmAudio[palmAudioSampleIndex] = (count < firstLowSample) ? 0x6666 : -0x6666;//not full volume, leave 20% for audio spikes
palmAudio[palmAudioSampleIndex + 1] = palmAudio[palmAudioSampleIndex];
palmAudioSampleIndex += 2;
}
}
}