From 131aca18dcd5327c7634bca3f3fed3d062f7482e Mon Sep 17 00:00:00 2001
From: Uwe Risse <dg2ycb@gmx.de>
Date: Mon, 23 Sep 2024 12:18:42 +0200
Subject: [PATCH] Revert "More (final?) corrections to logic for handling SF
 free text messages."

This reverts commit f8079fbcbebcc1e2c9f9a951405e29582ea94483.
---
 lib/ft8/foxgen.f90        |  2 +-
 lib/superfox/sftx_sub.f90 |  6 ++++--
 widgets/mainwindow.cpp    | 16 +++++++++++-----
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lib/ft8/foxgen.f90 b/lib/ft8/foxgen.f90
index 7f6365f1f..b9e39f624 100644
--- a/lib/ft8/foxgen.f90
+++ b/lib/ft8/foxgen.f90
@@ -38,7 +38,7 @@ subroutine foxgen(bSuperFox,fname)
      n=nslots
      if(bMoreCQs) cmsg(1)(40:40)='1'               !Set flag to include a CQ
      if(bSendMsg) then
-        n=min(nslots+1,5)
+        n=min(nslots+1,3)
         cmsg(n)=textMsg
         cmsg(n)(39:39)='1'                         !Set flag for text message
         nslots=n
diff --git a/lib/superfox/sftx_sub.f90 b/lib/superfox/sftx_sub.f90
index 9227c6ccc..ed6c678c7 100644
--- a/lib/superfox/sftx_sub.f90
+++ b/lib/superfox/sftx_sub.f90
@@ -1,4 +1,4 @@
-subroutine sftx_sub(ckey0,nslots,bSendMsg)
+subroutine sftx_sub(ckey0)
 
 ! This routine is required in order to create a SuperFox transmission.
 
@@ -24,7 +24,7 @@ subroutine sftx_sub(ckey0,nslots,bSendMsg)
   integer*1 y(0:127)                  !Encoded symbols as i*1 integers
   integer chansym0(127)               !Transmitted symbols, data only
   integer isync(24)                   !Symbol numbers for sync tones
-  common/foxcom3/nslots2,cmsg(5),itone(151)
+  common/foxcom3/nslots,cmsg(5),itone(151)
   data isync/1,2,4,7,11,16,22,29,37,39,42,43,45,48,52,57,63,70,78,80,  &
              83,84,86,89/
 
@@ -34,8 +34,10 @@ subroutine sftx_sub(ckey0,nslots,bSendMsg)
   call sfox_init(7,127,50,'no',fspread,delay,fsample,24)
   freeTextMsg='                          '
   bMoreCQs=cmsg(1)(40:40).eq.'1'
+  bSendMsg=cmsg(nslots)(39:39).eq.'1'
   if(bSendMsg) then
      freeTextMsg=cmsg(nslots)(1:26)
+     if(nslots.gt.4) nslots=4
   endif
 
   call foxgen2(nslots,cmsg,line,foxcall)    !Parse old-style Fox messages
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp
index 53cc01f89..4d2386b69 100644
--- a/widgets/mainwindow.cpp
+++ b/widgets/mainwindow.cpp
@@ -182,7 +182,7 @@ extern "C" {
 
   void sfox_wave_gfsk_();
 
-  void sftx_sub_(char const * otp_key, int* nslots, bool* b, FCL len1);
+  void sftx_sub_(char const * otp_key, FCL len1);
 
   void plotsave_(float swide[], int* m_w , int* m_h1, int* irow);
 
@@ -2673,7 +2673,11 @@ void MainWindow::statusChanged()
     ui->cbSendMsg->setVisible(true);
     if (m_config.superFox()) {
       ui->sbNslots->setVisible(false);
+      if(ui->cbSendMsg->isChecked()) {
+        ui->sbNslots->setValue(4);
+      } else {
         ui->sbNslots->setValue(5);
+      }
     } else {
       ui->sbNslots->setVisible(true);
       ui->sbNslots->setValue(m_Nslots0);
@@ -9217,7 +9221,11 @@ void MainWindow::on_cbSendMsg_toggled(bool b)
 {
   if (!(m_config.superFox() && m_specOp==SpecOp::FOX))
     return; // don't do anything with slot values unless SuperFox mode
-  if(b or !b) ui->sbNslots->setValue(5);  //SF always uses Nslots=5
+  if(b) {
+    ui->sbNslots->setValue(4);         //### Is the correct value 4? Or 2? Is better logic needed? ###
+  } else {
+    ui->sbNslots->setValue(5);
+  }
 }
 
 void MainWindow::on_cbShMsgs_toggled(bool b)
@@ -11463,8 +11471,6 @@ void MainWindow::sfox_tx() {
       }
   }
 #endif
-  bool b=ui->cbSendMsg->isChecked();
-  foxcom_.bSendMsg=b;
-  sftx_sub_(ckey.toLatin1().constData(), &m_Nslots, &b, (FCL)ckey.size());
+  sftx_sub_(ckey.toLatin1().constData(), (FCL)ckey.size());
   sfox_wave_gfsk_();
 }