/*-
 * Copyright (c) 2000-2001
 * Tatsuya Kudoh(CDR/TK),ROYALPANDA.    All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include<stdlib.h>
#include<sys/bios.h>

#include"pietable.h"
#include"keycode.h"

#pragma noregalo


/***********************
*
* main pie
*
************************


/* 2nd pies */

/*
** control code
*/

static pieent_t Menu_hira_ctrl[9] = {
    {"カナ",KEYSTR_KATAKANA}, {"英数",KEYSTR_ASCII},   {NULL,NULL},
    {"後退",KEYSTR_BACKSPACE},{"タブ",KEYSTR_TAB},     {"空白",KEYSTR_SPACE},
    {"行頭",KEYSTR_HOME},     {"改行",KEYSTR_RETURN},  {"行末",KEYSTR_END},
};

static pieent_t Menu_kata_ctrl[9] = {
    {NULL,NULL},              {"英数",KEYSTR_ASCII},   {"かな",KEYSTR_HIRAGANA},
    {"後退",KEYSTR_BACKSPACE},{"タブ",KEYSTR_TAB},     {"空白",KEYSTR_SPACE},
    {"行頭",KEYSTR_HOME},     {"改行",KEYSTR_RETURN},  {"行末",KEYSTR_END},
};

static pieent_t Menu_asc_ctrl[9] = {
    {"カナ",KEYSTR_KATAKANA}, {NULL,NULL},             {"かな",KEYSTR_HIRAGANA},
    {"後退",KEYSTR_BACKSPACE},{"タブ",KEYSTR_TAB},     {"空白",KEYSTR_SPACE},
    {"行頭",KEYSTR_HOME},     {"改行",KEYSTR_RETURN},  {"行末",KEYSTR_END},
};



/*
** hiragana/normal
*/

static pieent_t Menu_hira_k[9] = {
	{"きゃ"	,NULL},	{"き"	,NULL},	{NULL	,NULL},
	{"く"	,NULL},	{"か"	,NULL},	{"こ"	,NULL},
	{"きゅ"	,NULL},	{"け"	,NULL},	{"きょ"	,NULL},
};

static pieent_t Menu_hira_a[9] = {
	{"ー"	,NULL},	{"い"	,NULL},	{NULL	,NULL},
	{"う"	,NULL},	{"あ"	,NULL},	{"お"	,NULL},
	{"。"	,NULL},	{"え"	,NULL},	{"、"	,NULL},
};

static pieent_t Menu_hira_y[9] = {
	{"ん"	,NULL},	{"わ"	,NULL},	{"っ"	,NULL},
	{"ゆ"	,NULL},	{"や"	,NULL},	{"よ"	,NULL},
	{NULL	,NULL},	{"を"	,NULL},	{"・"	,NULL},
};
static pieent_t Menu_hira_s[9] = {
	{"しゃ"	,NULL},	{"し"	,NULL},	{NULL	,NULL},
	{"す"	,NULL},	{"さ"	,NULL},	{"そ"	,NULL},
	{"しゅ"	,NULL},	{"せ"	,NULL},	{"しょ"	,NULL},
};

static pieent_t Menu_hira_m[9] = {
	{"みゃ"	,NULL},	{"み"	,NULL},	{NULL	,NULL},
	{"む"	,NULL},	{"ま"	,NULL},	{"も"	,NULL},
	{"みゅ"	,NULL},	{"め"	,NULL},	{"みょ"	,NULL},
};

static pieent_t Menu_hira_t[9] = {
	{"ちゃ"	,NULL},	{"ち"	,NULL},	{NULL	,NULL},
	{"つ"	,NULL},	{"た"	,NULL},	{"と"	,NULL},
	{"ちゅ"	,NULL},	{"て"	,NULL},	{"ちょ"	,NULL},
};

static pieent_t Menu_hira_n[9] = {
	{"にゃ"	,NULL},	{"に"	,NULL},	{NULL	,NULL},
	{"ぬ"	,NULL},	{"な"	,NULL},	{"の"	,NULL},
	{"にゅ"	,NULL},	{"ね"	,NULL},	{"にょ"	,NULL},
};

static pieent_t Menu_hira_h[9] = {
	{"ひゃ"	,NULL},	{"ひ"	,NULL},	{NULL	,NULL},
	{"ふ"	,NULL},	{"は"	,NULL},	{"ほ"	,NULL},
	{"ひゅ"	,NULL},	{"へ"	,NULL},	{"ひょ"	,NULL},
};


/*
** hiragana/shifted
*/

static pieent_t Menu_hira_g[9] = {
	{"ぎゃ"	,NULL},	{"ぎ"	,NULL},	{NULL	,NULL},
	{"ぐ"	,NULL},	{"が"	,NULL},	{"ご"	,NULL},
	{"ぎゅ"	,NULL},	{"げ"	,NULL},	{"ぎょ"	,NULL},
};

static pieent_t Menu_hira_r[9] = {
	{"りゃ"	,NULL},	{"り"	,NULL},	{NULL	,NULL},
	{"る"	,NULL},	{"ら"	,NULL},	{"ろ"	,NULL},
	{"りゅ"	,NULL},	{"れ"	,NULL},	{"りょ"	,NULL},
};

static pieent_t Menu_hira_x[9] = {
	{"「"	,NULL},	{"ぃ"	,NULL},	{"」"	,NULL},
	{"ぅ"	,NULL},	{"ぁ"	,NULL},	{"ぉ"	,NULL},
	{NULL	,NULL},	{"ぇ"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_hira_z[9] = {
	{"じゃ"	,NULL},	{"じ"	,NULL},	{NULL	,NULL},
	{"ず"	,NULL},	{"ざ"	,NULL},	{"ぞ"	,NULL},
	{"じゅ"	,NULL},	{"ぜ"	,NULL},	{"じょ"	,NULL},
};

static pieent_t Menu_hira_d[9] = {
	{"ぢゃ"	,NULL},	{"ぢ"	,NULL},	{NULL	,NULL},
	{"づ"	,NULL},	{"だ"	,NULL},	{"ど"	,NULL},
	{"ぢゅ"	,NULL},	{"で"	,NULL},	{"ぢょ"	,NULL},
};

static pieent_t Menu_hira_b[9] = {
	{"びゃ"	,NULL},	{"び"	,NULL},	{NULL	,NULL},
	{"ぶ"	,NULL},	{"ば"	,NULL},	{"ぼ"	,NULL},
	{"びゅ"	,NULL},	{"べ"	,NULL},	{"びょ"	,NULL},
};

static pieent_t Menu_hira_p[9] = {
	{"ぴゃ"	,NULL},	{"ぴ"	,NULL},	{NULL	,NULL},
	{"ぷ"	,NULL},	{"ぱ"	,NULL},	{"ぽ"	,NULL},
	{"ぴゅ"	,NULL},	{"ぺ"	,NULL},	{"ぴょ"	,NULL},
};


/*
** katakana/normal
*/

static pieent_t Menu_kata_k[9] = {
	{"キャ"	,NULL},	{"キ"	,NULL},	{NULL	,NULL},
	{"ク"	,NULL},	{"カ"	,NULL},	{"コ"	,NULL},
	{"キュ"	,NULL},	{"ケ"	,NULL},	{"キョ"	,NULL},
};

static pieent_t Menu_kata_a[9] = {
	{"ー"	,NULL},	{"イ"	,NULL},	{NULL	,NULL},
	{"ウ"	,NULL},	{"ア"	,NULL},	{"オ"	,NULL},
	{"、"	,NULL},	{"エ"	,NULL},	{"。"	,NULL},
};

static pieent_t Menu_kata_y[9] = {
	{"ン"	,NULL},	{"ワ"	,NULL},	{"ッ"	,NULL},
	{"ユ"	,NULL},	{"ヤ"	,NULL},	{"ヨ"	,NULL},
	{NULL	,NULL},	{"ヲ"	,NULL},	{"・"	,NULL},
};
static pieent_t Menu_kata_s[9] = {
	{"シャ"	,NULL},	{"シ"	,NULL},	{NULL	,NULL},
	{"ス"	,NULL},	{"サ"	,NULL},	{"ソ"	,NULL},
	{"シュ"	,NULL},	{"セ"	,NULL},	{"ショ"	,NULL},
};

static pieent_t Menu_kata_m[9] = {
	{"ミャ"	,NULL},	{"ミ"	,NULL},	{NULL	,NULL},
	{"ム"	,NULL},	{"マ"	,NULL},	{"モ"	,NULL},
	{"ミュ"	,NULL},	{"メ"	,NULL},	{"ミョ"	,NULL},
};

static pieent_t Menu_kata_t[9] = {
	{"チャ"	,NULL},	{"チ"	,NULL},	{NULL	,NULL},
	{"ツ"	,NULL},	{"タ"	,NULL},	{"ト"	,NULL},
	{"チュ"	,NULL},	{"テ"	,NULL},	{"チョ"	,NULL},
};

static pieent_t Menu_kata_n[9] = {
	{"ニャ"	,NULL},	{"ニ"	,NULL},	{NULL	,NULL},
	{"ヌ"	,NULL},	{"ナ"	,NULL},	{"ノ"	,NULL},
	{"ニュ"	,NULL},	{"ネ"	,NULL},	{"ニョ"	,NULL},
};

static pieent_t Menu_kata_h[9] = {
	{"ヒャ"	,NULL},	{"ヒ"	,NULL},	{NULL	,NULL},
	{"フ"	,NULL},	{"ハ"	,NULL},	{"ホ"	,NULL},
	{"ヒュ"	,NULL},	{"ヘ"	,NULL},	{"ヒョ"	,NULL},
};


/*
** katakana/shifted
*/

static pieent_t Menu_kata_g[9] = {
	{"ギャ"	,NULL},	{"ギ"	,NULL},	{NULL	,NULL},
	{"グ"	,NULL},	{"ガ"	,NULL},	{"ゴ"	,NULL},
	{"ギュ"	,NULL},	{"ゲ"	,NULL},	{"ギョ"	,NULL},
};

static pieent_t Menu_kata_r[9] = {
	{"リャ"	,NULL},	{"リ"	,NULL},	{NULL	,NULL},
	{"ル"	,NULL},	{"ラ"	,NULL},	{"ロ"	,NULL},
	{"リュ"	,NULL},	{"レ"	,NULL},	{"リョ"	,NULL},
};

static pieent_t Menu_kata_x[9] = {
	{"「"	,NULL},	{"ィ"	,NULL},	{"」"	,NULL},
	{"ゥ"	,NULL},	{"ァ"	,NULL},	{"ォ"	,NULL},
	{NULL	,NULL},	{"ェ"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_kata_z[9] = {
	{"ジャ"	,NULL},	{"ジ"	,NULL},	{NULL	,NULL},
	{"ズ"	,NULL},	{"ザ"	,NULL},	{"ゾ"	,NULL},
	{"ジュ"	,NULL},	{"ゼ"	,NULL},	{"ジョ"	,NULL},
};

static pieent_t Menu_kata_d[9] = {
	{"ヂャ"	,NULL},	{"ヂ"	,NULL},	{NULL	,NULL},
	{"ヅ"	,NULL},	{"ダ"	,NULL},	{"ド"	,NULL},
	{"ヂュ"	,NULL},	{"デ"	,NULL},	{"ヂョ"	,NULL},
};

static pieent_t Menu_kata_b[9] = {
	{"ビャ"	,NULL},	{"ビ"	,NULL},	{NULL	,NULL},
	{"ブ"	,NULL},	{"バ"	,NULL},	{"ボ"	,NULL},
	{"ビュ"	,NULL},	{"ベ"	,NULL},	{"ビョ"	,NULL},
};

static pieent_t Menu_kata_p[9] = {
	{"ピャ"	,NULL},	{"ピ"	,NULL},	{NULL	,NULL},
	{"プ"	,NULL},	{"パ"	,NULL},	{"ポ"	,NULL},
	{"ピュ"	,NULL},	{"ペ"	,NULL},	{"ピョ"	,NULL},
};


/*
** ascii/normal
*/

static pieent_t Menu_asc_a[9] = {
	{NULL	,NULL},	{"b"	,NULL},	{NULL	,NULL},
	{"c"	,NULL},	{"a"	,NULL},	{"e"	,NULL},
	{NULL	,NULL},	{"d"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_asc_6[9] = {
	{"-"	,NULL},	{"7"	,NULL},	{NULL	,NULL},
	{"8"	,NULL},	{"6"	,NULL},	{"0"	,NULL},
	{"="	,NULL},	{"9"	,NULL},	{"\\"	,NULL},
};

static pieent_t Menu_asc_f[9] = {
	{","	,NULL},	{"g"	,NULL},	{NULL	,NULL},
	{"h"	,NULL},	{"f"	,NULL},	{"j"	,NULL},
	{"."	,NULL},	{"i"	,NULL},	{";"	,NULL},
};

static pieent_t Menu_asc_1[9] = {
	{"["	,NULL},	{"2"	,NULL},	{"]"	,NULL},
	{"3"	,NULL},	{"1"	,NULL},	{"5"	,NULL},
	{NULL	,NULL},	{"4"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_asc_k[9] = {
	{NULL	,NULL},	{"l"	,NULL},	{NULL	,NULL},
	{"m"	,NULL},	{"k"	,NULL},	{"o"	,NULL},
	{NULL	,NULL},	{"n"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_asc_p[9] = {
	{"'"	,NULL},	{"q"	,NULL},	{NULL	,NULL},
	{"r"	,NULL},	{"p"	,NULL},	{"t"	,NULL},
	{"`"	,NULL},	{"s"	,NULL},	{"/"	,NULL},
};

static pieent_t Menu_asc_u[9] = {
	{NULL	,NULL},	{"v"	,NULL},	{NULL	,NULL},
	{"w"	,NULL},	{"u"	,NULL},	{"z"	,NULL},
	{"x"	,NULL},	{"y"	,NULL},	{NULL	,NULL},
};


/*
** ascii/shifted
*/

static pieent_t Menu_asc_A[9] = {
	{NULL	,NULL},	{"B"	,NULL},	{NULL	,NULL},
	{"C"	,NULL},	{"A"	,NULL},	{"E"	,NULL},
	{NULL	,NULL},	{"D"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_asc_6s[9] = {
	{"_"	,NULL},	{"&"	,NULL},	{NULL	,NULL},
	{"*"	,NULL},	{"^"	,NULL},	{")"	,NULL},
	{"+"	,NULL},	{"("	,NULL},	{"|"	,NULL},
};

static pieent_t Menu_asc_F[9] = {
	{"<"	,NULL},	{"G"	,NULL},	{NULL	,NULL},
	{"H"	,NULL},	{"F"	,NULL},	{"J"	,NULL},
	{">"	,NULL},	{"I"	,NULL},	{":"	,NULL},
};

static pieent_t Menu_asc_1s[9] = {
	{"{"	,NULL},	{"@"	,NULL},	{"}"	,NULL},
	{"#"	,NULL},	{"!"	,NULL},	{"%"	,NULL},
	{NULL	,NULL},	{"$"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_asc_K[9] = {
	{NULL	,NULL},	{"L"	,NULL},	{NULL	,NULL},
	{"M"	,NULL},	{"K"	,NULL},	{"O"	,NULL},
	{NULL	,NULL},	{"N"	,NULL},	{NULL	,NULL},
};

static pieent_t Menu_asc_P[9] = {
	{"\""	,NULL},	{"Q"	,NULL},	{NULL	,NULL},
	{"R"	,NULL},	{"P"	,NULL},	{"T"	,NULL},
	{"~"	,NULL},	{"S"	,NULL},	{"?"	,NULL},
};

static pieent_t Menu_asc_U[9] = {
	{NULL	,NULL},	{"V"	,NULL},	{NULL	,NULL},
	{"W"	,NULL},	{"U"	,NULL},	{"Z"	,NULL},
	{"X"	,NULL},	{"Y"	,NULL},	{NULL	,NULL},
};


/*
** 1st pies
*/

static pieent_t Menu_hira_0[9] = {
	{"か",Menu_hira_k},	{"あ",Menu_hira_a},	{"や",Menu_hira_y},
	{"さ",Menu_hira_s},	{NULL	,NULL},		{"制御",Menu_hira_ctrl},
	{"た",Menu_hira_t},	{"な",Menu_hira_n},	{"は",Menu_hira_h},
};

static pieent_t Menu_hira_1[9] = {
	{"が",Menu_hira_g},	{"ら",Menu_hira_r},	{"ぁ",Menu_hira_x},
	{"ざ",Menu_hira_z},	{NULL,NULL},		{"ま",Menu_hira_m},
	{"だ",Menu_hira_d},	{"ぱ",Menu_hira_p},	{"ば",Menu_hira_b},
};

static pieent_t Menu_kata_0[9] = {
	{"カ",Menu_kata_k},	{"ア",Menu_kata_a},	{"ヤ",Menu_kata_y},
	{"サ",Menu_kata_s},	{NULL	,NULL},		{"制御",Menu_kata_ctrl},
	{"タ",Menu_kata_t},	{"ナ",Menu_kata_n},	{"ハ",Menu_kata_h},
};

static pieent_t Menu_kata_1[9] = {
	{"ガ",Menu_kata_g},	{"ラ",Menu_kata_r},	{"ァ",Menu_kata_x},
	{"ザ",Menu_kata_z},	{NULL,NULL},		{"マ",Menu_kata_m},
	{"ダ",Menu_kata_d},	{"パ",Menu_kata_p},	{"バ",Menu_kata_b},
};


static pieent_t Menu_ascii_0[9] = {
	{"a",Menu_asc_a},	{"6",Menu_asc_6},	{"1",Menu_asc_1},
	{"f",Menu_asc_f},	{NULL	,NULL},		{"制御",Menu_asc_ctrl},
	{"k",Menu_asc_k},	{"p",Menu_asc_p},	{"u",Menu_asc_u},
};


static pieent_t Menu_ascii_1[9] = {
	{"A",Menu_asc_A},	{"^",Menu_asc_6s},	{"!",Menu_asc_1s},
	{"F",Menu_asc_F},	{NULL	,NULL},		{"制御",Menu_asc_ctrl},
	{"K",Menu_asc_K},	{"P",Menu_asc_P},	{"U",Menu_asc_U},
};

/*
** Pies
*/

pieent_t *PieTable[3][2] = {
	{ Menu_hira_0, Menu_hira_1,},
	{ Menu_kata_0, Menu_kata_1,},
	{ Menu_ascii_0, Menu_ascii_1,},
};

