From 4f54d66aacae7724743cf7050c3377788594a634 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Tue, 10 Feb 2015 10:41:11 +0000
Subject: [PATCH] If using C64 or Atari fonts, and not using the corresponding
 terminal, enable xlat.

This makes the result of using the fonts in an unsupported mode understandable.
All of the non-ASCII glyphs will be messed up though with no way to get
some of them to display.
---
 src/syncterm/menu.c     |  3 ++-
 src/syncterm/term.c     | 12 ++++++++++--
 src/syncterm/uifcinit.c |  4 +++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/syncterm/menu.c b/src/syncterm/menu.c
index 4ff1a2cb07..423887fa39 100644
--- a/src/syncterm/menu.c
+++ b/src/syncterm/menu.c
@@ -23,6 +23,7 @@ void viewscroll(void)
 	struct	text_info txtinfo;
 	int	x,y;
 	struct mouse_event mevent;
+	int old_xlat=ciolib_xlat;
 
 	x=wherex();
 	y=wherey();
@@ -49,7 +50,7 @@ void viewscroll(void)
 		cputs("Scrollback");
 		gotoxy(cterm->width-9,1);
 		cputs("Scrollback");
-		ciolib_xlat = FALSE;
+		ciolib_xlat = old_xlat;
 		gotoxy(1,1);
 		key=getch();
 		switch(key) {
diff --git a/src/syncterm/term.c b/src/syncterm/term.c
index 69bab3b942..779a02b7e3 100644
--- a/src/syncterm/term.c
+++ b/src/syncterm/term.c
@@ -169,6 +169,7 @@ void update_status(struct bbslist *bbs, int speed, int ooii_mode)
 	static int oldspeed=0;
 	int	timeon;
 	char sep;
+	int old_xlat = ciolib_xlat;
 
 	switch(getfont()) {
 			case 0:
@@ -244,7 +245,7 @@ void update_status(struct bbslist *bbs, int speed, int ooii_mode)
 	window(txtinfo.winleft,txtinfo.wintop,txtinfo.winright,txtinfo.winbottom);
 	gotoxy(txtinfo.curx,txtinfo.cury);
 	hold_update=olddmc;
-	ciolib_xlat = FALSE;
+	ciolib_xlat = old_xlat;
 }
 
 #if defined(_WIN32) && defined(_DEBUG) && defined(DUMP)
@@ -1896,6 +1897,7 @@ void font_control(struct bbslist *bbs)
 	char *buf;
 	struct	text_info txtinfo;
 	int i,j,k;
+	int enable_xlat = 0;
 
 	if(safe_mode)
 		return;
@@ -1927,12 +1929,18 @@ void font_control(struct bbslist *bbs)
 						loadfont(fpick.selected[0]);
 					filepick_free(&fpick);
 				}
-				else
+				else {
 					setfont(i,FALSE,1);
+					if (i >=32 && i<= 35 && cterm->emulation != CTERM_EMULATION_PETASCII)
+						enable_xlat = TRUE;
+					if (i==36 && cterm->emulation != CTERM_EMULATION_ATASCII)
+						enable_xlat = TRUE;
+				}
 			}
 		break;
 	}
 	uifcbail();
+	ciolib_xlat = enable_xlat;
 	setup_mouse_events();
 	puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,buf);
 	window(txtinfo.winleft,txtinfo.wintop,txtinfo.winright,txtinfo.winbottom);
diff --git a/src/syncterm/uifcinit.c b/src/syncterm/uifcinit.c
index c641028a76..ac53827bad 100644
--- a/src/syncterm/uifcinit.c
+++ b/src/syncterm/uifcinit.c
@@ -19,6 +19,7 @@ static int uifc_initialized=0;
 #define WITH_BOT	(1<<2)
 
 static void (*bottomfunc)(int);
+int orig_ciolib_xlat;
 
 int	init_uifc(BOOL scrn, BOOL bottom) {
 	int	i;
@@ -29,6 +30,7 @@ int	init_uifc(BOOL scrn, BOOL bottom) {
 	if(!uifc_initialized) {
 		/* Set scrn_len to 0 to prevent textmode() call */
 		uifc.scrn_len=0;
+		orig_ciolib_xlat = ciolib_xlat;
 		ciolib_xlat = TRUE;
 		uifc.chars = NULL;
 		if((i=uifcini32(&uifc))!=0) {
@@ -72,7 +74,7 @@ void uifcbail(void)
 {
 	if(uifc_initialized) {
 		uifc.bail();
-		ciolib_xlat = FALSE;
+		ciolib_xlat = orig_ciolib_xlat;
 	}
 	uifc_initialized=0;
 }
-- 
GitLab