Mercurial > repos > blastem
diff ymz263b.h @ 2460:a4f8fa24764b
Initial work on emulating the YMZ263B in the Copera
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 23 Feb 2024 01:16:38 -0800 |
parents | |
children | b5640ac9aea9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ymz263b.h Fri Feb 23 01:16:38 2024 -0800 @@ -0,0 +1,50 @@ +#ifndef YMZ263B_H_ +#define YMZ263B_H_ + +#include <stdint.h> +#include "render_audio.h" +#include "oscilloscope.h" + +typedef struct { + uint8_t fifo[128]; + uint8_t fifo_read; + uint8_t fifo_write; + + uint8_t regs[4]; +} ymz263b_pcm; + +typedef struct { + uint8_t fifo[16]; + uint8_t read; + uint8_t write; +} ymz_midi_fifo; + +typedef struct { + audio_source *audio; + oscilloscope *scope; + ymz263b_pcm pcm[2]; + ymz_midi_fifo midi_rcv; + ymz_midi_fifo midi_trs; + + uint32_t clock_inc; + uint32_t cycle; + + uint16_t timers[4]; + + uint16_t status; + + uint8_t base_regs[9]; + uint8_t midi_regs[2]; + uint8_t address; + uint8_t midi_transmit; +} ymz263b; + +void ymz263b_init(ymz263b *ymz, uint32_t clock_divider); +void ymz263b_run(ymz263b *ymz, uint32_t target_cycle); +uint32_t ymz263b_next_int(ymz263b *ymz); +void ymz263b_address_write(ymz263b *ymz, uint8_t value); +void ymz263b_data_write(ymz263b *ymz, uint32_t channel, uint8_t value); +uint8_t ymz263b_data_read(ymz263b *ymz, uint32_t channel); +uint8_t ymz263b_status_read(ymz263b *ymz); + +#endif //YMZ263B_H_