comparison psg.c @ 843:715475788e93

Remove some debug junk from the PSG core
author Michael Pavone <pavone@retrodev.com>
date Sat, 31 Oct 2015 13:24:39 -0700
parents 9a5dc22297f2
children 252dfd29831d
comparison
equal deleted inserted replaced
842:ba93a3941300 843:715475788e93
7 #include "render.h" 7 #include "render.h"
8 #include "blastem.h" 8 #include "blastem.h"
9 #include <string.h> 9 #include <string.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <stdio.h> 11 #include <stdio.h>
12
13 FILE *blah;
14 12
15 void psg_init(psg_context * context, uint32_t sample_rate, uint32_t master_clock, uint32_t clock_div, uint32_t samples_frame) 13 void psg_init(psg_context * context, uint32_t sample_rate, uint32_t master_clock, uint32_t clock_div, uint32_t samples_frame)
16 { 14 {
17 memset(context, 0, sizeof(*context)); 15 memset(context, 0, sizeof(*context));
18 context->audio_buffer = malloc(sizeof(*context->audio_buffer) * samples_frame); 16 context->audio_buffer = malloc(sizeof(*context->audio_buffer) * samples_frame);
22 context->samples_frame = samples_frame; 20 context->samples_frame = samples_frame;
23 psg_adjust_master_clock(context, master_clock); 21 psg_adjust_master_clock(context, master_clock);
24 for (int i = 0; i < 4; i++) { 22 for (int i = 0; i < 4; i++) {
25 context->volume[i] = 0xF; 23 context->volume[i] = 0xF;
26 } 24 }
27 blah = fopen("psg.raw", "wb");
28 } 25 }
29 26
30 #define BUFFER_INC_RES 1000000000UL 27 #define BUFFER_INC_RES 1000000000UL
31 28
32 void psg_adjust_master_clock(psg_context * context, uint32_t master_clock) 29 void psg_adjust_master_clock(psg_context * context, uint32_t master_clock)
125 context->buffer_fraction -= BUFFER_INC_RES; 122 context->buffer_fraction -= BUFFER_INC_RES;
126 123
127 context->audio_buffer[context->buffer_pos++] = context->accum / context->sample_count; 124 context->audio_buffer[context->buffer_pos++] = context->accum / context->sample_count;
128 context->accum = context->sample_count = 0; 125 context->accum = context->sample_count = 0;
129 if (context->buffer_pos == context->samples_frame) { 126 if (context->buffer_pos == context->samples_frame) {
130 fwrite(context->audio_buffer, 1, context->buffer_pos, blah);
131 if (!headless) { 127 if (!headless) {
132 render_wait_psg(context); 128 render_wait_psg(context);
133 } 129 }
134 } 130 }
135 } 131 }