diff -ur angband-3.0.1.orig/lib/pref/pref-mac.prf angband-3.0.1.trig/lib/pref/pref-mac.prf
--- angband-3.0.1.orig/lib/pref/pref-mac.prf	Sat Jul 13 18:20:40 2002
+++ angband-3.0.1.trig/lib/pref/pref-mac.prf	Sun Jul 14 07:11:44 2002
@@ -7,6 +7,66 @@
 #
 
 
+#
+# Macro Trigger configuration
+#
+# T:<trigger template>:<modifiers>:<modifier name1>:<modifier name2>:....
+# '&' in <trigger template> specifies location of modifier character.
+# '#' in <trigger template> specifies location of key code.
+#
+# If <trigger template> is null string, all trigger difinition will be cleared.
+
+T:&#:CSOX:control-:shift-:option-:command-
+
+# T:<trigger name>:<keycode>:<keycode with shiftkey>
+# '\' in <trigger name> is escape character.
+
+T:KP_Decimal:1
+T:KP_Multiply:3
+T:KP_Add:5
+T:KP_Clear:7
+T:KP_Divide:11
+T:KP_Enter:12
+T:KP_Subtract:14
+T:KP_Equal:17
+T:KP_0:18
+T:KP_1:19
+T:KP_2:20
+T:KP_3:21
+T:KP_4:22
+T:KP_5:23
+T:KP_6:24
+T:KP_7:25
+T:KP_8:27
+T:KP_9:28
+T:F5:32
+T:F6:33
+T:F7:34
+T:F3:35
+T:F8:36
+T:F10:37
+T:F11:39
+T:F13:41
+T:F14:43
+T:F9:45
+T:F12:47
+T:F15:49
+T:Help:50
+T:Home:51
+T:Page_Up:52
+T:Delete:53
+T:F4:54
+T:End:55
+T:F2:56
+T:Page_Down:57
+T:F1:58
+T:Left:59
+T:Right:60
+T:Down:61
+T:Up:62
+
+
+
 ##### Simple Macros #####
 
 
diff -ur angband-3.0.1.orig/lib/pref/pref-win.prf angband-3.0.1.trig/lib/pref/pref-win.prf
--- angband-3.0.1.orig/lib/pref/pref-win.prf	Sat Jul 13 18:20:40 2002
+++ angband-3.0.1.trig/lib/pref/pref-win.prf	Sun Jul 14 07:11:44 2002
@@ -28,6 +28,298 @@
 
 
 #
+# Macro Trigger configuration
+#
+# T:<trigger template>:<modifiers>:<modifier name1>:<modifier name2>:....
+# '&' in <trigger template> specifies location of modifier character.
+# '#' in <trigger template> specifies location of key code.
+#
+# If <trigger template> is null string, all trigger difinition will be cleared.
+
+T:&x#:CSA:control-:shift-:alt-
+
+# T:<trigger name>:<keycode>:<keycode with shiftkey>
+# '\' in <trigger name> is escape character.
+
+# These keycodes are actually direct keyboard scan code taken from the 'dinput.h'.
+
+?:[EQU $KEYBOARD JAPAN]
+# For Japanese keyboard.
+T:-:0C
+T:^:0D
+T:@:1A
+T:[:1B
+T:;:27
+T:\::28
+T:]:2B
+T:,:33
+T:.:34
+T:\/:35
+T:_:73
+?:1
+
+?:[EQU $KEYBOARD 0]
+# For US keyboard.
+T:-:0C
+T:=:0D
+T:[:1A
+T:]:1B
+T:;:27
+T:\':28
+T:`:29
+T:\\:2B
+T:,:33
+T:.:34
+T:\/:35
+?:1
+
+############
+# Common keycodes (except NEC PC-98x1)
+
+?:[NOT [EQU $KEYBOARD NEC98]]
+T:1:02
+T:2:03
+T:3:04
+T:4:05
+T:5:06
+T:6:07
+T:7:08
+T:8:09
+T:9:0A
+T:0:0B
+T:Backspace:0E
+T:Q:10
+T:W:11
+T:E:12
+T:R:13
+T:T:14
+T:Y:15
+T:U:16
+T:I:17
+T:O:18
+T:P:19
+T:Enter:1C
+T:A:1E
+T:S:1F
+T:D:20
+T:F:21
+T:G:22
+T:H:23
+T:J:24
+T:K:25
+T:L:26
+T:Zenkaku_Hankaku:29
+T:Z:2C
+T:X:2D
+T:C:2E
+T:V:2F
+T:B:30
+T:N:31
+T:M:32
+T:KP_Multiply:37
+T:CapsLock:3A
+T:F1:3B
+T:F2:3C
+T:F3:3D
+T:F4:3E
+T:F5:3F
+T:F6:40
+T:F7:41
+T:F8:42
+T:F9:43
+T:F10:44
+T:Numlock:45
+T:Scroll:46
+#T:KP_7:47
+T:Home:47
+#T:KP_8:48
+T:Up:48
+#T:KP_9:49
+T:Page_Up:49
+T:KP_Subtract:4A
+#T:KP_4:4B
+T:Left:4B
+T:KP_5:4C
+#T:KP_6:4D
+T:Right:4D
+T:KP_Add:4E
+#T:KP_1:4F
+T:End:4F
+#T:KP_2:50
+T:Down:50
+#T:KP_3:51
+T:Page_Down:51
+#T:KP_0:52
+T:Insert:52
+#T:KP_Decimal:53
+T:Delete:53
+T:Oem_102:56
+T:F11:57
+T:F12:58
+T:Menu:5D
+T:F13:64
+T:F14:65
+T:F15:66
+T:Hiragana_Katakana:70
+T:Abnt_C1:73
+T:Henkan:79
+T:Muhenkan:7B
+T:Yen:7D
+T:Abnt_C2:7E
+T:KP_equals:8D
+T:Prevtrack:90
+T:Kanji:94
+T:Stop:95
+T:Ax:96
+T:Unlabeled:97
+T:Nexttrack:99
+T:KP_Enter:9C
+T:Mute:A0
+T:Calculator:A1
+T:Playpause:A2
+T:Mediastop:A4
+T:Volumedown:AE
+T:Volumeup:B0
+T:Webhome:B2
+T:KP_Comma:B3
+T:KP_Divide:B5
+T:Sys_Req:B7
+T:Pause:C5
+#T:Home:C7
+#T:Up:C8
+#T:Prior:C9
+#T:Left:CB
+#T:Right:CD
+#T:End:CF
+#T:Down:D0
+#T:Next:D1
+#T:Insert:D2
+#T:Delete:D3
+T:Lwin:DB
+T:Rwin:DC
+T:Apps:DD
+T:Power:DE
+T:Sleep:DF
+T:Wake:E3
+T:Websearch:E5
+T:Webfavorites:E6
+T:Webrefresh:E7
+T:Webstop:E8
+T:Webforward:E9
+T:Webback:EA
+T:Mycomputer:EB
+T:Mail:EC
+T:Mediaselect:ED
+?:1
+
+
+######################
+# For NEC PC-98x1
+
+?:[EQU $KEYBOARD NEC98]
+T:1:01
+T:2:02
+T:3:03
+T:4:04
+T:5:05
+T:6:06
+T:7:07
+T:8:08
+T:9:09
+T:0:0A
+T:-:0B
+T:^:0C
+T:Yen:0D
+T:Backspace:0E
+T:Q:10
+T:W:11
+T:E:12
+T:R:13
+T:T:14
+T:Y:15
+T:U:16
+T:I:17
+T:O:18
+T:P:19
+T:@:1a
+T:[:1b
+T:Enter:1C
+T:A:1D
+T:S:1E
+T:D:1F
+T:F:20
+T:G:21
+T:H:22
+T:J:23
+T:K:24
+T:L:25
+T:;:26
+T:\::27
+T:[:28
+T:Z:29
+T:X:2A
+T:C:2B
+T:V:2C
+T:B:2D
+T:N:2E
+T:M:2F
+T:,:30
+T:.:31
+T:\/:32
+T:_:33
+T:Henkan:35
+T:Page_Down:36
+T:Page_Up:37
+T:Insert:38
+T:Delete:39
+T:Up:3A
+T:Left:3B
+T:Right:3C
+T:Down:3D
+T:Home:3E
+T:End:3F
+T:KP_Subtract:40
+T:KP_Divide:41
+T:KP_7:42
+T:KP_8:43
+T:KP_9:44
+T:KP_Multiply:45
+T:KP_4:46
+T:KP_5:47
+T:KP_6:48
+T:KP_Add:49
+T:KP_1:4A
+T:KP_2:4B
+T:KP_3:4C
+T:KP_Equal:4D
+T:KP_0:4E
+T:KP_Comma:4F
+T:KP_Decimal:50
+T:Muhenkan:51
+T:F11:52
+T:F12:53
+T:F13:54
+T:F14:55
+T:F15:56
+T:Pause:60
+T:F1:62
+T:F2:63
+T:F3:64
+T:F4:65
+T:F5:66
+T:F6:67
+T:F7:68
+T:F8:69
+T:F9:6A
+T:F10:6B
+T:CapsLock:71
+T:Hiragana_Katakana:72
+T:Menu:79
+
+?:[NOT [EQU $KEYBOARD NEC98]]
+
+
+#
 # Hack -- Some foreign keyboards have a special key on the keyboard, which
 # is used to generate the "<", ">", and "|" keys (alone, shifted, alt-ed).
 #
diff -ur angband-3.0.1.orig/lib/pref/pref-x11.prf angband-3.0.1.trig/lib/pref/pref-x11.prf
--- angband-3.0.1.orig/lib/pref/pref-x11.prf	Sat Jul 13 18:20:40 2002
+++ angband-3.0.1.trig/lib/pref/pref-x11.prf	Sun Jul 14 07:11:44 2002
@@ -13,6 +13,217 @@
 
 
 
+#
+# Macro Trigger configuration
+#
+# T:<trigger template>:<modifiers>:<modifier name1>:<modifier name2>:....
+# '&' in <trigger template> specifies location of modifier character.
+# '#' in <trigger template> specifies location of key code.
+#
+# If <trigger template> is null string, all trigger difinition will be cleared.
+
+T:&_#:NSOM:control-:shift-:alt-:mod2-
+
+# T:<trigger name>:<keycode>:<keycode with shiftkey>
+# '\' in <trigger name> is escape character.
+
+T:Clear:FF0B
+T:Pause:FF13
+T:Scroll_Lock:FF14
+T:Sys_Req:FF15
+T:Escape:FF1B
+T:Delete:FFFF
+T:Multi_Key:FF20
+T:Codeinput:FF37
+T:SingleCandidate:FF3C
+T:MultipleCandidate:FF3D
+T:PreviousCandidate:FF3E
+T:Kanji:FF21
+T:Muhenkan:FF22
+T:Henkan:FF23
+T:Henkan_Mode:FF23
+T:Romaji:FF24
+T:Hiragana:FF25
+T:Katakana:FF26
+T:Hiragana_Katakana:FF27
+T:Zenkaku:FF28
+T:Hankaku:FF29
+T:Zenkaku_Hankaku:FF2A
+T:Touroku:FF2B
+T:Massyo:FF2C
+T:Kana_Lock:FF2D
+T:Kana_Shift:FF2E
+T:Eisu_Shift:FF2F
+T:Eisu_Toggle:FF30
+T:Kanji_Bangou:FF37
+T:Zen_Koho:FF3D
+T:Mae_Koho:FF3E
+T:Home:FF50
+T:Left:FF51
+T:Up:FF52
+T:Right:FF53
+T:Down:FF54
+T:Page_Up:FF55
+T:Page_Down:FF56
+T:End:FF57
+T:Begin:FF58
+T:Select:FF60
+T:Print:FF61
+T:Execute:FF62
+T:Insert:FF63
+T:Undo:FF65
+T:Redo:FF66
+T:Menu:FF67
+T:Find:FF68
+T:Cancel:FF69
+T:Help:FF6A
+T:Break:FF6B
+T:Mode_Switch:FF7E
+T:Num_Lock:FF7F
+T:KP_Space:FF80
+T:KP_Tab:FF89
+T:KP_Enter:FF8D
+T:KP_F1:FF91
+T:KP_F2:FF92
+T:KP_F3:FF93
+T:KP_F4:FF94
+T:KP_Home:FF95
+T:KP_Left:FF96
+T:KP_Up:FF97
+T:KP_Right:FF98
+T:KP_Down:FF99
+T:KP_Page_Up:FF9A
+T:KP_Page_Down:FF9B
+T:KP_End:FF9C
+T:KP_Begin:FF9D
+T:KP_Insert:FF9E
+T:KP_Delete:FF9F
+T:KP_Equal:FFBD
+T:KP_Multiply:FFAA
+T:KP_Add:FFAB
+T:KP_Comma:FFAC
+T:KP_Subtract:FFAD
+T:KP_Decimal:FFAE
+T:KP_Divide:FFAF
+T:KP_0:FFB0
+T:KP_1:FFB1
+T:KP_2:FFB2
+T:KP_3:FFB3
+T:KP_4:FFB4
+T:KP_5:FFB5
+T:KP_6:FFB6
+T:KP_7:FFB7
+T:KP_8:FFB8
+T:KP_9:FFB9
+T:F1:FFBE
+T:F2:FFBF
+T:F3:FFC0
+T:F4:FFC1
+T:F5:FFC2
+T:F6:FFC3
+T:F7:FFC4
+T:F8:FFC5
+T:F9:FFC6
+T:F10:FFC7
+T:F11:FFC8
+T:F12:FFC9
+T:F13:FFCA
+T:F14:FFCB
+T:F15:FFCC
+T:F16:FFCD
+T:F17:FFCE
+T:F18:FFCF
+T:F19:FFD0
+T:F20:FFD1
+T:F21:FFD2
+T:F22:FFD3
+T:F23:FFD4
+T:F24:FFD5
+T:F25:FFD6
+T:F26:FFD7
+T:F27:FFD8
+T:F28:FFD9
+T:F29:FFDA
+T:F30:FFDB
+T:F31:FFDC
+T:F32:FFDD
+T:F33:FFDE
+T:F34:FFDF
+T:F35:FFE0
+
+T:\::3A:2A
+T:*:3A:2A
+T:;:3B:2B
+T:+:3B:2B
+T:,:2C:3C
+T:<:2C:3C
+T:-:2D:3D
+T:=:2D:3D
+T:.:2E:3E
+T:>:2E:3E
+T:\/:2F:3F
+T:?:2F:3F
+T:0:30:7E
+T:~:30:7E
+T:1:31:21
+T:!:31:21
+T:2:32:22
+T:":32:22
+T:3:33:23
+T:#:33:23
+T:4:34:24
+T:$:34:24
+T:5:35:25
+T:%:35:25
+T:6:36:26
+T:&:36:26
+T:7:37:27
+T:\':37:27
+T:8:38:28
+T:(:38:28
+T:9:39:29
+T:):39:29
+T:@:40:60
+T:`:40:60
+T:A:61:41
+T:B:62:42
+T:C:63:43
+T:D:64:44
+T:E:65:45
+T:F:66:46
+T:G:67:47
+T:H:68:48
+T:I:69:49
+T:J:6A:4A
+T:K:6B:4B
+T:L:6C:4C
+T:M:6D:4D
+T:N:6E:4E
+T:O:6F:4F
+T:P:70:50
+T:Q:71:51
+T:R:72:52
+T:S:73:53
+T:T:74:54
+T:U:75:55
+T:V:76:56
+T:W:77:57
+T:X:78:58
+T:Y:79:59
+T:Z:7A:5A
+T:[:5B:7B
+T:{:5B:7B
+T:\\:5C:5F
+T:_:5C:5F
+T:]:5D:7D
+T:}:5D:7D
+T:^:5E:7E
+T:~:5E:7E
+T:|:A5:7C
+
+
+
+
 # Keypad (0-9)
 
 A:0
diff -ur angband-3.0.1.orig/src/defines.h angband-3.0.1.trig/src/defines.h
--- angband-3.0.1.orig/src/defines.h	Sat Jul 13 18:20:40 2002
+++ angband-3.0.1.trig/src/defines.h	Sun Jul 14 07:11:44 2002
@@ -2955,6 +2955,12 @@
 #define SOUND_MAX MSG_MAX
 
 
+/*
+ * Maximum number of Macro Trigger Name
+ */
+#define MAX_MACRO_TRIG 200
+#define MAX_MACRO_MOD 12
+
 
 /*** Hack ***/
 
Only in angband-3.0.1.trig/src: defines.h.orig
diff -ur angband-3.0.1.orig/src/externs.h angband-3.0.1.trig/src/externs.h
--- angband-3.0.1.orig/src/externs.h	Sat Jul 13 18:20:40 2002
+++ angband-3.0.1.trig/src/externs.h	Sun Jul 14 07:11:44 2002
@@ -19,6 +19,13 @@
  * Automatically generated "variable" declarations
  */
 
+extern int max_macrotrigger;
+extern char *macro_template;
+extern char *macro_modifier_chr;
+extern char *macro_modifier_name[MAX_MACRO_MOD];
+extern char *macro_trigger_name[MAX_MACRO_TRIG];
+extern char *macro_trigger_keycode[2][MAX_MACRO_TRIG];
+
 /* tables.c */
 extern const s16b ddd[9];
 extern const s16b ddx[10];
@@ -203,6 +210,7 @@
 extern char *flavor_name;
 extern char *flavor_text;
 extern cptr ANGBAND_SYS;
+extern cptr ANGBAND_KEYBOARD;
 extern cptr ANGBAND_GRAF;
 extern cptr ANGBAND_DIR;
 extern cptr ANGBAND_DIR_APEX;
Only in angband-3.0.1.trig/src: externs.h.orig
diff -ur angband-3.0.1.orig/src/files.c angband-3.0.1.trig/src/files.c
--- angband-3.0.1.orig/src/files.c	Sat Jul 13 18:20:40 2002
+++ angband-3.0.1.trig/src/files.c	Sun Jul 14 07:11:44 2002
@@ -478,7 +478,95 @@
 			return (0);
 		}
 	}
+	/* set macro trigger names and a template */
+	/* Process "T:<trigger>:<keycode>:<shift-keycode>" */
+	/* Process "T:<template>:<modifier chr>:<modifier name>:..." */
+	else if (buf[0] == 'T')
+	{
+		int len, tok;
+		tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz);
+		if (tok >= 4)
+		{
+			int i;
+			int num;
+
+			if (macro_template != NULL)
+			{
+				free(macro_template);
+				macro_template = NULL;
+				for (i = 0; i < max_macrotrigger; i++)
+					free(macro_trigger_name[i]);
+				max_macrotrigger = 0;
+			}
+			
+			if (*zz[0] == '\0') return 0; /* clear template */
+			num = strlen(zz[1]);
+			if (2 + num != tok) return 1; /* error */
+
+			len = strlen(zz[0])+1+num+1;
+			for (i = 0; i < num; i++)
+				len += strlen(zz[2+i])+1;
+			macro_template = malloc(len);
+
+			strcpy(macro_template, zz[0]);
+			macro_modifier_chr =
+				macro_template + strlen(macro_template) + 1;
+			strcpy(macro_modifier_chr, zz[1]);
+			macro_modifier_name[0] =
+				macro_modifier_chr + strlen(macro_modifier_chr) + 1;
+			for (i = 0; i < num; i++)
+			{
+				strcpy(macro_modifier_name[i], zz[2+i]);
+				macro_modifier_name[i+1] = macro_modifier_name[i] + 
+					strlen(macro_modifier_name[i]) + 1;
+			}
+		}
+		else if (tok >= 2)
+		{
+			int m;
+			char *t, *s;
+			if (max_macrotrigger >= MAX_MACRO_TRIG)
+			{
+#ifdef JP
+				msg_print("�ޥ����ȥꥬ�������꤬¿�����ޤ�!");
+#else
+				msg_print("Too many macro triggers!");
+#endif
+				return 1;
+			}
+			m = max_macrotrigger;
+			max_macrotrigger++;
+
+			len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
+			if (tok == 3)
+				len += strlen(zz[2]) + 1;
+			macro_trigger_name[m] = malloc(len);
+
+			t = macro_trigger_name[m];
+			s = zz[0];
+			while (*s)
+			{
+				if ('\\' == *s) s++;
+				*t++ = *s++;
+			}
+			*t = '\0';
 
+			macro_trigger_keycode[0][m] = macro_trigger_name[m] +
+				strlen(macro_trigger_name[m]) + 1;
+			strcpy(macro_trigger_keycode[0][m], zz[1]);
+			if (tok == 3)
+			{
+				macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
+					strlen(macro_trigger_keycode[0][m]) + 1;
+				strcpy(macro_trigger_keycode[1][m], zz[2]);
+			}
+			else
+			{
+				macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
+			}
+		}
+		return 0;
+	}
 
 	/* Process "X:<str>" -- turn option off */
 	else if (buf[0] == 'X')
@@ -737,6 +825,11 @@
 				v = ANGBAND_SYS;
 			}
 
+                        else if (streq(b+1, "KEYBOARD"))
+                        {
+                                v = ANGBAND_KEYBOARD;
+                        }
+
 			/* Graphics */
 			else if (streq(b+1, "GRAF"))
 			{
diff -ur angband-3.0.1.orig/src/main-win.c angband-3.0.1.trig/src/main-win.c
--- angband-3.0.1.orig/src/main-win.c	Sat Jul 13 17:26:09 2002
+++ angband-3.0.1.trig/src/main-win.c	Sun Jul 14 07:11:44 2002
@@ -603,7 +603,33 @@
  * Hack -- define which keys are "special"
  */
 static bool special_key[256];
+static bool ignore_key[256];
 
+#if 1
+/*
+ * Hack -- initialization list for "special_key"
+ */
+static byte special_key_list[] = {
+VK_CLEAR,VK_PAUSE,VK_CAPITAL,VK_KANA,VK_JUNJA,VK_FINAL,VK_KANJI,
+VK_CONVERT,VK_NONCONVERT,VK_ACCEPT,VK_MODECHANGE,
+VK_PRIOR,VK_NEXT,VK_END,VK_HOME,VK_LEFT,VK_UP,VK_RIGHT,VK_DOWN,
+VK_SELECT,VK_PRINT,VK_EXECUTE,VK_SNAPSHOT,VK_INSERT,VK_DELETE,
+VK_HELP,VK_APPS,
+VK_F1,VK_F2,VK_F3,VK_F4,VK_F5,VK_F6,VK_F7,VK_F8,VK_F9,VK_F10,
+VK_F11,VK_F12,VK_F13,VK_F14,VK_F15,VK_F16,VK_F17,VK_F18,VK_F19,VK_F20,
+VK_F21,VK_F22,VK_F23,VK_F24,VK_NUMLOCK,VK_SCROLL,
+VK_ATTN,VK_CRSEL,VK_EXSEL,VK_EREOF,VK_PLAY,VK_ZOOM,VK_NONAME,
+VK_PA1,0
+};
+
+static byte ignore_key_list[] = {
+VK_ESCAPE,VK_TAB,VK_SPACE,
+'F','W','O','H', /* these are menu characters.*/
+VK_SHIFT,VK_CONTROL,VK_MENU,VK_LWIN,VK_RWIN,
+VK_LSHIFT,VK_RSHIFT,VK_LCONTROL,VK_RCONTROL,VK_LMENU,VK_RMENU,0
+};
+
+#else
 /*
  * Hack -- initialization list for "special_key"
  *
@@ -683,6 +709,7 @@
 
 	0
 };
+#endif
 
 #if 0
 /*
@@ -3965,7 +3992,7 @@
 			if (GetKeyState(VK_MENU)    & 0x8000) ma = TRUE;
 
 			/* Handle "special" keys */
-			if (special_key[(byte)(wParam)])
+			if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
 			{
 				/* Begin the macro trigger */
 				Term_keypress(31);
@@ -4361,7 +4388,7 @@
 			if (GetKeyState(VK_MENU)    & 0x8000) ma = TRUE;
 
 			/* Handle "special" keys */
-			if (special_key[(byte)(wParam)])
+			if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
 			{
 				/* Begin the macro trigger */
 				Term_keypress(31);
@@ -5019,6 +5046,27 @@
 	/* Set the system suffix */
 	ANGBAND_SYS = "win";
 
+
+	/* Set the keyboard suffix */
+	if (7 != GetKeyboardType(0))
+		ANGBAND_KEYBOARD = "0";
+	else
+	{
+		/* Japanese keyboard */
+		switch (GetKeyboardType(1))
+		{
+		case 0x0D01: case 0x0D02:
+		case 0x0D03: case 0x0D04:
+		case 0x0D05: case 0x0D06:
+			/* NEC PC-98x1 */
+			ANGBAND_KEYBOARD = "NEC98";
+			break;
+		default:
+			/* PC/AT */
+			ANGBAND_KEYBOARD = "JAPAN";
+		}
+	}
+
 	/* Initialize */
 	init_angband();
 
@@ -5049,6 +5097,11 @@
 		TranslateMessage(&msg);
 		DispatchMessage(&msg);
 	}
+	/* Initialize the keypress analyzer */
+	for (i = 0; ignore_key_list[i]; ++i)
+	{
+		ignore_key[ignore_key_list[i]] = TRUE;
+	}
 
 	/* Paranoia */
 	quit(NULL);
Only in angband-3.0.1.trig/src: main-win.c.orig
diff -ur angband-3.0.1.orig/src/util.c angband-3.0.1.trig/src/util.c
--- angband-3.0.1.orig/src/util.c	Sun Jul 14 00:06:32 2002
+++ angband-3.0.1.trig/src/util.c	Sun Jul 14 07:11:44 2002
@@ -830,6 +830,166 @@
 }
 
 
+static int my_stricmp(cptr a, cptr b)
+{
+	cptr s1, s2;
+	char z1, z2;
+
+	/* Scan the strings */
+	for (s1 = a, s2 = b; TRUE; s1++, s2++)
+	{
+		z1 = FORCEUPPER(*s1);
+		z2 = FORCEUPPER(*s2);
+		if (z1 < z2) return (-1);
+		if (z1 > z2) return (1);
+		if (!z1) return (0);
+	}
+}
+
+static int my_strnicmp(cptr a, cptr b, int n)
+{
+	cptr s1, s2;
+	char z1, z2;
+
+	/* Scan the strings */
+	for (s1 = a, s2 = b; n > 0; s1++, s2++, n--)
+	{
+		z1 = FORCEUPPER(*s1);
+		z2 = FORCEUPPER(*s2);
+		if (z1 < z2) return (-1);
+		if (z1 > z2) return (1);
+		if (!z1) return (0);
+	}
+	return 0;
+}
+
+
+/*
+ * Transform macro trigger name ('\[alt-D]' etc..)
+ * into macro trigger key code ('^_O_64\r' or etc..) 
+ */
+static void trigger_text_to_ascii(char **bufptr, cptr *strptr)
+{
+	char *s = *bufptr;
+	cptr str = *strptr;
+	bool mod_status[MAX_MACRO_MOD];
+
+	int i, len = 0;
+	int shiftstatus = 0;
+	cptr key_code;
+
+        /* You don't have difinition of trigger names */
+	if (macro_template == NULL)
+		return;
+
+        /* Initialize modifier key status */	
+	for (i = 0; macro_modifier_chr[i]; i++)
+		mod_status[i] = FALSE;
+	str++;
+
+	/* Examine modifier keys */
+	while (1)
+	{
+                /* Look for modifier key name */
+		for (i=0; macro_modifier_chr[i]; i++)
+		{
+			len = strlen(macro_modifier_name[i]);
+			
+			if(!my_strnicmp(str, macro_modifier_name[i], len))
+				break;
+		}
+
+                /* None found? */
+		if (!macro_modifier_chr[i]) break;
+
+                /* Proceed */
+		str += len;
+
+                /* This modifier key is pressed */
+		mod_status[i] = TRUE;
+
+                /* Shift key might be going to change keycode */
+		if ('S' == macro_modifier_chr[i])
+			shiftstatus = 1;
+	}
+
+        /* Look for trigger name */
+	for (i = 0; i < max_macrotrigger; i++)
+	{
+		len = strlen(macro_trigger_name[i]);
+
+                /* Found it and it is ending with ']' */
+		if (!my_strnicmp(str, macro_trigger_name[i], len) && ']' == str[len])
+		{
+			/* a trigger name found */
+			break;
+		}
+	}
+
+	/* Invalid trigger name? */
+	if (i == max_macrotrigger)
+	{
+                /*
+                 * If this invalid trigger name is ending with ']', 
+                 * skip whole of it to avoid defining strange macro trigger
+                 */
+		str = strchr(str, ']');
+		if (str)
+		{
+			*s++ = (char)31;
+			*s++ = '\r';
+			*bufptr = s;
+			*strptr = str; /* where **strptr == ']' */
+		}
+		return;
+	}
+
+        /* Get keycode for this trigger name */
+	key_code = macro_trigger_keycode[shiftstatus][i];
+
+        /* Proceed */
+	str += len;
+
+        /* Beggin with '^_' */
+	*s++ = (char)31;
+
+        /* Write key code style trigger using template */
+	for (i = 0; macro_template[i]; i++)
+	{
+		char ch = macro_template[i];
+		int j;
+
+		switch(ch)
+		{
+		case '&':
+                        /* Modifier key character */
+			for (j = 0; macro_modifier_chr[j]; j++) {
+				if (mod_status[j])
+					*s++ = macro_modifier_chr[j];
+			}
+			break;
+		case '#':
+                        /* Key code */
+			strcpy(s, key_code);
+			s += strlen(key_code);
+			break;
+		default:
+                        /* Fixed string */
+			*s++ = ch;
+			break;
+		}
+	}
+
+        /* End with '\r' */
+	*s++ = '\r';
+
+        /* Succeed */
+	*bufptr = s;
+	*strptr = str; /* where **strptr == ']' */
+	return;
+}
+
+
 /*
  * Hack -- convert a printable string into real ascii
  *
@@ -856,6 +1016,13 @@
 			/* Paranoia */
 			if (!(*str)) break;
 
+                        /* Macro Trigger */
+			if (*str == '[')
+			{
+				trigger_text_to_ascii(&s, &str);
+			}
+			else
+
 			/* Hack -- simple way to specify Escape */
 			if (*str == 'e')
 			{
@@ -952,6 +1119,86 @@
 
 
 /*
+ * Transform macro trigger key code ('^_O_64\r' or etc..) 
+ * into macro trigger name ('\[alt-D]' etc..)
+ */
+static bool trigger_ascii_to_text(char **bufptr, cptr *strptr)
+{
+	char *s = *bufptr;
+	cptr str = *strptr;
+	char key_code[100];
+	int i;
+	cptr tmp;
+
+        /* You don't have difinition of trigger names */
+	if (macro_template == NULL)
+		return FALSE;
+
+        /* Trigger name will be written as '\[name]' */
+	*s++ = '\\';
+	*s++ = '[';
+
+        /* Use template to read key-code style trigger */
+	for (i = 0; macro_template[i]; i++)
+	{
+		int j;
+		char ch = macro_template[i];
+
+		switch(ch)
+		{
+		case '&':
+                        /* Read modifier */
+			while ((tmp = strchr(macro_modifier_chr, *str)))
+			{
+				j = (int)(tmp - macro_modifier_chr);
+				tmp = macro_modifier_name[j];
+				while(*tmp) *s++ = *tmp++;
+				str++;
+			}
+			break;
+		case '#':
+                        /* Read key code */
+			for (j = 0; *str && *str != '\r'; j++)
+				key_code[j] = *str++;
+			key_code[j] = '\0';
+			break;
+		default:
+                        /* Skip fixed strings */
+			if (ch != *str) return FALSE;
+			str++;
+		}
+	}
+
+        /* Key code style triggers always end with '\r' */
+	if (*str++ != '\r') return FALSE;
+
+        /* Look for trigger name with given keycode (normal or shifted keycode) */
+	for (i = 0; i < max_macrotrigger; i++)
+	{
+		if (!my_stricmp(key_code, macro_trigger_keycode[0][i])
+		    || !my_stricmp(key_code, macro_trigger_keycode[1][i]))
+			break;
+	}
+
+        /* Didn't found? */
+	if (i == max_macrotrigger)
+		return FALSE;
+
+        /* Write trigger name */
+	tmp = macro_trigger_name[i];
+	while (*tmp) *s++ = *tmp++;
+
+        /* Now trigger name is written as '\[name]' */
+	*s++ = ']';
+
+ 	/* Succeed */
+	*bufptr = s;
+	*strptr = str;
+	return TRUE;
+}
+
+
+/*
  * Hack -- convert a string into a printable form
  *
  * This function will not work on non-ascii systems.
@@ -1014,6 +1261,17 @@
 			*s++ = '\\';
 			*s++ = '^';
 		}
+
+		/* Macro Trigger */
+		else if (i == 31)
+		{
+			if(!trigger_ascii_to_text(&s, &str))
+			{
+				*s++ = '^';
+				*s++ = '_';
+			}
+		}
+
 		else if (i < 32)
 		{
 			*s++ = '^';
Only in angband-3.0.1.trig/src: util.c.orig
diff -ur angband-3.0.1.orig/src/variable.c angband-3.0.1.trig/src/variable.c
--- angband-3.0.1.orig/src/variable.c	Sat Jul 13 18:20:41 2002
+++ angband-3.0.1.trig/src/variable.c	Sun Jul 14 07:11:44 2002
@@ -184,6 +184,12 @@
 	"Term-7"
 };
 
+int max_macrotrigger = 0;
+char *macro_template = NULL;
+char *macro_modifier_chr;
+char *macro_modifier_name[MAX_MACRO_MOD];
+char *macro_trigger_name[MAX_MACRO_TRIG];
+char *macro_trigger_keycode[2][MAX_MACRO_TRIG];
 
 /*
  * Global table of color definitions (mostly zeros)
@@ -544,6 +550,16 @@
 cptr ANGBAND_SYS = "xxx";
 
 /*
+ * Hack -- The special Angband "Keyboard Suffix"
+ * This variable is used to choose an appropriate macro-trigger definition
+ */
+#ifdef JP
+cptr ANGBAND_KEYBOARD = "JAPAN";
+#else
+cptr ANGBAND_KEYBOARD = "0";
+#endif
+
+/*
  * Hack -- The special Angband "Graphics Suffix"
  * This variable is used to choose an appropriate "graf-xxx" file
  */
Only in angband-3.0.1.trig/src: variable.c.orig
