PROGRAMMING THE TI
I just returned from an interesting trip to Japan. I met several TI-99/4 users and spoke to a Commodore user group at Misawa Air Force Base. I ate all kinds of food and slept on the floor, experiencing real Japanese life that most tourists wouldn't see. I closed my eyes during the drives down narrow streets, but had fun shopping in the crowded stores. There were dozens of computer magazines—much like our magazine racks. I bought several that had interesting program listings to type in. The programming is in BASIC, so I can understand it, but I cannot understand the Japanese articles which tell what the programs do.
I was able to spend only a couple of hours in the Akihabara district of Tokyo seeing all the electronics shops. I would have enjoyed a longer time there, but then I would have just spent more money. Some people collect dolls or other trinkets, but it seems I collect computers. I bought an MSX computer that looks like lots of fun. (See "MSX Is Coming," Parts 1 and 2, COMPUTE!, December 1984 and January 1985.) I decided on a 64K Hitachi MB-H2 because it has a built-in cassette recorder and two cartridge slots (one is reserved for future disk drive expansion). It has one built-in music program that turns the keyboard into an organ. Another built-in program is like the Macintosh's MacPaint.
MSX BASIC is Microsoft BASIC with extended graphics commands such as LINE, CIRCLE, and PAINT. The music commands are similar to those in TI BASIC because the computer has the same sound chip found in the TI. MSX computers also use the TI video chip that allows 32 sprites. A graphics key lets you change the keyboard to graphics characters (similar to those on Commodore computers) plus some Japanese Kanji characters. Another key sets the keyboard to Hiragana characters (like our cursive writing), and a SHIFT adds the Katakana characters (comparable to our printing).
Reprogramming The Keyboard
This brings us to the following program. I've had several inquiries about how to print Japanese or Chinese characters on the TI, or how to change our QWERTY keyboard to a Dvorak keyboard. This program allows the keys to print the Japanese Katakana characters. You would use a similar technique for any other symbols you choose.
Reprogramming the keyboard requires two steps: You need to define the appropriate symbols, then print them on the screen when the corresponding key is pressed. I decided to use CTRL as the key to switch characters because I wanted to keep the English alphabet intact.
To find out what character code is returned for each keypress, you can refer to a chart in the appendix of the User's Reference Manual that came with the TI, or you can run a short program. As a key is pressed, the character code is printed on the screen. Notice that if you hold down CTRL while pressing a key, the computer returns a different number than it returns if the key is pressed by itself.
110 CALL KEY(0, K, S) 120 IF S<1 THEN 110 130 PRINT K 140 GOTO 110 150 END
You'll see that CTRL in combination with the number keys yields values greater than 156. For our special definitions, we are limited to numbers up to 156. Therefore, use SHIFT instead of CTRL for the top row. This means the symbols will be redefined.
Each Japanese Katakana symbol represents a syllable. The following chart places the characters in the same order as on the MSX computer keyboard, with a few exceptions on the right side of the keyboard:
When you run the program, instructions appear and then you can press a key. The Japanese Katakana symbol will appear along with the romaji or romanized syllable. You can use the program to practice "writing" Japanese or to learn how to read the symbols. You may want to use these character definitions and placements to expand to a Japanese language program which uses words and phrases.
Once you're familiar with this programming technique, you can change the character definitions to symbols for a different Asian language. Or you can try printing a code, such as Braille. Or you can convert your TI keyboard into a keyboard of graphic shapes.
S$ is the array to hold the syllables. To make things easy I just used the character number as the element number in S$. The characters from 128 to 156, however, subtract 128 for the element number. The highest symbol character number is 94, so the DIM statement reserves 94 for the array size. In a larger program you could be more efficient by numbering the elements differently, and you would need only about 50 elements.
Lines 150-350 define the characters for the symbols on the top row of the keyboard (SHIFT and the numbers) with the corresponding syllable sounds.
Lines 370-400 define the characters for the main section of the keyboard (CTRL and the letters), using the DATA statements in lines 420-630. The FOR-NEXT loop goes from character number 128 to 156 and READs first a character definition, then the syllable. Be careful typing the DATA lines. Don't use any extra commas, and don't put a comma at the end of a line. Each DATA statement except the last has three sets of character definitions with syllables.
Lines 540-650 define characters and syllables for the rest of the keyboard. Lines 660-710 print brief instructions. Lines 720-780 detect which key is pressed and accept only valid keys. The IF-THEN statements make sure the keypress is within certain ranges to print a symbol and a corresponding syllable. Line 790 prints the Japanese character. Lines 800–840 print the corresponding syllable, then return to the CALL KEY statement for the next keypress.
If you prefer to save typing effort, you can obtain a copy of this program by sending a blank cassette or disk, a stamped, self-addressed mailer, and $3 to:
P.O. Box 1502
Cedar City, UT 84720
Please specify the title of the program ("Japanese Katakana Characters") and that you need the TI version.
Japanese Katakana Characters
100 REM KATAKANA 110 DIM S$ (94) 120 CALL CLEAR 130 PRINT "CONVERTING THE TI KEYBOARD" 140 PRINT :"TO JAPANESE CHARACTERS" : : : : : 150 S$ (32) = " " 160 CALL CHAR (33, "FE02121C1010102") 170 S$ (33) = "A" 180 CALL CAHR (64, "0404081868080808") 190 S$(64) = "I" 200 CALL CHAR (35, "107E420204040808") 210 S$(35) = "U" 220 CALL CHAR (36, "007C10101010FE") 230 S$(36) = "E" 240 CALL CHAR (37, "0808FE1828284808") 250 S$(37) ="O" 260 CALL CHAR (94, "00087E0810102") 270 S$(94) = "NA" 280 CALL CHAR (38, "00003800007E") 290 S$ (38= "NI" 300 CALL CHAR (42, "007E020428102C02") 310 S$(42)="NU" 320 CALL CHAR (40, "107E040810142A49") 330 S$(40) = "NE" 340 CALL CHAR (41, "000404080810102") 350 S$(41)="NO" 360 REM 370 FOR C=128 To 156 380 READ C$, S$ (C-128) 390 CAll CHAR (C,C$) 400 NEXT C 410 REM 420 DATA 007E027E02027E, YO, 0024FE2404040808, SA, 606030282420202, TO 430 DATA 005454040408102, TSU, 007E040810182442, SU, 407C44040408081, KU440 DATA 00203C642820201E, SE, 002212020404081, SO, 007E0204180C, MA 450 REM 460 DATA 007E02020408102, FU, 3008001008003008, MI, 00102020445C62, MU 470 DATA 000414081410202, ME, 0038080808087C, YU, 207E22222C20202, YA 480 DATA 00102C43, HE, 10107C101054921, HO, 1016FA1212222242, KA 490 DATA 407EC80808101, KE, 000020012 204183, SHI, 003C040404047C, KO 500 REM 510 DATA 002020203820203F, HI, 38007C, 101010202, TE, 402C701678040201, KI 520 DATA 04380803E08101, CHI, 10082422224202, HA, 007E42441C08081, TA 530 DATA 7E42020204040808, WA, 003810, 781010100C, MO 540 CALL CHAR (47, "7E027E0204040808") 550 S$ (47) = "WO" 560 CALL CHAR (43, "7C007C040408102") 570 S$ (43) = "RA" 580 CALL CHAR (45, "242404040808081") 590 S$ (45) = "RI" 600 CALL CHAR (58, "002828282A4C08") 610 S$ (58) = "RU" 620 CALL CHAR (60, "4040404448506") 630 S$ (60) = "RE" 640 CALL CHAR (62, "003E424242427E") 650 S$ (62) = "RO" 660 PRINT : "USE THE SHIFT KEY WITH THE " 670 PRINT "TOP ROW OF KEYS," 680 PRINT "PLUS, MINUS, COLON, " 690 PRINT "GREATER THAN, OR LESS THAN." 700 PRINT : "SLASH IS 'WO'." 710 PRINT : "USE CTRL WITH OTHER KEYS." : : 720 CALL KEY (0, K, S) 730 IF S > 1 THEN 720 740 IF K < 156 THEN 720 750 IF (K = 94) + (K = 64) + (K = 60) + (K=62) + (K =58) + (K = 47) + (K = 45) THEN 790 760 IF (K < 128) + (K > 43) = - 2 THEN 720 770 IF K < 32 THEN 720 780 IF (K = 34) + (K = 39) THEN 720 790 PRINT : TAB (12) ; CHR$ (K) ; " " ; 800 if K > 128 THEN 830 810 PRINT S$ (K - 128) 820 GOTO 720 830 PRINT S$ (K) 840 GOTO 720 850 END