Debian Codegraph @

extern/Nuked-PSG/ympsg.h

raw
1 // Copyright (C) 2021 Nuke.YKT
2 // License: GPLv2+
3 // Version 1.0.1
4 #ifndef _YMPSG_H_
5 #define _YMPSG_H_
6 #include <stdint.h>
7
8 #define YMPSG_WRITEBUF_SIZE 2048
9 #define YMPSG_WRITEBUF_DELAY 8
10
11 typedef struct _ympsg_writebuf {
12 uint64_t time;
13 uint8_t stat;
14 uint8_t data;
15 } ympsg_writebuf;
16
17 typedef struct {
18 // IO
19 uint8_t data;
20 uint8_t latch;
21 uint8_t write_flag;
22 uint8_t write_flag_l;
23
24 uint8_t prescaler_1;
25 uint8_t prescaler_2;
26 uint8_t prescaler_2_l;
27 uint8_t reset_latch;
28 uint8_t ic;
29 uint8_t ic_latch1;
30 uint8_t ic_latch2;
31 uint8_t data_mask;
32 uint8_t reg_reset;
33 uint8_t volume[4];
34 uint16_t freq[3];
35 uint8_t noise_data;
36 uint8_t noise_of;
37 uint8_t noise_trig;
38 uint8_t noise_trig_l;
39 uint8_t rot;
40
41 uint8_t chan_sel;
42
43 uint16_t counter[4];
44 uint8_t counter_of;
45 uint8_t sign;
46 uint8_t sign_l;
47 uint8_t noise_sign_l;
48 uint16_t noise;
49 uint8_t noise_tap1;
50 uint8_t noise_tap2;
51 uint32_t noise_size;
52 uint8_t test;
53 uint8_t volume_out[4];
54
55 uint8_t stereo;
56
57 //
58 uint64_t writebuf_samplecnt;
59 uint32_t writebuf_cur;
60 uint32_t writebuf_last;
61 uint64_t writebuf_lasttime;
62 ympsg_writebuf writebuf[YMPSG_WRITEBUF_SIZE];
63
64 //
65 short vol_table[17];
66
67
68 uint8_t mute;
69 } ympsg_t;
70
71
72 void YMPSG_Write(ympsg_t *chip, uint8_t data);
73 void YMPSG_WriteStereo(ympsg_t *chip, uint8_t data);
74 uint16_t YMPSG_Read(ympsg_t *chip);
75 void YMPSG_Init(ympsg_t *chip, uint8_t real_sn, uint8_t noise_tap1, uint8_t noise_tap2, uint32_t noise_size);
76 void YMPSG_SetIC(ympsg_t *chip, uint32_t ic);
77 void YMPSG_Clock(ympsg_t *chip);
78 void YMPSG_GetOutput(ympsg_t *chip, int* left, int* right);
79 void YMPSG_Test(ympsg_t *chip, uint16_t test);
80
81
82 //void YMPSG_Generate(ympsg_t *chip, int32_t *buf);
83 void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data);
84
85 void YMPSG_SetMute(ympsg_t *chip, uint8_t mute);
86
87 #endif