diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /map65/libm65/packjt.f90 | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'map65/libm65/packjt.f90')
| -rw-r--r-- | map65/libm65/packjt.f90 | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/map65/libm65/packjt.f90 b/map65/libm65/packjt.f90 index e42a1662..c9928208 100644 --- a/map65/libm65/packjt.f90 +++ b/map65/libm65/packjt.f90 @@ -2,6 +2,28 @@ module packjt implicit none contains +pure logical function is_valid_jt65_codeword(dat) + integer, intent(in) :: dat(12) + + integer, parameter :: NBASE = 37*36*10*27*27*27 + integer, parameter :: LAST_V2_CALL = 267796945 + integer :: nc1, nc2, ng + + nc1 = ishft(dat(1),22) + ishft(dat(2),16) + ishft(dat(3),10) + & + ishft(dat(4),4) + iand(ishft(dat(5),-2),15) + nc2 = ishft(iand(dat(5),3),26) + ishft(dat(6),20) + & + ishft(dat(7),14) + ishft(dat(8),8) + ishft(dat(9),2) + & + iand(ishft(dat(10),-4),3) + ng = ishft(iand(dat(10),15),12) + ishft(dat(11),6) + dat(12) + + if (ng >= 32768) then + is_valid_jt65_codeword = .true. + else + is_valid_jt65_codeword = nc1 /= NBASE .and. nc1 <= LAST_V2_CALL .and. & + nc2 < NBASE + endif +end function is_valid_jt65_codeword + subroutine packbits(dbits,nsymd,m0,sym) ! Pack 0s and 1s from dbits() into sym() with m0 bits per word. @@ -147,12 +169,13 @@ subroutine unpackcall(ncall, word, iv2, psfx) character(len=37) :: c integer, parameter :: NBASE = 37*36*10*27*27*27 + integer, parameter :: LAST_V2_CALL = 267796945 data c /'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ '/ word = '......' psfx = ' ' - if ((ncall < 0 .or. ncall >= 262177560) .and. ncall .ne. 262177561) then + if (ncall < 0 .or. ncall == NBASE .or. ncall > LAST_V2_CALL) then write(*,*) 'unpackcall: ncall out of range = ', ncall end if @@ -496,10 +519,10 @@ end subroutine unpackcall if(c3.eq.'OOO ') c3=' ' !Strip out the OOO flag call getpfx1(c1,k1,nv2a) if(nv2a.ge.4) go to 10 - call packcall(c1,nc1,text1) + call packcall(c1(1:6),nc1,text1) if(text1) go to 10 call getpfx1(c2,k2,nv2b) - call packcall(c2,nc2,text2) + call packcall(c2(1:6),nc2,text2) if(text2) go to 10 if(nv2a.eq.2 .or. nv2a.eq.3 .or. nv2b.eq.2 .or. nv2b.eq.3) then if(k1.lt.0 .or. k2.lt.0 .or. k1*k2.ne.0) go to 10 @@ -529,7 +552,7 @@ end subroutine unpackcall ! The message will be treated as plain text. 10 itype=6 - call packtext(msg,nc1,nc2,ng) + call packtext(msg(1:13),nc1,nc2,ng) ng=ng+32768 ! Encode data into 6-bit words @@ -876,7 +899,7 @@ subroutine packpfx(call1, n1, ng, nadd) if(call1(i1+2:i1+2).eq.' ') then ! Single-character add-on suffix (maybe also fourth suffix letter?) call0=call1(:i1-1) - call packcall(call0,n1,text) + call packcall(call0(1:6),n1,text) nadd=1 nc=ichar(call1(i1+1:i1+1)) if(nc.ge.48 .and. nc.le.57) then @@ -891,7 +914,7 @@ subroutine packpfx(call1, n1, ng, nadd) else if(call1(i1+3:i1+3).eq.' ') then ! Two-character numerical suffix, /10 to /99 call0=call1(:i1-1) - call packcall(call0,n1,text) + call packcall(call0(1:6),n1,text) nadd=1 n=10*(ichar(call1(i1+1:i1+1))-48) + ichar(call1(i1+2:i1+2)) - 48 nadd=1 @@ -902,7 +925,7 @@ subroutine packpfx(call1, n1, ng, nadd) if(pfx(3:3).eq.' ') pfx=' '//pfx(1:2) if(pfx(3:3).eq.' ') pfx=' '//pfx(1:2) call0=call1(i1+1:) - call packcall(call0,n1,text) + call packcall(call0(1:6),n1,text) ng=0 do i=1,3 |
