752 | | _2byteFontPtr = new byte[2 * _2byteHeight * numChar]; |
753 | | fp.read(_2byteFontPtr, 2 * _2byteHeight * numChar); |
| 750 | _2byteFontPtr = new byte[((_2byteWidth + 7) / 8) * _2byteHeight * numChar]; |
| 751 | fp.read(_2byteFontPtr, ((_2byteWidth + 7) / 8) * _2byteHeight * numChar); |
| 752 | fp.close(); |
| 753 | } |
| 754 | } else if (_language == JA_JPN && _version <= 5) { //FM Towns Kanji |
| 755 | File fp; |
| 756 | int numChar = 256 * 32; |
| 757 | _2byteWidth = 16; |
| 758 | _2byteHeight = 16; |
| 759 | //use FM Towns font rom, since game files don't have kanji font resources |
| 760 | if (fp.open("fmt_fnt.rom", "./", 1)) { //FIXME: use getGameDataPath()? |
| 761 | _CJKMode = true; |
| 762 | debug(2, "Loading FM Towns Kanji rom"); |
| 763 | _2byteFontPtr = new byte[((_2byteWidth + 7) / 8) * _2byteHeight * numChar]; |
| 764 | fp.read(_2byteFontPtr, ((_2byteWidth + 7) / 8) * _2byteHeight * numChar); |
| 2504 | int SJIStoFMTChunk(int f, int s) //convert sjis code to fmt font offset |
| 2505 | { |
| 2506 | enum {KANA = 0, KANJI = 1, EKANJI = 2}; |
| 2507 | int base = s - (s % 32) - 1; |
| 2508 | int c = 0, p = 0, chunk_f = 0, chunk = 0, cr, kanjiType = KANA; |
| 2509 | |
| 2510 | if(f >= 0x81 && f <= 0x84) kanjiType = KANA; |
| 2511 | if(f >= 0x88 && f <= 0x9f) kanjiType = KANJI; |
| 2512 | if(f >= 0xe0 && f <= 0xea) kanjiType = EKANJI; |
| 2513 | |
| 2514 | if((f > 0xe8 || (f == 0xe8 && base >= 0x9f)) || (f > 0x90 || (f == 0x90 && base >= 0x9f))) { |
| 2515 | c = 48; //correction |
| 2516 | p = -8; //correction |
| 2517 | } |
| 2518 | |
| 2519 | if(kanjiType == KANA) {//Kana |
| 2520 | chunk_f = (f - 0x81) * 2; |
| 2521 | } else if(kanjiType == KANJI) {//Standard Kanji |
| 2522 | p += f - 0x88; |
| 2523 | chunk_f = c + 2 * p; |
| 2524 | } else if(kanjiType == EKANJI) {//Enhanced Kanji |
| 2525 | p += f - 0xe0; |
| 2526 | chunk_f = c + 2 * p; |
| 2527 | } |
| 2528 | |
| 2529 | if(base == 0x7f && s == 0x7f) |
| 2530 | base -= 0x20; //correction |
| 2531 | if((base == 0x7f && s == 0x9e) || (base == 0x9f && s == 0xbe) || (base == 0xbf && s == 0xde)) |
| 2532 | base += 0x20; //correction |
| 2533 | |
| 2534 | switch(base) { |
| 2535 | case 0x3f: |
| 2536 | cr = 0; //3f |
| 2537 | if(kanjiType == KANA) chunk = 1; |
| 2538 | else if(kanjiType == KANJI) chunk = 31; |
| 2539 | else if(kanjiType == EKANJI) chunk = 111; |
| 2540 | break; |
| 2541 | case 0x5f: |
| 2542 | cr = 0; //5f |
| 2543 | if(kanjiType == KANA) chunk = 17; |
| 2544 | else if(kanjiType == KANJI) chunk = 47; |
| 2545 | else if(kanjiType == EKANJI) chunk = 127; |
| 2546 | break; |
| 2547 | case 0x7f: |
| 2548 | cr = -1; //80 |
| 2549 | if(kanjiType == KANA) chunk = 9; |
| 2550 | else if(kanjiType == KANJI) chunk = 63; |
| 2551 | else if(kanjiType == EKANJI) chunk = 143; |
| 2552 | break; |
| 2553 | case 0x9f: |
| 2554 | cr = 1; //9e |
| 2555 | if(kanjiType == KANA) chunk = 2; |
| 2556 | else if(kanjiType == KANJI) chunk = 32; |
| 2557 | else if(kanjiType == EKANJI) chunk = 112; |
| 2558 | break; |
| 2559 | case 0xbf: |
| 2560 | cr = 1; //be |
| 2561 | if(kanjiType == KANA) chunk = 18; |
| 2562 | else if(kanjiType == KANJI) chunk = 48; |
| 2563 | else if(kanjiType == EKANJI) chunk = 128; |
| 2564 | break; |
| 2565 | case 0xdf: |
| 2566 | cr = 1; //de |
| 2567 | if(kanjiType == KANA) chunk = 10; |
| 2568 | else if(kanjiType == KANJI) chunk = 64; |
| 2569 | else if(kanjiType == EKANJI) chunk = 144; |
| 2570 | break; |
| 2571 | default: |
| 2572 | return 0; |
| 2573 | } |
| 2574 | |
| 2575 | return ((chunk_f + chunk) * 32 + (s - base)) + cr; |
| 2576 | } |
| 2577 | |