void pcm_reset(void) { /* reset chip & clear external RAM */ memset(&pcm, 0, sizeof(pcm_t)); /* reset default bank */ pcm.bank = pcm.ram; /* reset channels stereo panning */ pcm.chan[0].pan = 0xff; pcm.chan[1].pan = 0xff; pcm.chan[2].pan = 0xff; pcm.chan[3].pan = 0xff; pcm.chan[4].pan = 0xff; pcm.chan[5].pan = 0xff; pcm.chan[6].pan = 0xff; pcm.chan[7].pan = 0xff; /* reset master clocks counter */ pcm.cycles = 0; /* clear blip buffers */ blip_clear(snd.blips[1][0]); blip_clear(snd.blips[1][1]); }
void pcm_reset(void) { /* reset chip & clear external RAM */ memset(&pcm, 0, sizeof(pcm_t)); /* reset default bank */ pcm.bank = pcm.ram; /* reset master clocks counter */ pcm.cycles = 0; /* clear blip delta buffers */ blip_clear(blip[0]); blip_clear(blip[1]); }
void SN76489_Reset() { SN76489_Context *chip = &SN76489; int i; for(i = 0; i <= 3; i++) { /* Initialise PSG state */ chip->Registers[2*i] = 1; /* tone freq=1 */ chip->Registers[2*i+1] = 0xf; /* vol=off */ /* Set counters to 0 */ chip->ToneFreqVals[i] = 0; /* Set flip-flops to 1 */ chip->ToneFreqPos[i] = 1; /* Clear channels output */ chip->Channels[i] = 0; /* Clear current amplitudes in delta buffer */ chip->chan_amp[i] = 0; } chip->LatchedRegister=0; /* Initialise noise generator */ chip->NoiseShiftRegister=NoiseInitialState; chip->NoiseFreq = 0x10; /* Clear Blip delta buffer */ if (blip) blip_clear(blip); }
void SN76489_Reset() { int i; for(i = 0; i <= 3; i++) { /* Initialise PSG state */ SN76489.Registers[2*i] = 1; /* tone freq=1 */ SN76489.Registers[2*i+1] = 0xf; /* vol=off */ /* Set counters to 0 */ SN76489.ToneFreqVals[i] = 0; /* Set flip-flops to 1 */ SN76489.ToneFreqPos[i] = 1; /* Clear channels output */ SN76489.Channels[i] = 0; /* Clear current amplitudes in delta buffer */ SN76489.chan_amp[i] = 0; } SN76489.LatchedRegister=0; /* Initialise noise generator */ SN76489.NoiseShiftRegister=NoiseInitialState; SN76489.NoiseFreq = 0x10; SN76489.BoostNoise = config.psgBoostNoise; /* Clear Blip delta buffer */ if (blip) blip_clear(blip); }
int main(void) { /* DDRB = 0xFF; PORTB = 0xFB; DDRC = 0x00; PORTC = 0x00; DDRD = 0xFF; PORTD = 0x01; while(1) { PORTB = 0xFD; for (int i = 0; i < 8; i++) { _delay_ms(1000); PORTD = (PORTD << 1) | (PORTD >> 7); } PORTB = 0xFE; for (int i = 0; i < 8; i++) { _delay_ms(1000); PORTD = (PORTD << 1) | (PORTD >> 7); } PORTB = 0xFB; for (int i = 0; i < 8; i++) { _delay_ms(1000); PORTD = (PORTD << 1) | (PORTD >> 7); } } */ //blip_selftest(); blip_setup(); /* cli(); DDRD = 0xFF; PORTD = 0xFF; while(1); */ while(1) { ///* if((buttonstate1 == 1) && (debounce_down1 > 256)) { pattern_index++; if (pattern_index == pattern_count) pattern_index = 0; debounce_down1 = 0; } //*/ blip_clear(); //AudioMeter(); patterns[pattern_index](); //TempoPattern(); blip_swap(); } }
void GBAudioReset(struct GBAudio* audio) { audio->nextEvent = 0; audio->nextCh1 = 0; audio->nextCh2 = 0; audio->nextCh3 = 0; audio->fadeCh3 = 0; audio->nextCh4 = 0; audio->ch1 = (struct GBAudioChannel1) { .envelope = { .dead = 2 } }; audio->ch2 = (struct GBAudioChannel2) { .envelope = { .dead = 2 } }; audio->ch3 = (struct GBAudioChannel3) { .bank = 0 }; audio->ch4 = (struct GBAudioChannel4) { .envelope = { .dead = 2 } }; audio->eventDiff = 0; audio->nextFrame = 0; audio->frame = 0; audio->nextSample = 0; audio->sampleInterval = 128; audio->lastLeft = 0; audio->lastRight = 0; audio->clock = 0; audio->volumeRight = 0; audio->volumeLeft = 0; audio->ch1Right = false; audio->ch2Right = false; audio->ch3Right = false; audio->ch4Right = false; audio->ch1Left = false; audio->ch2Left = false; audio->ch3Left = false; audio->ch4Left = false; audio->playingCh1 = false; audio->playingCh2 = false; audio->playingCh3 = false; audio->playingCh4 = false; } void GBAudioResizeBuffer(struct GBAudio* audio, size_t samples) { mCoreSyncLockAudio(audio->p->sync); audio->samples = samples; blip_clear(audio->left); blip_clear(audio->right); audio->clock = 0; mCoreSyncConsumeAudio(audio->p->sync); }
void button_test() { blip_clear(); for(int i = 0; i < 4; i++) { if(buttonstate1) blip_pixels[i].g = 0xFFFF; else blip_pixels[i].r = 0xFFFF; } for(int i = 4; i < 8; i++) { if(buttonstate2) blip_pixels[i].g = 0xFFFF; else blip_pixels[i].r = 0xFFFF; } }
void SleepPattern() { // Clear the screen. blip_clear(); blip_swap(); // Go to sleep. blip_sleep(); // When we wake up, advance to the next pattern so we don't just go back // to sleep again. pattern_index++; if (pattern_index == pattern_count) pattern_index = 0; }
void end_audio_frame() { if (frame_offset == 0) // No audio added; blip_end_frame() dislikes being called with an // offset of 0 return; assert(!(is_backwards_frame && frame_offset != get_frame_len())); // Bring the signal level at the end of the frame to zero as outlined in // set_audio_signal_level() set_audio_signal_level(0); blip_end_frame(blip, frame_offset); if (playback_started) { // Fudge playback rate by an amount proportional to the difference // between the desired and current buffer fill levels to try to steer // towards it double const fudge_factor = 1.0 + 2*max_adjust*(0.5 - fill_level()); blip_set_rates(blip, cpu_clock_rate, sample_rate*fudge_factor); } else { if (fill_level() >= 0.5) { start_audio_playback(); playback_started = true; } } int const n_samples = blip_read_samples(blip, blip_samples, ARRAY_LEN(blip_samples), 0); // We expect to read all samples from blip_buf. If something goes wrong and // we don't, clear the buffer to prevent data piling up in blip_buf's // buffer (which lacks bounds checking). int const avail = blip_samples_avail(blip); if (avail != 0) { printf("Warning: didn't read all samples from blip_buf (%d samples remain) - dropping samples\n", avail); blip_clear(blip); } #ifdef RECORD_MOVIE add_movie_audio_frame(blip_samples, n_samples); #endif // Save the samples to the audio ring buffer lock_audio(); write_samples(blip_samples, n_samples); unlock_audio(); }
blip_buffer_t* blip_alloc( int clock_rate, int sample_rate, int size ) { /* Allocate space for structure and delta buffer */ blip_buffer_t* s = (blip_buffer_t*) malloc( sizeof(blip_buffer_t) ); if (!s) return 0; s->buf = (buf_t*) malloc((size + buf_extra) * sizeof (buf_t) ); if ( s->buf != NULL ) { /* Calculate output:input ratio and convert to fixed-point */ double ratio = (double) sample_rate / clock_rate; s->factor = (int) (ratio * time_unit + 0.5); s->size = size; blip_clear( s ); } return s; }
void audio_reset(void) { int i; /* Clear blip buffers */ for (i=0; i<3; i++) { if (snd.blips[i]) { blip_clear(snd.blips[i]); } } /* Low-Pass filter */ llp = 0; rrp = 0; /* 3 band EQ */ audio_set_equalizer(); }
static void _setup(struct GBAGUIRunner* runner) { struct GBAOptions opts = { .useBios = true, .logLevel = 0, .idleOptimization = IDLE_LOOP_DETECT }; GBAConfigLoadDefaults(&runner->context.config, &opts); runner->context.gba->logHandler = GBA3DSLog; runner->context.gba->rotationSource = &rotation.d; if (hasSound) { runner->context.gba->stream = &stream; } GBAVideoSoftwareRendererCreate(&renderer); renderer.outputBuffer = linearAlloc(256 * VIDEO_VERTICAL_PIXELS * 2); renderer.outputBufferStride = 256; runner->context.renderer = &renderer.d; GBAAudioResizeBuffer(&runner->context.gba->audio, AUDIO_SAMPLES); } static void _gameLoaded(struct GBAGUIRunner* runner) { if (runner->context.gba->memory.hw.devices & HW_TILT) { HIDUSER_EnableAccelerometer(); } if (runner->context.gba->memory.hw.devices & HW_GYRO) { HIDUSER_EnableGyroscope(); } #if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF double ratio = GBAAudioCalculateRatio(1, 60, 1); blip_set_rates(runner->context.gba->audio.left, GBA_ARM7TDMI_FREQUENCY, 0x8000 * ratio); blip_set_rates(runner->context.gba->audio.right, GBA_ARM7TDMI_FREQUENCY, 0x8000 * ratio); #endif if (hasSound) { memset(audioLeft, 0, AUDIO_SAMPLES * sizeof(int16_t)); memset(audioRight, 0, AUDIO_SAMPLES * sizeof(int16_t)); } } static void _gameUnloaded(struct GBAGUIRunner* runner) { if (hasSound) { CSND_SetPlayState(8, 0); CSND_SetPlayState(9, 0); csndExecCmds(false); } if (runner->context.gba->memory.hw.devices & HW_TILT) { HIDUSER_DisableAccelerometer(); } if (runner->context.gba->memory.hw.devices & HW_GYRO) { HIDUSER_DisableGyroscope(); } } static void _drawFrame(struct GBAGUIRunner* runner, bool faded) { GX_SetDisplayTransfer(0, renderer.outputBuffer, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), tex->data, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), 0x000002202); GSPGPU_FlushDataCache(0, tex->data, 256 * VIDEO_VERTICAL_PIXELS * 2); #if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF if (!hasSound) { blip_clear(runner->context.gba->audio.left); blip_clear(runner->context.gba->audio.right); } #endif gspWaitForPPF(); _drawStart(); sf2d_draw_texture_scale_blend(tex, 40, 296, 1, -1, 0xFFFFFF3F | (faded ? 0 : 0xC0)); _drawEnd(); }