--- lisp/mule/mule-coding.el.orig	Wed Nov 19 06:51:51 1997
+++ lisp/mule/mule-coding.el	Thu May  7 09:56:09 1998
@@ -104,6 +104,7 @@
   (interactive "zterminal-coding-system: ")
   (get-coding-system coding-system) ; correctness check
   (setq terminal-coding-system coding-system)
+  (set-console-tty-coding-system (device-console) terminal-coding-system)
   (redraw-modeline t))
 
 (defun set-pathname-coding-system (coding-system)
--- lisp/mule/mule-tty-init.el.orig	Thu May  7 10:01:00 1998
+++ lisp/mule/mule-tty-init.el	Thu May  7 10:01:00 1998
@@ -0,0 +1,43 @@
+;;; mule-tty-init.el --- Initialization code for console tty under MULE
+
+;; Copyright (C) 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1998 Kazuyuki IENAGA <kazz@imasy.or.jp>
+
+;; Author: Kazuyuki IENAGA <kazz@imasy.or.jp>
+;; Keywords: mule, tty, console, dumped
+
+;; This file is part of XEmacs.
+;;
+;; XEmacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; XEmacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file is dumped with XEmacs when Mule and TTY support are enabled.
+
+;;; Code:
+
+(defvar mule-tty-win-initted nil)
+
+(defun init-mule-tty-win ()
+  "Initialize TTY for MULE at startup. Don't call this."
+  (unless mule-tty-win-initted
+    (add-hook 'after-init-hook
+	      (lambda ()
+		(set-console-tty-coding-system
+		 (selected-console) terminal-coding-system)))
+    (setq mule-tty-win-initted t)))
+
+;;; mule-tty-init.el ends here
--- lisp/prim/dumped-lisp.el.orig	Mon Feb  2 14:46:58 1998
+++ lisp/prim/dumped-lisp.el	Thu May  7 09:59:41 1998
@@ -119,6 +119,7 @@
 	#+mule "mule-misc"
 	#+mule "kinsoku"
 	#+(and mule x) "mule-x-init"
+	#+(and mule tty) "mule-tty-init"
 	#+mule "mule-cmds" ; to sync with Emacs 20.1
 
 ;; after this goes the specific lisp routines for a particular input system
--- lisp/term/tty-init.el.orig	Thu Dec 19 07:42:59 1996
+++ lisp/term/tty-init.el	Thu May  7 10:00:03 1998
@@ -61,6 +61,8 @@
   ;; we don't do this at startup here so that the user can
   ;; override term-file-prefix. (startup.el does it after
   ;; loading the init file.)
+  (if (featurep 'mule)
+      (init-mule-tty-win))
   (when init-file-loaded
     ;; temporarily select the console so that the changes
     ;; to function-key-map are made for the right console.
--- src/console-tty.c.orig	Tue Oct 14 12:20:48 1997
+++ src/console-tty.c	Thu May  7 10:00:33 1998
@@ -226,6 +226,86 @@
   return CONSOLE_TTY_DATA (decode_tty_console (console))->controlling_process;
 }
 
+#ifdef MULE
+DEFUN ("set-console-tty-coding-system", Fset_console_tty_coding_system, 0, 2, 0, /*
+Set the coding system of tty console CONSOLE to CODESYS.
+CONSOLE defaults to the selected console.
+CODESYS defaults to the value of `terminal-coding-system'.
+*/
+	(console, codesys))
+{
+  struct console *con = decode_tty_console (console);
+  codesys = NILP (codesys) ?
+    Vterminal_coding_system :
+    Fget_coding_system (codesys);
+  set_encoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
+	codesys);
+  return Qnil;
+}
+#endif /* MULE */
+
+
+/* redefine coding system for console tty */
+#ifdef MULE
+DEFUN ("console-tty-input-coding-system", Fconsole_tty_input_coding_system, 1, 1, 0, /*
+Return TTY CONSOLE's input coding system.
+*/
+       (console))
+{
+  struct console *con = decode_tty_console (console);
+  return decoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->instream));
+}
+
+DEFUN ("set-console-tty-input-coding-system", Fset_console_tty_input_coding_system, 0, 2, 0, /*
+Set the coding system of tty input of console CONSOLE to CODESYS.
+CONSOLE defaults to the selected console.
+CODESYS defaults to the value of `keyboard-coding-system'.
+*/
+	(console, codesys))
+{
+  struct console *con;
+  if (!NILP(console)) {
+    con = decode_tty_console (console);
+    codesys = NILP (codesys) ?
+      Vkeyboard_coding_system :
+      Fget_coding_system (codesys);
+    set_encoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->instream),
+                                       codesys);
+  }
+  return Qnil;
+}
+
+DEFUN ("console-tty-output-coding-system", Fconsole_tty_output_coding_system, 1, 1, 0, /*
+Return TTY CONSOLE's output coding system.
+*/
+       (console))
+{
+  struct console *con = decode_tty_console (console);
+  return encoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream) );
+}
+
+DEFUN ("set-console-tty-output-coding-system", Fset_console_tty_output_coding_system, 0, 2, 0, /*
+Set the coding system of tty output of console CONSOLE to CODESYS.
+CONSOLE defaults to the selected console.
+CODESYS defaults to the value of `terminal-coding-system'.
+*/
+	(console, codesys))
+{
+  struct console *con;
+  if (!NILP(console)) {
+    con = decode_tty_console (console);
+    codesys = NILP (codesys) ?
+      Vterminal_coding_system :
+      Fget_coding_system (codesys);
+    set_encoding_stream_coding_system (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
+                                       codesys);
+  }
+  return Qnil;
+}
+
+#endif /* MULE */
+
+
 Lisp_Object
 tty_semi_canonicalize_console_connection (Lisp_Object connection,
 					  Error_behavior errb)
@@ -266,6 +346,13 @@
   DEFSUBR (Fconsole_tty_controlling_process);
   defsymbol (&Qterminal_type, "terminal-type");
   defsymbol (&Qcontrolling_process, "controlling-process");
+#ifdef MULE
+  DEFSUBR (Fconsole_tty_output_coding_system);
+  DEFSUBR (Fset_console_tty_output_coding_system);
+  DEFSUBR (Fconsole_tty_input_coding_system);
+  DEFSUBR (Fset_console_tty_input_coding_system);
+  DEFSUBR (Fset_console_tty_coding_system);
+#endif
 }
 
 void
