Hi, Their !
I made unbelievably profound programs of Flag Semaphore. Show THEM, NOW.
JRF Flag Semaphore for NES Emulators, inspired by Monty Python.

よう、やっとるか!
すげぇ手旗信号のプログラム作ったから、まぁ、見てってくれや。
JRF Flag Semaphore - ファミコン(エミュ)用 (モンティ・パイソンのコントをヒントに)。

Protocol

On this protocol of flag semaphore, the flagger hands one set of two flags each in different colors. Any language (including Japanese) must transfer the English flag semaphore but expecting transliteration. The following table shows flag codes on the protocol. The hand positions is numbered 0-7, 0 towards down, 2 towards horizontally outer, 4 towards up and 7 towards like to hide something:

プロトコル (手順規定)

この手旗プロトコルでは、旗持ちは一組二振りの色違いの旗を持つ。でも、だからと言って、日本語カナのコーディングは用いないのがミソだ。(日本語含む)どんな言語でも、英語版の信号しか使わず、その後にローマ字カナ変換のような "Transliteration" (逐字訳) をすりゃいいと考える。次の表は手旗コード。手の位置を 0 から 7 で付番する。0 が下向き、2 が水平に外向き、4 が上、7 で大事なところに向けるわけだ。

L\R01234567
0 $00'g''f''e''.'err'_'$03
1 'a''n''m''l''k''i''H'err
2 'b''s''r''q''p''o'err'h'
3 'c'$08'y''u''t'err'O''I'
4 'd''v''j''$'errerrerrerr
5 err'x''w'errerrerrerrerr
6 '&'errerr'W'errerrerr'Z'
7 $03err'z''X'errerrerr' '

This protocol specially implements '.'(period) and '_'(underbar) as "Morse characters". A dot of Morse code is '.' → $00. $00 is the null character which gives a "delimiter" between characters and sometimes a rest for flaggers. A dash '-' of Morse code is '.' → '_'. $03 is another $00 but can give a boundary of characters specially for Morse Code. Alphabets are lower case in default. However, '_' → Letter gives upper case. '_' → '.' gives '.'(period). '_' → ' ' (space) gives ',' (comma). In the table above, upper case letters mean another way of poses, which are different from the original ones in Wikipedia but similar. And they also give lower case instead of upper case.

To enter numeral mode, signal '$' in the table. In numeral mode, each character changes its meaning: 'a' → '1', 'b' → '2', 'c' → '3', 'd' → '4', 'e' → '5', 'f' → '6', 'g' → '7', 'h' → '8', 'i' → '9' and 'k' → '0'. To leave numeral mode, signal 'j'. In numeral mode of this protocol, normally 3 octets give one ascii code. However, '_' → Number gives that number.
If the first octet is 4-9, two numbers can give one ascii code,
8: if the next is 0, makes 1 → 0 (→ 0), otherwise makes 1 → 3, and
9: if the next is 0, makes 1 → 4 (→ 0), otherwise makes 1 → 7.

'&' is similar to '$', but it automatically ends "numeral mode" by one character (of ASCII code) without 'j' i.e. letter mode sign.

You can input $20-$7F in two codes at most excluding of control codes. The rest $08 in the table gives a "cancel"ling.

本プロトコルでは特殊な方法として、「モールス符号」の '.' と '_' を用意。モールス短音は、'.' → $00。$00 は NUL キャラクタで、文字区切りや旗持ちにちょっとした間を与える。モールス長音は '.' → '_' で '-'。モールス符号の文字区切りは特別に表中 $03 のものを使うとよい。アルファベットは基本、小文字とし、大文字は '_' → 文字 で指定。また、'_' → '.' で '.'、'_' → ' ' で ',' とする。上表の大文字は Wikipedia の方法と違うが、似ているのでそれでも入力でき、その入力は表中の大文字ではなく小文字となる。

数字モードに入るには、表中の '$' の信号を出す。数字モードでは各文字の意味が変わり: 'a' → '1', 'b' → '2', 'c' → '3', 'd' → '4', 'e' → '5', 'f' → '6', 'g' → '7', 'h' → '8', 'i' → '9', 'k' → '0' になる。数字モードから出るには、'j' の信号を出す。数字モードのときは、通常は 3 つの数字で、8進数3ケタの ascii コード指定。ただし、'_' → 数字 で、その数字が出る。
コード指定の数字の最初が 4-9 なら、2つの数字で入力可、
8 は次が 0 なら 1 → 0 (→ 0) に、そうでないなら 1 → 3 に同じと解釈、
9 は次が 0 なら 1 → 4 (→ 0) に、そうでないなら 1 → 7 に同じと解釈。

'&' は '$' とほとんど同じだが、(ASCII コードを)一文字分入力したところで自動的に数字モードが終る。モード終了のために 'j' を送る必要はないし送ってはならない。

制御符号を除けば、$20 から $7F までは最大二つの符号で入力可能。表で残った $08 は「キャンセル」。

Morse Code over Flag Semaphore

With Morse code, like flag semaphore above, as for international characters, you should expect transliteration.

Letters are lower case in default. '_' + Letters give upper case. '_' + Symbols give other symbols useful for transliteration:

手旗によるモールス信号

モールス信号を使うときも、上の手旗信号と同じく、特殊な欧文文字や日本語カナなど英語以外の文字は、Transliteration を使うのが前提となる。

ここでも、英文字は小文字がデフォルトで、'_' + 文字だと大文字になる。'_' + 記号は、Transliteration に都合がよい下のような記号になる。:

'_' + '_'→ '_',
'_' + '&'→ '&',
'_' + '$'→ '$',
'_' + " (quot.)→ '^',
'_' + ' (apos.)→ '`' (back quote),
'_' + '-'→ '~',
'_' + '/'→ $5C (backslash '\').

And more, in the jrf_semaphore, you can input an ascii character code by '&' + bits('·' = 0, '–' =1)-word. If 8bits-word is greater than $7F, it is interpreted as UTF-8. So, unicode of $80-$FF must also be coded by UTF-8 (or expect transliteraton). (Numbers like $5C are hex codes.)

'$' of Morse Code is not implemented like Flag Semaphore in which numeral mode continues til an explicit end. Do you want to click UTF-8 binary codes by hand?

jrf_semaphore においては、'&' + ビット列('·' = 0, '–' =1)で、ASCII コードを入力できるとする。ビット列の長さは 8 ビットまでで、UTF-8 コードと解釈する。カタカナ入力も UTF-8 で可能ではあるが、相手が文字を理解するとは限らない。($5C などの数字は 16 進数コード。)

モールス信号における '$' は、手旗のように数字モードが明示的な終了がない限り続くような実装を用意していない。それとも UTF-8 バイナリを手で打ちたいかい?

Try It !

やってみよう!

[PROGRAMMED UI SHOULD BE HERE.]

The program runs with JSNES which is a NES emulator written in JavaScript. I create the "ROM"-data for NES with the assebler NESASM and neat UI in an hommage of Japanese NES of "FamiCon".

I tested on Firefox and Google Chrome. This program uses progressive part of JavaScript, your browser possibly doesn't work or works but very slowly on lower-spec. machines. (Sorry.)

Direction buttons control flags. Other buttons are commands. Try and find.

The program is archived with sources below. Links on SugarSync may show ads.

このプログラムは JSNES 上で動いている。JSNES は JavaScript で書かれたファミコンエミュレータの一つである。私は、このファミコン用「ROM」データをアセンブラ NESASM で、またファミコンをオマージュしたちょっとした UI を作った。

Firefox と Google Chrome 上で動作確認している。先進的な JavaScript の機能を使ってるので、ひょっとして今見てるブラウザでは動いてないかもしれない。動いても低スペックマシンだととても遅いだろう。(すまん。)

方向ボタンで旗が動く。他のボタンは「コマンド」。いろいろ試して発見して欲しい。

プログラムはソースと共に以下んとこにアーカイブしてある。SugarSync 上のリンクは Ad を出すかも。

Transliteration

The above archives also have 'jrf_sempahore.pl'. That is a Perl script which can process transliteration or something.

Currently, 'jrf_semaphore.pl' supports transliteration only of very simple Hebrew named in 'j0heb.nes' and Japanese half-width Kana named in 'j0ja.hw'.

Documentation has not been completed at all, yet. Now, here is a simple example below, which transliterates "br'syt" into Hebrew characters and encode them to flag codes with (un)transliteraton and decode them and generate a GIF image of text.

Transliteration

上のアーカイブには 'jrf_sempahore.pl' も含まれている。この Perl スクリプトで Transliteration とかいろいろできる。

が、今のところ、'jrf_semaphore.pl' は日本語カナとかなりシンプルなヘブライ語のみサポートしている。日本語半角カナは 'j0ja.hw' という名で、ヘブライ語は 'j0heb.nes' という名で指定する。

ドキュメントはまったく書けてない。今は、下の簡単な例で許して欲しい。これは、"br'syt" を Transliteration してヘブライ文字にし、その後、旗番号に (逆)Transliteration しながらコード化して、さらに今度は、それを逆に文字に戻してそのテキストを GIF イメージにしている。

$ echo -n br\'syt | perl jrf_semaphore.pl -t -c -T j0heb.nes \
    | perl jrf_semaphore.pl -c -T j0heb.nes \
    | perl jrf_semaphore.pl -u --text-gif > test.gif
br\'syt

The next example encodes the text "This is a test" to flag codes and outputs them as a GIF animation.

次の例では、"This is a test" を旗番号にコード化して、それを GIF アニメーションとして出力している。

$ echo -n "This is a test." \
    | perl jrf_semaphore.pl -c --flag-gif -o test2.gif
jrf c This is a test.

If you have copied tankanji.txt, tankanji.txt.sdb.dir, taknanji.txt.sdb.pag, SKK-JISYO.L, SKK-JISYO.L.sdb.dir, SKK-JISYO.L.sdb.pag, bushu-skk-dic.txt, bushu-skk-dic.txt.sdb.dir, bushu-skk-dic.txt.sdb.pag, emoji-skk-dic.txt, emoji-skk-dic.txt.sdb.dir and emoji-skk-dic.txt.sdb.pag from the working quail-naggy directory, you can use Japanese conversion via -T naggy like below.

動作している quail-naggy ディレクトリから tankanji.txt, tankanji.txt.sdb.dir, taknanji.txt.sdb.pag, SKK-JISYO.L, SKK-JISYO.L.sdb.dir, SKK-JISYO.L.sdb.pag, bushu-skk-dic.txt, bushu-skk-dic.txt.sdb.dir, bushu-skk-dic.txt.sdb.pag, emoji-skk-dic.txt, emoji-skk-dic.txt.sdb.dir, emoji-skk-dic.txt.sdb.pag をコピーしていれば、次のように -T naggy で日本語変換が使える。

$ echo -n "koreha,h. English,a."\
    "majirino,h.nihongo,j.no,h.tesuto,k.desu.,h." \
    "[,h.atui,j,,.natu,J,m..],h." \
    | perl jrf_semaphore.pl -t -c -T naggy
これは English まじりの日本語のテストです。 「暑い夏。」

It means "This is a test of Japanese mixed with English. 'Hot Summer.'"

License

The author is a Japanese.

I intended this program to be public-domain, but you can treat this program under the (new) BSD-License or under the Artistic License, if it is convenient for you.

Within three months after the release of this program, I especially admit responsibility of efforts for rational requests of correction to this program.

I often have bouts of schizophrenia, but I believe that my intention is legitimately fulfilled.