From 807d5e595b04aadeb7de997a239e8245192e6612 Mon Sep 17 00:00:00 2001
From: Joe Taylor <k1jt@arrl.org>
Date: Thu, 7 Jul 2016 20:15:01 +0000
Subject: [PATCH] Commit most of what's necessary for decoding MSK144 short
 messages, including the hash test.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6889 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
---
 lib/detectmsk32.f90   | 11 +++++------
 lib/fast_decode.f90   |  8 ++++++--
 lib/msk144_decode.f90 |  5 +++--
 mainwindow.cpp        |  6 ++++--
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/detectmsk32.f90 b/lib/detectmsk32.f90
index 6f0601c26..bae71363f 100644
--- a/lib/detectmsk32.f90
+++ b/lib/detectmsk32.f90
@@ -1,4 +1,4 @@
-subroutine detectmsk32(cbig,n,lines,nmessages,nutc)
+subroutine detectmsk32(cbig,n,mycall,partnercall,lines,nmessages,nutc)
   use timer_module, only: timer
 
   parameter (NSPM=192, NPTS=3*NSPM, MAXSTEPS=7500, NFFT=3*NSPM, MAXCAND=40)
@@ -6,7 +6,6 @@ subroutine detectmsk32(cbig,n,lines,nmessages,nutc)
   character*6 mycall,partnercall
   character*22 msg,hashmsg,msgreceived,allmessages(20)
   character*80 lines(100)
-!  character*512 pchk_file,gen_file
   complex cbig(n)
   complex cdat(NPTS)                    !Analytic signal
   complex cdat2(NPTS)
@@ -98,19 +97,19 @@ subroutine detectmsk32(cbig,n,lines,nmessages,nutc)
      first=.false.
   endif
 
-  ! define the 32 likely messages 
+! Define the 32 likely messages 
   do irpt=0,31
-    hashmsg='K9AN K1JT '//rpt(irpt)
+    hashmsg=mycall//' '//partnercall//' '//rpt(irpt)
     call fmtmsg(hashmsg,iz)
     call hash(hashmsg,22,ihash)
     ihash=iand(ihash,127)
     ig=32*ihash + irpt
     likelymessages(irpt)=ig
-!    write(*,*) hashmsg,ig,ig24(ig)
+!    write(*,*) irpt,hashmsg,ig,ig24(ig)
   enddo  
   qsocontext=.false.
 
-  ! fill the detmet, detferr arrays
+! Fill the detmet, detferr arrays
   nstepsize=48  ! 4ms steps
   nstep=(n-NPTS)/nstepsize  
   detmet=0
diff --git a/lib/fast_decode.f90 b/lib/fast_decode.f90
index 9df75cd29..47e2521d7 100644
--- a/lib/fast_decode.f90
+++ b/lib/fast_decode.f90
@@ -1,4 +1,4 @@
-subroutine fast_decode(id2,narg,line,pchk_file)
+subroutine fast_decode(id2,narg,line,pchk_file,mycall_12,hiscall_12)
 
   parameter (NMAX=30*12000)
   integer*2 id2(NMAX)
@@ -10,8 +10,12 @@ subroutine fast_decode(id2,narg,line,pchk_file)
   character*6 cfile6
   character*80 line(100)
   character*512 pchk_file
+  character*12 mycall_12,hiscall_12
+  character*6 mycall,hiscall
   save npts
 
+  mycall=mycall_12(1:6)
+  hiscall=hiscall_12(1:6)
   nutc=narg(0)
   ndat0=narg(1)
   nsubmode=narg(2)
@@ -33,7 +37,7 @@ subroutine fast_decode(id2,narg,line,pchk_file)
      call jtmsk_decode(id2,narg,line)
      go to 900
   else if(nmode.eq.104) then
-     call msk144_decode(id2,ndat0,nutc,0,pchk_file,line)
+     call msk144_decode(id2,ndat0,nutc,0,pchk_file,mycall,hiscall,line)
      go to 900
   endif
 
diff --git a/lib/msk144_decode.f90 b/lib/msk144_decode.f90
index 374ab9910..0b3f8459b 100644
--- a/lib/msk144_decode.f90
+++ b/lib/msk144_decode.f90
@@ -1,4 +1,4 @@
-subroutine msk144_decode(id2,npts,nutc,nprint,pchk_file,line)
+subroutine msk144_decode(id2,npts,nutc,nprint,pchk_file,mycall,hiscall,line)
 
 ! Calls the experimental decoder for MSK 72ms/16ms messages
 
@@ -10,6 +10,7 @@ subroutine msk144_decode(id2,npts,nutc,nprint,pchk_file,line)
   complex c(NFFTMAX)                   !Complex (analytic) data
   character*80 line(100)               !Decodes passed back to caller
   character*512 pchk_file
+  character*6 mycall,hiscall
 
   line(1:100)(1:1)=char(0)
 
@@ -37,7 +38,7 @@ subroutine msk144_decode(id2,npts,nutc,nprint,pchk_file,line)
   endif
 
   if(nline .eq. 0) then
-    call detectmsk32(c,npts,line,nline,nutc)
+    call detectmsk32(c,npts,mycall,hiscall,line,nline,nutc)
     if( nprint .ne. 0 ) then
       do i=1,nline
         write(*,'(a80)') line(i)
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 53571ca65..2a136d853 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -106,7 +106,8 @@ extern "C" {
                 float* width);
 
   void fast_decode_(short id2[], int narg[], char msg[], char pchkFile[],
-                    int len1, int len2);
+                    char mycall[], char hiscall[], int len1, int len2,
+                    int len3, int len4);
   void hash_calls_(char calls[], int* ih9, int len);
   void degrade_snr_(short d2[], int* n, float* db, float* bandwidth);
   void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2);
@@ -2206,7 +2207,8 @@ void MainWindow::decode()                                       //decode()
     narg[14]=m_config.aggressive();
     memcpy(d2b,dec_data.d2,2*360000);
     watcher3.setFuture (QtConcurrent::run (std::bind (fast_decode_,&d2b[0],
-        &narg[0],&m_msg[0][0],&m_pchkFile[0],80,512)));
+        &narg[0],&m_msg[0][0],&m_pchkFile[0],dec_data.params.mycall,
+        dec_data.params.hiscall,80,512,12,12)));
   } else {
     memcpy(to, from, qMin(mem_jt9->size(), size));
     QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow jt9 to start