From 5b56c6e3a2b1ceff1a55e02793fce46f84b98243 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt <ol.sc@web.de>
Date: Mon, 4 May 2020 22:22:32 +0200
Subject: [PATCH] Disable potentially enabled double-width graphics.

---
 asminc/apple2.inc         | 22 ++++++++++++++--------
 libsrc/apple2/tgi/a2.hi.s |  4 ++++
 libsrc/apple2/tgi/a2.lo.s |  4 ++++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/asminc/apple2.inc b/asminc/apple2.inc
index 536a1d851..226a85778 100644
--- a/asminc/apple2.inc
+++ b/asminc/apple2.inc
@@ -50,15 +50,21 @@ LCBANK2 :=      $C083   ; Swap in LC bank 2
 LCBANK1 :=      $C08B   ; Swap in LC bank 1
 
 ; Video mode switches
-TXTCLR  :=      $C050   ; Display graphics
-TXTSET  :=      $C051   ; Display text
-MIXCLR  :=      $C052   ; Disable 4 lines of text
-MIXSET  :=      $C053   ; Enable 4 lines of text
-LOWSCR  :=      $C054   ; Page 1
-HISCR   :=      $C055   ; Page 2
-LORES   :=      $C056   ; Lores graphics
-HIRES   :=      $C057   ; Hires graphics
+TXTCLR     :=   $C050   ; Display graphics
+TXTSET     :=   $C051   ; Display text
+MIXCLR     :=   $C052   ; Disable 4 lines of text
+MIXSET     :=   $C053   ; Enable 4 lines of text
+LOWSCR     :=   $C054   ; Page 1
+HISCR      :=   $C055   ; Page 2
+LORES      :=   $C056   ; Lores graphics
+HIRES      :=   $C057   ; Hires graphics
+DHIRESON   :=   $C05E   ; Enable double-width graphics
+DHIRESOFF  :=   $C05F   ; Disable double-width graphics
 
 ; Game controller
 BUTN0   :=      $C061   ; Open-Apple Key
 BUTN1   :=      $C062   ; Closed-Apple Key
+
+; IOU
+IOUDISON   :=   $C07E   ; Disable IOU
+IOUDISOFF  :=   $C07F   ; Enable IOU
diff --git a/libsrc/apple2/tgi/a2.hi.s b/libsrc/apple2/tgi/a2.hi.s
index e06b4a617..aeb24f6be 100644
--- a/libsrc/apple2/tgi/a2.hi.s
+++ b/libsrc/apple2/tgi/a2.hi.s
@@ -175,6 +175,10 @@ INIT:
         ; Switch into graphics mode
         bit     MIXCLR
         bit     HIRES
+        .ifdef  __APPLE2ENH__
+        sta     IOUDISON
+        bit     DHIRESOFF
+        .endif
         bit     TXTCLR
 
         ; Beagle Bros Shape Mechanic fonts don't
diff --git a/libsrc/apple2/tgi/a2.lo.s b/libsrc/apple2/tgi/a2.lo.s
index 2f5485e02..6d1c6aa4a 100644
--- a/libsrc/apple2/tgi/a2.lo.s
+++ b/libsrc/apple2/tgi/a2.lo.s
@@ -126,6 +126,10 @@ INIT:
         bit     $C082           ; Switch in ROM
         jsr     SETGR
         bit     MIXCLR
+        .ifdef  __APPLE2ENH__
+        sta     IOUDISON
+        bit     DHIRESOFF
+        .endif
         bit     $C080           ; Switch in LC bank 2 for R/O
 
         ; Done, reset the error code