summaryrefslogtreecommitdiff
path: root/lib/qra/q65/q65_ap.f90
blob: e656867647796f476453afc1cb4061f6d762b35f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
subroutine q65_ap(nQSOprogress,ipass,ncontest,lq65pileup,lapcqonly,iaptype, &
     apsym0,apmask,apsymbols)

  integer apsym0(58),aph10(10)
  integer apmask(78),apsymbols(78)
  integer naptypes(0:5,4) ! (nQSOProgress, ipass)  maximum of 4 passes for now
  integer mcqru(29),mcqfd(29),mcqtest(29),mcqww(29)
  integer mcq(29),mrrr(19),m73(19),mrr73(19)
  logical lq65pileup,lapcqonly,first
  data     mcq/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0/
  data   mcqru/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0/
  data   mcqfd/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0/
  data mcqtest/0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0/
  data   mcqww/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,1,1,1,1,0/
  data    mrrr/0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,1/
  data     m73/0,1,1,1,1,1,1,0,1,0,0,1,0,1,0,0,0,0,1/
  data   mrr73/0,1,1,1,1,1,1,0,0,1,1,1,0,1,0,1,0,0,1/
  data ncontest0/99/
  data first/.true./
  save naptypes,ncontest0

! nQSOprogress
!   0  CALLING
!   1  REPLYING
!   2  REPORT
!   3  ROGER_REPORT
!   4  ROGERS
!   5  SIGNOFF

  if(first.or.(ncontest.ne.ncontest0)) then
! iaptype
!------------------------
!   1        CQ     ???    ???           (29+4=33 ap bits)
!   2        MyCall ???    ???           (29+4=33 ap bits)
!   3        MyCall DxCall ???           (58+4=62 ap bits)
!   4        MyCall DxCall RRR           (78 ap bits)
!   5        MyCall DxCall 73            (78 ap bits)
!   6        MyCall DxCall RR73          (78 ap bits)

     naptypes(0,1:4)=(/1,2,0,0/) ! Tx6 selected (CQ)
     naptypes(1,1:4)=(/2,3,0,0/) ! Tx1
     naptypes(2,1:4)=(/2,3,0,0/) ! Tx2
     naptypes(3,1:4)=(/3,4,5,6/) ! Tx3
     naptypes(4,1:4)=(/3,4,5,6/) ! Tx4
     naptypes(5,1:4)=(/3,1,2,0/) ! Tx5
     first=.false.
     ncontest0=ncontest
  endif

  apsymbols=0
  iaptype=naptypes(nQSOProgress,ipass)
  if(lapcqonly) iaptype=1
  
! ncontest=0 : NONE
!          1 : NA_VHF
!          2 : EU_VHF
!          3 : FIELD DAY
!          4 : RTTY
!          5 : WW_DIGI 
!          6 : FOX
!          7 : HOUND

! Conditions that cause us to bail out of AP decoding
!  if(ncontest.le.5 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) goto 900
!  if(ncontest.eq.6) goto 900                      !No AP for Foxes
!  if(ncontest.eq.7.and.f1.gt.950.0) goto 900      !Hounds use AP only below 950 Hz
  if(ncontest.ge.6) goto 900
  if(iaptype.ge.2 .and. apsym0(1).gt.1) goto 900  !No, or nonstandard, mycall 
  if(ncontest.eq.7 .and. iaptype.ge.2 .and. aph10(1).gt.1) goto 900
  if(iaptype.ge.3 .and. apsym0(30).gt.1) goto 900 !No, or nonstandard, dxcall

  if(iaptype.eq.1) then ! CQ or CQ RU or CQ TEST or CQ FD
     apmask=0
     apmask(1:29)=1  
     if(ncontest.eq.0) apsymbols(1:29)=mcq
     if(ncontest.eq.1) apsymbols(1:29)=mcqtest
     if(ncontest.eq.2) apsymbols(1:29)=mcqtest
     if(ncontest.eq.3) apsymbols(1:29)=mcqfd
     if(ncontest.eq.4) apsymbols(1:29)=mcqru
     if(ncontest.eq.5) apsymbols(1:29)=mcqww
     if(ncontest.eq.7) apsymbols(1:29)=mcq
     apmask(75:78)=1 
     apsymbols(75:78)=(/0,0,1,0/)
  endif

  if(iaptype.eq.2) then ! MyCall,???,??? 
     apmask=0
     if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.5) then
        apmask(1:29)=1  
        apsymbols(1:29)=apsym0(1:29)
        apmask(75:78)=1
        apsymbols(75:78)=(/0,0,1,0/)
     else if(ncontest.eq.2) then
        apmask(1:28)=1  
        apsymbols(1:28)=apsym0(1:28)
        apmask(72:74)=1
        apsymbols(72)=0
        apsymbols(73)=(+1)
        apsymbols(74)=0
        apmask(75:78)=1 
        apsymbols(75:78)=0
     else if(ncontest.eq.3) then
        apmask(1:28)=1  
        apsymbols(1:28)=apsym0(1:28)
        apmask(75:78)=1 
        apsymbols(75:78)=0
     else if(ncontest.eq.4) then
        apmask(2:29)=1  
        apsymbols(2:29)=apsym0(1:28)
        apmask(75:78)=1 
        apsymbols(75:78)=(/0,0,1,0/)
     else if(ncontest.eq.7) then ! ??? RR73; MyCall <Fox Call hash10> ???
        apmask(29:56)=1  
        apsymbols(29:56)=apsym0(1:28)
        apmask(57:66)=1
        apsymbols(57:66)=aph10(1:10)
        apmask(72:78)=1
        apsymbols(72:74)=(/0,0,1/)
        apsymbols(75:78)=0
     endif
  endif

  if(iaptype.eq.3) then ! MyCall,DxCall,???
     apmask=0
! Q65 Pileup uses bit 78 for the copied-last-transmission indication.
! Other Q65 AP decodes retain the normal known-zero bit.
     if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2.or.ncontest.eq.5.or.ncontest.eq.7) then
        apmask(1:58)=1
        apsymbols(1:58)=apsym0
        apmask(75:77)=1
        apsymbols(75:77)=(/0,0,1/)
        if(.not.lq65pileup) then
           apmask(78)=1
           apsymbols(78)=0
        endif
     else if(ncontest.eq.3) then ! Field Day
        apmask(1:56)=1
        apsymbols(1:28)=apsym0(1:28)
        apsymbols(29:56)=apsym0(30:57)
        apmask(72:77)=1
        apsymbols(75:77)=0
     else if(ncontest.eq.4) then
        apmask(2:57)=1
        apsymbols(2:29)=apsym0(1:28)
        apsymbols(30:57)=apsym0(30:57)
        apmask(75:77)=1
        apsymbols(75:77)=(/0,0,1/)
     endif
  endif

  if(iaptype.eq.5.and.ncontest.eq.7) goto 900 !Hound
  if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then  
     apmask=0
     if(ncontest.le.5 .or. (ncontest.eq.7.and.iaptype.eq.6)) then
        apmask(1:78)=1                      !MyCall, HisCall, RRR|73|RR73
        apmask(72:74)=0                     !Check for <blank>, RRR, RR73, 73
        apsymbols(1:58)=apsym0
        if(iaptype.eq.4) apsymbols(59:77)=mrrr
        if(iaptype.eq.5) apsymbols(59:77)=m73
        if(iaptype.eq.6) apsymbols(59:77)=mrr73
     else if(ncontest.eq.7.and.iaptype.eq.4) then ! Hound listens for MyCall RR73;...
        apmask(1:28)=1
        apsymbols(1:28)=apsym0(1:28)
        apmask(57:66)=1
        apsymbols(57:66)=aph10(1:10)
        apmask(72:78)=1
        apsymbols(72:78)=(/0,0,1,0,0,0,0/)
     endif
  endif

900 return
end subroutine q65_ap