Mercurial > repos > blastem
comparison ym2612.c @ 535:aaa77e351c24
Better emulation of the YM-2612 busy flag
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 13 Feb 2014 00:55:01 -0800 |
parents | 666210adf87b |
children | 55b550fe8891 |
comparison
equal
deleted
inserted
replaced
534:c641006da28e | 535:aaa77e351c24 |
---|---|
19 #else | 19 #else |
20 #define dfprintf | 20 #define dfprintf |
21 #define dfopen(var, fname, mode) | 21 #define dfopen(var, fname, mode) |
22 #endif | 22 #endif |
23 | 23 |
24 #define BUSY_CYCLES 17 | 24 #define BUSY_CYCLES_ADDRESS 17 |
25 #define BUSY_CYCLES_DATA_LOW 83 | |
26 #define BUSY_CYCLES_DATA_HIGH 47 | |
25 #define OP_UPDATE_PERIOD 144 | 27 #define OP_UPDATE_PERIOD 144 |
26 | 28 |
27 enum { | 29 enum { |
28 REG_LFO = 0x22, | 30 REG_LFO = 0x22, |
29 REG_TIMERA_HIGH = 0x24, | 31 REG_TIMERA_HIGH = 0x24, |
503 render_wait_ym(context); | 505 render_wait_ym(context); |
504 } | 506 } |
505 } | 507 } |
506 } | 508 } |
507 } | 509 } |
508 if (context->current_cycle >= context->write_cycle + (BUSY_CYCLES * context->clock_inc / 6)) { | 510 if (context->current_cycle >= context->write_cycle + (context->busy_cycles * context->clock_inc / 6)) { |
509 context->status &= 0x7F; | 511 context->status &= 0x7F; |
510 context->write_cycle = CYCLE_NEVER; | 512 context->write_cycle = CYCLE_NEVER; |
511 } | 513 } |
512 //printf("Done running YM2612 at cycle %d\n", context->current_cycle, to_cycle); | 514 //printf("Done running YM2612 at cycle %d\n", context->current_cycle, to_cycle); |
513 } | 515 } |
515 void ym_address_write_part1(ym2612_context * context, uint8_t address) | 517 void ym_address_write_part1(ym2612_context * context, uint8_t address) |
516 { | 518 { |
517 //printf("address_write_part1: %X\n", address); | 519 //printf("address_write_part1: %X\n", address); |
518 context->selected_reg = address; | 520 context->selected_reg = address; |
519 context->selected_part = 0; | 521 context->selected_part = 0; |
522 context->write_cycle = context->current_cycle; | |
523 context->busy_cycles = BUSY_CYCLES_ADDRESS; | |
520 } | 524 } |
521 | 525 |
522 void ym_address_write_part2(ym2612_context * context, uint8_t address) | 526 void ym_address_write_part2(ym2612_context * context, uint8_t address) |
523 { | 527 { |
524 //printf("address_write_part2: %X\n", address); | 528 //printf("address_write_part2: %X\n", address); |
525 context->selected_reg = address; | 529 context->selected_reg = address; |
526 context->selected_part = 1; | 530 context->selected_part = 1; |
531 context->write_cycle = context->current_cycle; | |
532 context->busy_cycles = BUSY_CYCLES_ADDRESS; | |
527 } | 533 } |
528 | 534 |
529 uint8_t fnum_to_keycode[] = { | 535 uint8_t fnum_to_keycode[] = { |
530 //F11 = 0 | 536 //F11 = 0 |
531 0,0,0,0,0,0,0,1, | 537 0,0,0,0,0,0,0,1, |
800 } | 806 } |
801 } | 807 } |
802 } | 808 } |
803 | 809 |
804 context->write_cycle = context->current_cycle; | 810 context->write_cycle = context->current_cycle; |
811 context->busy_cycles = context->selected_reg < 0xA0 ? BUSY_CYCLES_DATA_LOW : BUSY_CYCLES_DATA_HIGH; | |
805 context->status |= 0x80; | 812 context->status |= 0x80; |
806 } | 813 } |
807 | 814 |
808 uint8_t ym_read_status(ym2612_context * context) | 815 uint8_t ym_read_status(ym2612_context * context) |
809 { | 816 { |