OPLx decapsulated Matthew Gambrell and Olli Niemitalo, 2008/04/20 We have an interest in emulation of YM3812, which is the OPL2 sound chip found in the Adlib and 8-bit Sound Blaster cards. A later derivative OPL3 is found in early 16-bit Sound Blasters. We sent one YM3812 and one YMF262 (OPL3) to MEFAS for decapsulation; the cost was around 90 USD each. They indicated that the chips would still be operational after decapsulation, but we had no need to test this. Looking at the revealed YM3812 die surface with a microscope turned out two ROM's. The contents could be read bit-by-bit. The first ROM was a log-sin waveform table, containing one quarter of a sine wave, 256 samples long. The second ROM was an exponential table, 256 samples long. There were no other ROM's larger than 16 samples. This is strong evidence that YM3812 produces the sound without any multiplications, using for frequency modulated (actually phase modulated) synthesis the formula: out = exp(logsin(phase2 + exp(logsin(phase1) + gain1)) + gain2) There was first some difficulty understanding the ROM's because they were compressed. Every second sample was stored as a difference value to the previous. Once this was understood, we were able to derive formulas that met our expectations and re-created the contents of the ROM tables exactly (yes, they used the same rounding and everything at Yamaha, back then when they created these tables). Exponential table: x = 0..255, y = round((power(2, x/256)-1)*1024) When such a table is used for calculation of the exponential, the table is read at the position given by the 8 LSB's of the input. The value + 1024 (the hidden bit) is then the significand of the floating point output and the yet unused MSB's of the input are the exponent of the floating point output. Indeed, YM3812 sends the audio to the YM3014B DAC in floating point, so it is quite possible that summing of voices is done in floating point also. Log-sin table: x = 0..255, y = round(-log(sin((x+0.5)*pi/256/2))/log(2)*256) This is the first (rising) quarter of sine wave. The rest can be constructed by flipping all the bits of x and/or by changing the sign of the samples. We hope this will be useful for anyone writing a good emulator. Also, there are no extra ROM's on the YMF262 (OPL3), so the additional waveform is probably simply the exponential table. Figure 1. Decapsulated YM3812 (OPL2). The ROM's are the rectangular areas horizontally next to each other on the middle-right side. Figure 2. Decapsulated YMF262 (OPL3). The ROM's are the bright rectangular areas in the top-right corner. Figure 3. How a YM3812 ROM could be read. Table I. The exponential table of YM3812 generated by y = round((power(2, x/256)-1)*1024) x y 0 0 1 3 2 6 3 8 4 11 5 14 6 17 7 20 8 22 9 25 10 28 11 31 12 34 13 37 14 40 15 42 16 45 17 48 18 51 19 54 20 57 21 60 22 63 23 66 24 69 25 72 26 75 27 78 28 81 29 84 30 87 31 90 32 93 33 96 34 99 35 102 36 105 37 108 38 111 39 114 40 117 41 120 42 123 43 126 44 130 45 133 46 136 47 139 48 142 49 145 50 148 51 152 52 155 53 158 54 161 55 164 56 168 57 171 58 174 59 177 60 181 61 184 62 187 63 190 64 194 65 197 66 200 67 204 68 207 69 210 70 214 71 217 72 220 73 224 74 227 75 231 76 234 77 237 78 241 79 244 80 248 81 251 82 255 83 258 84 262 85 265 86 268 87 272 88 276 89 279 90 283 91 286 92 290 93 293 94 297 95 300 96 304 97 308 98 311 99 315 100 318 101 322 102 326 103 329 104 333 105 337 106 340 107 344 108 348 109 352 110 355 111 359 112 363 113 367 114 370 115 374 116 378 117 382 118 385 119 389 120 393 121 397 122 401 123 405 124 409 125 412 126 416 127 420 128 424 129 428 130 432 131 436 132 440 133 444 134 448 135 452 136 456 137 460 138 464 139 468 140 472 141 476 142 480 143 484 144 488 145 492 146 496 147 501 148 505 149 509 150 513 151 517 152 521 153 526 154 530 155 534 156 538 157 542 158 547 159 551 160 555 161 560 162 564 163 568 164 572 165 577 166 581 167 585 168 590 169 594 170 599 171 603 172 607 173 612 174 616 175 621 176 625 177 630 178 634 179 639 180 643 181 648 182 652 183 657 184 661 185 666 186 670 187 675 188 680 189 684 190 689 191 693 192 698 193 703 194 708 195 712 196 717 197 722 198 726 199 731 200 736 201 741 202 745 203 750 204 755 205 760 206 765 207 770 208 774 209 779 210 784 211 789 212 794 213 799 214 804 215 809 216 814 217 819 218 824 219 829 220 834 221 839 222 844 223 849 224 854 225 859 226 864 227 869 228 874 229 880 230 885 231 890 232 895 233 900 234 906 235 911 236 916 237 921 238 927 239 932 240 937 241 942 242 948 243 953 244 959 245 964 246 969 247 975 248 980 249 986 250 991 251 996 252 1002 253 1007 254 1013 255 1018 Table II. The log-sin table of YM3812 generated by y = round(-log(sin((x+0.5)*pi/256/2))/log(2)*256) x y 0 2137 1 1731 2 1543 3 1419 4 1326 5 1252 6 1190 7 1137 8 1091 9 1050 10 1013 11 979 12 949 13 920 14 894 15 869 16 846 17 825 18 804 19 785 20 767 21 749 22 732 23 717 24 701 25 687 26 672 27 659 28 646 29 633 30 621 31 609 32 598 33 587 34 576 35 566 36 556 37 546 38 536 39 527 40 518 41 509 42 501 43 492 44 484 45 476 46 468 47 461 48 453 49 446 50 439 51 432 52 425 53 418 54 411 55 405 56 399 57 392 58 386 59 380 60 375 61 369 62 363 63 358 64 352 65 347 66 341 67 336 68 331 69 326 70 321 71 316 72 311 73 307 74 302 75 297 76 293 77 289 78 284 79 280 80 276 81 271 82 267 83 263 84 259 85 255 86 251 87 248 88 244 89 240 90 236 91 233 92 229 93 226 94 222 95 219 96 215 97 212 98 209 99 205 100 202 101 199 102 196 103 193 104 190 105 187 106 184 107 181 108 178 109 175 110 172 111 169 112 167 113 164 114 161 115 159 116 156 117 153 118 151 119 148 120 146 121 143 122 141 123 138 124 136 125 134 126 131 127 129 128 127 129 125 130 122 131 120 132 118 133 116 134 114 135 112 136 110 137 108 138 106 139 104 140 102 141 100 142 98 143 96 144 94 145 92 146 91 147 89 148 87 149 85 150 83 151 82 152 80 153 78 154 77 155 75 156 74 157 72 158 70 159 69 160 67 161 66 162 64 163 63 164 62 165 60 166 59 167 57 168 56 169 55 170 53 171 52 172 51 173 49 174 48 175 47 176 46 177 45 178 43 179 42 180 41 181 40 182 39 183 38 184 37 185 36 186 35 187 34 188 33 189 32 190 31 191 30 192 29 193 28 194 27 195 26 196 25 197 24 198 23 199 23 200 22 201 21 202 20 203 20 204 19 205 18 206 17 207 17 208 16 209 15 210 15 211 14 212 13 213 13 214 12 215 12 216 11 217 10 218 10 219 9 220 9 221 8 222 8 223 7 224 7 225 7 226 6 227 6 228 5 229 5 230 5 231 4 232 4 233 4 234 3 235 3 236 3 237 2 238 2 239 2 240 2 241 1 242 1 243 1 244 1 245 1 246 1 247 1 248 0 249 0 250 0 251 0 252 0 253 0 254 0 255 0