annotate ymz263b.h @ 2496:187bc857a76a default tip

Fix bug in MED mapper protection bit implementation
author Michael Pavone <pavone@retrodev.com>
date Sun, 28 Apr 2024 23:33:11 -0700
parents e8eba0cd5444
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2460
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #ifndef YMZ263B_H_
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #define YMZ263B_H_
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <stdint.h>
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include "render_audio.h"
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #include "oscilloscope.h"
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 typedef struct {
2466
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
9 uint16_t output;
2471
2f4c17b4fe10 Switch to YMZ280B ADPCM algorithm. Still sounds a little rough, but definitely much better than with the YM2610 ADPCM-A setup
Michael Pavone <pavone@retrodev.com>
parents: 2466
diff changeset
10 uint16_t adpcm_step;
2466
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
11 uint8_t fifo[128];
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
12 uint8_t fifo_read;
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
13 uint8_t fifo_write;
2460
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14
2466
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
15 uint8_t regs[4];
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
16 uint8_t counter;
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
17 uint8_t nibble;
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
18 uint8_t nibble_write;
2460
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 } ymz263b_pcm;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 typedef struct {
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 uint8_t fifo[16];
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 uint8_t read;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 uint8_t write;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 } ymz_midi_fifo;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 typedef struct {
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 audio_source *audio;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 oscilloscope *scope;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 ymz263b_pcm pcm[2];
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 ymz_midi_fifo midi_rcv;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 ymz_midi_fifo midi_trs;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 uint32_t clock_inc;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 uint32_t cycle;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 uint16_t timers[4];
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 uint16_t status;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 uint8_t base_regs[9];
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 uint8_t midi_regs[2];
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 uint8_t address;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 uint8_t midi_transmit;
2466
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
45 uint8_t pcm_counter;
2460
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 } ymz263b;
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47
2466
b5640ac9aea9 Initial stab at PCM/ADPCM support in YMZ263B emulation
Michael Pavone <pavone@retrodev.com>
parents: 2460
diff changeset
48 void ymz263b_init(ymz263b *ymz, uint32_t master_clock, uint32_t clock_divider);
2486
e8eba0cd5444 Implement turbo/slow for Pico and Copera
Michael Pavone <pavone@retrodev.com>
parents: 2471
diff changeset
49 void ymz263b_free(ymz263b *ymz);
e8eba0cd5444 Implement turbo/slow for Pico and Copera
Michael Pavone <pavone@retrodev.com>
parents: 2471
diff changeset
50 void ymz263b_adjust_master_clock(ymz263b *ymz, uint32_t master_clock);
2460
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 void ymz263b_run(ymz263b *ymz, uint32_t target_cycle);
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 uint32_t ymz263b_next_int(ymz263b *ymz);
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 void ymz263b_address_write(ymz263b *ymz, uint8_t value);
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 void ymz263b_data_write(ymz263b *ymz, uint32_t channel, uint8_t value);
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 uint8_t ymz263b_data_read(ymz263b *ymz, uint32_t channel);
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 uint8_t ymz263b_status_read(ymz263b *ymz);
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57
a4f8fa24764b Initial work on emulating the YMZ263B in the Copera
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 #endif //YMZ263B_H_