summaryrefslogtreecommitdiff
path: root/ym2612.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2014-02-13 00:55:01 -0800
committerMike Pavone <pavone@retrodev.com>2014-02-13 00:55:01 -0800
commit1eebc33bf12ccec34aba87c9b6d9f05013fb037f (patch)
tree32ea3ad88d8aa31a1f7d3d497ab13f8e8f60985f /ym2612.c
parent3ef25e453e0c72b7dd19046f27977345f5dc0d2f (diff)
Better emulation of the YM-2612 busy flag
Diffstat (limited to 'ym2612.c')
-rw-r--r--ym2612.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ym2612.c b/ym2612.c
index bd4c0f2..3e43b63 100644
--- a/ym2612.c
+++ b/ym2612.c
@@ -21,7 +21,9 @@
#define dfopen(var, fname, mode)
#endif
-#define BUSY_CYCLES 17
+#define BUSY_CYCLES_ADDRESS 17
+#define BUSY_CYCLES_DATA_LOW 83
+#define BUSY_CYCLES_DATA_HIGH 47
#define OP_UPDATE_PERIOD 144
enum {
@@ -505,7 +507,7 @@ void ym_run(ym2612_context * context, uint32_t to_cycle)
}
}
}
- if (context->current_cycle >= context->write_cycle + (BUSY_CYCLES * context->clock_inc / 6)) {
+ if (context->current_cycle >= context->write_cycle + (context->busy_cycles * context->clock_inc / 6)) {
context->status &= 0x7F;
context->write_cycle = CYCLE_NEVER;
}
@@ -517,6 +519,8 @@ void ym_address_write_part1(ym2612_context * context, uint8_t address)
//printf("address_write_part1: %X\n", address);
context->selected_reg = address;
context->selected_part = 0;
+ context->write_cycle = context->current_cycle;
+ context->busy_cycles = BUSY_CYCLES_ADDRESS;
}
void ym_address_write_part2(ym2612_context * context, uint8_t address)
@@ -524,6 +528,8 @@ void ym_address_write_part2(ym2612_context * context, uint8_t address)
//printf("address_write_part2: %X\n", address);
context->selected_reg = address;
context->selected_part = 1;
+ context->write_cycle = context->current_cycle;
+ context->busy_cycles = BUSY_CYCLES_ADDRESS;
}
uint8_t fnum_to_keycode[] = {
@@ -802,6 +808,7 @@ void ym_data_write(ym2612_context * context, uint8_t value)
}
context->write_cycle = context->current_cycle;
+ context->busy_cycles = context->selected_reg < 0xA0 ? BUSY_CYCLES_DATA_LOW : BUSY_CYCLES_DATA_HIGH;
context->status |= 0x80;
}