This article is taken from MSX Technical Guidebook, authored by ASCAT. Japanese original is not available in WWW yet, though.
Kanji ROM info is here. (emulate this first)
This page contains a document concerning how an MSX with a kanji input system installed accepts inputs and turns them into fonts (Japanese language utilizes multiple kinds of character sets in order to scribe itself) you prefer to write.
This relatively large document was originally authored for Japanese readers (which can naturally understand Japanese language) who want to introduce kanji input sequences integrated in their software.
However, this part is inevitable for development of true emulators. Up until now, no one has emulated renbunsetsu henkan (sequential bunsetsu conversion). This info might help such developers too.
And this document describes procedures and effects a boot of MSX-JE system, therefore giving you clues to successfully reverse-engineer Japanese software of recent release, which occasionally use CALL KANJI statement or similar means to boot MSX-JE and enter kanji input mode.
Since most readers are not expected
to have Japanese browsers to read Japanese characters in text
format, Japanese
font faces are provided in GIFs.
Though there quantity is immense, their sizes are 88 bytes at
one character and do not exceed 1 kilobyte in any cases, so there
are only 6KB of them approx.
Definitions
* Zenkaku and hankaku
"zen" means "whole", "han" means "half", while "kaku" means for "square" in Japanese. In MSX or in any word processing related with computers, hankaku is an adjective to describe 1-byte characters (English alphabets, numbers, western punctuation, unaccented katakanas, Japanese punctuation, Japanese accents; MSX supports unaccented hiraganas, unlike PC) while zenkaku, "2-byte" characters, include all hiraganas and katakanas, both accented and unaccented, English alphabets, special pictograms like large circles and measurement terms, Greek and Russian fonts, and thousands of kanjis.
* Bunsetsu and candidate
"bun" stands for "paragraph" or "sentence", while "setsu" is a segment. In word-processing sense, this indicates one specific domain in one input which is waiting to be converted. MSX guesses how many characters in one input string is best to convert into any kanji string MSX knows. MSX treats that part of a input as 1 "bunsetsu", and thinks up several "candidates" or "candidates" it thinks best to replace the kanas in bunsetsu, and show them to you, and let you to select the one he or she wanted to write. You can manually adjust length or location of bunsetsu coverage (i.e. from what character a bunsetsu begins and at what character it ends; referred to as candidate block in this document) if you want to, through manipulation with keyboard. When you finally get the kanji+kanas proposal from MSX which satisfy you, you press RETURN, and MSX-JE sends the converted bunsetsu to MSX as actual finalized data. Then MSX-JE guesses where next bunsetsu it must convert correspond to what part of input.
Section 5 MSX-JE
Here we describe MSX Standard Japanese Input Front End Processor, commonly called MSX-JE.
I would like to mention that I referred
to VJE-80A Specifications; 2nd Edition (from ASCII Corp.) while
authorizing these resources.
Chapter 1 What is MSX-JE?
"Japanese input front end processor" includes means to input Japanese with word processors, how to do so, and programs which control such procedures. Before coming of MSX-JE as standard, every word processors had their own Japanese input front end processors. This was fine in old days, but in these cases, let's say, when you want your modem connection software to support Japanese input, you must make your own Japanese input front end processor by yourself. However, this is a tremendous amount of work. Moreover, this costs users, who have to learn how to use different kind of Japanese front end processor each time they acquire another software. It's naturally convenient if you could use same input system with your modem connection software, and with your word processor. Therefore, a standard was established concerning means to input Japanese, and how to call them from programs. This is the, "MSX Standard Japanese Input Front End Processor" or "MSX-JE" (commonly called MJE).
For example, once you have registered
a term into internal SRAM while using Bunsho Sakuzaemon, a word
processor software on your Sony HB-F1XDJ, you can use that term
in occasions you conduct kanji input with kanji BASIC (during
CALL KANJI status), too. And also usable when you are using modem
through Canon's modem connection cartridge VM-300. Kanji conversion
method is standardized as one, too.
Chapter 2 How to Boot MSX-JE
Use expanded BIOS call, as usual, in order to use MSX-JE.
Firstly, you need to check whether you are able to use expanded BIOS call or not. If lowest bit in address FB20H of the work area is standing, and value of FFCAH is other than C9H, expanded BIOS call is possible. If these conditions are not met, it means there are no machines which rely on expanded BIOS calls; which means that MSX-JE does not exist, accordingly.
If above conditions are met, then input 10H to D register, 0 to E register, header address of the work area to HL register, slot no. which the work area is present into B register. Then call address FFCAH. Be noted that, work area should be placed on page 2 or 3, and stack should be placed on page 3. Size of the work area is 64 bytes.
If Japanese front end processors exist,
then value of HL will be incremented by 4, and following table
is originated. If there are 2 or more Japanese front end processors
connected, then equal number of tables are originated.
Former HL =>
Capability vector
Slot no.is not compatible.
If bit 1 is 0, then virtual terminal interface is exists. If 1, it does not exist.
If bit 2 is 0, then dictionary interface exists. If 1, it does not exist.
If bit 3 is 0, then dictionary registration and deletion function is available. If 1, they are not available.
Bits 4 to 7 are for future expansion, and they are all fixed to 1 this point.
Check statuses of these bits to check whether functions you want to use are there when you use MSX-JE. For example, a capability vector of VJE-80 (ASCII-made MSX-JE) is F8H (dictionary cannot be changed), while VJE-80A (new version of ASCII-made MSX-JE) is F0H (all functions described above are available).
Let your software to prompt a menu
and let users to select which MSX-JE they want to use if there
are 2 or more MSX-JEs. In some machines, MSX-JE embedded in the
machines always boots, thus negating the use of external MSX-JEs.
For example, though you insert MSX-WRITE cartridge into a Panasonic
FS-4600F, internal MSX-JE is always chosen to be booted. :(
Chapter 3 How to Use MSX-JE
To use MSX-JE, input value to registers, and insterslot-call the aforementioned routines.
However, you need to use rather uncommon
procedure to substitute character strings. I would like to explain
firstly.
5.3.1 Format of Character Strings
Format of character strings are;
[number of characters] + "character
string".
Character strings are in SHIFT-JIS format. For instance, 97H+"
"("red
balloon"). Then, specify its header address to BC or DE register.
Zenkaku characters are always regarded as 2-bytes even if they
are not kanjis. Below are several examples.
08H+"
"
("red balloon" in kanjis and kanas, 4 zenkaku characters
overall)
0DH+"
"("spaghetti
with fermented beans", 2 kanjis + 9 hankaku katakanas)
07H+"
"
("club-house style sandwiches", 7 hankaku katakanas)
0EH+"
"
("red balloon" in 7 zenkaku hiraganas)
07H+"TOUKYOU" (7 hankaku characters)
1-byte accents ("
"
and "
")
are treated as single characters. You cannot treat hankaku hiraganas
(which are supported by MSX but not with PCs) and kanas which
are not supported by MSX in non-kanji modes - like "
",
"
",
"
",
"
" or "
"
- as hankaku characters and use them. Length of a character string
is 64 bytes at maximum.
Note on Japanese accents: Japanese hiraganas and katakanas require 2 kind of "accents" to be added on upper-right of kana characters. They are essential for recognition and pronunciation, and should not be omitted in any cases.
In non-kanji mode MSX, there are only
hiraganas and katakanas without accents, and these 2 accents (DEH
and DFH in ASCII) available, therefore you are required to represent
one accented kana using 2 characters. However, 2-byte characters
support both kanas with and without accents.
5.3.2 MSX-JE Function Calls
Inquiry (Function 01H)
Input: 1 to A
Output: MAX to HL
MIN to DE
MIN2 to BC
This returns necessary size of work
area to enable execution of MSX-JE. MAX is a maximum size of work
area. Even if you grant any more than MAX to MSX-JE, MSX-JE uses
only this size. Least necessary size goes into DE, while least
necessary size in case learning option is chosen goes into BC.
Value is counted by unit of bytes. For example, in case of VJE-80,
MAX=MIN2=3328 bytes and MIN=2304. In case of VJE-80A, MAX=MIN2=520
and MIN=512. In case of SONY JFEP, MAX=MIN=MIN2=2560.
invoke (02H)
Input: 2 to A
Header address of BW to HL
Length of BW to DE
Output: None
This command allocates work area for
MSX-JE. You should call this whenever you boot MSX-JE. BW stands
for work area of MSX-JE. You should always allocate it in page
2 or 3. It seems that, several restrictions occur if you place
ASCII VJE-80 in page 2 and use it, but I do not think it's worth
being afraid of. You must check necessary length of work area
using function 1 (Inquiry) before calling this function. As a
point of fact, since MSX-JE never needs more than 2560 bytes as
its least necessary work area to boot, so it's OK if you allocate
2560 bytes.
release (03H)
Input: 3 to A
Header address of BW to HL
Output: None
This frees work area allocated for
MSX-JE. You should call this whenever you quit any program which
use MSX-JE. If you do not call this, learning dictionary might
be damaged.
han_zen (40H)
Input: 40H to A
Address of BW to HL
Address of source buffer (hankaku character string) to DE
Address of destination (zenkaku character string) to BC
Output: If A is 0, it means conversion was successfully done.
If A is other than 0 then conversion was a failure. The value of A then stands for position of the character that prevented the conversion, in buffer.
This converts a hankaku character string to a zenkaku character string. Both accents will be converted into independent characters (though rarely used, 2-byte character table does include accents as characters by their own).
Example: Input 05H+"
"
to DE
Output 0AH+"
"
to BC
zen_han (41H)
Input: 41H to A
Address of BW to HL
Address of source buffer (zenkaku character string) to DE
Address of destination (hankaku character string) to BC
Output: If A is 0, it means conversion was successfully done.
IF A is other than 0 then conversion was a failure. The value of A then stands for position of the character that prevented the conversion, in buffer.
This converts a zenkaku character string to a hankaku character string. Both accents, which were integrated as a single kana to a certain kana when they were zenkau, will be converted into independent character.
Example: Input 058+"
"
to DE
Output 05H+"
"
to BC
han_kata (42H)
Input: 42H to A
Address of BW to HL
Address of source buffer (hankaku character string) to DE
Address of destination (katakana character string) to BC
Output: If A is 0, it means conversion was successfully done.
IF A is other than 0 then conversion was a failure. The value of A then stands for position of the character that prevented the conversion, in buffer.
This converts a hankaku character string into zenkaku katakana string. Input is expected to be katakanas or romaji string.
Example: Input 07H+"AKATUKA" to DE
Output 08H+"
"
to BC
han_hira (43H)
Input: 43H to A
Address of BW to HL
Address of source buffer (hankaku character string) to DE
Address of destination (hiragana character string) to BC
Output: If A is 0, it means conversion was successfully done.
IF A is other than 0 then conversion was a failure. The value of A then stands for position of the character that prevented the conversion, in buffer.
This converts a hankaku character string into zenkaku hiragana string. Input is expected to be in katakanas (MSX 1-byte hiraganas are not accepted) or romaji string.
Example: Input 0AH+"KAIRAKUENN" to DE
Output 08H+"
"
to BC
kata_hira (44H)
Input: 44H to A
Address of BW to HL
Address of source buffer (katakana character string) to DE
Address of destination (hiragana character string) to BC
Output: None.
This converts a zenkaku katakana string into zenkaku hiragana string. If input string included characters other than zenkaku katakanas, that character will not be converted. Conversion result is not certified if there were hankaku characters in input string. :(
Example: Input 0AH+"
"
to DE
Output 0AH+"
"
to BC
kata_hira (45H)
Input: 45H to A
Address of BW to HL
Address of source buffer (hiragana character string) to DE
Address of destination (katakana character string) to BC
Output: None.
Same as kata_hira, except in aspect that this converts a zenkaku hiragana string into zenkaku katakana string.
Example: Input 0AH+"
"
to DE
Output 0AH+"
"
to BC
open_dic (46H)
Users are not expected to call this.
henkan1 (47H)
Input: 47H to A
Address of BW to HL
Address of read data (zenkaku katakana string)
Output: If A=0, it means there is no suitable candidate.
If A is other than 0 then it is a number of candidates for header bunsetsu
This converts a zenkaku katakana string into a kanji+kana passage. Acquire the result through ji_koho or other means.
Example: Input 10H+"
"
to DE
Output number of candidates for "
"
to A
ji_koho (48H)
Input: 48H to A
Address of BW to HL
Candidate buffer to DE
Proceeding bunsetsu buffer to BC
Output: If A=0, it means there is no suitable candidate.
If A is than 0 then it's a lot number within a candidate block
This gets next candidate (jikoho) for header bunsetsu. You must read with henkan1 to set the data before you call this function.
Example: Suppose you called this function
after trying to convert an input "
"
using henkan1.
Output: Lot number within a candidate block to A
04H+"
"
to DE
06H+"
"
to BC
zen_koho (49H)
Input: 49H to A
Address of BW to HL
Candidate buffer to DE
Proceeding bunsetsu buffer to BC
Output: If A=0, it means there is no suitable candidate.
If A is than 0 then it's a lot number within a candidate block
This gets prior candidate (zenkoho) for header bunsetsu. You must read with henkan1 to set the data before you call this function.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
Output: After execution of 1st ji_koho
04H+"
"
to DE
02H+"
"
to BC
After execution of 2nd ji_koho
04H+"
"
to DE
02H+"
"
to BC
After execution of zen_koho
Lot number within a candidate block to A
04H+"
"
to DE
02H+"
"
to BC
ji_block (4AH)
Input: 4AH to A
Address of BW to HL
Output: If A is 0, it means there is no suitable block group.
If A is other than 0 then it's a number of candidates.
This sends a group of candidate block to next level, by retracting length of header bunsetsu, regarding sense of terms in different way and other means, and remakes group of candidate blocks. You must read with henkan1 to set the data before you call this function. Acquire the result through ji_koho or other means.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
Output: After execution of 1st ji_koho
06H+"
"
to DE
08H+"
"
to BC
Execute ji_block, then execute a 2nd ji_koho
04H+"
"
to DE
08H+"
"
to BC
zen_block (4BH)
Input: 4BH to A
Address of BW to HL
Output: Output: If A is 0, it means there is no suitable block group.
If A is other than 0 then it's a number of candidates.
This sends a group of candidate back to prior level, and remakes group of candidate blocks. You must read with henkan1 to set the data before you call this function. You are not requested to call ji_block before execution of this function, however.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
Output: After execution of 1st ji_koho
06H+"
"
to DE
08H+"
"
to BC
Execute ji_block, then execute a 2nd ji_koho
04H+"
"
to DE
08H+"
"
to BC
Then execute zen_block, then execute ji_koho
06H+"
"
to DE
08H+"
"
to BC
kakutei1 (4CH)
Input: 4CH to A
Address of BW to HL
Lot number within a candidate block to E
Address of conversion result container buffer to BC
Output: Conversion result will be contained in the buffer stated by BC.
This finalizes ("kakutei") the candidate specified by E register, as the result of conversion. Result enters into address stated by BC. You must read with henkan1 to set the data before you call this function. You are not requested to call ji_block or similar functions before execution of this function.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
Input: Lot number within a candidate block to E
Output: 0AH+"
"
to E
kakutei2 (4DH)
Input: 4DH to A
Address of BW to HL
Lot number within a candidate block to E
Address of conversion result container buffer to BC
Output: Pronounced length of header bunsetsu (byte length)
Conversion result will be contained in the buffer stated by BC.
This finalizes ("kakutei") the candidate specified by E register. Pronounced length of the finalized header bunsetsu enters A, while conversion result enters into address stated by BC. A "pronounced length" is a length of conversion result when it is read in all kanas (no kanjis). You must read with henkan1 to set the data before you call this function. You are not requested to call ji_block or similar functions before execution of this function.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
Input: Lot number within a candidate block to E
Pronounced length of header bunsetsu (08H) to A
0AH+"
"
to E
close_dic (4EH)
Users are not expected to call this
function.
touroku (4FH)
Input: 4FH to A
Address of BW to HL
Address of pronunciation buffer to DE
Address of term registration buffer to BC
Output: If A=0, it means registration was successful.
A=1 means registration failed, because there was no empty space.
A=2 means registration failed, because there were too many homonyms.
A=4 means registration failed because pronunciation data was improper.
A=8 means registration failed because term data was improper.
A=16 means registration failed because grammar (sense) was improper.
This registers ("touroku") a term into the user dictionary.
Formats for pronunciation data and term data are as follows.
[number of characters]+"[pronunciation data (zenkaku katakanas, max. 64 bytes)]" to DE
[number of characters]+"[term data (zenkaku characters, max. 64 bytes)]"+[sense code]"
Pronunciation data should be in zenkaku
katakanas, 2 bytes or more, 64 bytes or less (which means between
1 to 32 characters long), and should not include characters "
",
"
",
"
",
"
",
"
" or "
".
Term data should be in SHIFT-JIS codes, with characters restriction
between 2 to 64 bytes, like pronunciation data. You can register
up to 255 homonyms (there are quite many homonyms in Japanese
language, which are spelled with different kanjis). Choose a sense
out of following 5.
1 for nouns (like natto (fermented beans)), 2 for surnames (like Tokugawa), 3 for first names (like Mitsukuni), 4 for location names (like Mito, a city which houses both natto and Mitsukuni Tokugawa;), and 5 for verbs which require "suru" suffix (like shipansuru ("to judge") or kagakusuru ("let scientific mind work"))
If your MSX-JE does not support term registration (VJE-80 from ASCII for example), then this function returns FFH to A.
Example: You registered term "
",
which is pronounced "
"
and has a sense of surname.
Input: 0AH+"
"
to DE
06H+"
"+02H
to BC
Output: 0 to A (successful registration)
sakujo (50H)
Input: 50H to A
Address of BW to HL
Address of pronunciation buffer to DE
Address of term registration buffer to BC
Output: If A=0, it means deletion was successful.
A=1 means deletion failed because it was not found in dictionary.
A=2 means deletion failed because pronunciation data was improper.
A=8 means deletion failed because term data was improper.
A=16 means deletion failed because sense was improper.
This deletes ("sakujo")
a term from the user dictionary. Formats of data are same as touroku.
If your MSX-JE does not support this function, then it returns
FFH to A.
These so far are function calls defined
to MSX-JE. Normally, these functions are enough, but since VJE-80A
defines several other function calls as expansion, so we describe
them too.
henkan2 (58H)
Input: 58H to A
Address of BW to HL
Address of zenkaku katakana string to DE
Output: Number of candidates to A
Execution is exactly identical to
henkan1. VJE-80 returns presence/absence of candidates (1: at
least one candidates is available).
number of candidates (59H)
Input: 59H to A
Address of BW to HL
Output: Number of candidates for current candidate block
This returns number of candidates
available for candidate block currently under conversion.
henkan3 (5AH)
Input: 5AH to A
Address of BW to HL
Output: Number of candidates for header bunsetsu of proceeding bunsetsu
This repeats the conversion over the part which was regarded as proceeding bunsetsu.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
After execution of 1st ji_koho
04H+"
"
to DE
06H+"
"
to BC
Execute henkan3, then execute ji_koho
04H+"
"
to DE
02H+"
"
to BC
hiragana (60H)
Input: 60H to A
Address of BW to HL
Candidate buffer to DE
Proceeding bunsetsu buffer to BC
Output: A=0 means successful completion.
A=FFH means operation quitted abnormally (error).
This converts the header bunsetsu which was most lately converted into zenkaku hiragana string of equivalent pronunciation. You must acquire candidates through functions like ji_koho or zen_koho before using this function.
Example: Suppose you tried to convert
an input "
"
using henkan1 prior.
After execution of 1st ji_koho
04H+"
"
to DE
06H+"
"
to BC
Then execute hiragana
06H+"
"
to DE
06H+"
"
to BC
katakana (61H)
Input: 61H to A
Address of BW to HL
Candidate buffer to DE
Proceeding bunsetsu buffer to BC
Output: A=0 means successful completion.
A=FFH means operation quitted abnormally (error).
This converts the header bunsetsu
which was most lately converted into zenkaku katakana string of
equivalent pronunciation. You must acquire candidates through
functions like ji_koho or zen_koho before using this function.
All others are same with hiragana function
Descriptions of expanded function calls ends here. Note, these expanded function calls return FFH to A if your MSX-JE does not support them. For instance, since hiragana and katakana functions are not supported by VJE-80, so they will return FFH to A if you execute them on VJE-80.
For your notice, if in future the
functions not defined yet will be added, they will be assigned
to functions 62H and later, by youngest order.
Chapter 4 Virtual Terminal
Interface
We described about basic usage of
MSX-JE, but they are for use of word processor software and like
when they want to convert kanjis. They are still too much a workload
when a simple user want use a little bit of MSX-JE functions in
their programs. Therefore, MSX-JE supports a facility called virtual
terminal interface, which allows you to use MSX-JE functions with
relative ease. In this, a virtual terminal do all kanji conversion
processes, and what program should do is to display character
strings which the virtual terminal return. When virtual terminal
is used, work flow is as follows.
1) When a program wants to input Japanese, it opens a window in a screen, and call virtual terminal.
2) User looks at it (the window in this case), and input, say, YUUGURE.
3) Virtual terminal converts that
to
,
and returns the converted one to program.
4) The program displays
on the window it opened, and gives the responsibility of execution
back to virtual terminal.
5) User looks at
,
and press conversion key.
6) Virtual terminal, knowing that
conversion key was pressed, converts
to
,
and returns it to the program.
7) Program displays
in window, and gives the execution responsibility back to virtual
terminal.
8) User looks at it, and press finalizing key.
9) Virtual terminal, knowing that
finalizing key was pressed, returns the notion that result was
finalized as
to the program.
10)
is input.
Kanji BASIC supported by MSX2+ and later does this way, so if you cannot understand above, try booting kanji BASIC or so and convert kanjis. A program (BASIC interpreter in this case) calls virtual terminal when CTRT+SPACE are pressed, then window opens in lowest line, and tells you that MSX entered kanji conversion mode. When you input the characters, virtual terminal converts, while program (BASIC interpreter) displays them in the window. If you press finalizing key (RETURN), then character string present in window then are assumed as your input. Finally, when you press CTRL+SPACE, program quits out of kanji input mode.
If you try to use MSX-JE functions directly, then your program should process everything including whether conversion or finalizing keys are pressed or not. On the other hand, if you use virtual terminal, if you make a window and call the terminal, then what you should do is to display ongoing processes and final result, so kanji input will cost you far less. As a price to pay, window size has restriction, and keys to finalize or to convert are fixed, since virtual terminal processes such steps.
I recommend you to use MSX-JE when
you make your own word processor, and virtual terminal in cases
you want to prompt some kanji input in your modem software or
so.
5.4.2 How to Boot Virtual Terminal
Boot process for virtual terminal
is exactly same with that for MSX-JE. Call address FFCAH to check
interslot call address for MSX-JE (virtual terminal), call function
1 (see 5.3.2, MSX-JE Function Calls) to check necessary size of
work area, and call function 2 to boot MSX-JE (virtual terminal).
When you have finished using virtual terminal facility, call function
3 to quit virtual terminal.
5.4.3 Character Strings Outputted
by Virtual Terminal
As explained in 5.4.1,
a virtual terminal does not display character strings it converted,
but prefers to return them to the program and let it to display
them. This is, to allow program to choose position of the window,
and to enable use of virtual terminal in any screen mode. You
can use virtual terminal in interlaced screen 6 or in screen 2
because of this feature. While window is mostly located on lowest
line, but you are free to locate it, say, in middle of the screen.
Character string data are in a little strange format, for occasions like when a virtual terminal wants cursor to vanish. The format is called STB format. Programs are supposed to display character strings of STB format to the window.
Format of STB
1: SHIFT-JIS character string
Displays a character on cursor position, and cursor advances. Hankaku western and katakanas are possible.
2: NULL (0)
End of text.
3: ^L (12)
Wipes away the window. Cursor returns to top of the screen.
4: ^E (5)
Wipes away all characters later than the cursor.
5: ^H (8)
A character before the cursor is deleted, and cursor moves back one space.
6: ^R (18)
Reverse the characters by length stated by next 1 byte, from cursor position.
7: ^Z (26)
Upper 4 bits of next 1 byte becomes color of the character, while lower 4 bits are selected background color.
8: ^X (24)
Move the cursor. Next 1 byte is X-axis.
9: ^Y (25)
Move the cursor. Next 1 byte is Y-axis. (optional)
10: ^W (23)
Open the window specified by next 1 byte. (optional)
11: Any value between 0 to 15 and
is not mentioned above will be skipped. Any value between 16 to
31 and is not mentioned above will be skipped, and 1 byte next
to it will be skipped too.
Any positions of characters should be specified by units of hankaku (1-byte). Be noted though, that when you specify X-axis of a cursor, 1 is the initiating value, and 0 means cursor will not be displayed.
Size of a window supported by virtual terminal is 1 line * 28 characters (14 zenkaku characters), but a program can use windows of other sizes. Function call 9 which will be explained later is used in such cases. If you are going to use default 1 line * 28 characters window, then you have no need to support ^Y or ^W.
If you open a window, the graphic there will be wiped out, of course. If you do not want graphic to be gone, then you must let program to reserve such contents.
A virtual terminal assumes that information
like contents of windows or cursor position are kept when it is
working, so make sure you do not harm such information. For instance,
when you add one character on end of a character string, virtual
terminal only returns one character long STB.
5.4.4 Virtual Terminal Function Calls
Virtual terminal functions can be called by same procedure you follow to use MSX-JE normally.
Interslot-call the address you acquired
by calling address FFCAH. Function 05H, 08H, 09H and 0AH are optional;
some MSX-JEs lack them.
clear (Function 04H)
Input: 04H to A
BW to HL
Output: None
This clears buffer for kanji conversion.
Use this when you want to clear inputted text so far.
set TTB (05H; optional. Some MSX-JEs lack this function)
Input: 05H to A
Address of BW to HL
Address of text data you want to re-convert to DE
Address of TTB to BC
Output: If A=0, it means re-conversion is possible.
FFH means re-conversion is impossible.
Use this when you want to convert
a specific character string. If your MSX-JE does not support this
function (like VJE-80A), it returns FFH to A.
dispatch (06H)
Input: 06H to A
Address of BW to HL
Output: Status to A
Address of STB to HL
This dispatches processor resource from application to virtual terminal. Or, simply said, it starts kanji conversion. A virtual terminal sets the parameters and temporarily gives away execution responsibility to program in cases like when it displays characters in window. The program then displays STB the virtual terminal returned on window, looks at statuses, and decide what program has to do afterward. STB is within BW.
Meaning of statuses are as follows.
Bit 0: if 1, then program displays STB.
Bit 1: if 1, then program can get conversion result.
Bit 2: If 1, it means conversion at virtual terminal is completed.
Meaning for each statuses;
000 Virtual terminal ignored key inputs, or no key inputs occured
001 In middle of inputs, or in middle of conversion
010 Partially finalized
011 Partially finalized
100 Conversion was interrupted and quitted
101 Conversion was interrupted and quitted
110 Wholly finalized
111 Wholly finalized
You must let your program to look
at 3 bits independently. For instance, if all 3 bits are standing,
then your program firstly should display STB, acquire the result
of conversion using function 07H, and quit dispatch function.
You can easily see that programs should repeat displaying to screen
and calling function 06H infinitely until bit 2 stands.
get_result (07H)
Input: 07H to A
Address of BW to HL
Output: Header address of acquired conversion result to HL
This returns result of conversion.
The result will be returned in SHIFT-JIS format which ends with
00H.
get_TTB (08H; optional. Some MSX-JEs lack this function)
Input: 07H to A
Address of BW to HL
Output: Address of TTB to HL
This gets the pronunciation data of
the text you acquired using get_result. The result will be returned
in TTB format. If your MSX-JE does not support this function (like
VJE-80A), it returns pointer to 0 to HL.
* translator's note: "TTB format"
might be misspelled "STB format".
Inquire_window_size (09H; optional. Some MSX-JEs lack this function)
Input: 07H to A
Address of BW to HL
Maximum length of tail format to E
Maximum height of window format to B
Maximum length of window format to C
Output: Window specification data to HL
Window used by a virtual terminal is 1 line * 28 characters (14 zenkaku characters) at default, but you can use this function when you want to use windows of other sizes. Enter size of window that your program can handle, and call. You have no need to call this if you are going to use a window of default size.
A window specification data is an array of several window specification items, and ends with 0.
3 bytes in one window specification item is as follows.
1st byte: Window type
2nd byte: Window length
3rd byte: Window height
About window type, if you want to let the input goes back to left tip of next line when it reaches the rightmost tip of the screen, choose 2 (a window of this type is called tail format), and if you do not want the input to back to left, then choose 1 (a window of this type is called independent format). Default window is of independent format.
If your virtual terminal is not supporting the window of specified size and format, then it returns header address of next data. In another word, it specified the default window back again. [01H+1CH+01H+00H]
There is no guarantee that every virtual
terminals support the window of the size you want to use, so you
are not recommended to use this function in normal situations.
conflict_detect (0AH; optional. Some MSX-JEs lack this function)
Input: 07H to A
Address of BW to HL
Output: If A is 0, then conflict is not detected.
If A is FFH, it means conflict is detected.
This is used to transfer control responsibility
to virtual terminal, when you prefer to let the terminal to pick
up key input that program is supposed to pick up. This function
is for purpose of avoiding conflicts between keys which program
uses, and keys which virtual terminal uses. I do not expect much
use of this in normal occasions. ;)
The explanations for virtual terminal
function calls end here.
5.4.5 Specified Control Keys for
Virtual Terminal
Virtual terminal processes
key inputs by itself. Therefore, if your program and virtual terminal
try assign same key for their functions, then program ends up
to hangup (a sort of malfunction).
For instance, suppose you made the
program so it will transfer control responsibility to terminal
if you press SPACE key. At the same time, if a virtual terminal
assumed it will return the execution to program by pressing SPACE,
then if you press SPACE key then execution will keep bouncing
back and forth like badminton match;), never to return, leaving
a stroke SPACE of key buffer. To prevent these kind of things to
happen, there are several fixed agreements about keys that a virtual
terminal and application programs should take out of buffer.
For virtual terminal;
Keys that interrupt conversion without removing contents of key buffer: F6 to F10 or CTRL+STOP
Keys that interrupt conversion and remove contents of key buffer: ESC
Keys that always remove contents of
key buffer: F1 to F5, SPACE or any character keys including graphic
characters
For application programs;
Keys that always take out contents
of key buffer: F6 to F10, CTRL+STOP or any character keys including
graphic characters
Keys that initiate conversion and do not take out contents of key buffer: F1 to F5, SPACE or any character keys including graphic characters
A program needs to check these keys during the period between the time it called _clear_ function and the time it calls _dispatch_. Virtual terminal will do the processes later then.
By the way, you must check the first character in key buffer without taking it out of key buffer if you do not want to transgress this rule. For this purpose, use following method.
Firstly, use the CHSNS (009CH) bios to check whether there is any content in key buffer.
If it is not empty, you can find the
next key code to be taken out, in an address specified by 2 bytes
from address F3FAH.
Also, since an MSX cannot check whether its function keys are pressed, virtual terminal sets following codes to function keys to recognize function key strokes. These values are set at the time you call _clear_ function. If you do not want original contents to be gone, let your program to reserve initial contents of function keys.
F1: 01H+31H, F2: 01H+32H, F3: 01H+33H,
F4: 01H+34H, F5: 01H+35H
Moreover, if you set following values to F6 to F10m then a virtual terminal processes then as F6 to F10. Inputs of other values are regarded as input of equivalent character strings, and will be processed so.
F6: FFH+36H, F7: FFH+37H, F8: FFH+38H,
F9: FFH+39H, F10: FFH+3AH
5.4.7 Keys Assigned by Virtual
Terminal
[F1] Switch input mode (romaji / western characters)
[F2] Hiragana conversion
[F3] Katakana conversion
[F4] Convert to hankaku
[F5] Convert using JIS code
[CTRL]+[F5] Finalize all
[BS] Step back and delete (backspace)
[DEL] Delete a character on cursor position
[ESC] Quit editing (keystrokes do not remain in buffer)
[RETURN] Finalize partially (same as CTRL+F5 during edit)
[UP] Start conversion (same as SPACE)
[DOWN] Start conversion (same as SPACE)
[RIGHT] Move cursor to right
[SHIFT]+[RIGHT] Move cursor to rightmost
[LEFT] Move cursor to left
[SHIFT]+[LEFT] Move cursor to leftmost
[SPACE] Start conversion
[SHIFT]+[SPACE] Input zenkaku space (which is different with 1-byte space)
[CTRL]+[STOP] Quit editing (keystrokes remain in buffer)
[F6] to [F10] Quit editing (keystrokes remain in buffer)
If there are any character strings in buffer, and they are not keys mentioned above, such keystrokes will be ignored and removed out of buffer. Even in such cases, virtual terminal return the execution responsibility to your program anyway (status is 000B in such state). It returns execution responsibility when there is not key input at all, too. This is to enable your program to process other jobs simultaneously with Japanese inputs. If you do not need simultaneous tasktaking, then call _dispatch_ as is. If keys 00H to 1FH are pressed when there is no character string during editing, then conversion quits while still leaving such inputs in buffer. (status will be 100B)
If you press SPACE when there is no character string during editing, then virtual terminal finalizes (generates) zenkaku space, and returns execution responsibility to program.
The characters you can add to editing
character strings are limited to western characters and hiraganas.
Katakanas will be processed as equivalent hiraganas.
During conversion
[F1] to [F5] Same as editing
[CTRL]+[F5] Finalize all (finalizes the domain up to cursor position)
[ESC] Quit conversion (keystrokes do not remain in buffer)
[RETURN] Finalize partially (finalizes header bunsetsu)
[UP] Move to prior block
[DOWN] Move to proceeding block
[RIGHT] Quit conversion
[LEFT] Quit conversion
[SPACE] Next candidate
[SHIFT]+[SPACE] Prior candidate
[CTRL]+[STOP] Quit editing (keystrokes remain in buffer)
[F6] to [F10] Quit editing (keystrokes remain in buffer)
Key buffers will be cleared when "move to prior block" and "move to proceeding block" were selected.
The characters up to one position before the cursor will be subject to conversion and finalizing.
Be noted that key assignment described
here are, for ASCII VJE-80 and 80A only. As long as you keep rules
noted in 5, they should not be exactly this way. Therefore, some
function keys might differ with ASCII's assignment on MSX-JEs
of other machines. For example, "next candidate" is
[GRAPH] instead of [SHIFT]+[SPACE] in case of Sony machines. Accordingly,
[F2] converts to katakanasm and [F3] converts to hankakus. There
are several more differences.
Chapter 5 Cautions upon
Using MSX-JE
Difference between MSX-JE and VJE-80
It seems too many people are confusing
MSX-JE and VJE-80, so I explain that, MSX-JE is a name of standard
when MSX performs Japanese input, while VJE-80 is a name of "a
Japanese front end which satisfies MSX-JE standard".
"MSX-WRITE II" released
by ASCII has a backup option for its internal S-RAM dictionary.
I thought it was a useful option, but specification book did not
state any explanations about this option. It seems, implementation
of this option was possible simply because MSX-WRITEII has word
processor software and S-RAM stuffed in a same cartridge. You
can see this vividly, when you insert a Sony MSX-JE cartridge
and this MSX-WRITE II, MSX-WRITE II boots as word processor software,
while Sony's MSX-JE happens to boot. ;) If you perform S-RAM backup
here, what is backed up is not Sony's, but MSX-WRITE II's internal
SRAM. I was bit disappointed, since I expected functions like
dictionary backups and summary of current dictionary were available.
Because you cannot remember all the terms you have registered,
can you?
A least necessary size of work area
a MSX-JE requests to boot never exceeds 2560 bytes. Therefore,
if your software has limitations on memories, then it's recommended
to allocate 2560 bytes of domain for MSX-JE when the software
boots.
About character colors a STB specifies. STB select character colors using ^Z. This option is supported as follows.
Alignment of character string Character/background color
Editing character string 1FH
Character string subject to conversion F5H
Proceeding bunsetsu 1FH
Bunsetsu that is not converted yet 1FH
If software which have customized
palettes, or software which runs on SCREEN6 displays the MSX-JE
windows in these colors as they are, the outlook will be strange,
so you better let such software do some clever configuration about
these settings and display using color you think suitable.