comparison blastem.c @ 364:62177cc39049

Incredibly broken YM2612 support plus a fix to Z80 bus request
author Mike Pavone <pavone@retrodev.com>
date Wed, 29 May 2013 00:57:19 -0700
parents b7c3facee762
children 836585d389b8
comparison
equal deleted inserted replaced
363:c708dea45f8b 364:62177cc39049
196 z80_context * z_context = gen->z80; 196 z80_context * z_context = gen->z80;
197 uint32_t mclks = context->current_cycle * MCLKS_PER_68K; 197 uint32_t mclks = context->current_cycle * MCLKS_PER_68K;
198 sync_z80(z_context, mclks); 198 sync_z80(z_context, mclks);
199 if (mclks >= mclks_per_frame) { 199 if (mclks >= mclks_per_frame) {
200 ym_run(gen->ym, context->current_cycle); 200 ym_run(gen->ym, context->current_cycle);
201 gen->ym->current_cycle -= ((mclks_per_frame/MCLKS_PER_68K) / 6) * 6; 201 gen->ym->current_cycle -= mclks_per_frame/MCLKS_PER_68K;
202 //printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, mclks); 202 //printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, mclks);
203 vdp_run_context(v_context, mclks_per_frame); 203 vdp_run_context(v_context, mclks_per_frame);
204 psg_run(gen->psg, mclks/MCLKS_PER_PSG); 204 psg_run(gen->psg, mclks/MCLKS_PER_PSG);
205 gen->psg->cycles -= mclks_per_frame/MCLKS_PER_PSG; 205 gen->psg->cycles -= mclks_per_frame/MCLKS_PER_PSG;
206 if (!headless) { 206 if (!headless) {
532 dputs("bus requesting Z80"); 532 dputs("bus requesting Z80");
533 533
534 if(!reset && !busreq) { 534 if(!reset && !busreq) {
535 busack_cycle = ((gen->z80->current_cycle + Z80_ACK_DELAY) * MCLKS_PER_Z80) / MCLKS_PER_68K;//context->current_cycle + Z80_ACK_DELAY; 535 busack_cycle = ((gen->z80->current_cycle + Z80_ACK_DELAY) * MCLKS_PER_Z80) / MCLKS_PER_68K;//context->current_cycle + Z80_ACK_DELAY;
536 new_busack = Z80_REQ_ACK; 536 new_busack = Z80_REQ_ACK;
537 busreq = 1;
538 } 537 }
538 busreq = 1;
539 } else { 539 } else {
540 if (busreq) { 540 if (busreq) {
541 dputs("releasing z80 bus"); 541 dputs("releasing z80 bus");
542 #ifdef DO_DEBUG_PRINT 542 #ifdef DO_DEBUG_PRINT
543 char fname[20]; 543 char fname[20];
633 dprintf("bus requesting Z80 @ %d\n", (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80); 633 dprintf("bus requesting Z80 @ %d\n", (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80);
634 634
635 if(!reset && !busreq) { 635 if(!reset && !busreq) {
636 busack_cycle = ((gen->z80->current_cycle + Z80_ACK_DELAY) * MCLKS_PER_Z80) / MCLKS_PER_68K;//context->current_cycle + Z80_ACK_DELAY; 636 busack_cycle = ((gen->z80->current_cycle + Z80_ACK_DELAY) * MCLKS_PER_Z80) / MCLKS_PER_68K;//context->current_cycle + Z80_ACK_DELAY;
637 new_busack = Z80_REQ_ACK; 637 new_busack = Z80_REQ_ACK;
638 busreq = 1;
639 } 638 }
639 busreq = 1;
640 } else { 640 } else {
641 if (busreq) { 641 if (busreq) {
642 dprintf("releasing Z80 bus @ %d\n", (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80); 642 dprintf("releasing Z80 bus @ %d\n", (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80);
643 #ifdef DO_DEBUG_PRINT 643 #ifdef DO_DEBUG_PRINT
644 char fname[20]; 644 char fname[20];
1418 } 1418 }
1419 } 1419 }
1420 1420
1421 #define PSG_CLKS_NTSC (3579545/16) 1421 #define PSG_CLKS_NTSC (3579545/16)
1422 #define PSG_CLKS_PAL (3546893/16) 1422 #define PSG_CLKS_PAL (3546893/16)
1423 #define YM_CLKS_NTSC 7670454
1424 #define YM_CLKS_PAL 7600485
1423 1425
1424 int main(int argc, char ** argv) 1426 int main(int argc, char ** argv)
1425 { 1427 {
1426 if (argc < 2) { 1428 if (argc < 2) {
1427 fputs("Usage: blastem FILENAME\n", stderr); 1429 fputs("Usage: blastem FILENAME\n", stderr);
1503 vdp_context v_context; 1505 vdp_context v_context;
1504 1506
1505 init_vdp_context(&v_context); 1507 init_vdp_context(&v_context);
1506 1508
1507 ym2612_context y_context; 1509 ym2612_context y_context;
1508 ym_init(&y_context); 1510 ym_init(&y_context, render_sample_rate(), fps == 60 ? YM_CLKS_NTSC : YM_CLKS_PAL, render_audio_buffer());
1509 1511
1510 psg_context p_context; 1512 psg_context p_context;
1511 psg_init(&p_context, render_sample_rate(), fps == 60 ? PSG_CLKS_NTSC : PSG_CLKS_PAL, render_audio_buffer()); 1513 psg_init(&p_context, render_sample_rate(), fps == 60 ? PSG_CLKS_NTSC : PSG_CLKS_PAL, render_audio_buffer());
1512 1514
1513 z80_context z_context; 1515 z80_context z_context;