Mercurial > repos > blastem
comparison blastem.c @ 785:0e5f14d9a579
Prep for 0.3.0 release
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 21 Jul 2015 22:03:58 -0700 |
parents | 6e1711d56633 |
children | 283bdcd5bdb8 |
comparison
equal
deleted
inserted
replaced
784:c3e3a0d734e2 | 785:0e5f14d9a579 |
---|---|
16 #include "romdb.h" | 16 #include "romdb.h" |
17 #include <stdio.h> | 17 #include <stdio.h> |
18 #include <stdlib.h> | 18 #include <stdlib.h> |
19 #include <string.h> | 19 #include <string.h> |
20 | 20 |
21 #define BLASTEM_VERSION "0.2.0" | 21 #define BLASTEM_VERSION "0.3.0" |
22 | 22 |
23 #define MCLKS_NTSC 53693175 | 23 #define MCLKS_NTSC 53693175 |
24 #define MCLKS_PAL 53203395 | 24 #define MCLKS_PAL 53203395 |
25 | 25 |
26 #define MCLKS_PER_68K 7 | 26 #define MCLKS_PER_68K 7 |
27 #define MCLKS_PER_YM MCLKS_PER_68K | 27 #define MCLKS_PER_YM MCLKS_PER_68K |
28 #define MCLKS_PER_Z80 15 | 28 #define MCLKS_PER_Z80 15 |
29 #define MCLKS_PER_PSG (MCLKS_PER_Z80*16) | 29 #define MCLKS_PER_PSG (MCLKS_PER_Z80*16) |
30 #define DEFAULT_SYNC_INTERVAL MCLKS_LINE | |
30 | 31 |
31 //TODO: Figure out the exact value for this | 32 //TODO: Figure out the exact value for this |
32 #define LINES_NTSC 262 | 33 #define LINES_NTSC 262 |
33 #define LINES_PAL 312 | 34 #define LINES_PAL 312 |
34 | 35 |
223 vdp_context * v_context = gen->vdp; | 224 vdp_context * v_context = gen->vdp; |
224 z80_context * z_context = gen->z80; | 225 z80_context * z_context = gen->z80; |
225 uint32_t mclks = context->current_cycle; | 226 uint32_t mclks = context->current_cycle; |
226 sync_z80(z_context, mclks); | 227 sync_z80(z_context, mclks); |
227 sync_sound(gen, mclks); | 228 sync_sound(gen, mclks); |
228 while (context->current_cycle > mclks) { | |
229 mclks = context->current_cycle; | |
230 sync_z80(z_context, mclks); | |
231 sync_sound(gen, mclks); | |
232 } | |
233 vdp_run_context(v_context, mclks); | 229 vdp_run_context(v_context, mclks); |
234 if (v_context->frame != last_frame_num) { | 230 if (v_context->frame != last_frame_num) { |
235 //printf("reached frame end %d | MCLK Cycles: %d, Target: %d, VDP cycles: %d, vcounter: %d, hslot: %d\n", last_frame_num, mclks, gen->frame_end, v_context->cycles, v_context->vcounter, v_context->hslot); | 231 //printf("reached frame end %d | MCLK Cycles: %d, Target: %d, VDP cycles: %d, vcounter: %d, hslot: %d\n", last_frame_num, mclks, gen->frame_end, v_context->cycles, v_context->vcounter, v_context->hslot); |
236 last_frame_num = v_context->frame; | 232 last_frame_num = v_context->frame; |
237 | 233 |
1051 gen.master_clock = gen.normal_clock = fps == 60 ? MCLKS_NTSC : MCLKS_PAL; | 1047 gen.master_clock = gen.normal_clock = fps == 60 ? MCLKS_NTSC : MCLKS_PAL; |
1052 | 1048 |
1053 init_vdp_context(&v_context, version_reg & 0x40); | 1049 init_vdp_context(&v_context, version_reg & 0x40); |
1054 gen.frame_end = vdp_cycles_to_frame_end(&v_context); | 1050 gen.frame_end = vdp_cycles_to_frame_end(&v_context); |
1055 char * config_cycles = tern_find_path(config, "clocks\0max_cycles\0").ptrval; | 1051 char * config_cycles = tern_find_path(config, "clocks\0max_cycles\0").ptrval; |
1056 gen.max_cycles = config_cycles ? atoi(config_cycles) : 10000000; | 1052 gen.max_cycles = config_cycles ? atoi(config_cycles) : DEFAULT_SYNC_INTERVAL; |
1057 | 1053 |
1058 ym2612_context y_context; | 1054 ym2612_context y_context; |
1059 ym_init(&y_context, render_sample_rate(), gen.master_clock, MCLKS_PER_YM, render_audio_buffer(), ym_log ? YM_OPT_WAVE_LOG : 0); | 1055 ym_init(&y_context, render_sample_rate(), gen.master_clock, MCLKS_PER_YM, render_audio_buffer(), ym_log ? YM_OPT_WAVE_LOG : 0); |
1060 | 1056 |
1061 psg_context p_context; | 1057 psg_context p_context; |