diff --git a/bugs/unimplementedHardware.txt b/bugs/unimplementedHardware.txt index e80c382..6775f2c 100644 --- a/bugs/unimplementedHardware.txt +++ b/bugs/unimplementedHardware.txt @@ -25,6 +25,7 @@ ICR POL(1,2,3,6) may flip the pin value as well as the interrupt, POL5 does not edge triggered INT* don't clear on write to ISR when masked in IMR(at least that seems to be the reason) if a sound interrupt is triggered while the button interrupt is disabled the button interrupt will still trigger(in galax game) Cyclone will cause SIGSEGVs, don't know why yet +audio can max out the resampler buffer, the max 1 FIFO sample can play is around 2.5 minutes(CLK32 / period(257) / clockDivider(16) / prescaler(128) / repeat(8))(257 * 16 * 128 * 8 / 32768=128.5 seconds) Debug tools: ADS7846 channels can't be read in single reference mode in hwTestSuite diff --git a/src/audio/inductor.c b/src/audio/inductor.c index 0d4fae8..b2b5814 100644 --- a/src/audio/inductor.c +++ b/src/audio/inductor.c @@ -6,7 +6,7 @@ #include "blip_buf.h" -#define INDUCTOR_CLOCK_POWER 0.000001//the amount 1 clock of true or false will change the inductors total value +#define INDUCTOR_CLOCK_POWER 0.0001//the amount 1 clock of true or false will change the inductors total value double inductorCurrentCharge; @@ -19,10 +19,10 @@ void inductorReset(){ } void inductorAddClocks(int32_t clocks, bool charge){ - inductorCurrentCharge = dClamp(0.0, inductorCurrentCharge + (charge ? +clocks : -clocks) * INDUCTOR_CLOCK_POWER, 1.0); + inductorCurrentCharge = dClamp(-1.0, inductorCurrentCharge + (charge ? +clocks : -clocks) * INDUCTOR_CLOCK_POWER, 1.0); } void inductorSampleAudio(int32_t now){ - blip_add_delta_fast(palmAudioResampler, now, (inductorCurrentCharge - inductorChargeAtLastSample) * AUDIO_VOLUME); + blip_add_delta_fast(palmAudioResampler, now, (inductorCurrentCharge - inductorChargeAtLastSample) * INT16_MAX); inductorChargeAtLastSample = inductorCurrentCharge; } diff --git a/src/emulator.c b/src/emulator.c index 2079e0f..0657fb2 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -63,7 +63,7 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec palmRom = malloc(ROM_SIZE + 4); palmReg = malloc(REG_SIZE + 4); palmAudio = malloc(AUDIO_SAMPLES_PER_FRAME * 2 * sizeof(int16_t)); - palmAudioResampler = blip_new(AUDIO_SAMPLES_PER_FRAME * 2);//have more than one frame of samples in case its written to at the end of the frame + palmAudioResampler = blip_new(AUDIO_SAMPLE_RATE);//have 1 second of samples if(specialFeatures & FEATURE_320x320) palmExtendedFramebuffer = malloc(320 * (320 + 120) * sizeof(uint16_t));//really 320*320, the extra pixels are the silkscreened digitizer area else @@ -104,7 +104,7 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec //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_PER_FRAME * 2/*channels*/ * sizeof(int16_t)); - blip_set_rates(palmAudioResampler, AUDIO_END_OF_FRAME, AUDIO_SAMPLES_PER_FRAME); + blip_set_rates(palmAudioResampler, AUDIO_END_OF_FRAME * EMU_FPS, AUDIO_SAMPLE_RATE); flx68000Reset(); sed1376Reset(); ads7846Reset(); diff --git a/src/emulator.h b/src/emulator.h index 14ad258..934867f 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -113,7 +113,6 @@ typedef struct{ //system constants #define CRYSTAL_FREQUENCY 32768 -#define AUDIO_VOLUME 1000000 #define AUDIO_SAMPLES_PER_FRAME (AUDIO_SAMPLE_RATE / EMU_FPS) #define AUDIO_END_OF_FRAME (235929600 / EMU_FPS)//smallest amount of time a second can be split into:(2.0 * (14.0 * (255 + 1.0) + 15 + 1.0)) * 32768 == 235929600, used to convert the variable timing of SYSCLK and CLK32 to a fixed location in the current frame 0<->AUDIO_END_OF_FRAME #define AUDIO_WAIT_FOR_SAMPLE INT32_MIN