SoundMonitor.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.event.*;
17: import java.awt.image.*;
18: import java.lang.*;
19: import java.util.*;
20: import javax.swing.*;
21:
22: public class SoundMonitor {
23:
24:
25: public static final int SMN_WIDTH = 4 + 8 + 4 * (14 * 8 + 6) + 4;
26: public static final int SMN_OFFSET = SMN_WIDTH + 3 >> 2;
27:
28:
29: public static final byte SMN_BLACK = (byte) 0b00000000;
30: public static final byte SMN_BLUE = (byte) 0b01010101;
31: public static final byte SMN_ORANGE = (byte) 0b10101010;
32: public static final byte SMN_WHITE = (byte) 0b11111111;
33:
34:
35: public static final byte[] SMN_FONT_1 = new byte[5 * 127];
36: public static final byte[] SMN_FONT_2 = new byte[5 * 127];
37: public static final byte[] SMN_FONT_3 = new byte[5 * 127];
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144: public static final byte[] SMN_ICON_1 = "UT@\4A\4A\4A\4A\4A\4@\4UTUT@\4ED@DEDD\4ED@\4UTUT@\4ED@DED@DED@\4UTUT@\4DDDDED@D@D@\4UTUT@\4EDD\4ED@DED@\4UTUT@\4EDD\4EDDDED@\4UTUT@\4ED@D@D@D@D@\4UTUT@\4EDDDEDDDED@\4UTUT@\4DDDDEDEDDD@\4UTUT@\4ADD\4A\4@DE\4@\4UTUT@\4E\4DDE\4D\4D\4@\4UT".getBytes (XEiJ.ISO_8859_1);
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249: public static final byte[] SMN_ICON_3 = "\377\374\300\f\303\f\303\f\303\f\303\f\303\f\300\f\377\374\377\374\300\f\317\314\300\314\317\314\314\f\317\314\300\f\377\374\377\374\300\f\317\314\300\314\317\314\300\314\317\314\300\f\377\374\377\374\300\f\314\314\314\314\317\314\300\314\300\314\300\f\377\374\377\374\300\f\317\314\314\f\317\314\300\314\317\314\300\f\377\374\377\374\300\f\317\314\314\f\317\314\314\314\317\314\300\f\377\374\377\374\300\f\317\314\300\314\300\314\300\314\300\314\300\f\377\374\377\374\300\f\317\314\314\314\317\314\314\314\317\314\300\f\377\374\377\374\300\f\314\314\314\314\317\314\317\314\314\314\300\f\377\374\377\374\300\f\303\314\314\f\303\f\300\314\317\f\300\f\377\374\377\374\300\f\317\f\314\314\317\f\314\f\314\f\300\f\377\374".getBytes (XEiJ.ISO_8859_1);
250:
251:
252: public static final int SMN_WAVE_X = 12;
253: public static final int SMN_WAVE_Y = 4;
254: public static final int SMN_WAVE_WIDTH = SMN_WIDTH - 4 - SMN_WAVE_X;
255: public static final int SMN_WAVE_VALUE_SHIFT = 11;
256: public static final int SMN_WAVE_HEIGHT = (1 << 16 - SMN_WAVE_VALUE_SHIFT) + 1;
257: public static final int SMN_WAVE_SCALE_X_MAX = 5;
258: public static final int SMN_WAVE_SCALE_Y_MAX = 3;
259: public static final int[] smnOPMBuffer = new int[SoundSource.SND_CHANNELS * OPM.OPM_BLOCK_SAMPLES];
260: public static final int[] smnPCMBuffer = new int[SoundSource.SND_CHANNELS * OPM.OPM_BLOCK_SAMPLES];
261: public static final int[][] smnWaveIndex0 = new int[SMN_WAVE_SCALE_X_MAX + 1][];
262: public static final int[][] smnWaveIndex1 = new int[SMN_WAVE_SCALE_X_MAX + 1][];
263: public static int smnWaveScaleX;
264: public static int smnWaveScaleY;
265: public static int smnWaveOffsetMax;
266: public static int smnWaveOffset;
267: public static int smnWaveElevation;
268: public static boolean smnWaveDragOn;
269: public static int smnWavePressedX;
270: public static int smnWavePressedY;
271: public static final int[] smnWaveLastYPCMLeft = new int[2];
272: public static final int[] smnWaveLastYPCMRight = new int[2];
273: public static final int[] smnWaveLastYOPMLeft = new int[2];
274: public static final int[] smnWaveLastYOPMRight = new int[2];
275:
276:
277:
278: public static final int SMN_SPECTRUM_X = 4;
279: public static final int SMN_SPECTRUM_Y = SMN_WAVE_Y + SMN_WAVE_HEIGHT + 4;
280: public static final int SMN_SPECTRUM_WIDTH = 480;
281: public static final int SMN_SPECTRUM_HEIGHT = 32;
282:
283:
284:
285:
286:
287:
288:
289:
290:
291: public static final byte[] SMN_SPECTRUM_MAP = "\0\1\2\3\5\7\t\13\r\17\21\23\25\27\31\33\35\37!#$%&\'()*+-/13579;=?ACEGIKMOQSUWY[\\]^_".getBytes (XEiJ.ISO_8859_1);
292: public static final int SMN_SPECTRUM_BIT = 10;
293: public static final int SMN_SPECTRUM_N = 1 << SMN_SPECTRUM_BIT;
294: public static final int SMN_SPECTRUM_PARTITIONS = 6;
295: public static final int SMN_SPECTRUM_RANGE = 480 / SMN_SPECTRUM_PARTITIONS;
296: public static final int[] SMN_SPECTRUM_INTERVAL = new int[] { 100, 100, 50, 25, 10, 5 };
297: public static final double[][] smnSpectrumBuffer = new double[SMN_SPECTRUM_PARTITIONS][];
298: public static final double[] smnSpectrumX = new double[SMN_SPECTRUM_N];
299: public static final double[] smnSpectrumY = new double[SMN_SPECTRUM_N];
300: public static final int[] smnSpectrumIndex = new int[480];
301: public static final int[] smnSpectrumValue = new int[480];
302: public static final double[] smnSpectrumWindow = new double[SMN_SPECTRUM_N];
303: public static final int SMN_SPECTRUM_TRAIL = 2;
304: public static final double SMN_SPECTRUM_SCALE = 64.0;
305: public static FFT smnFFT;
306:
307:
308: public static final int[] SMN_440HZ_PATTERN = { 18, SMN_BLUE, 0, 0, -1, 1, 1, 1, -2, 2, 2, 2, -1, 3, 1, 3, 0, 4 };
309:
310:
311: public static final int SMN_KEY_X = 12;
312: public static final int SMN_KEY_Y = SMN_SPECTRUM_Y + SMN_SPECTRUM_HEIGHT + 1;
313: public static final int SMN_KEY_HEIGHT = 6 + 12 * 8;
314: public static final byte[] SMN_KEY_COLOR = {
315: SMN_WHITE,
316: SMN_BLUE,
317: SMN_WHITE,
318: SMN_BLUE,
319: SMN_WHITE,
320: SMN_WHITE,
321: SMN_BLUE,
322: SMN_WHITE,
323: SMN_BLUE,
324: SMN_WHITE,
325: SMN_BLUE,
326: SMN_WHITE,
327: };
328: public static final int[] smnKey = new int[8];
329:
330:
331: public static final int SMN_TONE_X = 20;
332: public static final int SMN_TONE_Y = SMN_KEY_Y + SMN_KEY_HEIGHT + 4;
333: public static final int SMN_TONE_BOX_COLS = 3 * 12 + 2;
334: public static final int SMN_TONE_BOX_HEIGHT = 6 * 7 + 4;
335: public static final int SMN_TONE_HEIGHT = SMN_TONE_BOX_HEIGHT * 3 - 4;
336: public static final char[] SMN_TONE_H1 = "FC SL WA SY SP PD AD PS AS PN" .toCharArray ();
337: public static final char[] SMN_TONE_V0 = "00 00 00 00 00 00 00 00 00 00 00".toCharArray ();
338: public static final char[] SMN_TONE_H2 = "AR 1R 2R RR 1L TL KS ML T1 T2 AE".toCharArray ();
339: public static final char[] SMN_TONE_M1 = "M1".toCharArray ();
340: public static final char[] SMN_TONE_V1 = "00 00 00 00 00 00 00 00 00 00 00".toCharArray ();
341: public static final char[] SMN_TONE_C1 = "C1".toCharArray ();
342: public static final char[] SMN_TONE_V2 = "00 00 00 00 00 00 00 00 00 00 00".toCharArray ();
343: public static final char[] SMN_TONE_M2 = "M2".toCharArray ();
344: public static final char[] SMN_TONE_V3 = "00 00 00 00 00 00 00 00 00 00 00".toCharArray ();
345: public static final char[] SMN_TONE_C2 = "C2".toCharArray ();
346: public static final char[] SMN_TONE_V4 = "00 00 00 00 00 00 00 00 00 00 00".toCharArray ();
347:
348:
349: public static final int SMN_PCM_COL = SMN_TONE_X / 4 + SMN_TONE_BOX_COLS * 2 + 6;
350: public static final int SMN_PCM_Y = SMN_TONE_Y + SMN_TONE_BOX_HEIGHT * 2;
351:
352:
353:
354:
355:
356:
357: public static final char[][] SMN_PCM_OSCILLATOR = {
358: " 8".toCharArray (),
359: " 4".toCharArray (),
360: " 8".toCharArray (),
361: "16".toCharArray (),
362: };
363: public static final char[][] SMN_PCM_DIVIDER = {
364: "1024".toCharArray (),
365: "768 ".toCharArray (),
366: "512 ".toCharArray (),
367: "768 ".toCharArray (),
368: };
369: public static final char[][] SMN_PCM_FREQ = {
370: " 7.8".toCharArray (),
371: "10.4".toCharArray (),
372: "15.6".toCharArray (),
373: "10.4".toCharArray (),
374: " 3.9".toCharArray (),
375: " 5.2".toCharArray (),
376: " 7.8".toCharArray (),
377: " 5.2".toCharArray (),
378: " 7.8".toCharArray (),
379: "10.4".toCharArray (),
380: "15.6".toCharArray (),
381: "10.4".toCharArray (),
382: "15.6".toCharArray (),
383: "20.8".toCharArray (),
384: "31.3".toCharArray (),
385: "20.8".toCharArray (),
386: };
387: public static final char[][] SMN_PCM_PLAY = {
388: " ".toCharArray (),
389: "PLAY".toCharArray (),
390: };
391: public static final char[][] SMN_PCM_DATA = {
392: " ".toCharArray (),
393: "DATA".toCharArray (),
394: };
395: public static final char[][] SMN_PCM_LEFT = {
396: " ".toCharArray (),
397: "LEFT".toCharArray (),
398: };
399: public static final char[][] SMN_PCM_RIGHT = {
400: " ".toCharArray (),
401: "RIGHT".toCharArray (),
402: };
403:
404:
405: public static final int SMN_PALET_X = SMN_TONE_X + 4 * SMN_TONE_BOX_COLS * 2;
406: public static final int SMN_PALET_Y = SMN_TONE_Y + SMN_TONE_BOX_HEIGHT * 2 + 6 * 2;
407: public static final int SMN_PALET_WIDTH = 140;
408: public static final int SMN_PALET_HEIGHT = 6 * 5;
409: public static final int[][] SMN_SLIDER_ARRAY = {
410: { SMN_PALET_X + 4 * 2, SMN_PALET_Y + 6 * 1, 48, SMN_WHITE , 0 },
411: { SMN_PALET_X + 4 * 16, SMN_PALET_Y + 6 * 1, 32, SMN_WHITE , 0 },
412: { SMN_PALET_X + 4 * 26, SMN_PALET_Y + 6 * 1, 32, SMN_WHITE , 0 },
413: { SMN_PALET_X + 4 * 2, SMN_PALET_Y + 6 * 2, 48, SMN_BLUE , 30 },
414: { SMN_PALET_X + 4 * 16, SMN_PALET_Y + 6 * 2, 32, SMN_BLUE , 30 },
415: { SMN_PALET_X + 4 * 26, SMN_PALET_Y + 6 * 2, 32, SMN_BLUE , 32 },
416: { SMN_PALET_X + 4 * 2, SMN_PALET_Y + 6 * 3, 48, SMN_ORANGE, 3 },
417: { SMN_PALET_X + 4 * 16, SMN_PALET_Y + 6 * 3, 32, SMN_ORANGE, 30 },
418: { SMN_PALET_X + 4 * 26, SMN_PALET_Y + 6 * 3, 32, SMN_ORANGE, 32 },
419: { SMN_PALET_X + 4 * 2, SMN_PALET_Y + 6 * 4, 48, SMN_WHITE , 30 },
420: { SMN_PALET_X + 4 * 16, SMN_PALET_Y + 6 * 4, 32, SMN_WHITE , 3 },
421: { SMN_PALET_X + 4 * 26, SMN_PALET_Y + 6 * 4, 32, SMN_WHITE , 30 },
422: };
423: public static final int[][] SMN_SLIDER_PATTERN = {
424: { 18, SMN_WHITE , 1, -2, 2, -2, 0, -1, 3, -1, 0, 1, 3, 1, 1, 2, 2, 2,
425: 14, SMN_BLACK , 1, -1, 2, -1, 1, 0, 2, 0, 1, 1, 2, 1 },
426: { 26, SMN_BLUE , 1, -2, 2, -2, 0, -1, 1, -1, 2, -1, 3, -1, 0, 1, 1, 1, 2, 1, 3, 1, 1, 2, 2, 2 },
427: { 26, SMN_ORANGE, 1, -2, 2, -2, 0, -1, 1, -1, 2, -1, 3, -1, 0, 1, 1, 1, 2, 1, 3, 1, 1, 2, 2, 2 },
428: { 26, SMN_WHITE , 1, -2, 2, -2, 0, -1, 1, -1, 2, -1, 3, -1, 0, 1, 1, 1, 2, 1, 3, 1, 1, 2, 2, 2 },
429: };
430: public static int smnPaletDragSlider;
431: public static int smnPaletPressedX;
432: public static IndexColorModel smnColorModel;
433:
434:
435: public static final int SMN_PAUSE_WIDTH = 16;
436: public static final int SMN_PAUSE_HEIGHT = 16;
437: public static final int SMN_PAUSE_X = SMN_WIDTH - 4 - SMN_PAUSE_WIDTH;
438: public static final int SMN_PAUSE_Y = SMN_TONE_Y + SMN_TONE_BOX_HEIGHT * 2 + 6 * 3 + (6 * 4 - SMN_PAUSE_HEIGHT >> 1);
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460: public static final byte[] SMN_PAUSE_ICON_3 = "\0\0\0\0?\377\377\3740\0\0\f0\0\0\f0\377\377\f0\377\377\f0\377\377\f0\377\377\f0\377\377\f0\377\377\f0\377\377\f0\377\377\f0\0\0\f0\0\0\f?\377\377\374\0\0\0\0".getBytes (XEiJ.ISO_8859_1);
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482: public static final byte[] SMN_PLAY_ICON_3 = "\0\0\0\0?\377\377\3740\0\0\f0\0\0\f0\360\0\f0\377\0\f0\377\360\f0\377\377\f0\377\377\f0\377\360\f0\377\0\f0\360\0\f0\0\0\f0\0\0\f?\377\377\374\0\0\0\0".getBytes (XEiJ.ISO_8859_1);
483: public static boolean smnPauseRequest;
484: public static boolean smnPauseUpdate;
485:
486:
487: public static final int SMN_ZOOM_WIDTH = 16;
488: public static final int SMN_ZOOM_HEIGHT = 16;
489: public static final int SMN_ZOOM_X = SMN_PAUSE_X;
490: public static final int SMN_ZOOM_Y = SMN_PAUSE_Y - 24;
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512: public static final byte[] SMN_ZOOM_X1_ICON = "\0\0\0\0?\377\377\3740\0\0\f0\0\0\f0\0\17\f0\0\17\f0\0\17\f3\317\17\f3\317\17\f0\374\17\f3\317\17\f3\317\17\f0\0\0\f0\0\0\f?\377\377\374\0\0\0\0".getBytes (XEiJ.ISO_8859_1);
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534: public static final byte[] SMN_ZOOM_X2_ICON = "\0\0\0\0?\377\377\3740\0\0\f0\0\0\f0\0?\f0\0\3\3140\0\3\3143\317\17\f3\317\17\f0\374<\f3\317<\f3\317?\3140\0\0\f0\0\0\f?\377\377\374\0\0\0\0".getBytes (XEiJ.ISO_8859_1);
535: public static int smnZoomRequest;
536: public static int smnZoomShift;
537:
538:
539: public static final int SMN_HEIGHT = SMN_TONE_Y + SMN_TONE_HEIGHT + 4;
540: public static boolean smnIsVisible;
541: public static BufferedImage smnImage;
542: public static byte[] smnBitmap;
543: public static JPanel smnPanel;
544: public static JFrame smnFrame;
545:
546:
547:
548: public static void smnInit () {
549:
550:
551: {
552: final long m = 0b01010100_01010000_01000100_01000000_00010100_00010000_00000100_00000000L;
553: int k = 0;
554: for (int i = 0; i < 127; i++) {
555: int t = Indicator.IND_ASCII_3X5[i];
556: int d;
557:
558: d = (int) (m >>> (t >>> 12 - 3 & 7 << 3)) & 255;
559: SMN_FONT_1[k] = (byte) d;
560: SMN_FONT_2[k] = (byte) (d * 2);
561: SMN_FONT_3[k] = (byte) (d * 3);
562: k++;
563:
564: d = (int) (m >>> (t >>> 9 - 3 & 7 << 3)) & 255;
565: SMN_FONT_1[k] = (byte) d;
566: SMN_FONT_2[k] = (byte) (d * 2);
567: SMN_FONT_3[k] = (byte) (d * 3);
568: k++;
569:
570: d = (int) (m >>> (t >>> 6 - 3 & 7 << 3)) & 255;
571: SMN_FONT_1[k] = (byte) d;
572: SMN_FONT_2[k] = (byte) (d * 2);
573: SMN_FONT_3[k] = (byte) (d * 3);
574: k++;
575:
576: d = (int) (m >>> (t & 7 << 3)) & 255;
577: SMN_FONT_1[k] = (byte) d;
578: SMN_FONT_2[k] = (byte) (d * 2);
579: SMN_FONT_3[k] = (byte) (d * 3);
580: k++;
581:
582: d = (int) (m >>> (t << 6 - 3 & 7 << 3)) & 255;
583: SMN_FONT_1[k] = (byte) d;
584: SMN_FONT_2[k] = (byte) (d * 2);
585: SMN_FONT_3[k] = (byte) (d * 3);
586: k++;
587: }
588: }
589:
590:
591:
592:
593: for (int scaleX = 0; scaleX <= SMN_WAVE_SCALE_X_MAX; scaleX++) {
594: int limit = SMN_WAVE_WIDTH << scaleX;
595: int[] index0 = smnWaveIndex0[scaleX] = new int[limit];
596: if (SoundSource.SND_CHANNELS == 1) {
597: for (int x = 0; x < limit; x++) {
598: index0[x] = x * OPM.OPM_BLOCK_SAMPLES / limit;
599: }
600: } else {
601: int[] index1 = smnWaveIndex1[scaleX] = new int[limit];
602: for (int x = 0; x < limit; x++) {
603: index1[x] = (index0[x] = x * OPM.OPM_BLOCK_SAMPLES / limit << 1) + 1;
604: }
605: }
606: }
607: smnWaveScaleX = 0;
608: smnWaveScaleY = 0;
609: smnWaveOffsetMax = (SMN_WAVE_WIDTH << smnWaveScaleX) - SMN_WAVE_WIDTH;
610: smnWaveOffset = 0;
611: smnWaveElevation = 0;
612: smnWaveDragOn = false;
613: smnWavePressedX = -1;
614: smnWavePressedY = -1;
615:
616:
617:
618:
619: smnWaveLastYPCMLeft[0] = 0;
620: smnWaveLastYPCMLeft[1] = 0;
621: smnWaveLastYPCMRight[0] = 0;
622: smnWaveLastYPCMRight[1] = 0;
623: smnWaveLastYOPMLeft[0] = 0;
624: smnWaveLastYOPMLeft[1] = 0;
625: smnWaveLastYOPMRight[0] = 0;
626: smnWaveLastYOPMRight[1] = 0;
627:
628:
629:
630:
631:
632:
633:
634: for (int partition = 0; partition < SMN_SPECTRUM_PARTITIONS; partition++) {
635: if (partition != 1) {
636: smnSpectrumBuffer[partition] = new double[SMN_SPECTRUM_N];
637: }
638: double coeff = (double) SMN_SPECTRUM_N * 440.0 / 62500.0 * (double) SMN_SPECTRUM_INTERVAL[partition];
639: for (int x = SMN_SPECTRUM_RANGE * partition, x1 = x + SMN_SPECTRUM_RANGE; x < x1; x++) {
640: int k = (int) Math.floor (coeff * Math.pow (
641: 2.0,
642: (double) (((56 - 8 + x) / 56 - 1) * 96 + SMN_SPECTRUM_MAP[(56 - 8 + x) % 56] - (96 * 4 + 75)) / 96.0));
643: int n = (int) Math.floor (coeff * Math.pow (
644: 2.0,
645: (double) (((56 - 8 + 1 + x) / 56 - 1) * 96 + SMN_SPECTRUM_MAP[(56 - 8 + 1 + x) % 56] - (96 * 4 + 75)) / 96.0)) - k;
646: smnSpectrumIndex[x] = n << 16 | k;
647:
648: }
649: }
650: Arrays.fill (smnSpectrumValue, -1);
651:
652: for (int i = 0; i < SMN_SPECTRUM_N; i++) {
653: smnSpectrumWindow[i] = 0.5 * (1.0 - Math.cos (2.0 * Math.PI / (double) SMN_SPECTRUM_N * (double) i));
654: }
655: smnFFT = new FFT (SMN_SPECTRUM_N);
656:
657:
658:
659: smnPauseRequest = false;
660: smnPauseUpdate = true;
661:
662:
663: smnZoomRequest = 0;
664: smnZoomShift = 1;
665:
666:
667: smnPaletDragSlider = -1;
668: smnPaletPressedX = 0;
669:
670: }
671:
672:
673: public static void smnStart () {
674: if (RestorableFrame.rfmGetOpened (Settings.SGS_SMN_FRAME_KEY)) {
675: smnOpen ();
676: }
677: }
678:
679:
680:
681: public static void smnOpen () {
682: if (smnFrame == null) {
683: smnMakeFrame ();
684: }
685: smnIsVisible = true;
686: smnUpdate ();
687: XEiJ.pnlExitFullScreen (false);
688: smnFrame.setVisible (true);
689: }
690:
691:
692:
693:
694: public static void smnMakeFrame () {
695:
696:
697: smnMakeImage ();
698:
699:
700: smnPanel = ComponentFactory.setFixedSize (new JPanel () {
701: @Override public void paint (Graphics g) {
702: if (smnZoomShift == 0) {
703: g.drawImage (smnImage, 0, 0, null);
704: } else {
705: g.drawImage (smnImage,
706: 0, 0, SMN_WIDTH << smnZoomShift, SMN_HEIGHT << smnZoomShift,
707: 0, 0, SMN_WIDTH, SMN_HEIGHT,
708: null);
709: }
710: }
711: @Override protected void paintComponent (Graphics g) {
712: }
713: @Override protected void paintBorder (Graphics g) {
714: }
715: @Override protected void paintChildren (Graphics g) {
716: }
717: @Override public void update (Graphics g) {
718: }
719: }, SMN_WIDTH, SMN_HEIGHT);
720: smnPanel.setOpaque (true);
721:
722:
723: ComponentFactory.addListener (
724: smnPanel,
725: new MouseAdapter () {
726: @Override public void mouseClicked (MouseEvent me) {
727: int x = me.getX () >> smnZoomShift;
728: int y = me.getY () >> smnZoomShift;
729: int button = me.getButton ();
730: int modifiersEx = me.getModifiersEx ();
731: if (SMN_WAVE_X <= x && x < SMN_WAVE_X + SMN_WAVE_WIDTH &&
732: SMN_WAVE_Y <= y && y < SMN_WAVE_Y + SMN_WAVE_HEIGHT) {
733: if ((modifiersEx & InputEvent.SHIFT_DOWN_MASK) == 0) {
734: int d = 0;
735: if (button == MouseEvent.BUTTON1) {
736: if (smnWaveScaleX < SMN_WAVE_SCALE_X_MAX) {
737: d = 1;
738: }
739: } else if (button == MouseEvent.BUTTON3) {
740: if (0 < smnWaveScaleX) {
741: d = -1;
742: }
743: }
744: if (d != 0) {
745: smnWaveScaleX += d;
746: smnWaveOffsetMax = (SMN_WAVE_WIDTH << smnWaveScaleX) - SMN_WAVE_WIDTH;
747: int o = x - SMN_WAVE_X;
748: smnWaveOffset = Math.max (0, Math.min (smnWaveOffsetMax, (d >= 0 ? smnWaveOffset + o << d : smnWaveOffset + o >> -d) - o));
749: if (smnPauseUpdate) {
750: smnWavePaint ();
751: smnPanel.repaint ();
752: }
753: }
754: } else {
755: int d = 0;
756: if (button == MouseEvent.BUTTON1) {
757: if (smnWaveScaleY < SMN_WAVE_SCALE_Y_MAX) {
758: d = 1;
759: }
760: } else if (button == MouseEvent.BUTTON3) {
761: if (0 < smnWaveScaleY) {
762: d = -1;
763: }
764: }
765: if (d != 0) {
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776: smnWaveScaleY += d;
777: int spaceY = (SMN_WAVE_HEIGHT >> 1 << smnWaveScaleY) - (SMN_WAVE_HEIGHT >> 1);
778: int o = y - (SMN_WAVE_Y + SMN_WAVE_HEIGHT / 2);
779: smnWaveElevation = Math.max (-spaceY, Math.min (spaceY, (d >= 0 ? smnWaveElevation + o << d : smnWaveElevation + o >> -d) - o));
780: if (smnPauseUpdate) {
781: smnWavePaint ();
782: smnPanel.repaint ();
783: }
784: }
785: }
786: } else if (SMN_PAUSE_X <= x && x < SMN_PAUSE_X + SMN_PAUSE_WIDTH &&
787: SMN_PAUSE_Y <= y && y < SMN_PAUSE_Y + SMN_PAUSE_HEIGHT) {
788: smnPauseRequest = !smnPauseRequest;
789: } else if (SMN_ZOOM_X <= x && x < SMN_ZOOM_X + SMN_ZOOM_WIDTH &&
790: SMN_ZOOM_Y <= y && y < SMN_ZOOM_Y + SMN_ZOOM_HEIGHT) {
791: smnZoomRequest = smnZoomShift ^ 1;
792: }
793: }
794: @Override public void mousePressed (MouseEvent me) {
795: int x = me.getX () >> smnZoomShift;
796: int y = me.getY () >> smnZoomShift;
797: smnWaveDragOn = false;
798: smnPaletDragSlider = -1;
799: if (SMN_WAVE_X <= x && x < SMN_WAVE_X + SMN_WAVE_WIDTH &&
800: SMN_WAVE_Y <= y && y < SMN_WAVE_Y + SMN_WAVE_HEIGHT) {
801: smnWaveDragOn = true;
802: smnWavePressedX = x;
803: smnWavePressedY = y;
804: } else if (SMN_PALET_X <= x && x < SMN_PALET_X + SMN_PALET_WIDTH &&
805: SMN_PALET_Y <= y && y < SMN_PALET_Y + SMN_PALET_HEIGHT) {
806: for (int n = 0; n < SMN_SLIDER_ARRAY.length; n++) {
807: int[] slider = SMN_SLIDER_ARRAY[n];
808: int x0 = slider[0];
809: int y0 = slider[1];
810: int max = slider[2];
811: int value = slider[4];
812: if (x0 <= x && x < x0 + max + 4 && y0 <= y && y < y0 + 5) {
813: smnPaletDragSlider = n;
814: smnPaletPressedX = x;
815: if (x < x0 + value || x0 + value + 4 <= x) {
816: slider[4] = Math.max (0, Math.min (max, x - x0));
817: smnDrawPaletSlider ();
818: smnUpdateColor ();
819: }
820: break;
821: }
822: }
823: }
824: }
825: @Override public void mouseReleased (MouseEvent me) {
826: smnWaveDragOn = false;
827: smnPaletDragSlider = -1;
828: }
829: });
830:
831:
832: ComponentFactory.addListener (
833: smnPanel,
834: new MouseMotionAdapter () {
835: @Override public void mouseDragged (MouseEvent me) {
836: int x = me.getX () >> smnZoomShift;
837: int y = me.getY () >> smnZoomShift;
838: if (smnWaveDragOn) {
839: int offset = Math.max (0, Math.min (smnWaveOffsetMax, smnWaveOffset - (x - smnWavePressedX)));
840: int spaceY = (SMN_WAVE_HEIGHT >> 1 << smnWaveScaleY) - (SMN_WAVE_HEIGHT >> 1);
841: int elevation = Math.max (-spaceY, Math.min (spaceY, smnWaveElevation - (y - smnWavePressedY)));
842: smnWavePressedX = x;
843: smnWavePressedY = y;
844: if (smnWaveOffset != offset || smnWaveElevation != elevation) {
845: smnWaveOffset = offset;
846: smnWaveElevation = elevation;
847: if (smnPauseUpdate) {
848: smnWavePaint ();
849: smnPanel.repaint ();
850: }
851: }
852: } else if (smnPaletDragSlider >= 0) {
853: int[] slider = SMN_SLIDER_ARRAY[smnPaletDragSlider];
854: int max = slider[2];
855: int value = slider[4];
856: slider[4] = Math.max (0, Math.min (max, value + x - smnPaletPressedX));
857: smnPaletPressedX = x;
858: smnDrawPaletSlider ();
859: smnUpdateColor ();
860: }
861: }
862: });
863:
864:
865: smnFrame = Multilingual.mlnTitle (
866: ComponentFactory.createRestorableSubFrame (
867: Settings.SGS_SMN_FRAME_KEY,
868: "Sound Monitor",
869: null,
870: smnPanel,
871: false
872: ),
873: "ja", "音声モニタ");
874: ComponentFactory.addListener (
875: smnFrame,
876: new WindowAdapter () {
877: @Override public void windowClosing (WindowEvent we) {
878: smnIsVisible = false;
879: }
880: });
881:
882: }
883:
884:
885:
886: public static void smnMakeImage () {
887:
888:
889: smnMakeColorModel ();
890: smnImage = new BufferedImage (SMN_WIDTH, SMN_HEIGHT, BufferedImage.TYPE_BYTE_BINARY, smnColorModel);
891: byte[] bb = smnBitmap = ((DataBufferByte) smnImage.getRaster ().getDataBuffer ()).getData ();
892:
893:
894:
895:
896:
897:
898:
899: smnDrawIcon3 (SMN_SPECTRUM_X / 4, SMN_SPECTRUM_Y, 9);
900:
901:
902: smnDrawPattern (SMN_KEY_X + 56 * 4 + 43, SMN_KEY_Y, SMN_440HZ_PATTERN);
903:
904:
905: for (int ch = 0; ch < 8; ch++) {
906:
907: smnDrawIcon3 (SMN_KEY_X / 4 - 2, SMN_KEY_Y + 6 + 12 * ch, ch);
908: smnKey[ch] = -1;
909: for (int o = 0, i = SMN_KEY_X / 4 + SMN_OFFSET * (SMN_KEY_Y + 6 + 12 * ch); ; o++, i += 14) {
910: smnDrawChar1 (SMN_KEY_X / 4 + 14 * o, SMN_KEY_Y, '0' + o);
911: smnPaintKey (i , 0, SMN_KEY_COLOR[ 0]);
912: smnPaintKey (i + 1, 1, SMN_KEY_COLOR[ 1]);
913: smnPaintKey (i + 2, 2, SMN_KEY_COLOR[ 2]);
914: smnPaintKey (i + 3, 3, SMN_KEY_COLOR[ 3]);
915: smnPaintKey (i + 4, 4, SMN_KEY_COLOR[ 4]);
916: if (o == 8) {
917: break;
918: }
919: smnPaintKey (i + 6, 5, SMN_KEY_COLOR[ 5]);
920: smnPaintKey (i + 7, 6, SMN_KEY_COLOR[ 6]);
921: smnPaintKey (i + 8, 7, SMN_KEY_COLOR[ 7]);
922: smnPaintKey (i + 9, 8, SMN_KEY_COLOR[ 8]);
923: smnPaintKey (i + 10, 9, SMN_KEY_COLOR[ 9]);
924: smnPaintKey (i + 11, 10, SMN_KEY_COLOR[10]);
925: smnPaintKey (i + 12, 11, SMN_KEY_COLOR[11]);
926: }
927:
928:
929:
930:
931:
932:
933:
934:
935:
936:
937: {
938: int x = SMN_TONE_X / 4 + SMN_TONE_BOX_COLS * (0b01_00_10_01_00_10_01_00 >> (ch << 1) & 3);
939: int y = SMN_TONE_Y + SMN_TONE_BOX_HEIGHT * (0b10_10_01_01_01_00_00_00 >> (ch << 1) & 3);
940: smnDrawIcon3 (x, y, ch);
941: smnDrawString1 (3 + x, y, SMN_TONE_H1);
942: smnDrawString1 (3 + x, 6 * 2 + y, SMN_TONE_H2);
943: smnDrawString1 ( x, 6 * 3 + y, SMN_TONE_M1);
944: smnDrawString1 ( x, 6 * 4 + y, SMN_TONE_C1);
945: smnDrawString1 ( x, 6 * 5 + y, SMN_TONE_M2);
946: smnDrawString1 ( x, 6 * 6 + y, SMN_TONE_C2);
947: }
948: }
949:
950:
951: smnDrawIcon3 (SMN_PCM_COL, SMN_PCM_Y, 10);
952: smnDrawString3 (SMN_PCM_COL + 5, SMN_PCM_Y , "MHz");
953: smnDrawString3 (SMN_PCM_COL + 9, SMN_PCM_Y , "1/");
954: smnDrawString3 (SMN_PCM_COL + 20, SMN_PCM_Y , "kHz");
955:
956:
957:
958:
959:
960:
961:
962:
963:
964: smnDrawChar1 (SMN_PALET_X / 4 + 8, SMN_PALET_Y, 'H');
965: smnDrawChar1 (SMN_PALET_X / 4 + 20, SMN_PALET_Y, 'S');
966: smnDrawChar1 (SMN_PALET_X / 4 + 30, SMN_PALET_Y, 'B');
967: for (int p = 0; p < 4; p++) {
968: smnDrawChar1 (SMN_PALET_X / 4, SMN_PALET_Y + 6 + 6 * p, '0' + p);
969: }
970: smnDrawPaletSlider ();
971:
972: }
973:
974:
975:
976: public static void smnDrawPaletSlider () {
977: for (int p = 0; p < 4; p++) {
978: int[] pattern = SMN_SLIDER_PATTERN[p];
979: smnDrawSlider (SMN_SLIDER_ARRAY[3 * p ], pattern);
980: smnDrawSlider (SMN_SLIDER_ARRAY[3 * p + 1], pattern);
981: smnDrawSlider (SMN_SLIDER_ARRAY[3 * p + 2], pattern);
982: }
983: }
984:
985:
986:
987: public static void smnMakeColorModel () {
988: byte[] r = new byte[4];
989: byte[] g = new byte[4];
990: byte[] b = new byte[4];
991: for (int p = 0; p < 4; p++) {
992: int rgb = Color.HSBtoRGB ((float) SMN_SLIDER_ARRAY[3 * p ][4] / 48F,
993: (float) SMN_SLIDER_ARRAY[3 * p + 1][4] / 32F,
994: (float) SMN_SLIDER_ARRAY[3 * p + 2][4] / 32F);
995: if (false) {
996: System.out.printf ("%d 0x%08x %2d %2d %2d\n", p, rgb,
997: SMN_SLIDER_ARRAY[3 * p ][4],
998: SMN_SLIDER_ARRAY[3 * p + 1][4],
999: SMN_SLIDER_ARRAY[3 * p + 2][4]);
1000: }
1001: r[p] = (byte) (rgb >> 16);
1002: g[p] = (byte) (rgb >> 8);
1003: b[p] = (byte) rgb;
1004: }
1005: smnColorModel = new IndexColorModel (2, 4, r, g, b);
1006: }
1007:
1008:
1009: public static void smnUpdateColor () {
1010: smnMakeColorModel ();
1011: smnImage = new BufferedImage (smnColorModel, smnImage.getRaster(), false, null);
1012:
1013: smnPanel.repaint ();
1014: }
1015:
1016:
1017:
1018: public static void smnUpdate () {
1019: byte[] bb = smnBitmap;
1020:
1021:
1022: if (smnZoomShift != smnZoomRequest) {
1023: smnZoomShift = smnZoomRequest;
1024: byte[] icon = smnZoomShift == 0 ? SMN_ZOOM_X2_ICON : SMN_ZOOM_X1_ICON;
1025: int i = SMN_ZOOM_X / 4 + SMN_OFFSET * SMN_ZOOM_Y;
1026: int j = 0;
1027: for (int v = 0; v < SMN_ZOOM_HEIGHT; v++) {
1028: for (int u = 0; u < SMN_ZOOM_WIDTH; u += 4) {
1029: bb[i++] = icon[j++];
1030: }
1031: i += SMN_OFFSET - SMN_ZOOM_WIDTH / 4;
1032: }
1033: int panelWidth = SMN_WIDTH << smnZoomShift;
1034: int panelHeight = SMN_HEIGHT << smnZoomShift;
1035: int marginWidth = smnFrame.getWidth () - smnPanel.getWidth ();
1036: int marginHeight = smnFrame.getHeight () - smnPanel.getHeight ();
1037: ComponentFactory.setFixedSize (smnFrame, panelWidth + marginWidth, panelHeight + marginHeight);
1038: smnFrame.setResizable (false);
1039: ComponentFactory.setFixedSize (smnPanel, panelWidth, panelHeight);
1040: smnFrame.pack ();
1041: }
1042:
1043:
1044: if (smnPauseUpdate) {
1045: if (smnPauseRequest) {
1046: return;
1047: }
1048: smnPauseUpdate = false;
1049: int i = SMN_PAUSE_X / 4 + SMN_OFFSET * SMN_PAUSE_Y;
1050: int j = 0;
1051: for (int v = 0; v < SMN_PAUSE_HEIGHT; v++) {
1052: for (int u = 0; u < SMN_PAUSE_WIDTH; u += 4) {
1053: bb[i++] = SMN_PAUSE_ICON_3[j++];
1054: }
1055: i += SMN_OFFSET - SMN_PAUSE_WIDTH / 4;
1056: }
1057: } else if (smnPauseRequest) {
1058: smnPauseUpdate = true;
1059: int i = SMN_PAUSE_X / 4 + SMN_OFFSET * SMN_PAUSE_Y;
1060: int j = 0;
1061: for (int v = 0; v < SMN_PAUSE_HEIGHT; v++) {
1062: for (int u = 0; u < SMN_PAUSE_WIDTH; u += 4) {
1063: bb[i++] = SMN_PLAY_ICON_3[j++];
1064: }
1065: i += SMN_OFFSET - SMN_PAUSE_WIDTH / 4;
1066: }
1067: smnPanel.repaint ();
1068: return;
1069: }
1070:
1071:
1072: System.arraycopy (OPM.opmBuffer, 0, smnOPMBuffer, 0, SoundSource.SND_CHANNELS * OPM.OPM_BLOCK_SAMPLES);
1073: System.arraycopy (ADPCM.pcmBuffer, 0, smnPCMBuffer, 0, SoundSource.SND_CHANNELS * OPM.OPM_BLOCK_SAMPLES);
1074: smnWavePaint ();
1075:
1076:
1077:
1078:
1079:
1080:
1081:
1082:
1083:
1084:
1085:
1086:
1087:
1088:
1089:
1090:
1091:
1092:
1093:
1094:
1095:
1096:
1097:
1098:
1099:
1100:
1101:
1102:
1103:
1104:
1105:
1106:
1107:
1108:
1109:
1110:
1111:
1112:
1113:
1114:
1115:
1116:
1117:
1118:
1119:
1120:
1121:
1122:
1123:
1124:
1125:
1126:
1127:
1128:
1129:
1130:
1131:
1132:
1133:
1134:
1135:
1136:
1137:
1138:
1139:
1140:
1141:
1142:
1143:
1144:
1145:
1146:
1147:
1148:
1149:
1150:
1151:
1152:
1153:
1154:
1155:
1156:
1157:
1158:
1159:
1160:
1161:
1162:
1163:
1164:
1165:
1166:
1167:
1168:
1169:
1170:
1171:
1172:
1173:
1174:
1175:
1176:
1177:
1178:
1179:
1180:
1181:
1182:
1183:
1184:
1185:
1186:
1187:
1188:
1189:
1190:
1191:
1192:
1193:
1194:
1195:
1196:
1197:
1198:
1199:
1200:
1201:
1202:
1203:
1204:
1205:
1206:
1207:
1208:
1209:
1210:
1211:
1212:
1213:
1214:
1215:
1216:
1217:
1218:
1219:
1220:
1221:
1222:
1223:
1224: double[] buffer0 = smnSpectrumBuffer[0];
1225: double[] buffer2 = smnSpectrumBuffer[2];
1226: double[] buffer3 = smnSpectrumBuffer[3];
1227: double[] buffer4 = smnSpectrumBuffer[4];
1228: double[] buffer5 = smnSpectrumBuffer[5];
1229:
1230: System.arraycopy (buffer5, 500, buffer5, 0, SMN_SPECTRUM_N - 500);
1231: if (SoundSource.SND_CHANNELS == 1) {
1232: for (int i = SMN_SPECTRUM_N - 500, k = 0; i < SMN_SPECTRUM_N; i++, k += 5) {
1233: buffer5[i] = (double) (OPM.opmBuffer[k ] + ADPCM.pcmBuffer[k ] +
1234: OPM.opmBuffer[k + 1] + ADPCM.pcmBuffer[k + 1] +
1235: OPM.opmBuffer[k + 2] + ADPCM.pcmBuffer[k + 2] +
1236: OPM.opmBuffer[k + 3] + ADPCM.pcmBuffer[k + 3] +
1237: OPM.opmBuffer[k + 4] + ADPCM.pcmBuffer[k + 4]) * (0.2 / 32768.0);
1238: }
1239: } else {
1240: for (int i = SMN_SPECTRUM_N - 500, k = 0; i < SMN_SPECTRUM_N; i++, k += 10) {
1241: buffer5[i] = (double) (OPM.opmBuffer[k ] + OPM.opmBuffer[k + 1] + ADPCM.pcmBuffer[k ] + ADPCM.pcmBuffer[k + 1] +
1242: OPM.opmBuffer[k + 2] + OPM.opmBuffer[k + 3] + ADPCM.pcmBuffer[k + 2] + ADPCM.pcmBuffer[k + 3] +
1243: OPM.opmBuffer[k + 4] + OPM.opmBuffer[k + 5] + ADPCM.pcmBuffer[k + 4] + ADPCM.pcmBuffer[k + 5] +
1244: OPM.opmBuffer[k + 6] + OPM.opmBuffer[k + 7] + ADPCM.pcmBuffer[k + 6] + ADPCM.pcmBuffer[k + 7] +
1245: OPM.opmBuffer[k + 8] + OPM.opmBuffer[k + 9] + ADPCM.pcmBuffer[k + 8] + ADPCM.pcmBuffer[k + 9]) * (0.1 / 32768.0);
1246: }
1247: }
1248:
1249: System.arraycopy (buffer4, 250, buffer4, 0, SMN_SPECTRUM_N - 250);
1250: for (int i = SMN_SPECTRUM_N - 250, k = SMN_SPECTRUM_N - 500; i < SMN_SPECTRUM_N; i++, k += 2) {
1251: buffer4[i] = (buffer5[k] + buffer5[k + 1]) * 0.5;
1252: }
1253:
1254: System.arraycopy (buffer3, 100, buffer3, 0, SMN_SPECTRUM_N - 100);
1255: for (int i = SMN_SPECTRUM_N - 100, k = SMN_SPECTRUM_N - 500; i < SMN_SPECTRUM_N; i++, k += 5) {
1256: buffer3[i] = (buffer5[k] + buffer5[k + 1] + buffer5[k + 2] + buffer5[k + 3] + buffer5[k + 4]) * 0.2;
1257: }
1258:
1259: System.arraycopy (buffer2, 50, buffer2, 0, SMN_SPECTRUM_N - 50);
1260: for (int i = SMN_SPECTRUM_N - 50, k = SMN_SPECTRUM_N - 100; i < SMN_SPECTRUM_N; i++, k += 2) {
1261: buffer2[i] = (buffer3[k] + buffer3[k + 1]) * 0.5;
1262: }
1263:
1264: System.arraycopy (buffer0, 25, buffer0, 0, SMN_SPECTRUM_N - 25);
1265: for (int i = SMN_SPECTRUM_N - 25, k = SMN_SPECTRUM_N - 50; i < SMN_SPECTRUM_N; i++, k += 2) {
1266: buffer0[i] = (buffer2[k] + buffer2[k + 1]) * 0.5;
1267: }
1268: for (int partition = 0; partition < SMN_SPECTRUM_PARTITIONS; partition++) {
1269: if (partition != 1) {
1270:
1271: double[] buffer = smnSpectrumBuffer[partition];
1272: for (int i = 0; i < SMN_SPECTRUM_N; i++) {
1273: smnSpectrumX[i] = smnSpectrumWindow[i] * buffer[i];
1274: }
1275:
1276: Arrays.fill (smnSpectrumY, 0, SMN_SPECTRUM_N, 0.0);
1277:
1278:
1279: smnFFT.fftSandeTukey4 (smnSpectrumX, smnSpectrumY);
1280: }
1281:
1282:
1283: for (int x = partition == 0 ? 8 : SMN_SPECTRUM_RANGE * partition, x1 = x + SMN_SPECTRUM_RANGE, b = 6; x < x1; x++, b = b - 2 & 6) {
1284: int k = smnSpectrumIndex[x];
1285: int n = k >> 16;
1286: k = (char) k;
1287: double level = smnSpectrumX[k];
1288: while (--n > 0) {
1289: level = Math.max (level, smnSpectrumX[++k]);
1290: }
1291: int value = Math.max (0, Math.min (SMN_SPECTRUM_HEIGHT - 1, (int) ((double) SMN_SPECTRUM_HEIGHT / (double) SMN_SPECTRUM_N * SMN_SPECTRUM_SCALE * level)));
1292: int value0 = smnSpectrumValue[x];
1293: if (value > value0) {
1294: smnSpectrumValue[x] = value;
1295: int i = SMN_OFFSET * (SMN_SPECTRUM_Y + SMN_SPECTRUM_HEIGHT - 1 - value) + SMN_SPECTRUM_X / 4 + (x >> 2);
1296: while (value > value0) {
1297: bb[i] = (byte) (bb[i] & ~(3 << b) | (SMN_WHITE & 3) << b);
1298: i += SMN_OFFSET;
1299: value--;
1300: }
1301: } else if (value < value0) {
1302: if (value < value0 - SMN_SPECTRUM_TRAIL) {
1303: value = value0 - SMN_SPECTRUM_TRAIL;
1304: }
1305: smnSpectrumValue[x] = value;
1306: int i = SMN_OFFSET * (SMN_SPECTRUM_Y + SMN_SPECTRUM_HEIGHT - 1 - value0) + SMN_SPECTRUM_X / 4 + (x >> 2);
1307: while (value < value0) {
1308: bb[i] = (byte) (bb[i] & ~(3 << b));
1309: i += SMN_OFFSET;
1310: value++;
1311: }
1312: }
1313: }
1314: }
1315:
1316:
1317: for (int ch = 0; ch < 8; ch++) {
1318: YM2151.fm_channel channel = OPM.opmYM2151.m_channel[ch];
1319: YM2151.fm_operator opM1 = channel.m_op[0];
1320: YM2151.fm_operator opM2 = channel.m_op[1];
1321: YM2151.fm_operator opC1 = channel.m_op[2];
1322: YM2151.fm_operator opC2 = channel.m_op[3];
1323:
1324: int k0 = smnKey[ch];
1325:
1326: int m1 = opM1.m_env_state < YM2151.EG_RELEASE ? -1 : opM1.m_env_attenuation < YM2151.EG_QUIET ? 0 : 1;
1327: int m2 = opM2.m_env_state < YM2151.EG_RELEASE ? -1 : opM2.m_env_attenuation < YM2151.EG_QUIET ? 0 : 1;
1328: int c1 = opC1.m_env_state < YM2151.EG_RELEASE ? -1 : opC1.m_env_attenuation < YM2151.EG_QUIET ? 0 : 1;
1329: int c2 = opC2.m_env_state < YM2151.EG_RELEASE ? -1 : opC2.m_env_attenuation < YM2151.EG_QUIET ? 0 : 1;
1330: int k1;
1331: if (m1 > 0 && m2 > 0 && c1 > 0 && c2 > 0) {
1332: k1 = -1;
1333: } else {
1334:
1335: int kc = OPM.opmRegister[0x28 + ch] & 127;
1336: int kf = (OPM.opmRegister[0x30 + ch] >> 2) & 63;
1337: k1 = (((kc - (kc >> 2)) << 6 | kf) + (3 << 6) + (64 - 38)) >> 6;
1338: if (m1 >= 0 && m2 >= 0 && c1 >= 0 && c2 >= 0) {
1339: k1 |= 0x10000;
1340: }
1341: }
1342: if (k0 != k1) {
1343: int i = SMN_KEY_X / 4 + SMN_OFFSET * (SMN_KEY_Y + 6 + 12 * ch);
1344: if (k0 >= 0 && (short) k0 != (short) k1) {
1345:
1346:
1347: int kk = (short) k0;
1348: int o = kk * 43 >>> 9;
1349: kk -= 12 * o;
1350: smnPaintKey (i + 14 * o + (kk < 5 ? kk : kk + 1), kk, SMN_KEY_COLOR[kk]);
1351: }
1352: if (k1 >= 0 && k0 != k1) {
1353:
1354:
1355: int kk = (short) k1;
1356: int o = kk * 43 >>> 9;
1357: kk -= 12 * o;
1358: if (k1 >> 16 == 0) {
1359: smnPaintKey (i + 14 * o + (kk < 5 ? kk : kk + 1), kk, SMN_ORANGE);
1360: } else {
1361: smnPaintKey2 (i + 14 * o + (kk < 5 ? kk : kk + 1), kk, SMN_KEY_COLOR[kk], SMN_ORANGE);
1362: }
1363: }
1364: smnKey[ch] = k1;
1365: }
1366:
1367: {
1368: XEiJ.fmtHex2 (SMN_TONE_V0, 0, OPM.opmRegister[0x20 + ch] & 63);
1369: XEiJ.fmtHex2 (SMN_TONE_V0, 3, OPM.opmRegister[256 + ch]);
1370: XEiJ.fmtHex2 (SMN_TONE_V0, 6, OPM.opmRegister[0x1b] & 3);
1371: XEiJ.fmtHex2 (SMN_TONE_V0, 9, 0);
1372: XEiJ.fmtHex2 (SMN_TONE_V0, 12, OPM.opmRegister[0x18] & 255);
1373: XEiJ.fmtHex2 (SMN_TONE_V0, 15, OPM.opmRegister[265]);
1374: XEiJ.fmtHex2 (SMN_TONE_V0, 18, OPM.opmRegister[264]);
1375: XEiJ.fmtHex2 (SMN_TONE_V0, 21, (OPM.opmRegister[0x38 + ch] >> 4) & 7);
1376: XEiJ.fmtHex2 (SMN_TONE_V0, 24, OPM.opmRegister[0x38 + ch] & 3);
1377: XEiJ.fmtHex2 (SMN_TONE_V0, 27, (OPM.opmRegister[0x20 + ch] >> 6) & 3);
1378: XEiJ.fmtHex2 (SMN_TONE_V1, 0, OPM.opmRegister[0x80 + ch] & 31);
1379: XEiJ.fmtHex2 (SMN_TONE_V2, 0, OPM.opmRegister[0x90 + ch] & 31);
1380: XEiJ.fmtHex2 (SMN_TONE_V3, 0, OPM.opmRegister[0x88 + ch] & 31);
1381: XEiJ.fmtHex2 (SMN_TONE_V4, 0, OPM.opmRegister[0x98 + ch] & 31);
1382: XEiJ.fmtHex2 (SMN_TONE_V1, 3, OPM.opmRegister[0xa0 + ch] & 31);
1383: XEiJ.fmtHex2 (SMN_TONE_V2, 3, OPM.opmRegister[0xb0 + ch] & 31);
1384: XEiJ.fmtHex2 (SMN_TONE_V3, 3, OPM.opmRegister[0xa8 + ch] & 31);
1385: XEiJ.fmtHex2 (SMN_TONE_V4, 3, OPM.opmRegister[0xb8 + ch] & 31);
1386: XEiJ.fmtHex2 (SMN_TONE_V1, 6, OPM.opmRegister[0xc0 + ch] & 31);
1387: XEiJ.fmtHex2 (SMN_TONE_V2, 6, OPM.opmRegister[0xd0 + ch] & 31);
1388: XEiJ.fmtHex2 (SMN_TONE_V3, 6, OPM.opmRegister[0xc8 + ch] & 31);
1389: XEiJ.fmtHex2 (SMN_TONE_V4, 6, OPM.opmRegister[0xd8 + ch] & 31);
1390: XEiJ.fmtHex2 (SMN_TONE_V1, 9, OPM.opmRegister[0xe0 + ch] & 15);
1391: XEiJ.fmtHex2 (SMN_TONE_V2, 9, OPM.opmRegister[0xf0 + ch] & 15);
1392: XEiJ.fmtHex2 (SMN_TONE_V3, 9, OPM.opmRegister[0xe8 + ch] & 15);
1393: XEiJ.fmtHex2 (SMN_TONE_V4, 9, OPM.opmRegister[0xf8 + ch] & 15);
1394: XEiJ.fmtHex2 (SMN_TONE_V1, 12, (OPM.opmRegister[0xe0 + ch] >> 4) & 15);
1395: XEiJ.fmtHex2 (SMN_TONE_V2, 12, (OPM.opmRegister[0xf0 + ch] >> 4) & 15);
1396: XEiJ.fmtHex2 (SMN_TONE_V3, 12, (OPM.opmRegister[0xe8 + ch] >> 4) & 15);
1397: XEiJ.fmtHex2 (SMN_TONE_V4, 12, (OPM.opmRegister[0xf8 + ch] >> 4) & 15);
1398: XEiJ.fmtHex2 (SMN_TONE_V1, 15, OPM.opmRegister[0x60 + ch] & 127);
1399: XEiJ.fmtHex2 (SMN_TONE_V2, 15, OPM.opmRegister[0x70 + ch] & 127);
1400: XEiJ.fmtHex2 (SMN_TONE_V3, 15, OPM.opmRegister[0x68 + ch] & 127);
1401: XEiJ.fmtHex2 (SMN_TONE_V4, 15, OPM.opmRegister[0x78 + ch] & 127);
1402: XEiJ.fmtHex2 (SMN_TONE_V1, 18, (OPM.opmRegister[0x80 + ch] >> 6) & 3);
1403: XEiJ.fmtHex2 (SMN_TONE_V2, 18, (OPM.opmRegister[0x90 + ch] >> 6) & 3);
1404: XEiJ.fmtHex2 (SMN_TONE_V3, 18, (OPM.opmRegister[0x88 + ch] >> 6) & 3);
1405: XEiJ.fmtHex2 (SMN_TONE_V4, 18, (OPM.opmRegister[0x98 + ch] >> 6) & 3);
1406: XEiJ.fmtHex2 (SMN_TONE_V1, 21, OPM.opmRegister[0x40 + ch] & 15);
1407: XEiJ.fmtHex2 (SMN_TONE_V2, 21, OPM.opmRegister[0x50 + ch] & 15);
1408: XEiJ.fmtHex2 (SMN_TONE_V3, 21, OPM.opmRegister[0x48 + ch] & 15);
1409: XEiJ.fmtHex2 (SMN_TONE_V4, 21, OPM.opmRegister[0x58 + ch] & 15);
1410: XEiJ.fmtHex2 (SMN_TONE_V1, 24, (OPM.opmRegister[0x40 + ch] >> 4) & 7);
1411: XEiJ.fmtHex2 (SMN_TONE_V2, 24, (OPM.opmRegister[0x50 + ch] >> 4) & 7);
1412: XEiJ.fmtHex2 (SMN_TONE_V3, 24, (OPM.opmRegister[0x48 + ch] >> 4) & 7);
1413: XEiJ.fmtHex2 (SMN_TONE_V4, 24, (OPM.opmRegister[0x58 + ch] >> 4) & 7);
1414: XEiJ.fmtHex2 (SMN_TONE_V1, 27, (OPM.opmRegister[0xc0 + ch] >> 6) & 3);
1415: XEiJ.fmtHex2 (SMN_TONE_V2, 27, (OPM.opmRegister[0xd0 + ch] >> 6) & 3);
1416: XEiJ.fmtHex2 (SMN_TONE_V3, 27, (OPM.opmRegister[0xc8 + ch] >> 6) & 3);
1417: XEiJ.fmtHex2 (SMN_TONE_V4, 27, (OPM.opmRegister[0xd8 + ch] >> 6) & 3);
1418: XEiJ.fmtHex2 (SMN_TONE_V1, 30, (OPM.opmRegister[0xa0 + ch] >> 7) & 1);
1419: XEiJ.fmtHex2 (SMN_TONE_V2, 30, (OPM.opmRegister[0xb0 + ch] >> 7) & 1);
1420: XEiJ.fmtHex2 (SMN_TONE_V3, 30, (OPM.opmRegister[0xa8 + ch] >> 7) & 1);
1421: XEiJ.fmtHex2 (SMN_TONE_V4, 30, (OPM.opmRegister[0xb8 + ch] >> 7) & 1);
1422: int x = SMN_TONE_X / 4 + SMN_TONE_BOX_COLS * (0b01_00_10_01_00_10_01_00 >> (ch << 1) & 3);
1423: int y = SMN_TONE_Y + SMN_TONE_BOX_HEIGHT * (0b10_10_01_01_01_00_00_00 >> (ch << 1) & 3);
1424: smnDrawString3 (3 + x, 6 + y, SMN_TONE_V0);
1425: smnDrawString3 (3 + x, 6 * 3 + y, SMN_TONE_V1);
1426: smnDrawString3 (3 + x, 6 * 4 + y, SMN_TONE_V2);
1427: smnDrawString3 (3 + x, 6 * 5 + y, SMN_TONE_V3);
1428: smnDrawString3 (3 + x, 6 * 6 + y, SMN_TONE_V4);
1429: }
1430: }
1431:
1432:
1433: smnDrawString3 (SMN_PCM_COL + 3, SMN_PCM_Y , SMN_PCM_OSCILLATOR[ADPCM.pcmOSCFreqMode << 1 | ADPCM.pcmOscillator]);
1434: smnDrawString3 (SMN_PCM_COL + 11, SMN_PCM_Y , SMN_PCM_DIVIDER[ADPCM.pcmDivider]);
1435: smnDrawString3 (SMN_PCM_COL + 16, SMN_PCM_Y , SMN_PCM_FREQ[ADPCM.pcmOSCFreqMode << 3 | ADPCM.pcmOscillator << 2 | ADPCM.pcmDivider]);
1436: smnDrawString2 (SMN_PCM_COL + 3, SMN_PCM_Y + 6, SMN_PCM_PLAY[ADPCM.pcmActive ? 1 : 0]);
1437: smnDrawString2 (SMN_PCM_COL + 8, SMN_PCM_Y + 6, SMN_PCM_DATA[ADPCM.pcmEncodedData >= 0 ? 1 : 0]);
1438: smnDrawString2 (SMN_PCM_COL + 13, SMN_PCM_Y + 6, SMN_PCM_LEFT[ADPCM.pcmPanLeft == 0 || ADPCM.pcmPanLeft < 0x80000000 + ADPCM.PCM_ATTACK_SPAN * 2 ? 0 : 1]);
1439: smnDrawString2 (SMN_PCM_COL + 18, SMN_PCM_Y + 6, SMN_PCM_RIGHT[SoundSource.SND_CHANNELS == 1 ?
1440: ADPCM.pcmPanLeft == 0 || ADPCM.pcmPanLeft < 0x80000000 + ADPCM.PCM_ATTACK_SPAN * 2 ? 0 : 1 :
1441: ADPCM.pcmPanRight == 0 || ADPCM.pcmPanRight < 0x80000000 + ADPCM.PCM_ATTACK_SPAN * 2 ? 0 : 1]);
1442:
1443: smnPanel.repaint ();
1444:
1445: }
1446:
1447:
1448:
1449: public static void smnWavePaint () {
1450: byte[] bb = smnBitmap;
1451:
1452: Arrays.fill (bb, SMN_OFFSET * SMN_WAVE_Y, SMN_OFFSET * (SMN_WAVE_Y + SMN_WAVE_HEIGHT), SMN_BLACK);
1453:
1454: smnDrawIcon3 (SMN_WAVE_X / 4 - 2, SMN_WAVE_Y, 8);
1455:
1456: if (-SMN_WAVE_HEIGHT / 2 <= smnWaveElevation && smnWaveElevation <= SMN_WAVE_HEIGHT / 2) {
1457: int i = SMN_OFFSET * (SMN_WAVE_Y + SMN_WAVE_HEIGHT / 2 - smnWaveElevation) + SMN_WAVE_X / 4;
1458: Arrays.fill (bb, i, i + SMN_WAVE_WIDTH / 4, SMN_BLUE);
1459: }
1460:
1461: int ms0 = (1000 / SoundSource.SND_BLOCK_FREQ * smnWaveOffset + (SMN_WAVE_WIDTH << smnWaveScaleX) - 1) / (SMN_WAVE_WIDTH << smnWaveScaleX);
1462: int ms1 = 1000 / SoundSource.SND_BLOCK_FREQ * (smnWaveOffset + SMN_WAVE_WIDTH) / (SMN_WAVE_WIDTH << smnWaveScaleX);
1463: for (int ms = ms0; ms <= ms1; ms++) {
1464:
1465:
1466:
1467: int x = Math.max (0, Math.min (SMN_WAVE_WIDTH - 1, (SoundSource.SND_BLOCK_FREQ * SMN_WAVE_WIDTH * ms * 8389 >>> 23 << smnWaveScaleX) - smnWaveOffset));
1468: int b = (~x & 3) << 1;
1469: if (ms1 - ms0 <= 10 ||
1470: ms1 - ms0 <= 20 && (1L << 63 - 0 |
1471: 1L << 63 - 5 |
1472: 1L << 63 - 10 |
1473: 1L << 63 - 15 |
1474: 1L << 63 - 20 |
1475: 1L << 63 - 25 |
1476: 1L << 63 - 30 |
1477: 1L << 63 - 35 |
1478: 1L << 63 - 40 |
1479: 1L << 63 - 45 |
1480: 1L << 63 - 50 |
1481: 1L << 63 - 55 |
1482: 1L << 63 - 60) << ms < 0 ||
1483: (1L << 63 - 0 |
1484: 1L << 63 - 10 |
1485: 1L << 63 - 20 |
1486: 1L << 63 - 30 |
1487: 1L << 63 - 40 |
1488: 1L << 63 - 50 |
1489: 1L << 63 - 60) << ms < 0) {
1490: int t = XEiJ.FMT_BCD4[ms];
1491: int col = SMN_WAVE_X / 4 + Math.max (0, Math.min (SMN_WAVE_WIDTH / 4 - (t >= 0x10 ? 4 : 3), (x + 3 >> 2) - (t >= 0x10 ? 2 : 1)));
1492: if (t >= 0x10) {
1493: smnDrawChar1 (col++, SMN_WAVE_Y + SMN_WAVE_HEIGHT - 6, '0' | t >> 4);
1494: }
1495: smnDrawChar1 (col , SMN_WAVE_Y + SMN_WAVE_HEIGHT - 6, '0' | t & 15);
1496: smnDrawChar1 (col + 1, SMN_WAVE_Y + SMN_WAVE_HEIGHT - 6, 'm');
1497: smnDrawChar1 (col + 2, SMN_WAVE_Y + SMN_WAVE_HEIGHT - 6, 's');
1498: }
1499: int v0, v1;
1500: if ((1L << 63 - 0 |
1501: 1L << 63 - 10 |
1502: 1L << 63 - 20 |
1503: 1L << 63 - 30 |
1504: 1L << 63 - 40 |
1505: 1L << 63 - 50 |
1506: 1L << 63 - 60) << ms < 0) {
1507: v0 = SMN_WAVE_HEIGHT / 2 - SMN_WAVE_HEIGHT * 4 / 16;
1508: v1 = SMN_WAVE_HEIGHT / 2 + SMN_WAVE_HEIGHT * 4 / 16;
1509: } else if ((1L << 63 - 0 |
1510: 1L << 63 - 5 |
1511: 1L << 63 - 10 |
1512: 1L << 63 - 15 |
1513: 1L << 63 - 20 |
1514: 1L << 63 - 25 |
1515: 1L << 63 - 30 |
1516: 1L << 63 - 35 |
1517: 1L << 63 - 40 |
1518: 1L << 63 - 45 |
1519: 1L << 63 - 50 |
1520: 1L << 63 - 55 |
1521: 1L << 63 - 60) << ms < 0) {
1522: v0 = SMN_WAVE_HEIGHT / 2 - SMN_WAVE_HEIGHT * 3 / 16;
1523: v1 = SMN_WAVE_HEIGHT / 2 + SMN_WAVE_HEIGHT * 3 / 16;
1524: } else {
1525: v0 = SMN_WAVE_HEIGHT / 2 - SMN_WAVE_HEIGHT * 2 / 16;
1526: v1 = SMN_WAVE_HEIGHT / 2 + SMN_WAVE_HEIGHT * 2 / 16;
1527: }
1528: v0 -= smnWaveElevation;
1529: v1 -= smnWaveElevation;
1530: if (v0 < 0) {
1531: v0 = 0;
1532: }
1533: if (v1 > SMN_WAVE_HEIGHT - 1) {
1534: v1 = SMN_WAVE_HEIGHT - 1;
1535: }
1536: int i = SMN_OFFSET * (SMN_WAVE_Y + v0) + SMN_WAVE_X / 4 + (x >> 2);
1537: for (int v = v0; v <= v1; v++) {
1538: bb[i] = (byte) (bb[i] & ~(3 << b) | (SMN_BLUE & 3) << b);
1539: i += SMN_OFFSET;
1540: }
1541: }
1542: if (SoundSource.SND_CHANNELS == 1) {
1543: smnWavePaint1 (smnPCMBuffer, smnWaveIndex0[smnWaveScaleX], SMN_ORANGE & 3, smnWaveLastYPCMLeft);
1544: smnWavePaint1 (smnOPMBuffer, smnWaveIndex0[smnWaveScaleX], SMN_WHITE & 3, smnWaveLastYOPMLeft);
1545: } else {
1546: smnWavePaint1 (smnPCMBuffer, smnWaveIndex0[smnWaveScaleX], SMN_ORANGE & 3, smnWaveLastYPCMLeft);
1547: smnWavePaint1 (smnPCMBuffer, smnWaveIndex1[smnWaveScaleX], SMN_ORANGE & 3, smnWaveLastYPCMRight);
1548: smnWavePaint1 (smnOPMBuffer, smnWaveIndex0[smnWaveScaleX], SMN_WHITE & 3, smnWaveLastYOPMLeft);
1549: smnWavePaint1 (smnOPMBuffer, smnWaveIndex1[smnWaveScaleX], SMN_WHITE & 3, smnWaveLastYOPMRight);
1550: }
1551: }
1552:
1553:
1554: public static void smnWavePaint1 (int[] buffer, int[] index, int palet, int[] lastY) {
1555: byte[] bb = smnBitmap;
1556: int o = smnWaveOffset;
1557: int t;
1558: int y0 = lastY[0];
1559: int y1 = lastY[1];
1560: int scaleY = SMN_WAVE_VALUE_SHIFT - smnWaveScaleY;
1561: for (int x = 0, b = 6; x < SMN_WAVE_WIDTH; x++, b = b - 2 & 6) {
1562: int y2 = SMN_WAVE_HEIGHT / 2 - ((t = buffer[index[o + x]]) + (t >>> -scaleY) >> scaleY);
1563: int min, max;
1564: if (y0 < y1) {
1565: if (y1 < y2) {
1566: min = y0 + y1 >> 1;
1567: max = y1 + y2 >> 1;
1568: } else if (y0 < y2) {
1569: min = y0 + y1 >> 1;
1570: max = y1;
1571: } else {
1572: min = y1 + y2 >> 1;
1573: max = y1;
1574: }
1575: } else {
1576: if (y0 < y2) {
1577: min = y1;
1578: max = y1 + y2 >> 1;
1579: } else if (y1 < y2) {
1580: min = y1;
1581: max = y0 + y1 >> 1;
1582: } else {
1583: min = y1 + y2 >> 1;
1584: max = y0 + y1 >> 1;
1585: }
1586: }
1587: min -= smnWaveElevation;
1588: max -= smnWaveElevation;
1589:
1590: if (min < 0) {
1591: min = 0;
1592: }
1593: if (max > SMN_WAVE_HEIGHT - 1) {
1594: max = SMN_WAVE_HEIGHT - 1;
1595: }
1596: for (int y = min; y <= max; y++) {
1597: int i = SMN_OFFSET * (SMN_WAVE_Y + y) + SMN_WAVE_X / 4 + (x >> 2);
1598: bb[i] = (byte) (bb[i] & ~(3 << b) | palet << b);
1599: }
1600: y0 = y1;
1601: y1 = y2;
1602: }
1603: lastY[0] = y0;
1604: lastY[1] = y1;
1605: }
1606:
1607:
1608:
1609:
1610:
1611:
1612:
1613:
1614:
1615:
1616:
1617:
1618:
1619:
1620:
1621:
1622:
1623:
1624:
1625:
1626:
1627:
1628:
1629: public static void smnPaintKey (int i, int k, int c1111) {
1630: int c1110 = c1111 & 0b11111100;
1631: byte[] bb = smnBitmap;
1632: switch (k) {
1633: case 0:
1634: case 5:
1635: bb[ SMN_OFFSET * 6 + i] = (
1636: bb[ SMN_OFFSET * 7 + i] =
1637: bb[ SMN_OFFSET * 8 + i] =
1638: bb[ SMN_OFFSET * 9 + i] =
1639: bb[ SMN_OFFSET * 10 + i] = (byte) c1111);
1640: bb[ + i] = (
1641: bb[ SMN_OFFSET + i] =
1642: bb[ SMN_OFFSET * 2 + i] =
1643: bb[ SMN_OFFSET * 3 + i] =
1644: bb[ SMN_OFFSET * 4 + i] =
1645: bb[ SMN_OFFSET * 5 + i] =
1646: bb[ 1 + SMN_OFFSET * 6 + i] =
1647: bb[ 1 + SMN_OFFSET * 7 + i] =
1648: bb[ 1 + SMN_OFFSET * 8 + i] =
1649: bb[ 1 + SMN_OFFSET * 9 + i] =
1650: bb[ 1 + SMN_OFFSET * 10 + i] = (byte) c1110);
1651: break;
1652: case 1:
1653: case 3:
1654: case 6:
1655: case 8:
1656: case 10:
1657: bb[ i] = (
1658: bb[ SMN_OFFSET + i] =
1659: bb[ SMN_OFFSET * 2 + i] =
1660: bb[ SMN_OFFSET * 3 + i] =
1661: bb[ SMN_OFFSET * 4 + i] = (byte) c1111);
1662: bb[ 1 + + i] = (
1663: bb[ 1 + SMN_OFFSET + i] =
1664: bb[ 1 + SMN_OFFSET * 2 + i] =
1665: bb[ 1 + SMN_OFFSET * 3 + i] =
1666: bb[ 1 + SMN_OFFSET * 4 + i] = (byte) c1110);
1667: break;
1668: case 2:
1669: case 7:
1670: case 9:
1671: bb[ SMN_OFFSET * 6 + i] = (
1672: bb[ SMN_OFFSET * 7 + i] =
1673: bb[ SMN_OFFSET * 8 + i] =
1674: bb[ SMN_OFFSET * 9 + i] =
1675: bb[ SMN_OFFSET * 10 + i] = (byte) c1111);
1676: bb[ 1 + SMN_OFFSET * 6 + i] = (
1677: bb[ 1 + SMN_OFFSET * 7 + i] =
1678: bb[ 1 + SMN_OFFSET * 8 + i] =
1679: bb[ 1 + SMN_OFFSET * 9 + i] =
1680: bb[ 1 + SMN_OFFSET * 10 + i] = (byte) c1110);
1681: break;
1682: case 4:
1683: case 11:
1684: bb[ SMN_OFFSET * 6 + i] = (
1685: bb[ SMN_OFFSET * 7 + i] =
1686: bb[ SMN_OFFSET * 8 + i] =
1687: bb[ SMN_OFFSET * 9 + i] =
1688: bb[ SMN_OFFSET * 10 + i] = (byte) c1111);
1689: bb[ 1 + + i] = (
1690: bb[ 1 + SMN_OFFSET + i] =
1691: bb[ 1 + SMN_OFFSET * 2 + i] =
1692: bb[ 1 + SMN_OFFSET * 3 + i] =
1693: bb[ 1 + SMN_OFFSET * 4 + i] =
1694: bb[ 1 + SMN_OFFSET * 5 + i] =
1695: bb[ 1 + SMN_OFFSET * 6 + i] =
1696: bb[ 1 + SMN_OFFSET * 7 + i] =
1697: bb[ 1 + SMN_OFFSET * 8 + i] =
1698: bb[ 1 + SMN_OFFSET * 9 + i] =
1699: bb[ 1 + SMN_OFFSET * 10 + i] = (byte) c1110);
1700: break;
1701: }
1702: }
1703:
1704:
1705:
1706:
1707:
1708:
1709:
1710:
1711:
1712:
1713:
1714:
1715:
1716:
1717:
1718:
1719:
1720:
1721:
1722:
1723:
1724:
1725:
1726:
1727: public static void smnPaintKey2 (int i, int k, int c1111a, int c1111b) {
1728: int c1111ab = c1111a & 0b11001100 | c1111b & 0b00110011;
1729: int c1111ba = c1111b & 0b11001100 | c1111a & 0b00110011;
1730: int c1110ab = c1111ab & 0b11111100;
1731: int c1110ba = c1111ba & 0b11111100;
1732: byte[] bb = smnBitmap;
1733: switch (k) {
1734: case 0:
1735: case 5:
1736: bb[ SMN_OFFSET * 6 + i] = (
1737: bb[ SMN_OFFSET * 8 + i] =
1738: bb[ SMN_OFFSET * 10 + i] = (byte) c1111ab);
1739: bb[ SMN_OFFSET * 7 + i] = (
1740: bb[ SMN_OFFSET * 9 + i] = (byte) c1111ba);
1741: bb[ + i] = (
1742: bb[ SMN_OFFSET * 2 + i] =
1743: bb[ SMN_OFFSET * 4 + i] =
1744: bb[ 1 + SMN_OFFSET * 6 + i] =
1745: bb[ 1 + SMN_OFFSET * 8 + i] =
1746: bb[ 1 + SMN_OFFSET * 10 + i] = (byte) c1110ab);
1747: bb[ SMN_OFFSET + i] = (
1748: bb[ SMN_OFFSET * 3 + i] =
1749: bb[ SMN_OFFSET * 5 + i] =
1750: bb[ 1 + SMN_OFFSET * 7 + i] =
1751: bb[ 1 + SMN_OFFSET * 9 + i] = (byte) c1110ba);
1752: break;
1753: case 1:
1754: case 3:
1755: case 6:
1756: case 8:
1757: case 10:
1758: bb[ i] = (
1759: bb[ SMN_OFFSET * 2 + i] =
1760: bb[ SMN_OFFSET * 4 + i] = (byte) c1111ab);
1761: bb[ SMN_OFFSET + i] = (
1762: bb[ SMN_OFFSET * 3 + i] = (byte) c1111ba);
1763: bb[ 1 + + i] = (
1764: bb[ 1 + SMN_OFFSET * 2 + i] =
1765: bb[ 1 + SMN_OFFSET * 4 + i] = (byte) c1110ab);
1766: bb[ 1 + SMN_OFFSET + i] = (
1767: bb[ 1 + SMN_OFFSET * 3 + i] = (byte) c1110ba);
1768: break;
1769: case 2:
1770: case 7:
1771: case 9:
1772: bb[ SMN_OFFSET * 6 + i] = (
1773: bb[ SMN_OFFSET * 8 + i] =
1774: bb[ SMN_OFFSET * 10 + i] = (byte) c1111ab);
1775: bb[ SMN_OFFSET * 7 + i] = (
1776: bb[ SMN_OFFSET * 9 + i] = (byte) c1111ba);
1777: bb[ 1 + SMN_OFFSET * 6 + i] = (
1778: bb[ 1 + SMN_OFFSET * 8 + i] =
1779: bb[ 1 + SMN_OFFSET * 10 + i] = (byte) c1110ab);
1780: bb[ 1 + SMN_OFFSET * 7 + i] = (
1781: bb[ 1 + SMN_OFFSET * 9 + i] = (byte) c1110ba);
1782: break;
1783: case 4:
1784: case 11:
1785: bb[ SMN_OFFSET * 6 + i] = (
1786: bb[ SMN_OFFSET * 8 + i] =
1787: bb[ SMN_OFFSET * 10 + i] = (byte) c1111ab);
1788: bb[ SMN_OFFSET * 7 + i] = (
1789: bb[ SMN_OFFSET * 9 + i] = (byte) c1111ba);
1790: bb[ 1 + + i] = (
1791: bb[ 1 + SMN_OFFSET * 2 + i] =
1792: bb[ 1 + SMN_OFFSET * 4 + i] =
1793: bb[ 1 + SMN_OFFSET * 6 + i] =
1794: bb[ 1 + SMN_OFFSET * 8 + i] =
1795: bb[ 1 + SMN_OFFSET * 10 + i] = (byte) c1110ab);
1796: bb[ 1 + SMN_OFFSET + i] = (
1797: bb[ 1 + SMN_OFFSET * 3 + i] =
1798: bb[ 1 + SMN_OFFSET * 5 + i] =
1799: bb[ 1 + SMN_OFFSET * 7 + i] =
1800: bb[ 1 + SMN_OFFSET * 9 + i] = (byte) c1110ba);
1801: break;
1802: }
1803: }
1804:
1805:
1806:
1807: public static void smnDrawIcon1 (int x, int y, int c) {
1808: byte[] bb = smnBitmap;
1809: x += SMN_OFFSET * y;
1810: c *= 18;
1811: bb[ + x] = SMN_ICON_1[c ];
1812: bb[1 + x] = SMN_ICON_1[c + 1];
1813: bb[ SMN_OFFSET + x] = SMN_ICON_1[c + 2];
1814: bb[1 + SMN_OFFSET + x] = SMN_ICON_1[c + 3];
1815: bb[ SMN_OFFSET * 2 + x] = SMN_ICON_1[c + 4];
1816: bb[1 + SMN_OFFSET * 2 + x] = SMN_ICON_1[c + 5];
1817: bb[ SMN_OFFSET * 3 + x] = SMN_ICON_1[c + 6];
1818: bb[1 + SMN_OFFSET * 3 + x] = SMN_ICON_1[c + 7];
1819: bb[ SMN_OFFSET * 4 + x] = SMN_ICON_1[c + 8];
1820: bb[1 + SMN_OFFSET * 4 + x] = SMN_ICON_1[c + 9];
1821: bb[ SMN_OFFSET * 5 + x] = SMN_ICON_1[c + 10];
1822: bb[1 + SMN_OFFSET * 5 + x] = SMN_ICON_1[c + 11];
1823: bb[ SMN_OFFSET * 6 + x] = SMN_ICON_1[c + 12];
1824: bb[1 + SMN_OFFSET * 6 + x] = SMN_ICON_1[c + 13];
1825: bb[ SMN_OFFSET * 7 + x] = SMN_ICON_1[c + 14];
1826: bb[1 + SMN_OFFSET * 7 + x] = SMN_ICON_1[c + 15];
1827: bb[ SMN_OFFSET * 8 + x] = SMN_ICON_1[c + 16];
1828: bb[1 + SMN_OFFSET * 8 + x] = SMN_ICON_1[c + 17];
1829: }
1830:
1831:
1832:
1833: public static void smnDrawIcon3 (int x, int y, int c) {
1834: byte[] bb = smnBitmap;
1835: x += SMN_OFFSET * y;
1836: c *= 18;
1837: bb[ + x] = SMN_ICON_3[c ];
1838: bb[1 + x] = SMN_ICON_3[c + 1];
1839: bb[ SMN_OFFSET + x] = SMN_ICON_3[c + 2];
1840: bb[1 + SMN_OFFSET + x] = SMN_ICON_3[c + 3];
1841: bb[ SMN_OFFSET * 2 + x] = SMN_ICON_3[c + 4];
1842: bb[1 + SMN_OFFSET * 2 + x] = SMN_ICON_3[c + 5];
1843: bb[ SMN_OFFSET * 3 + x] = SMN_ICON_3[c + 6];
1844: bb[1 + SMN_OFFSET * 3 + x] = SMN_ICON_3[c + 7];
1845: bb[ SMN_OFFSET * 4 + x] = SMN_ICON_3[c + 8];
1846: bb[1 + SMN_OFFSET * 4 + x] = SMN_ICON_3[c + 9];
1847: bb[ SMN_OFFSET * 5 + x] = SMN_ICON_3[c + 10];
1848: bb[1 + SMN_OFFSET * 5 + x] = SMN_ICON_3[c + 11];
1849: bb[ SMN_OFFSET * 6 + x] = SMN_ICON_3[c + 12];
1850: bb[1 + SMN_OFFSET * 6 + x] = SMN_ICON_3[c + 13];
1851: bb[ SMN_OFFSET * 7 + x] = SMN_ICON_3[c + 14];
1852: bb[1 + SMN_OFFSET * 7 + x] = SMN_ICON_3[c + 15];
1853: bb[ SMN_OFFSET * 8 + x] = SMN_ICON_3[c + 16];
1854: bb[1 + SMN_OFFSET * 8 + x] = SMN_ICON_3[c + 17];
1855: }
1856:
1857:
1858:
1859: public static void smnDrawChar1 (int x, int y, int c) {
1860: byte[] bb = smnBitmap;
1861: x += SMN_OFFSET * y;
1862: c *= 5;
1863: bb[x ] = SMN_FONT_1[c ];
1864: bb[x + SMN_OFFSET ] = SMN_FONT_1[c + 1];
1865: bb[x + SMN_OFFSET * 2] = SMN_FONT_1[c + 2];
1866: bb[x + SMN_OFFSET * 3] = SMN_FONT_1[c + 3];
1867: bb[x + SMN_OFFSET * 4] = SMN_FONT_1[c + 4];
1868: }
1869:
1870:
1871:
1872: public static void smnDrawChar2 (int x, int y, int c) {
1873: byte[] bb = smnBitmap;
1874: x += SMN_OFFSET * y;
1875: c *= 5;
1876: bb[x ] = SMN_FONT_2[c ];
1877: bb[x + SMN_OFFSET ] = SMN_FONT_2[c + 1];
1878: bb[x + SMN_OFFSET * 2] = SMN_FONT_2[c + 2];
1879: bb[x + SMN_OFFSET * 3] = SMN_FONT_2[c + 3];
1880: bb[x + SMN_OFFSET * 4] = SMN_FONT_2[c + 4];
1881: }
1882:
1883:
1884:
1885: public static void smnDrawChar3 (int x, int y, int c) {
1886: byte[] bb = smnBitmap;
1887: x += SMN_OFFSET * y;
1888: c *= 5;
1889: bb[x ] = SMN_FONT_3[c ];
1890: bb[x + SMN_OFFSET ] = SMN_FONT_3[c + 1];
1891: bb[x + SMN_OFFSET * 2] = SMN_FONT_3[c + 2];
1892: bb[x + SMN_OFFSET * 3] = SMN_FONT_3[c + 3];
1893: bb[x + SMN_OFFSET * 4] = SMN_FONT_3[c + 4];
1894: }
1895:
1896:
1897:
1898: public static void smnDrawString1 (int x, int y, String s) {
1899: smnDrawString1 (x, y, s.toCharArray ());
1900: }
1901: public static void smnDrawString1 (int x, int y, char[] s) {
1902: byte[] bb = smnBitmap;
1903: x += SMN_OFFSET * y;
1904: for (char c : s) {
1905: c *= 5;
1906: bb[x ] = SMN_FONT_1[c ];
1907: bb[x + SMN_OFFSET ] = SMN_FONT_1[c + 1];
1908: bb[x + SMN_OFFSET * 2] = SMN_FONT_1[c + 2];
1909: bb[x + SMN_OFFSET * 3] = SMN_FONT_1[c + 3];
1910: bb[x + SMN_OFFSET * 4] = SMN_FONT_1[c + 4];
1911: x++;
1912: }
1913: }
1914:
1915:
1916:
1917: public static void smnDrawString2 (int x, int y, String s) {
1918: smnDrawString2 (x, y, s.toCharArray ());
1919: }
1920: public static void smnDrawString2 (int x, int y, char[] s) {
1921: byte[] bb = smnBitmap;
1922: x += SMN_OFFSET * y;
1923: for (char c : s) {
1924: c *= 5;
1925: bb[x ] = SMN_FONT_2[c ];
1926: bb[x + SMN_OFFSET ] = SMN_FONT_2[c + 1];
1927: bb[x + SMN_OFFSET * 2] = SMN_FONT_2[c + 2];
1928: bb[x + SMN_OFFSET * 3] = SMN_FONT_2[c + 3];
1929: bb[x + SMN_OFFSET * 4] = SMN_FONT_2[c + 4];
1930: x++;
1931: }
1932: }
1933:
1934:
1935:
1936: public static void smnDrawString3 (int x, int y, String s) {
1937: smnDrawString3 (x, y, s.toCharArray ());
1938: }
1939: public static void smnDrawString3 (int x, int y, char[] s) {
1940: byte[] bb = smnBitmap;
1941: x += SMN_OFFSET * y;
1942: for (char c : s) {
1943: c *= 5;
1944: bb[x ] = SMN_FONT_3[c ];
1945: bb[x + SMN_OFFSET ] = SMN_FONT_3[c + 1];
1946: bb[x + SMN_OFFSET * 2] = SMN_FONT_3[c + 2];
1947: bb[x + SMN_OFFSET * 3] = SMN_FONT_3[c + 3];
1948: bb[x + SMN_OFFSET * 4] = SMN_FONT_3[c + 4];
1949: x++;
1950: }
1951: }
1952:
1953:
1954:
1955:
1956:
1957:
1958:
1959:
1960:
1961:
1962: public static void smnDrawSlider (int[] slider, int[] pattern) {
1963: byte[] bb = smnBitmap;
1964: int x0 = slider[0];
1965: int y0 = slider[1];
1966: int max = slider[2];
1967: int palet = slider[3];
1968: int value = slider[4];
1969: int width = max + 4;
1970: for (int i = (x0 >> 2) + SMN_OFFSET * y0, l = i + (width >> 2); i < l; i++) {
1971: bb[ i ] = (
1972: bb[i + SMN_OFFSET * 1] =
1973: bb[i + SMN_OFFSET * 3] =
1974: bb[i + SMN_OFFSET * 4] = SMN_BLACK);
1975: bb[ i + SMN_OFFSET * 2] = (byte) palet;
1976: }
1977: smnDrawPattern (x0 + value, y0 + 2, pattern);
1978: }
1979:
1980:
1981:
1982:
1983:
1984: public static void smnDrawPattern (int x0, int y0, int[] pattern) {
1985: byte[] bb = smnBitmap;
1986: for (int k = 0; k < pattern.length; ) {
1987: int limit = k + pattern[k];
1988: int palet = pattern[k + 1] & 3;
1989: for (k += 2; k < limit; k += 2) {
1990: int x = x0 + pattern[k];
1991: int y = y0 + pattern[k + 1];
1992: int b = (~x & 3) << 1;
1993: int i = SMN_OFFSET * y + (x >> 2);
1994: bb[i] = (byte) (bb[i] & ~(3 << b) | palet << b);
1995: }
1996: }
1997: }
1998:
1999: }
2000:
2001:
2002: