TextCopy.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.event.*;
16: import javax.swing.*;
17:
18:
19:
20: public class TextCopy {
21:
22: public static final int TXC_AREA_DISPLAY = 0;
23: public static final int TXC_AREA_C_WIDTH = 1;
24: public static final int TXC_AREA_VRAM = 2;
25: public static final int TXC_AREA_ENCLOSED = 3;
26: public static int txcAreaMode;
27: public static boolean txcEncloseEachTime;
28:
29:
30:
31: static class HanPat {
32: int c;
33: int p0, p1, p2, p3;
34: HanPat next;
35: }
36:
37:
38:
39: static class ZenPat {
40: int c;
41: int p0, p1, p2, p3, p4, p5, p6, p7;
42: ZenPat next;
43: }
44:
45: static HanPat[] hanTable;
46: static ZenPat[] zenTable;
47: static int pressedX, pressedY;
48: static int enclosedX1, enclosedY1, enclosedX2, enclosedY2;
49:
50: public static int txcRow1, txcRow2, txcCol1, txcCol2;
51:
52:
53:
54: public static void txcInit () {
55: String v = Settings.sgsGetString ("textcopyarea").toLowerCase ();
56: txcAreaMode = (v.equals ("display") ? TXC_AREA_DISPLAY :
57: v.equals ("c_width") ? TXC_AREA_C_WIDTH :
58: v.equals ("vram") ? TXC_AREA_VRAM :
59: v.equals ("enclosed") ? TXC_AREA_ENCLOSED :
60: TXC_AREA_DISPLAY);
61: txcEncloseEachTime = Settings.sgsGetOnOff ("textcopy");
62: pressedX = -1;
63: pressedY = -1;
64: enclosedX1 = 0;
65: enclosedY1 = 0;
66: enclosedX2 = 0;
67: enclosedY2 = 0;
68: txcRow1 = -1;
69: txcRow2 = -1;
70: txcCol1 = -1;
71: txcCol2 = -1;
72: }
73:
74:
75:
76: public static void txcTini () {
77: Settings.sgsPutString ("textcopyarea",
78: txcAreaMode == TXC_AREA_DISPLAY ? "display" :
79: txcAreaMode == TXC_AREA_C_WIDTH ? "c_width" :
80: txcAreaMode == TXC_AREA_VRAM ? "vram" :
81: txcAreaMode == TXC_AREA_ENCLOSED ? "enclosed" :
82: "display");
83: Settings.sgsPutOnOff ("textcopy", txcEncloseEachTime);
84: }
85:
86:
87:
88: public static JMenuItem txcMakeMenuItem () {
89: return ComponentFactory.setEnabled (
90: Multilingual.mlnText (
91: ComponentFactory.createMenuItem (
92: "Text screen copy", 'C', XEiJ.MNB_MODIFIERS,
93: new ActionListener () {
94: @Override public void actionPerformed (ActionEvent ae) {
95: txcCopy ();
96: }
97: }),
98: "ja", "テキスト画面コピー"),
99: XEiJ.clpClipboard != null);
100: }
101:
102:
103:
104: public static JMenu txcMakeSettingMenu () {
105: ActionListener listener = new ActionListener () {
106: @Override public void actionPerformed (ActionEvent ae) {
107: Object source = ae.getSource ();
108: String command = ae.getActionCommand ();
109: switch (command) {
110: case "Display area":
111: txcAreaMode = TXC_AREA_DISPLAY;
112: break;
113: case "C_WIDTH":
114: txcAreaMode = TXC_AREA_C_WIDTH;
115: break;
116: case "Entire VRAM":
117: txcAreaMode = TXC_AREA_VRAM;
118: break;
119: case "Last enclosed area":
120: txcAreaMode = TXC_AREA_ENCLOSED;
121: break;
122: case "Enclose each time with mouse":
123: txcEncloseEachTime = ((JCheckBoxMenuItem) source).isSelected ();
124: break;
125: }
126: }
127: };
128: ButtonGroup areaGroup = new ButtonGroup ();
129: return ComponentFactory.setEnabled (
130: Multilingual.mlnText (
131: ComponentFactory.createMenu (
132: "Text screen copy setting",
133: Multilingual.mlnText (
134: ComponentFactory.createRadioButtonMenuItem (areaGroup, txcAreaMode == TXC_AREA_DISPLAY, "Display area", listener),
135: "ja", "表示領域"),
136: ComponentFactory.createRadioButtonMenuItem (areaGroup, txcAreaMode == TXC_AREA_C_WIDTH, "C_WIDTH", listener),
137: Multilingual.mlnText (
138: ComponentFactory.createRadioButtonMenuItem (areaGroup, txcAreaMode == TXC_AREA_VRAM, "Entire VRAM", listener),
139: "ja", "VRAM 全体"),
140: Multilingual.mlnText (
141: ComponentFactory.createRadioButtonMenuItem (areaGroup, txcAreaMode == TXC_AREA_ENCLOSED, "Last enclosed area", listener),
142: "ja", "最後に囲んだ範囲"),
143: ComponentFactory.createHorizontalSeparator (),
144: Multilingual.mlnText (
145: ComponentFactory.createCheckBoxMenuItem (txcEncloseEachTime, "Enclose each time with mouse", listener),
146: "ja", "マウスで都度囲む")
147: ),
148: "ja", "テキスト画面コピー設定"),
149: XEiJ.clpClipboard != null);
150: }
151:
152:
153:
154:
155: public static void txcReset () {
156: hanTable = null;
157: zenTable = null;
158: }
159:
160:
161:
162:
163:
164: public static void txcMousePressed (int screenX, int screenY) {
165: if ((VideoController.vcnReg3Curr & (1 << 5)) == 0) {
166: return;
167: }
168: screenX = Math.max (0, Math.min (XEiJ.pnlScreenWidth - 1, screenX));
169: screenY = Math.max (0, Math.min (XEiJ.pnlScreenHeight - 1, screenY));
170: pressedX = screenX;
171: pressedY = screenY;
172: }
173:
174:
175:
176: public static void txcMouseMoved (int screenX, int screenY) {
177: if ((VideoController.vcnReg3Curr & (1 << 5)) == 0) {
178: return;
179: }
180: if (pressedX < 0) {
181: return;
182: }
183: screenX = Math.max (0, Math.min (XEiJ.pnlScreenWidth - 1, screenX));
184: screenY = Math.max (0, Math.min (XEiJ.pnlScreenHeight - 1, screenY));
185: calcLocation (screenX, screenY);
186: if (0 <= txcRow1) {
187: XEiJ.pnlPanel.repaint ();
188: }
189: }
190:
191:
192:
193: public static void txcMouseReleased (int screenX, int screenY) {
194: if ((VideoController.vcnReg3Curr & (1 << 5)) == 0) {
195: return;
196: }
197: if (pressedX < 0) {
198: return;
199: }
200: screenX = Math.max (0, Math.min (XEiJ.pnlScreenWidth - 1, screenX));
201: screenY = Math.max (0, Math.min (XEiJ.pnlScreenHeight - 1, screenY));
202: calcLocation (screenX, screenY);
203: if (0 <= txcRow1) {
204: XEiJ.clpCopy (getText (txcRow1, txcRow2, txcCol1, txcCol2));
205: }
206: pressedX = -1;
207: pressedY = -1;
208: txcRow1 = -1;
209: txcRow2 = -1;
210: txcCol1 = -1;
211: txcCol2 = -1;
212: XEiJ.pnlPanel.repaint ();
213: }
214:
215:
216:
217: static void calcLocation (int screenX, int screenY) {
218: int x1 = pressedX;
219: int y1 = pressedY;
220: int x2 = screenX;
221: int y2 = screenY;
222: if (x2 < x1) {
223: int t = x1;
224: x1 = x2;
225: x2 = t;
226: }
227: if (y2 < y1) {
228: int t = y1;
229: y1 = y2;
230: y2 = t;
231: }
232: x1 += CRTC.crtR10TxXCurr;
233: y1 += CRTC.crtR11TxYCurr;
234: x2 += CRTC.crtR10TxXCurr;
235: y2 += CRTC.crtR11TxYCurr;
236: int col1 = (x1 + 4) >> 3;
237: int col2 = (x2 - 4) >> 3;
238: int row1 = (y1 + 8) >> 4;
239: int row2 = (y2 - 8) >> 4;
240: if (col1 <= col2 && row1 <= row2) {
241: enclosedX1 = x1;
242: enclosedY1 = y1;
243: enclosedX2 = x2;
244: enclosedY2 = y2;
245: txcCol1 = col1;
246: txcCol2 = col2;
247: txcRow1 = row1;
248: txcRow2 = row2;
249: } else {
250: txcCol1 = -1;
251: txcCol2 = -1;
252: txcRow1 = -1;
253: txcRow2 = -1;
254: }
255: }
256:
257:
258:
259:
260:
261: public static void txcCopy () {
262: int x1 = CRTC.crtR10TxXCurr;
263: int y1 = CRTC.crtR11TxYCurr;
264: int x2, y2;
265: if (txcAreaMode == TXC_AREA_DISPLAY) {
266: int w = (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3;
267: int h = (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr);
268: if (CRTC.crtDuplication || CRTC.crtDupExceptSp) {
269: h >>= 1;
270: } else if (CRTC.crtInterlace) {
271: h <<= 1;
272: }
273: x2 = x1 + w - 1;
274: y2 = y1 + h - 1;
275: } else if (txcAreaMode == TXC_AREA_C_WIDTH) {
276:
277:
278:
279:
280:
281:
282:
283: int v = MainMemory.mmrHumanVersion;
284: int a = (v == 0x0302 ? 0x6800 + 0xa890 + 0x29b1 :
285: v == 0x0301 ? 0x6800 + 0xa77a + 0x29b1 :
286: v == 0x020f ? 0x6800 + 0xa822 + 0x29b1 :
287: v == 0x0203 ? 0x6800 + 0x96dc + 0x29af :
288: v == 0x0202 ? 0x6800 + 0x9950 + 0x29af :
289: v == 0x0201 ? 0x6800 + 0x9910 + 0x29af :
290: v == 0x0200 ? 0x6800 + 0x9910 + 0x29af :
291:
292: -1);
293: if (a < 0) {
294: return;
295: }
296: int n = MC68060.mmuPeekByteZeroData (a, 1);
297: if (0 <= n && n <= 1) {
298: x2 = x1 + 768 - 1;
299: y2 = y1 + 512 - 1;
300: } else if (2 <= n && n <= 5) {
301: x2 = x1 + 512 - 1;
302: y2 = y1 + 512 - 1;
303: } else {
304: return;
305: }
306: } else if (txcAreaMode == TXC_AREA_VRAM) {
307: x2 = x1 + 1024 - 1;
308: y2 = y1 + 1024 - 1;
309: } else if (txcAreaMode == TXC_AREA_ENCLOSED) {
310: x1 = enclosedX1;
311: y1 = enclosedY1;
312: x2 = enclosedX2;
313: y2 = enclosedY2;
314: } else {
315: return;
316: }
317: int col1 = (x1 + 4) >> 3;
318: int col2 = (x2 - 4) >> 3;
319: int row1 = (y1 + 8) >> 4;
320: int row2 = (y2 - 8) >> 4;
321:
322: XEiJ.clpCopy (getText (row1, row2, col1, col2));
323: }
324:
325:
326:
327:
328:
329: static void makeHash () {
330: byte[] m = MainMemory.mmrM8;
331: hanTable = new HanPat[65536];
332: zenTable = new ZenPat[65536];
333:
334: for (int s = 0xff; 0x20 <= s; s--) {
335: int c = CharacterCode.chrSJISToChar[
336: s == 0x80 ? 0x5c :
337: s == 0x81 ? 0x7e :
338: s == 0x82 ? 0x7c :
339: (0x86 <= s && s <= 0x9f && s != 0x90) || (0xe0 <= s && s <= 0xfd) ? s ^ 0x20 :
340: s];
341: if (c == 0) {
342: continue;
343: }
344: for (int n = 2; 0 <= n; n--) {
345: int a;
346: int p0, p1, p2, p3;
347: int h;
348: if (n == 0) {
349: a = 0x00f3a800 + (s << 4);
350: } else {
351: a = 0x00f3a000 + (s << 3);
352: }
353: p0 = ((m[a ] ) << 24 |
354: (m[a + 1] & 255) << 16 |
355: (m[a + 2] & 255) << 8 |
356: (m[a + 3] & 255));
357: p1 = ((m[a + 4] ) << 24 |
358: (m[a + 5] & 255) << 16 |
359: (m[a + 6] & 255) << 8 |
360: (m[a + 7] & 255));
361: if (n == 0) {
362: p2 = ((m[a + 8] ) << 24 |
363: (m[a + 9] & 255) << 16 |
364: (m[a + 10] & 255) << 8 |
365: (m[a + 11] & 255));
366: p3 = ((m[a + 12] ) << 24 |
367: (m[a + 13] & 255) << 16 |
368: (m[a + 14] & 255) << 8 |
369: (m[a + 15] & 255));
370: } else if (n == 1) {
371: p2 = 0;
372: p3 = 0;
373: } else {
374: p2 = p0;
375: p3 = p1;
376: p0 = 0;
377: p1 = 0;
378: }
379: if ((p0 | p1 | p2 | p3) == 0 ||
380: (p0 & p1 & p2 & p3) == -1) {
381: continue;
382: }
383: for (int u = 3; 0 <= u; u--) {
384: int q0 = p0, q1 = p1, q2 = p2, q3 = p3;
385: if ((u & 1) != 0) {
386: q0 |= (q0 >> 1) & 0x7f7f7f7f;
387: q1 |= (q1 >> 1) & 0x7f7f7f7f;
388: q2 |= (q2 >> 1) & 0x7f7f7f7f;
389: q3 |= (q3 >> 1) & 0x7f7f7f7f;
390: }
391: if ((u & 2) != 0) {
392: q0 = ~q0;
393: q1 = ~q1;
394: q2 = ~q2;
395: q3 = ~q3;
396: }
397: h = ((q0 * 31 + q1) * 31 + q2) * 31 + q3;
398: h = ((h >> 16) + h) & 65535;
399: HanPat pat = new HanPat ();
400: pat.c = c;
401: pat.p0 = q0;
402: pat.p1 = q1;
403: pat.p2 = q2;
404: pat.p3 = q3;
405: pat.next = hanTable[h];
406: hanTable[h] = pat;
407: }
408: }
409: }
410:
411: for (int row = 77 - 1; 0 <= row; row--) {
412: for (int col = 94 - 1; 0 <= col; col--) {
413: int kum1 = row < 8 ? row : row + 7;
414: int sh = kum1 >> 1;
415: int sl = 94 * (kum1 & 1) + col;
416: sh += 0x81;
417: sl += 0x40;
418: if (0xa0 <= sh) {
419: sh += 0xe0 - 0xa0;
420: }
421: if (0x7f <= sl) {
422: sl += 0x80 - 0x7f;
423: }
424: int s = (sh << 8) | sl;
425: int c = CharacterCode.chrSJISToChar[s];
426: if (c == 0) {
427: continue;
428: }
429: int a = 0x00f00000 + ((col + 94 * row) << 5);
430: int p0 = ((m[a ] ) << 24 | (m[a + 1] & 255) << 16 |
431: (m[a + 2] & 255) << 8 | (m[a + 3] & 255));
432: int p1 = ((m[a + 4] ) << 24 | (m[a + 5] & 255) << 16 |
433: (m[a + 6] & 255) << 8 | (m[a + 7] & 255));
434: int p2 = ((m[a + 8] ) << 24 | (m[a + 9] & 255) << 16 |
435: (m[a + 10] & 255) << 8 | (m[a + 11] & 255));
436: int p3 = ((m[a + 12] ) << 24 | (m[a + 13] & 255) << 16 |
437: (m[a + 14] & 255) << 8 | (m[a + 15] & 255));
438: int p4 = ((m[a + 16] ) << 24 | (m[a + 17] & 255) << 16 |
439: (m[a + 18] & 255) << 8 | (m[a + 19] & 255));
440: int p5 = ((m[a + 20] ) << 24 | (m[a + 21] & 255) << 16 |
441: (m[a + 22] & 255) << 8 | (m[a + 23] & 255));
442: int p6 = ((m[a + 24] ) << 24 | (m[a + 25] & 255) << 16 |
443: (m[a + 26] & 255) << 8 | (m[a + 27] & 255));
444: int p7 = ((m[a + 28] ) << 24 | (m[a + 29] & 255) << 16 |
445: (m[a + 30] & 255) << 8 | (m[a + 31] & 255));
446: if ((p0 | p1 | p2 | p3 | p4 | p5 | p6 | p7) == 0 ||
447: (p0 & p1 & p2 & p3 & p4 & p5 & p6 & p7) == -1) {
448: continue;
449: }
450: for (int u = 3; 0 <= u; u--) {
451: int q0 = p0, q1 = p1, q2 = p2, q3 = p3, q4 = p4, q5 = p5, q6 = p6, q7 = p7;
452: if ((u & 1) != 0) {
453: q0 |= (q0 >> 1) & 0x7fff7fff;
454: q1 |= (q1 >> 1) & 0x7fff7fff;
455: q2 |= (q2 >> 1) & 0x7fff7fff;
456: q3 |= (q3 >> 1) & 0x7fff7fff;
457: q4 |= (q4 >> 1) & 0x7fff7fff;
458: q5 |= (q5 >> 1) & 0x7fff7fff;
459: q6 |= (q6 >> 1) & 0x7fff7fff;
460: q7 |= (q7 >> 1) & 0x7fff7fff;
461: }
462: if ((u & 2) != 0) {
463: q0 = ~q0;
464: q1 = ~q1;
465: q2 = ~q2;
466: q3 = ~q3;
467: q4 = ~q4;
468: q5 = ~q5;
469: q6 = ~q6;
470: q7 = ~q7;
471: }
472: int h = ((((((q0 * 31 + q1) * 31 + q2) * 31 + q3) * 31 + q4) * 31 + q5) * 31 + q6) * 31 + q7;
473: h = ((h >> 16) + h) & 65535;
474: ZenPat pat = new ZenPat ();
475: pat.c = c;
476: pat.p0 = q0;
477: pat.p1 = q1;
478: pat.p2 = q2;
479: pat.p3 = q3;
480: pat.p4 = q4;
481: pat.p5 = q5;
482: pat.p6 = q6;
483: pat.p7 = q7;
484: pat.next = zenTable[h];
485: zenTable[h] = pat;
486: }
487: }
488: }
489: }
490:
491:
492:
493:
494: public static String getText (int row1, int row2, int col1, int col2) {
495: int cols = col2 - col1 + 1;
496: int rows = row2 - row1 + 1;
497: if (cols <= 0 && rows <= 0) {
498: return "NO DATA";
499: }
500: int[] co = new int[cols + 1];
501: for (int c = 0; c < co.length; c++) {
502: co[c] = (col1 + c) & 127;
503: }
504: int[] ra = new int[rows + 15];
505: for (int r = 0; r < ra.length; r++) {
506: ra[r] = 0x00e00000 + (((row1 + r) & 63) << 11);
507: }
508:
509: if (hanTable == null) {
510: makeHash ();
511: }
512: byte[] m = MainMemory.mmrM8;
513: StringBuilder sb = new StringBuilder ();
514: for (int r = 0; r < rows; r++) {
515: int a = ra[r];
516: if (0 < r) {
517: sb.append ('\n');
518: }
519: for (int c = 0; c < cols; c++) {
520:
521: if (c + 1 < cols) {
522: int a0 = a + co[c];
523: int a1 = a + co[c + 1];
524: int p0 = ((m[a0 ] ) << 24 | (m[a1 ] & 255) << 16 |
525: (m[a0 + ( 1 << 7)] & 255) << 8 | (m[a1 + ( 1 << 7)] & 255));
526: int p1 = ((m[a0 + ( 2 << 7)] ) << 24 | (m[a1 + ( 2 << 7)] & 255) << 16 |
527: (m[a0 + ( 3 << 7)] & 255) << 8 | (m[a1 + ( 3 << 7)] & 255));
528: int p2 = ((m[a0 + ( 4 << 7)] ) << 24 | (m[a1 + ( 4 << 7)] & 255) << 16 |
529: (m[a0 + ( 5 << 7)] & 255) << 8 | (m[a1 + ( 5 << 7)] & 255));
530: int p3 = ((m[a0 + ( 6 << 7)] ) << 24 | (m[a1 + ( 6 << 7)] & 255) << 16 |
531: (m[a0 + ( 7 << 7)] & 255) << 8 | (m[a1 + ( 7 << 7)] & 255));
532: int p4 = ((m[a0 + ( 8 << 7)] ) << 24 | (m[a1 + ( 8 << 7)] & 255) << 16 |
533: (m[a0 + ( 9 << 7)] & 255) << 8 | (m[a1 + ( 9 << 7)] & 255));
534: int p5 = ((m[a0 + (10 << 7)] ) << 24 | (m[a1 + (10 << 7)] & 255) << 16 |
535: (m[a0 + (11 << 7)] & 255) << 8 | (m[a1 + (11 << 7)] & 255));
536: int p6 = ((m[a0 + (12 << 7)] ) << 24 | (m[a1 + (12 << 7)] & 255) << 16 |
537: (m[a0 + (13 << 7)] & 255) << 8 | (m[a1 + (13 << 7)] & 255));
538: int p7 = ((m[a0 + (14 << 7)] ) << 24 | (m[a1 + (14 << 7)] & 255) << 16 |
539: (m[a0 + (15 << 7)] & 255) << 8 | (m[a1 + (15 << 7)] & 255));
540: if ((p0 | p1 | p2 | p3 | p4 | p5 | p6 | p7) == 0 ||
541: (p0 & p1 & p2 & p3 & p4 & p5 & p6 & p7) == -1) {
542: a0 += 0x00020000;
543: a1 += 0x00020000;
544: p0 = ((m[a0 ] ) << 24 | (m[a1 ] & 255) << 16 |
545: (m[a0 + ( 1 << 7)] & 255) << 8 | (m[a1 + ( 1 << 7)] & 255));
546: p1 = ((m[a0 + ( 2 << 7)] ) << 24 | (m[a1 + ( 2 << 7)] & 255) << 16 |
547: (m[a0 + ( 3 << 7)] & 255) << 8 | (m[a1 + ( 3 << 7)] & 255));
548: p2 = ((m[a0 + ( 4 << 7)] ) << 24 | (m[a1 + ( 4 << 7)] & 255) << 16 |
549: (m[a0 + ( 5 << 7)] & 255) << 8 | (m[a1 + ( 5 << 7)] & 255));
550: p3 = ((m[a0 + ( 6 << 7)] ) << 24 | (m[a1 + ( 6 << 7)] & 255) << 16 |
551: (m[a0 + ( 7 << 7)] & 255) << 8 | (m[a1 + ( 7 << 7)] & 255));
552: p4 = ((m[a0 + ( 8 << 7)] ) << 24 | (m[a1 + ( 8 << 7)] & 255) << 16 |
553: (m[a0 + ( 9 << 7)] & 255) << 8 | (m[a1 + ( 9 << 7)] & 255));
554: p5 = ((m[a0 + (10 << 7)] ) << 24 | (m[a1 + (10 << 7)] & 255) << 16 |
555: (m[a0 + (11 << 7)] & 255) << 8 | (m[a1 + (11 << 7)] & 255));
556: p6 = ((m[a0 + (12 << 7)] ) << 24 | (m[a1 + (12 << 7)] & 255) << 16 |
557: (m[a0 + (13 << 7)] & 255) << 8 | (m[a1 + (13 << 7)] & 255));
558: p7 = ((m[a0 + (14 << 7)] ) << 24 | (m[a1 + (14 << 7)] & 255) << 16 |
559: (m[a0 + (15 << 7)] & 255) << 8 | (m[a1 + (15 << 7)] & 255));
560: if ((p0 | p1 | p2 | p3 | p4 | p5 | p6 | p7) == 0 ||
561: (p0 & p1 & p2 & p3 & p4 & p5 & p6 & p7) == -1) {
562: sb.append (" ");
563: c++;
564: continue;
565: }
566: }
567: int h = ((((((p0 * 31 + p1) * 31 + p2) * 31 + p3) * 31 + p4) * 31 + p5) * 31 + p6) * 31 + p7;
568: h = ((h >> 16) + h) & 65535;
569: ZenPat pat = zenTable[h];
570: while (pat != null) {
571: if (pat.p0 == p0 &&
572: pat.p1 == p1 &&
573: pat.p2 == p2 &&
574: pat.p3 == p3 &&
575: pat.p4 == p4 &&
576: pat.p5 == p5 &&
577: pat.p6 == p6 &&
578: pat.p7 == p7) {
579: break;
580: }
581: pat = pat.next;
582: }
583: if (pat != null) {
584: sb.append ((char) pat.c);
585: c++;
586: continue;
587: }
588: }
589:
590: {
591: int a0 = a + co[c];
592: int p0 = ((m[a0 ] ) << 24 |
593: (m[a0 + ( 1 << 7)] & 255) << 16 |
594: (m[a0 + ( 2 << 7)] & 255) << 8 |
595: (m[a0 + ( 3 << 7)] & 255));
596: int p1 = ((m[a0 + ( 4 << 7)] ) << 24 |
597: (m[a0 + ( 5 << 7)] & 255) << 16 |
598: (m[a0 + ( 6 << 7)] & 255) << 8 |
599: (m[a0 + ( 7 << 7)] & 255));
600: int p2 = ((m[a0 + ( 8 << 7)] ) << 24 |
601: (m[a0 + ( 9 << 7)] & 255) << 16 |
602: (m[a0 + (10 << 7)] & 255) << 8 |
603: (m[a0 + (11 << 7)] & 255));
604: int p3 = ((m[a0 + (12 << 7)] ) << 24 |
605: (m[a0 + (13 << 7)] & 255) << 16 |
606: (m[a0 + (14 << 7)] & 255) << 8 |
607: (m[a0 + (15 << 7)] & 255));
608: if ((p0 | p1 | p2 | p3) == 0 ||
609: (p0 & p1 & p2 & p3) == -1) {
610: a0 += 0x00020000;
611: p0 = ((m[a0 ] ) << 24 |
612: (m[a0 + ( 1 << 7)] & 255) << 16 |
613: (m[a0 + ( 2 << 7)] & 255) << 8 |
614: (m[a0 + ( 3 << 7)] & 255));
615: p1 = ((m[a0 + ( 4 << 7)] ) << 24 |
616: (m[a0 + ( 5 << 7)] & 255) << 16 |
617: (m[a0 + ( 6 << 7)] & 255) << 8 |
618: (m[a0 + ( 7 << 7)] & 255));
619: p2 = ((m[a0 + ( 8 << 7)] ) << 24 |
620: (m[a0 + ( 9 << 7)] & 255) << 16 |
621: (m[a0 + (10 << 7)] & 255) << 8 |
622: (m[a0 + (11 << 7)] & 255));
623: p3 = ((m[a0 + (12 << 7)] ) << 24 |
624: (m[a0 + (13 << 7)] & 255) << 16 |
625: (m[a0 + (14 << 7)] & 255) << 8 |
626: (m[a0 + (15 << 7)] & 255));
627: if ((p0 | p1 | p2 | p3) == 0 ||
628: (p0 & p1 & p2 & p3) == -1) {
629: sb.append (' ');
630: continue;
631: }
632: }
633: int h = ((p0 * 31 + p1) * 31 + p2) * 31 + p3;
634: h = ((h >> 16) + h) & 65535;
635: HanPat pat = hanTable[h];
636: while (pat != null) {
637: if (pat.p0 == p0 &&
638: pat.p1 == p1 &&
639: pat.p2 == p2 &&
640: pat.p3 == p3) {
641: break;
642: }
643: pat = pat.next;
644: }
645: if (pat != null) {
646: sb.append ((char) pat.c);
647: continue;
648: }
649: }
650:
651: sb.append ('?');
652: }
653: }
654: return sb.toString ();
655: }
656:
657:
658:
659: }