├── opnb.h
├── opnb.c
└── LICENSE
/opnb.h:
--------------------------------------------------------------------------------
1 | /* Nuked OPNB
2 | * Copyright (C) 2020 Nuke.YKT
3 | *
4 | * This file is part of Nuked OPNB.
5 | *
6 | * Nuked OPNB is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as
8 | * published by the Free Software Foundation, either version 2.1
9 | * of the License, or (at your option) any later version.
10 | *
11 | * Nuked OPNB is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with Nuked OPNB. If not, see .
18 | *
19 | * Nuked OPNB emulator.
20 | * Thanks:
21 | * siliconpr0n.org(John McMaster, digshadow):
22 | * YM2610 and other FM chip decaps and die shots.
23 | *
24 | * version: 0.0
25 | */
26 | #ifndef _OPM_H_
27 | #define _OPM_H_
28 |
29 | #include
30 |
31 |
32 | typedef struct {
33 | uint32_t clock_state;
34 | uint32_t cycles;
35 | uint8_t ic;
36 | uint32_t ic_sr;
37 | uint32_t ic2;
38 | uint32_t ic_latch;
39 |
40 | uint32_t fmcycles;
41 | uint32_t fmstate_l, fmstate_h;
42 | uint32_t slot_counter_l, slot_counter_h;
43 | uint32_t fmcycle[24];
44 | uint8_t fm_data;
45 | uint16_t fm_address;
46 | uint16_t timer_a_reg;
47 | uint8_t timer_b_reg;
48 | uint8_t mode_1c;
49 | uint8_t mode_ch3;
50 | uint8_t mode_csm;
51 | uint8_t mode_test;
52 | uint8_t mode_test2;
53 | uint8_t mode_kon_operator[4];
54 | uint8_t mode_kon_channel;
55 | uint8_t lfo_en;
56 | uint8_t lfo_freq;
57 | uint8_t timer_a_load;
58 | uint8_t timer_a_enable;
59 | uint8_t timer_a_reset;
60 | uint8_t timer_b_load;
61 | uint8_t timer_b_enable;
62 | uint8_t timer_b_reset;
63 | uint8_t write_fm_address;
64 | uint8_t write_fm_data;
65 | uint8_t write_mode_1c;
66 | uint8_t write_mode_27;
67 | uint8_t write_mode_25;
68 | uint8_t write_mode_24;
69 | uint8_t write_mode_21;
70 | uint8_t write_mode_28;
71 | uint8_t write_mode_26;
72 | uint8_t write_mode_22;
73 | uint8_t write_mode_02;
74 | uint8_t write_d;
75 | uint8_t write_d_en;
76 | uint8_t write_a;
77 | uint8_t write_a_en;
78 | uint16_t write_data;
79 | uint8_t write_ssg;
80 | uint8_t fm_multi[2][12];
81 | uint8_t fm_dt[2][12];
82 | uint8_t fm_tl[2][12];
83 | uint8_t fm_ar[2][12];
84 | uint8_t fm_ks[2][12];
85 | uint8_t fm_ar[2][12];
86 | uint8_t fm_ks[2][12];
87 | uint8_t fm_dr[2][12];
88 | uint8_t fm_am[2][12];
89 | uint8_t fm_sr[2][12];
90 | uint8_t fm_rr[2][12];
91 | uint8_t fm_sl[2][12];
92 | uint8_t fm_ssg_eg[2][12];
93 | uint8_t fm_reg_a4;
94 | uint8_t fm_reg_ac;
95 | uint16_t fm_fnum[6];
96 | uint8_t fm_block[6];
97 | uint16_t fm_fnum_3ch[6];
98 | uint8_t fm_block_3ch[6];
99 | uint8_t fm_connect[6];
100 | uint8_t fm_fb[6];
101 | uint8_t fm_pms[6];
102 | uint8_t fm_ams[6];
103 | uint8_t fm_pan_l[6];
104 | uint8_t fm_pan_r[6];
105 | } opnb_t;
106 |
107 | #endif
108 |
--------------------------------------------------------------------------------
/opnb.c:
--------------------------------------------------------------------------------
1 | /* Nuked OPNB
2 | * Copyright (C) 2020 Nuke.YKT
3 | *
4 | * This file is part of Nuked OPNB.
5 | *
6 | * Nuked OPNB is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as
8 | * published by the Free Software Foundation, either version 2.1
9 | * of the License, or (at your option) any later version.
10 | *
11 | * Nuked OPNB is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with Nuked OPNB. If not, see .
18 | *
19 | * Nuked OPNB emulator.
20 | * Thanks:
21 | * siliconpr0n.org(John McMaster, digshadow):
22 | * YM2610 and other FM chip decaps and die shots.
23 | *
24 | * version: 0.0
25 | */
26 | #include
27 | #include
28 | #include "opnb.h"
29 |
30 | enum {
31 | eg_num_attack = 0,
32 | eg_num_decay = 1,
33 | eg_num_sustain = 2,
34 | eg_num_release = 3
35 | };
36 |
37 | enum {
38 | clock_fm_1 = 0,
39 | clock_fm_2,
40 | };
41 |
42 | /* logsin table */
43 | static const uint16_t logsinrom[256] = {
44 | 0x859, 0x6c3, 0x607, 0x58b, 0x52e, 0x4e4, 0x4a6, 0x471,
45 | 0x443, 0x41a, 0x3f5, 0x3d3, 0x3b5, 0x398, 0x37e, 0x365,
46 | 0x34e, 0x339, 0x324, 0x311, 0x2ff, 0x2ed, 0x2dc, 0x2cd,
47 | 0x2bd, 0x2af, 0x2a0, 0x293, 0x286, 0x279, 0x26d, 0x261,
48 | 0x256, 0x24b, 0x240, 0x236, 0x22c, 0x222, 0x218, 0x20f,
49 | 0x206, 0x1fd, 0x1f5, 0x1ec, 0x1e4, 0x1dc, 0x1d4, 0x1cd,
50 | 0x1c5, 0x1be, 0x1b7, 0x1b0, 0x1a9, 0x1a2, 0x19b, 0x195,
51 | 0x18f, 0x188, 0x182, 0x17c, 0x177, 0x171, 0x16b, 0x166,
52 | 0x160, 0x15b, 0x155, 0x150, 0x14b, 0x146, 0x141, 0x13c,
53 | 0x137, 0x133, 0x12e, 0x129, 0x125, 0x121, 0x11c, 0x118,
54 | 0x114, 0x10f, 0x10b, 0x107, 0x103, 0x0ff, 0x0fb, 0x0f8,
55 | 0x0f4, 0x0f0, 0x0ec, 0x0e9, 0x0e5, 0x0e2, 0x0de, 0x0db,
56 | 0x0d7, 0x0d4, 0x0d1, 0x0cd, 0x0ca, 0x0c7, 0x0c4, 0x0c1,
57 | 0x0be, 0x0bb, 0x0b8, 0x0b5, 0x0b2, 0x0af, 0x0ac, 0x0a9,
58 | 0x0a7, 0x0a4, 0x0a1, 0x09f, 0x09c, 0x099, 0x097, 0x094,
59 | 0x092, 0x08f, 0x08d, 0x08a, 0x088, 0x086, 0x083, 0x081,
60 | 0x07f, 0x07d, 0x07a, 0x078, 0x076, 0x074, 0x072, 0x070,
61 | 0x06e, 0x06c, 0x06a, 0x068, 0x066, 0x064, 0x062, 0x060,
62 | 0x05e, 0x05c, 0x05b, 0x059, 0x057, 0x055, 0x053, 0x052,
63 | 0x050, 0x04e, 0x04d, 0x04b, 0x04a, 0x048, 0x046, 0x045,
64 | 0x043, 0x042, 0x040, 0x03f, 0x03e, 0x03c, 0x03b, 0x039,
65 | 0x038, 0x037, 0x035, 0x034, 0x033, 0x031, 0x030, 0x02f,
66 | 0x02e, 0x02d, 0x02b, 0x02a, 0x029, 0x028, 0x027, 0x026,
67 | 0x025, 0x024, 0x023, 0x022, 0x021, 0x020, 0x01f, 0x01e,
68 | 0x01d, 0x01c, 0x01b, 0x01a, 0x019, 0x018, 0x017, 0x017,
69 | 0x016, 0x015, 0x014, 0x014, 0x013, 0x012, 0x011, 0x011,
70 | 0x010, 0x00f, 0x00f, 0x00e, 0x00d, 0x00d, 0x00c, 0x00c,
71 | 0x00b, 0x00a, 0x00a, 0x009, 0x009, 0x008, 0x008, 0x007,
72 | 0x007, 0x007, 0x006, 0x006, 0x005, 0x005, 0x005, 0x004,
73 | 0x004, 0x004, 0x003, 0x003, 0x003, 0x002, 0x002, 0x002,
74 | 0x002, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001,
75 | 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000
76 | };
77 |
78 | /* exp table */
79 | static const uint16_t exprom[256] = {
80 | 0x7fa, 0x7f5, 0x7ef, 0x7ea, 0x7e4, 0x7df, 0x7da, 0x7d4,
81 | 0x7cf, 0x7c9, 0x7c4, 0x7bf, 0x7b9, 0x7b4, 0x7ae, 0x7a9,
82 | 0x7a4, 0x79f, 0x799, 0x794, 0x78f, 0x78a, 0x784, 0x77f,
83 | 0x77a, 0x775, 0x770, 0x76a, 0x765, 0x760, 0x75b, 0x756,
84 | 0x751, 0x74c, 0x747, 0x742, 0x73d, 0x738, 0x733, 0x72e,
85 | 0x729, 0x724, 0x71f, 0x71a, 0x715, 0x710, 0x70b, 0x706,
86 | 0x702, 0x6fd, 0x6f8, 0x6f3, 0x6ee, 0x6e9, 0x6e5, 0x6e0,
87 | 0x6db, 0x6d6, 0x6d2, 0x6cd, 0x6c8, 0x6c4, 0x6bf, 0x6ba,
88 | 0x6b5, 0x6b1, 0x6ac, 0x6a8, 0x6a3, 0x69e, 0x69a, 0x695,
89 | 0x691, 0x68c, 0x688, 0x683, 0x67f, 0x67a, 0x676, 0x671,
90 | 0x66d, 0x668, 0x664, 0x65f, 0x65b, 0x657, 0x652, 0x64e,
91 | 0x649, 0x645, 0x641, 0x63c, 0x638, 0x634, 0x630, 0x62b,
92 | 0x627, 0x623, 0x61e, 0x61a, 0x616, 0x612, 0x60e, 0x609,
93 | 0x605, 0x601, 0x5fd, 0x5f9, 0x5f5, 0x5f0, 0x5ec, 0x5e8,
94 | 0x5e4, 0x5e0, 0x5dc, 0x5d8, 0x5d4, 0x5d0, 0x5cc, 0x5c8,
95 | 0x5c4, 0x5c0, 0x5bc, 0x5b8, 0x5b4, 0x5b0, 0x5ac, 0x5a8,
96 | 0x5a4, 0x5a0, 0x59c, 0x599, 0x595, 0x591, 0x58d, 0x589,
97 | 0x585, 0x581, 0x57e, 0x57a, 0x576, 0x572, 0x56f, 0x56b,
98 | 0x567, 0x563, 0x560, 0x55c, 0x558, 0x554, 0x551, 0x54d,
99 | 0x549, 0x546, 0x542, 0x53e, 0x53b, 0x537, 0x534, 0x530,
100 | 0x52c, 0x529, 0x525, 0x522, 0x51e, 0x51b, 0x517, 0x514,
101 | 0x510, 0x50c, 0x509, 0x506, 0x502, 0x4ff, 0x4fb, 0x4f8,
102 | 0x4f4, 0x4f1, 0x4ed, 0x4ea, 0x4e7, 0x4e3, 0x4e0, 0x4dc,
103 | 0x4d9, 0x4d6, 0x4d2, 0x4cf, 0x4cc, 0x4c8, 0x4c5, 0x4c2,
104 | 0x4be, 0x4bb, 0x4b8, 0x4b5, 0x4b1, 0x4ae, 0x4ab, 0x4a8,
105 | 0x4a4, 0x4a1, 0x49e, 0x49b, 0x498, 0x494, 0x491, 0x48e,
106 | 0x48b, 0x488, 0x485, 0x482, 0x47e, 0x47b, 0x478, 0x475,
107 | 0x472, 0x46f, 0x46c, 0x469, 0x466, 0x463, 0x460, 0x45d,
108 | 0x45a, 0x457, 0x454, 0x451, 0x44e, 0x44b, 0x448, 0x445,
109 | 0x442, 0x43f, 0x43c, 0x439, 0x436, 0x433, 0x430, 0x42d,
110 | 0x42a, 0x428, 0x425, 0x422, 0x41f, 0x41c, 0x419, 0x416,
111 | 0x414, 0x411, 0x40e, 0x40b, 0x408, 0x406, 0x403, 0x400
112 | };
113 |
114 | /* Note table */
115 | static const uint32_t fn_note[16] = {
116 | 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3
117 | };
118 |
119 | /* Envelope generator */
120 | static const uint32_t eg_stephi[4][4] = {
121 | { 0, 0, 0, 0 },
122 | { 1, 0, 0, 0 },
123 | { 1, 0, 1, 0 },
124 | { 1, 1, 1, 0 }
125 | };
126 |
127 | static const uint8_t eg_am_shift[4] = {
128 | 7, 3, 1, 0
129 | };
130 |
131 | /* Phase generator */
132 | static const uint32_t pg_detune[8] = { 16, 17, 19, 20, 22, 24, 27, 29 };
133 |
134 | static const uint32_t pg_lfo_sh1[8][8] = {
135 | { 7, 7, 7, 7, 7, 7, 7, 7 },
136 | { 7, 7, 7, 7, 7, 7, 7, 7 },
137 | { 7, 7, 7, 7, 7, 7, 1, 1 },
138 | { 7, 7, 7, 7, 1, 1, 1, 1 },
139 | { 7, 7, 7, 1, 1, 1, 1, 0 },
140 | { 7, 7, 1, 1, 0, 0, 0, 0 },
141 | { 7, 7, 1, 1, 0, 0, 0, 0 },
142 | { 7, 7, 1, 1, 0, 0, 0, 0 }
143 | };
144 |
145 | static const uint32_t pg_lfo_sh2[8][8] = {
146 | { 7, 7, 7, 7, 7, 7, 7, 7 },
147 | { 7, 7, 7, 7, 2, 2, 2, 2 },
148 | { 7, 7, 7, 2, 2, 2, 7, 7 },
149 | { 7, 7, 2, 2, 7, 7, 2, 2 },
150 | { 7, 7, 2, 7, 7, 7, 2, 7 },
151 | { 7, 7, 7, 2, 7, 7, 2, 1 },
152 | { 7, 7, 7, 2, 7, 7, 2, 1 },
153 | { 7, 7, 7, 2, 7, 7, 2, 1 }
154 | };
155 |
156 | /* Address decoder */
157 | static const uint32_t slot_map[16] = {
158 | 0x000, /* Ch1 OP1/OP2 */
159 | 0x001, /* Ch2 OP1/OP2 */
160 | 0x002, /* Ch3 OP1/OP2 */
161 | 0x003, /* Illegal */
162 | 0x100, /* Ch4 OP1/OP2 */
163 | 0x101, /* Ch5 OP1/OP2 */
164 | 0x102, /* Ch6 OP1/OP2 */
165 | 0x103, /* Illegal */
166 | 0x004, /* Ch1 OP3/OP4 */
167 | 0x005, /* Ch2 OP3/OP4 */
168 | 0x006, /* Ch3 OP3/OP4 */
169 | 0x007, /* Illegal */
170 | 0x104, /* Ch4 OP3/OP4 */
171 | 0x105, /* Ch5 OP3/OP4 */
172 | 0x106 /* Ch6 OP3/OP4 */
173 | 0x107, /* Illegal */
174 | };
175 |
176 | /* LFO */
177 | static const uint32_t lfo_cycles[8] = {
178 | 108, 77, 71, 67, 62, 44, 8, 5
179 | };
180 |
181 | /* FM algorithm */
182 | static const uint32_t fm_algorithm[4][6][8] = {
183 | {
184 | { 1, 1, 1, 1, 1, 1, 1, 1 }, /* OP1_0 */
185 | { 1, 1, 1, 1, 1, 1, 1, 1 }, /* OP1_1 */
186 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* OP2 */
187 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* Last operator */
188 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* Last operator */
189 | { 0, 0, 0, 0, 0, 0, 0, 1 } /* Out */
190 | },
191 | {
192 | { 0, 1, 0, 0, 0, 1, 0, 0 }, /* OP1_0 */
193 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* OP1_1 */
194 | { 1, 1, 1, 0, 0, 0, 0, 0 }, /* OP2 */
195 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* Last operator */
196 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* Last operator */
197 | { 0, 0, 0, 0, 0, 1, 1, 1 } /* Out */
198 | },
199 | {
200 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* OP1_0 */
201 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* OP1_1 */
202 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* OP2 */
203 | { 1, 0, 0, 1, 1, 1, 1, 0 }, /* Last operator */
204 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* Last operator */
205 | { 0, 0, 0, 0, 1, 1, 1, 1 } /* Out */
206 | },
207 | {
208 | { 0, 0, 1, 0, 0, 1, 0, 0 }, /* OP1_0 */
209 | { 0, 0, 0, 0, 0, 0, 0, 0 }, /* OP1_1 */
210 | { 0, 0, 0, 1, 0, 0, 0, 0 }, /* OP2 */
211 | { 1, 1, 0, 1, 1, 0, 0, 0 }, /* Last operator */
212 | { 0, 0, 1, 0, 0, 0, 0, 0 }, /* Last operator */
213 | { 1, 1, 1, 1, 1, 1, 1, 1 } /* Out */
214 | }
215 | };
216 |
217 | static void OPNB_FMDoIO1(opnb_t *chip)
218 | {
219 | chip->write_d_en = (chip->write_d & 20) == 4;
220 | chip->write_a_en = (chip->write_a & 20) == 4;
221 | chip->write_d <<= 1;
222 | chip->write_a <<= 1;
223 | }
224 |
225 | static void OPNB_FMDoIO2(opnb_t *chip)
226 | {
227 | chip->write_d <<= 1;
228 | chip->write_a <<= 1;
229 | }
230 |
231 | static void OPNB_DoRegWrite(opnb_t *chip)
232 | {
233 | uint32_t i, bank, slot, channel;
234 | uint16_t bus, businv, addr;
235 |
236 | if (chip->ic_latch & 2)
237 | {
238 | bus = 0;
239 | businv = (chip->write_data ^ 255) & 255;
240 | }
241 | else
242 | {
243 | bus = chip->write_data & 255;
244 | businv = bus ^ 255;
245 | }
246 | bus |= chip->write_data & 256;
247 | /* Update registers */
248 | if (chip->write_fm_data)
249 | {
250 | /* Slot */
251 | if (slot_map[chip->slot_counter_h * 4 + chip->slot_counter_l] == (chip->fm_address & 0x107))
252 | {
253 | slot = chip->fmcycles % 12;
254 | bank = (chip->fm_address & 8) != 0;
255 | switch (chip->fm_address & 0xf0)
256 | {
257 | case 0x30: /* DT, MULTI */
258 | chip->fm_multi[bank][slot] = chip->fm_data & 0x0f;
259 | chip->fm_dt[bank][slot] = (chip->fm_data >> 4) & 0x07;
260 | break;
261 | case 0x40: /* TL */
262 | chip->fm_tl[bank][slot] = chip->fm_data & 0x7f;
263 | break;
264 | case 0x50: /* KS, AR */
265 | chip->fm_ar[bank][slot] = chip->fm_data & 0x1f;
266 | chip->fm_ks[bank][slot] = (chip->fm_data >> 6) & 0x03;
267 | break;
268 | case 0x60: /* AM, DR */
269 | chip->fm_dr[bank][slot] = chip->fm_data & 0x1f;
270 | chip->fm_am[bank][slot] = (chip->fm_data >> 7) & 0x01;
271 | break;
272 | case 0x70: /* SR */
273 | chip->fm_sr[bank][slot] = chip->fm_data & 0x1f;
274 | break;
275 | case 0x80: /* SL, RR */
276 | chip->fm_rr[bank][slot] = chip->fm_data & 0x0f;
277 | chip->fm_sl[bank][slot] = (chip->fm_data >> 4) & 0x0f;
278 | break;
279 | case 0x90: /* SSG-EG */
280 | chip->fm_ssg_eg[bank][slot] = chip->fm_data & 0x0f;
281 | break;
282 | }
283 | }
284 | /* Channel */
285 | if (slot_map[(chip->slot_counter_h & 1) * 4 + chip->slot_counter_l] == (chip->fm_address & 0x103))
286 | {
287 | channel = chip->fmcycles % 6;
288 | switch (chip->fm_address & 0xfc)
289 | {
290 | case 0xa0:
291 | chip->fm_fnum[channel] = (chip->fm_data & 0xff) | ((chip->fm_reg_a4 & 0x07) << 8);
292 | chip->fm_block[channel] = (chip->fm_reg_a4 >> 3) & 0x07;
293 | break;
294 | case 0xa4:
295 | chip->fm_reg_a4 = chip->fm_data & 0x3f;
296 | break;
297 | case 0xa8:
298 | chip->fm_fnum_3ch[channel] = (chip->fm_data & 0xff) | ((chip->fm_reg_ac & 0x07) << 8);
299 | chip->fm_block_3ch[channel] = (chip->fm_reg_ac >> 3) & 0x07;
300 | break;
301 | case 0xac:
302 | chip->fm_reg_ac = chip->fm_data & 0x3f;
303 | break;
304 | case 0xb0:
305 | chip->fm_connect[channel] = chip->fm_data & 0x07;
306 | chip->fm_fb[channel] = (chip->fm_data >> 3) & 0x07;
307 | break;
308 | case 0xb4:
309 | chip->fm_pms[channel] = chip->fm_data & 0x07;
310 | chip->fm_ams[channel] = (chip->fm_data >> 4) & 0x07;
311 | chip->fm_pan_l[channel] = (chip->fm_data >> 7) & 0x01;
312 | chip->fm_pan_r[channel] = (chip->fm_data >> 6) & 0x01;
313 | break;
314 | }
315 | }
316 | }
317 | /* Data */
318 | if (chip->write_d_en)
319 | {
320 | if ((bus & 256) == 0)
321 | {
322 | if (chip->write_mode_1c)
323 | {
324 | chip->mode_1c = bus & 191;
325 | }
326 | if (chip->write_mode_27) /* CSM, Timer control */
327 | {
328 | chip->mode_ch3 = (bus & 0xc0) >> 6;
329 | chip->mode_csm = chip->mode_ch3 == 2;
330 | chip->timer_a_load = bus & 0x01;
331 | chip->timer_a_enable = (bus >> 2) & 0x01;
332 | chip->timer_a_reset = (bus >> 4) & 0x01;
333 | chip->timer_b_load = (bus >> 1) & 0x01;
334 | chip->timer_b_enable = (bus >> 3) & 0x01;
335 | chip->timer_b_reset = (bus >> 5) & 0x01;
336 | }
337 | if (chip->write_mode_25) /* Timer A */
338 | {
339 | chip->timer_a_reg &= 0x3fc;
340 | chip->timer_a_reg |= bus & 0x03;
341 | }
342 | if (chip->write_mode_24)
343 | {
344 | chip->timer_a_reg &= 0x03;
345 | chip->timer_a_reg |= (bus & 0xff) << 2;
346 | }
347 | if (chip->write_mode_21) /* LSI test */
348 | {
349 | chip->mode_test = bus & 253;
350 | }
351 | if (chip->write_mode_28) /* Key on/off */
352 | {
353 | for (i = 0; i < 4; i++)
354 | {
355 | chip->mode_kon_operator[i] = (bus >> (4 + i)) & 0x01;
356 | }
357 | chip->mode_kon_channel = bus & 0x07;
358 | }
359 | if (chip->write_mode_26) /* Timer B */
360 | {
361 | chip->timer_b_reg = bus & 255;
362 | }
363 | if (chip->write_mode_22) /* LFO control */
364 | {
365 | if ((bus >> 3) & 0x01)
366 | {
367 | chip->lfo_en = 0x7f;
368 | }
369 | else
370 | {
371 | chip->lfo_en = 0;
372 | }
373 | chip->lfo_freq = bus & 0x07;
374 | }
375 | if (chip->write_mode_02) /* ADPCM LSI Test */
376 | {
377 | chip->mode_test2 = bus & 184;
378 | }
379 | }
380 | if (chip->write_fm_address)
381 | {
382 | chip->fm_data = bus;
383 | }
384 | }
385 | if (chip->write_a_en)
386 | {
387 | chip->write_fm_data = 0;
388 | }
389 | if (chip->write_fm_address && chip->write_d_en)
390 | {
391 | chip->write_fm_data = 1;
392 | }
393 | /* Address */
394 | if (chip->write_a_en)
395 | {
396 | chip->write_fm_address = (bus & 0xf0) != 0;
397 | if (chip->write_fm_address)
398 | {
399 | chip->fm_address = bus & 0x1ff;
400 | }
401 | if (chip->ic_latch & 2)
402 | {
403 | chip->write_mode_1c = (bus & 0x100) == 0 && (businv & 0x1c) == 0;
404 | chip->write_mode_27 = (bus & 0x100) == 0 && (businv & 0x27) == 0;
405 | chip->write_mode_25 = (bus & 0x100) == 0 && (businv & 0x25) == 0;
406 | chip->write_mode_24 = (bus & 0x100) == 0 && (businv & 0x24) == 0;
407 | chip->write_mode_21 = (bus & 0x100) == 0 && (businv & 0x21) == 0;
408 | chip->write_mode_28 = (bus & 0x100) == 0 && (businv & 0x28) == 0;
409 | chip->write_mode_26 = (bus & 0x100) == 0 && (businv & 0x26) == 0;
410 | chip->write_mode_22 = (bus & 0x100) == 0 && (businv & 0x22) == 0;
411 | chip->write_mode_02 = (bus & 0x100) == 0 && (businv & 0x02) == 0;
412 | }
413 | else
414 | {
415 | chip->write_mode_1c = bus == 0x1c;
416 | chip->write_mode_27 = bus == 0x27;
417 | chip->write_mode_25 = bus == 0x25;
418 | chip->write_mode_24 = bus == 0x24;
419 | chip->write_mode_21 = bus == 0x21;
420 | chip->write_mode_28 = bus == 0x28;
421 | chip->write_mode_26 = bus == 0x26;
422 | chip->write_mode_22 = bus == 0x22;
423 | chip->write_mode_02 = bus == 0x02;
424 | }
425 | }
426 | if (chip->slot_counter_l & 2)
427 | {
428 | chip->slot_counter_h = (chip->slot_counter_h + 1) & 3;
429 | chip->slot_counter_l = 0;
430 | }
431 | else
432 | {
433 | chip->slot_counter_l++;
434 | }
435 | if (chip->fmcycles[22] & 2)
436 | {
437 | chip->slot_counter_h = 0;
438 | chip->slot_counter_l = 0;
439 | }
440 | if (chip->ic)
441 | {
442 | chip->mode_1c = 0;
443 | chip->mode_ch3 = 0;
444 | chip->mode_csm = 0;
445 | chip->timer_a_load = 0;
446 | chip->timer_a_enable = 0;
447 | chip->timer_a_reset = 0;
448 | chip->timer_b_load = 0;
449 | chip->timer_b_enable = 0;
450 | chip->timer_b_reset = 0;
451 | chip->timer_a_reg = 0;
452 | chip->mode_test = 0;
453 | chip->mode_kon_operator[0] = 0;
454 | chip->mode_kon_operator[1] = 0;
455 | chip->mode_kon_operator[2] = 0;
456 | chip->mode_kon_operator[3] = 0;
457 | chip->mode_kon_channel = 0;
458 | chip->timer_b_reg = 0;
459 | chip->lfo_en = 0;
460 | chip->lfo_freq = 0;
461 | chip->mode_test2 = 0;
462 | chip->fm_address = 0;
463 | chip->fm_data = 0;
464 | chip->slot_counter_h = 0;
465 | chip->slot_counter_l = 0;
466 | slot = chip->fmcycles % 12;
467 | channel = chip->fmcycles % 6;
468 | chip->fm_reg_a4 = 0;
469 | chip->fm_reg_ac = 0;
470 | chip->fm_fnum[channel] = 0;
471 | chip->fm_block[channel] = 0;
472 | chip->fm_fnum_3ch[channel] = 0;
473 | chip->fm_block_3ch[channel] = 0;
474 | chip->fm_connect[channel] = 0;
475 | chip->fm_fb[channel] = 0;
476 | chip->fm_pms[channel] = 0;
477 | chip->fm_ams[channel] = 0;
478 | chip->fm_pan_l[channel] = 1;
479 | chip->fm_pan_r[channel] = 1;
480 | chip->fm_ssg_eg[0][slot] = 0;
481 | chip->fm_ssg_eg[1][slot] = 0;
482 | chip->fm_dt[0][slot] = 0;
483 | chip->fm_dt[1][slot] = 0;
484 | chip->fm_multi[0][slot] = 0;
485 | chip->fm_multi[1][slot] = 0;
486 | chip->fm_tl[0][slot] = 0;
487 | chip->fm_tl[1][slot] = 0;
488 | chip->fm_ks[0][slot] = 0;
489 | chip->fm_ks[1][slot] = 0;
490 | chip->fm_ar[0][slot] = 0;
491 | chip->fm_ar[1][slot] = 0;
492 | chip->fm_am[0][slot] = 0;
493 | chip->fm_am[1][slot] = 0;
494 | chip->fm_dr[0][slot] = 0;
495 | chip->fm_dr[1][slot] = 0;
496 | chip->fm_sr[0][slot] = 0;
497 | chip->fm_sr[1][slot] = 0;
498 | chip->fm_rr[0][slot] = 0;
499 | chip->fm_rr[1][slot] = 0;
500 | chip->fm_sl[0][slot] = 0;
501 | chip->fm_sl[1][slot] = 0;
502 | }
503 | }
504 |
505 | static void OPNB_FMCounter1(opnb_t *chip)
506 | {
507 | if (chip->fmstate_l & 2)
508 | {
509 | chip->fmstate_h = (chip->fmstate_h + 1) & 7;
510 | chip->fmstate_l = 0;
511 | }
512 | else
513 | {
514 | chip->fmstate_l++;
515 | }
516 | if (chip->ic2 & 8)
517 | {
518 | chip->fmstate_h = 0;
519 | chip->fmstate_l = 0;
520 | }
521 | }
522 |
523 | static void OPNB_FMCounter2(opnb_t* chip)
524 | {
525 | chip->fmcycle[22] <<= 1;
526 | chip->fmcycle[22] |= chip->fmstate_h == 7 && chip->fmstate_l == 1;
527 | }
528 |
529 | static void OPNB_FMClock1(opnb_t *chip)
530 | {
531 | chip->ic_latch |= chip->ic;
532 | OPNB_FMDoIO1(chip);
533 | OPNB_DoRegWrite(chip);
534 | OPNB_FMCounter1(chip);
535 | }
536 |
537 | static void OPNB_FMClock2(opnb_t *chip)
538 | {
539 | chip->ic_latch <<= 1;
540 | OPNB_FMDoIO2(chip);
541 | chip->fmcycles = (chip->fmcycles + 1) % 24;
542 |
543 | }
544 |
545 | static uint8_t OPNB_ReadBus(opnb_t *chip, uint32_t ssgread)
546 | {
547 | if (chip->ic_latch & 2)
548 | {
549 | return 0;
550 | }
551 | if (ssgread)
552 | {
553 | return 0; // TODO:
554 | }
555 | return chip->write_data & 255;
556 | }
557 |
558 | void OPNB_Clock(opnb_t *chip)
559 | {
560 | uint32_t cycle;
561 | if (chip->ic)
562 | {
563 | chip->write_data = 0;
564 | }
565 | for (cycle = 0; cycle < 12; cycle++)
566 | {
567 | if (chip->cycles & (1 << cycle))
568 | {
569 | // FM clock
570 | switch (cycle % 6)
571 | {
572 | case 2: // rising
573 | case 3:
574 | if (!(chip->clock_state & clock_fm_1))
575 | {
576 | OPNB_FMClock1(chip);
577 | chip->clock_state |= clock_fm_1;
578 | }
579 | break;
580 | case 4: // falling
581 | chip->clock_state &= ~clock_fm_1;
582 | break;
583 | case 0: // rising
584 | case 5:
585 | case 3:
586 | if (!(chip->clock_state & clock_fm_2))
587 | {
588 | OPNB_FMClock2(chip);
589 | chip->clock_state |= clock_fm_2;
590 | }
591 | break;
592 | case 1: // falling
593 | chip->clock_state &= ~clock_fm_2;
594 | break;
595 | default:
596 | break;
597 | }
598 | }
599 | }
600 |
601 | // Cycle one-hot
602 | chip->cycles <<= 1;
603 | if ((chip->cycles & 0xffe) == 0)
604 | {
605 | chip->cycles |= 1;
606 | }
607 | chip->ic2 <<= 1;
608 | if ((chip->ic_sr & 1) && !(chip->ic_sr & (1<<18)))
609 | {
610 | chip->cycles &= ~1;
611 | chip->ic2 |= 1;
612 | }
613 | chip->ic_sr <<= 1;
614 | chip->ic_sr |= chip->ic;
615 | }
616 |
617 | void OPNB_Write(opnb_t *chip, uint32_t port, uint8_t data)
618 | {
619 | port &= 3;
620 | chip->write_data = ((port << 7) & 0x100) | data;
621 | if (port & 1)
622 | {
623 | if (!(chip->write_d & 4))
624 | {
625 | chip->write_d |= 1;
626 | }
627 | }
628 | else
629 | {
630 | if (!(chip->write_a & 4))
631 | {
632 | chip->write_a |= 1;
633 | }
634 | }
635 | }
636 |
637 | uint8_t OPNB_Read(opnb_t *chip, uint32_t port)
638 | {
639 | uint8_t ret = 0;
640 | switch (port & 3)
641 | {
642 | case 1:
643 | ret = OPNB_ReadBus(chip, 1);
644 | break;
645 | default:
646 | break;
647 | }
648 | return ret;
649 | }
650 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | [This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.]
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 |
474 | Copyright (C)
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
489 | USA
490 |
491 | Also add information on how to contact you by electronic and paper mail.
492 |
493 | You should also get your employer (if you work as a programmer) or your
494 | school, if any, to sign a "copyright disclaimer" for the library, if
495 | necessary. Here is a sample; alter the names:
496 |
497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
498 | library `Frob' (a library for tweaking knobs) written by James Random
499 | Hacker.
500 |
501 | , 1 April 1990
502 | Ty Coon, President of Vice
503 |
504 | That's all there is to it!
505 |
--------------------------------------------------------------------------------