;ProfiPacket - packet radio terminal program
;Copyright (C) 1999  Alexander Feigl
;
;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
;
;Author:
;
;Alexander Feigl
;Burachstraße 51
;
;D-88250 Weingarten
;
;EMail : Alexander.Feigl@gmx.de


                CPU M68000
                SNMAOPT Q+,P+,A+,B-,S+,M+,E+
                nolist

AJUMP                   MACRO
                        dc.w $4ef9
                        dc.l \1
                        ENDM

                
                        incdir "sys:include/"
                        include "exec/exec_lib.i"
                        include "dos/dos_lib.i"
                        include "/global.i"

                                
_Nil                    moveq #0,d0
                        rts
                        dc.b "ProfCmds"
                
                
                        dc.l COMP_Name
                        dc.l 1
                        dc.l COMP_Init
                        dc.l RING_Head
                        dc.l 8                  ;Subtype (3=General)
                        
COMP_Name               dc.b "COMP",$01,"RESSION",0
                        even
COMP_Init               movem.l a6/a2-a4/d5-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #COMP_Functions-COMP_FunctionsBegin,d0
                        move.l #comp_Size,d1
                        lea COMP_Functions,a0
                        move.l ppb_Global(a6),a5
                        jsr _QVOCreateServerBase(A6)
                        tst.l d0
                        beq .Cannot_Serve
                        move.l d0,a6
                        move.l a3,a5
                        move.l a3,comp_QSOBase(a6)
                        move.l d7,comp_OldServer(A6)
                        move.l d6,comp_Channel(a6)
                        move.l a2,comp_Parameter(a6)
                        move.l a4,comp_ThisQSO(a6)
                        move.l a6,qso_Server(a4)
                        
                        move.l a2,a0
                        GOQSO ParseComLine
                        tst.l d0
                        blt .Invalid_Parameters
                        cmp.l #1,d0
                        bgt .Invalid_Parameters
                        move.l comp_Parameter(a6),a0
                        cmp.b #"O",(a0)
                        beq .OnOffParam
                        cmp.b #"o",(a0)
                        beq .OnOffParam
                        cmp.b #"0",(a0)
                        beq .ZeroParam
                        cmp.b #"1",(a0)
                        beq .OneParam
                        cmp.b #"+",(a0)
                        beq .XPStyleOn
                        cmp.b #"-",(a0)
                        beq .XPStyleOff
                        cmp.b #">",(a0)
                        beq .XPStyleCodeOn
                        cmp.b #"<",(a0)
                        beq .XPStyleCodeOff
                        bra .Invalid_Parameters
.OnOffParam             cmp.b #"n",1(a0)
                        beq .OnParam
                        cmp.b #"N",1(a0)
                        beq .OnParam
                        cmp.b #"f",1(a0)
                        beq .OffParam_T
                        cmp.b #"F",1(a0)
                        beq .OffParam_T
                        bra .Invalid_Parameters
.OffParam_T             cmp.b #"f",2(a0)
                        beq .OffParam
                        cmp.b #"F",2(a0)
                        bne .Invalid_Parameters
.OffParam               tst.b 3(a0)
                        bne .Invalid_Parameters
                        move.l comp_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        lea COMP_Comp0,a0
                        GOQSO TransmitText
                        move.l comp_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l comp_Channel(A6),d0
                        GOQSO CompressionOff
                        bra .Server_Success
.OnParam                tst.b 2(a0)
                        bne .Invalid_Parameters
                        move.l comp_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        lea COMP_Comp1,a0
                        GOQSO TransmitText
                        
                        move.l comp_Channel(A6),d0
                        GOQSO ForceTransmit
                        move.l comp_Channel(a6),d0
                        GOQSO CompressionOn
                        tst.l d0
                        bne .Compress_Error
                        bra .Server_Success
.ZeroParam              tst.b 1(a0)
                        bne .Invalid_Parameters
                        move.l comp_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l comp_Channel(A6),d0
                        GOQSO CompressionOff
                        bra .Server_Success
.OneParam               tst.b 1(a0)
                        bne .Invalid_Parameters
                        move.l comp_Channel(A6),d0
                        GOQSO ForceTransmit
                        move.l comp_Channel(A6),d0
                        GOQSO CompressionOn
                        tst.l d0
                        bne .Compress_Error
                        bra .Server_Success
                        
.XPStyleOn              move.l comp_Channel(a6),d0
                        moveq #0,d1
                        GOQSO ControlXPCompress
                        bra .Server_Success
.XPStyleOff             move.l comp_Channel(a6),d0
                        moveq #1,d1
                        GOQSO ControlXPCompress
                        bra .Server_Success
.XPStyleCodeOn          move.l comp_Channel(a6),d0
                        move.l #128,d1
                        GOQSO ControlXPCompress
                        bra .Server_Success
.XPStyleCodeOff         move.l comp_Channel(a6),d0
                        move.l #129,d1
                        GOQSO ControlXPCompress
                        bra .Server_Success
.Compress_Error         moveq #1,d0
                        bra .Abort_With_Text                    
                        
.Server_Success         move.l comp_ThisQSO(a6),a0
                        clr.l qso_SendPrompt(a0)
                        bsr COMP_Cleanup
                        movem.l (sp)+,a6/a2-a4/d5-d7
                        moveq #0,d0
                        rts


.Cannot_Serve           movem.l (sp)+,a6/a2-a4/d5-d7
                        moveq #-1,d0
                        rts

.No_User_Possible       moveq #1,d0
                        bra .Abort_With_Text
                        
.Invalid_Parameters     moveq #0,d0
.Abort_With_Text        bsr Get_Text
                        move.l d0,a0
                        move.l comp_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bsr COMP_Cleanup
                        movem.l (Sp)+,a6/a2-a4/d5-d7
                        moveq #0,d0
                        rts
                        

COMP_Cleanup            move.l comp_OldServer(a6),d0
                        move.l comp_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #COMP_Functions-COMP_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

COMP_ConnectProced      rts

COMP_ReceivePacket      rts

COMP_TerminalInput      rts     

COMP_AbortServer                rts

COMP_GetServerType      moveq #8,d0
                        rts

COMP_Nop                        rts

                        
COMP_FunctionsBegin     
                        AJUMP GEN_AskAudioPass                  ;-54
                        AJUMP COMP_AbortServer          ;-48
                        AJUMP COMP_GetServerType                ;-42
                        AJUMP COMP_TerminalInput                ;-36
                        AJUMP COMP_ReceivePacket                ;-30
                        AJUMP COMP_Nop                  ;-24
                        AJUMP COMP_ConnectProced                ;-18
                        AJUMP COMP_Cleanup                      ;-12
                        AJUMP COMP_Init                 ;-6
COMP_Functions          
                        
                        even
                        
                        
                        rsreset
comp_ThisQSO            rs.l 1
comp_Channel            rs.l 1
comp_OldServer          rs.l 1
comp_QSOBase            rs.l 1
comp_Parameter          rs.l 1
comp_Size               rs.b 0

                
                
RING_Head               dc.l RING_Name
                        dc.l 1
                        dc.l RING_Init
                        dc.l RING_Head_2
                        dc.l 32                 ;Subtype (5=Sysop Interactive)
RING_Head_2             dc.l RING_Name_2
                        dc.l 1
                        dc.l RING_Init
                        dc.l VER_Head
                        dc.l 32                 ;Subtype (5=Sysop Interactive)
                        
RING_Name               dc.b "RI",$01,"NG",0
RING_Name_2             dc.b "B",$01,"ELL",0
                        even
RING_Init               movem.l a6/a2-a4/d5-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #RING_Functions-RING_FunctionsBegin,d0
                        move.l #ring_Size,d1
                        lea RING_Functions,a0
                        move.l ppb_Global(a6),a5
                        jsr _QVOCreateServerBase(A6)
                        tst.l d0
                        beq .Cannot_Serve
                        move.l d0,a6
                        move.l a3,a5
                        move.l a3,ring_QSOBase(a6)
                        move.l d7,ring_OldServer(A6)
                        move.l d6,ring_Channel(a6)
                        move.l a2,ring_Parameter(a6)
                        move.l a4,ring_ThisQSO(a6)
                        move.l a6,qso_Server(a4)
                        
                        move.l a2,a0
                        GOQSO ParseComLine
                        tst.l d0
                        blt .Invalid_Parameters
                        cmp.l #0,d0
                        bgt .Invalid_Parameters
                        moveq #2,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l ring_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        move.l ring_ThisQSO(a6),a0
                        moveq #7,d0
                        GOQSO AudioEffect
.Server_Success         bsr RING_Cleanup
                        movem.l (sp)+,a6/a2-a4/d5-d7
                        moveq #0,d0
                        rts


.Cannot_Serve           movem.l (sp)+,a6/a2-a4/d5-d7
                        moveq #-1,d0
                        rts

.No_User_Possible       moveq #1,d0
                        bra .Abort_With_Text
                        
.Invalid_Parameters     moveq #0,d0
.Abort_With_Text        bsr Get_Text
                        move.l d0,a0
                        move.l ring_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bsr RING_Cleanup
                        movem.l (Sp)+,a6/a2-a4/d5-d7
                        moveq #0,d0
                        rts
                        

RING_Cleanup            move.l ring_OldServer(a6),d0
                        move.l ring_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #RING_Functions-RING_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

RING_ConnectProced      rts

RING_ReceivePacket      rts

RING_TerminalInput      rts     

RING_AbortServer                rts

RING_GetServerType      moveq #32,d0
                        rts

RING_Nop                        rts

                        
RING_FunctionsBegin     
                        AJUMP GEN_AskAudioPass                  ;-54
                        AJUMP RING_AbortServer          ;-48
                        AJUMP RING_GetServerType                ;-42
                        AJUMP RING_TerminalInput                ;-36
                        AJUMP RING_ReceivePacket                ;-30
                        AJUMP RING_Nop                  ;-24
                        AJUMP RING_ConnectProced                ;-18
                        AJUMP RING_Cleanup                      ;-12
                        AJUMP RING_Init                 ;-6
RING_Functions          
                        
                        even
                        
                        
                        rsreset
ring_ThisQSO            rs.l 1
ring_Channel            rs.l 1
ring_OldServer          rs.l 1
ring_QSOBase            rs.l 1
ring_Parameter          rs.l 1
ring_Size               rs.b 0

                
VER_Head                dc.l VER_Name
                        dc.l 1
                        dc.l VER_Init
                        dc.l PARAM_Head
                        dc.l 8                  ;Subtype (3=General)
                        
VER_Name                dc.b "VER",$1,"SION",0
                        even
VER_Init                movem.l a6/a2-a4/d5-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #VER_Functions-VER_FunctionsBegin,d0
                        move.l #ver_Size,d1
                        lea VER_Functions,a0
                        move.l ppb_Global(a6),a5
                        jsr _QVOCreateServerBase(A6)
                        tst.l d0
                        beq .Cannot_Serve
                        move.l d0,a6
                        move.l a3,a5
                        move.l a3,ver_QSOBase(a6)
                        move.l d7,ver_OldServer(A6)
                        move.l d6,ver_Channel(a6)
                        move.l a2,ver_Parameter(a6)
                        move.l a4,ver_ThisQSO(a6)
                        move.l a6,qso_Server(a4)
                        
                        move.l a2,a0
                        GOQSO ParseComLine
                        tst.l d0
                        blt .Invalid_Parameters
                        cmp.l #0,d0
                        bgt .Invalid_Parameters
                        
                        lea ver_Converter(a6),a2
                        moveq #-2,d0
                        GOQSO GetString
                        move.l d0,a0
.LoopVERCol             cmp.b #":",(a0)+
                        bne .LoopVERCol
.LoopVERBlank           cmp.b #" ",(a0)
                        bne .LoopVERed
                        addq.l #1,a0
                        bra .LoopVERBlank
.LoopVERed
.LoopX                  tst.b (a0)
                        beq .LoopXX
                        move.b (a0)+,(a2)+
                        bra .LoopX
.LoopXX                 move.b #$d,(a2)+
                        move.b #$d,(a2)+

                        moveq #106,d0
                        GOQSO GetString
                        move.l d0,a0
.LoopCR                 tst.b (a0)
                        beq .Loop_End
                        cmp.b #$0a,(a0)+
                        bne .LoopCR

                        move.l a2,a1
                        move.l #4040,d0
.Loop                   tst.l d0
                        beq .Loop_End
                        subq.l #1,d0
                        tst.b (A0)
                        beq .Loop_End
                        move.b (a0)+,(a1)+
                        cmp.b #$a,-1(a1)
                        bne .Loop
                        move.b #$d,-1(a1)
                        bra .Loop
.Loop_End               move.b #$d,(A1)+
                        move.b #$d,(A1)+
                        clr.b (a1)+
                        lea ver_Converter(a6),a0
                        GOQSO ConvertToPC
                        lea ver_Converter(a6),a0
                        move.l ver_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
.Server_Success         bsr VER_Cleanup
                        movem.l (sp)+,a6/a2-a4/d5-d7
                        moveq #0,d0
                        rts


.Cannot_Serve           movem.l (sp)+,a6/a2-a4/d5-d7
                        moveq #-1,d0
                        rts

.No_User_Possible       moveq #1,d0
                        bra .Abort_With_Text
                        
.Invalid_Parameters     moveq #0,d0
.Abort_With_Text        bsr Get_Text
                        move.l d0,a0
                        move.l ver_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bsr VER_Cleanup
                        movem.l (Sp)+,a6/a2-a4/d5-d7
                        moveq #0,d0
                        rts
                        

VER_Cleanup             move.l ver_OldServer(a6),d0
                        move.l ver_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #VER_Functions-VER_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

VER_ConnectProced       rts

VER_ReceivePacket       rts

VER_TerminalInput       rts     

VER_AbortServer         rts

VER_GetServerType       moveq #8,d0
                        rts

VER_Nop                 rts

                        
VER_FunctionsBegin      
                        AJUMP GEN_AskAudioPass          ;-54
                        AJUMP VER_AbortServer           ;-48
                        AJUMP VER_GetServerType         ;-42
                        AJUMP VER_TerminalInput         ;-36
                        AJUMP VER_ReceivePacket         ;-30
                        AJUMP VER_Nop                   ;-24
                        AJUMP VER_ConnectProced         ;-18
                        AJUMP VER_Cleanup                       ;-12
                        AJUMP VER_Init                  ;-6
VER_Functions           
                        
                        even
                        
                        
                        rsreset
ver_ThisQSO             rs.l 1
ver_Channel             rs.l 1
ver_OldServer           rs.l 1
ver_QSOBase             rs.l 1
ver_Parameter           rs.l 1
ver_Converter           rs.b 4096
ver_Size                rs.b 0


                
PARAM_Head              dc.l PARAM_Name
                        dc.l 1
                        dc.l PARAM_Init
                        dc.l RTT_Head
                        dc.l 8                  ;Subtype (3=General)
                        
PARAM_Name              dc.b "PARAM",$1,"ETER",0
                        even
PARAM_Init              movem.l a6/a2-a4/d2-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #PARAM_Functions-PARAM_FunctionsBegin,d0
                        move.l #param_Size,d1
                        lea PARAM_Functions,a0
                        move.l ppb_Global(a6),a5
                        jsr _QVOCreateServerBase(A6)
                        tst.l d0
                        beq .Cannot_Serve
                        move.l d0,a6
                        move.l a3,a5
                        move.l a3,param_QSOBase(a6)
                        move.l d7,param_OldServer(A6)
                        move.l d6,param_Channel(a6)
                        move.l a2,param_Parameter(a6)
                        move.l a4,param_ThisQSO(a6)
                        move.l a6,qso_Server(a4)
                        
                        move.l a2,a0
                        GOQSO ParseComLine
                        tst.l d0
                        blt .Invalid_Parameters
                        cmp.l #0,d0
                        bgt .Invalid_Parameters
                        
                        sub.l #param_Size,a7
                        move.l a7,a0
                        move.l param_Channel(a6),d0
                        GOQSO AskParameter
                        tst.l d0
                        bne .Error_Para
                        moveq #4,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l a7,a1
                        lea .PutChar(pc),a2
                        lea param_Converter(a6),a3
                        move.l a6,-(sp)
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(a6)
                        move.l (sp)+,a6
                        add.l #param_Size,a7
                        lea param_Converter(a6),a0
.Outy_Text              move.l param_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
.Server_Success         bsr PARAM_Cleanup
                        movem.l (sp)+,a6/a2-a4/d2-d7
                        moveq #0,d0
                        rts
.PutChar                move.b d0,(a3)+
                        clr.b (a3)
                        rts
.Error_Para             add.l #param_Size,a7
                        moveq #3,d0
                        bsr Get_Text
                        move.l d0,a0
                        bra .Outy_Text

.Cannot_Serve           movem.l (sp)+,a6/a2-a4/d2-d7
                        moveq #-1,d0
                        rts

.No_User_Possible       moveq #1,d0
                        bra .Abort_With_Text
                        
.Invalid_Parameters     moveq #0,d0
.Abort_With_Text        bsr Get_Text
                        move.l d0,a0
                        move.l param_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bsr PARAM_Cleanup
                        movem.l (Sp)+,a6/a2-a4/d2-d7
                        moveq #0,d0
                        rts
                        

PARAM_Cleanup           move.l param_OldServer(a6),d0
                        move.l param_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #PARAM_Functions-PARAM_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

PARAM_ConnectProced     rts

PARAM_ReceivePacket     rts

PARAM_TerminalInput     rts

PARAM_AbortServer       rts

PARAM_GetServerType     moveq #8,d0
                        rts

PARAM_Nop                       rts

                        
PARAM_FunctionsBegin
                        AJUMP GEN_AskAudioPass                  ;-54
                        AJUMP PARAM_AbortServer         ;-48
                        AJUMP PARAM_GetServerType               ;-42
                        AJUMP PARAM_TerminalInput               ;-36
                        AJUMP PARAM_ReceivePacket               ;-30
                        AJUMP PARAM_Nop                 ;-24
                        AJUMP PARAM_ConnectProced               ;-18
                        AJUMP PARAM_Cleanup             ;-12
                        AJUMP PARAM_Init                        ;-6
PARAM_Functions
                        
                        even
                        
                        
                        rsreset
param_ThisQSO           rs.l 1
param_Channel           rs.l 1
param_OldServer         rs.l 1
param_QSOBase           rs.l 1
param_Parameter         rs.l 1
param_Converter         rs.b 2048
param_Size              rs.b 0


RTT_Head              dc.l RTT_Name
                        dc.l 1
                        dc.l RTT_Init
                        dc.l ACT_Head
                        dc.l 8                  ;Subtype (3=General)

RTT_Name              dc.b "RTT",$1,"IME",0
                        even
RTT_Init              movem.l a6/a2-a4/d2-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #RTT_Functions-RTT_FunctionsBegin,d0
                        move.l #rtt_Size,d1
                        lea RTT_Functions,a0
                        move.l ppb_Global(a6),a5
                        jsr _QVOCreateServerBase(A6)
                        tst.l d0
                        beq .Cannot_Serve
                        move.l d0,a6
                        move.l a3,a5
                        move.l a3,rtt_QSOBase(a6)
                        move.l d7,rtt_OldServer(A6)
                        move.l d6,rtt_Channel(a6)
                        move.l a2,rtt_Parameter(a6)
                        move.l a4,rtt_ThisQSO(a6)
                        move.l a6,qso_Server(a4)

                        lea rtt_DateStamp(a6),a0
                        move.l a0,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODateStamp(a6)
                        move.l (sp)+,a6

                        move.l a2,a0
                        GOQSO ParseComLine
                        tst.l d0
                        blt .Invalid_Parameters
                        cmp.l #1,d0
                        bgt .Invalid_Parameters
                        tst.l d0
                        beq .First_Invokation
                        move.l rtt_Parameter(a6),a0
                        cmp.b #"P",(a0)
                        bne .Invalid_Parameters
                        cmp.b #"P",1(a0)
                        bne .Invalid_Parameters
                        cmp.b #"R",2(a0)
                        bne .Invalid_Parameters
                        cmp.b #"T",3(a0)
                        bne .Invalid_Parameters
                        cmp.b #"T",4(a0)
                        bne .Invalid_Parameters
                        cmp.b #"#",5(a0)
                        bne .Invalid_Parameters
                        lea 6(a0),a0
                        move.l a0,d1
                        clr.l -(sp)
                        move.l sp,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOStrToLong(a6)
                        move.l (sp)+,a6
                        move.l (sp)+,d1
                        cmp.l #-1,d0
                        beq .Invalid_Parameters
                        move.l d1,d0
                        lea rtt_DateStamp(a6),a0
                        move.l 4(a0),d1
                        mulu #60,d1
                        move.l 8(a0),d2
                        divu #50,d2
                        ext.l d2
                        add.l d2,d1
                        cmp.l d1,d0
                        ble .Good_RTT
                        add.l #60*60*24,d1
.Good_RTT               sub.l d0,d1
                        move.l d1,-(sp)
                        moveq #5,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l (sp)+,d0
                        move.l rtt_ThisQSO(a6),a1
                        lea qso_Call(a1),a2
                        move.l d0,-(sp)
                        lea qso_MyCall(a1),a3
                        move.l a3,-(sp)
                        move.l a2,-(sp)
                        move.l a3,-(sp)
                        move.l a7,a1
                        lea .PutChar(pc),a2
                        lea rtt_Temporary(a6),a3
                        move.l a6,-(sp)
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(A6)
                        move.l (sp)+,a6
                        add.l #16,sp
                        lea rtt_Temporary(a6),a0
                        move.l rtt_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bra .Server_Success




.First_Invokation       lea rtt_DateStamp(a6),a0
                        move.l 4(a0),d1
                        mulu #60,d1
                        move.l 8(a0),d2
                        divu #50,d2
                        ext.l d2
                        add.l d2,d1
                        move.l d1,d0
                        lea RTT_InvokeString(pc),a0
                        move.l d0,-(sp)
                        move.l a7,a1
                        lea .PutChar(pc),a2
                        lea rtt_Temporary(a6),a3
                        move.l a6,-(sp)
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(A6)
                        move.l (sp)+,a6
                        move.l (sp)+,d0
                        move.l rtt_ThisQSO(a6),a0
                        clr.l qso_SendPrompt(a0)
.Print_Invoke           lea rtt_Temporary(a6),a0
                        move.l rtt_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        move.l rtt_Channel(a6),d0
                        GOQSO ForceTransmit
.Server_Success         bsr RTT_Cleanup
                        movem.l (sp)+,a6/a2-a4/d2-d7
                        moveq #0,d0
                        rts

.PutChar                move.b d0,(a3)+
                        rts
.Cannot_Serve           movem.l (sp)+,a6/a2-a4/d2-d7
                        moveq #-1,d0
                        rts

.Invalid_Parameters     moveq #0,d0
.Abort_With_Text        bsr Get_Text
                        move.l d0,a0
                        move.l rtt_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bsr RTT_Cleanup
                        movem.l (Sp)+,a6/a2-a4/d2-d7
                        moveq #0,d0
                        rts


RTT_Cleanup             move.l rtt_OldServer(a6),d0
                        move.l rtt_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #RTT_Functions-RTT_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

RTT_ConnectProced     rts

RTT_ReceivePacket     rts

RTT_TerminalInput     rts

RTT_AbortServer       rts

RTT_GetServerType     moveq #8,d0
                        rts

RTT_Nop                       rts


RTT_FunctionsBegin
                        AJUMP GEN_AskAudioPass                  ;-54
                        AJUMP RTT_AbortServer         ;-48
                        AJUMP RTT_GetServerType               ;-42
                        AJUMP RTT_TerminalInput               ;-36
                        AJUMP RTT_ReceivePacket               ;-30
                        AJUMP RTT_Nop                 ;-24
                        AJUMP RTT_ConnectProced               ;-18
                        AJUMP RTT_Cleanup             ;-12
                        AJUMP RTT_Init                        ;-6
RTT_Functions

                        even


                        rsreset
rtt_ThisQSO           rs.l 1
rtt_Channel           rs.l 1
rtt_OldServer         rs.l 1
rtt_QSOBase           rs.l 1
rtt_Parameter         rs.l 1
rtt_DateStamp         rs.b 16
rtt_Temporary         rs.b 1024
rtt_Size              rs.b 0


ACT_Head              dc.l ACT_Name
                        dc.l 1
                        dc.l ACT_Init
                        dc.l 0
                        dc.l 8                  ;Subtype (5=Sysop interactive)

ACT_Name              dc.b "A",$1,"CTIVITY",0
                        even
ACT_Init              movem.l a6/a2-a4/d2-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #ACT_Functions-ACT_FunctionsBegin,d0
                        move.l #act_Size,d1
                        lea ACT_Functions,a0
                        move.l ppb_Global(a6),a5
                        jsr _QVOCreateServerBase(A6)
                        tst.l d0
                        beq .Cannot_Serve
                        move.l d0,a6
                        move.l a3,a5
                        move.l a3,act_QSOBase(a6)
                        move.l d7,act_OldServer(A6)
                        move.l d6,act_Channel(a6)
                        move.l a2,act_Parameter(a6)
                        move.l a4,act_ThisQSO(a6)
                        move.l a6,qso_Server(a4)

                        move.l a2,a0
                        GOQSO ParseComLine
                        tst.l d0
                        bne .Invalid_Parameters

                        lea act_DateStamp(a6),a0
                        move.l a0,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODateStamp(a6)
                        move.l (sp)+,a6

                        lea act_DateStamp2(a6),a0
                        GOQSO GetLastActivity

                        lea act_DateStamp2(a6),a0
                        move.l 4(a0),d1
                        mulu #60,d1
                        move.l 8(a0),d2
                        divu #50,d2
                        ext.l d2
                        add.l d2,d1
                        move.l d1,d0

                        lea act_DateStamp(a6),a1
                        move.l 4(a1),d1
                        mulu #60,d1
                        move.l 8(a1),d2
                        divu #50,d2
                        ext.l d2
                        add.l d2,d1

                        sub.l d0,d1

                        move.l (a1),d2
                        sub.l (a0),d2

.XLoop                  tst.l d2
                        beq .Good_ACT
                        add.l #3600*24,d1
.Good_ACT
                        move.l d1,-(sp)
                        moveq #6,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l (sp)+,d0
                        move.l d0,-(sp)

                        move.l a7,a1
                        lea .PutChar(pc),a2
                        lea act_Temporary(a6),a3
                        move.l a6,-(sp)
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(A6)
                        move.l (sp)+,a6
                        add.l #4,sp
                        lea act_Temporary(a6),a0
                        move.l act_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bra .Server_Success








.Server_Success         bsr ACT_Cleanup
                        movem.l (sp)+,a6/a2-a4/d2-d7
                        moveq #0,d0
                        rts

.PutChar                move.b d0,(a3)+
                        rts
.Cannot_Serve           movem.l (sp)+,a6/a2-a4/d2-d7
                        moveq #-1,d0
                        rts

.Invalid_Parameters     moveq #0,d0
.Abort_With_Text        bsr Get_Text
                        move.l d0,a0
                        move.l act_Channel(a6),d0
                        moveq #1,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        bsr ACT_Cleanup
                        movem.l (Sp)+,a6/a2-a4/d2-d7
                        moveq #0,d0
                        rts


ACT_Cleanup             move.l act_OldServer(a6),d0
                        move.l act_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #ACT_Functions-ACT_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

ACT_ConnectProced     rts

ACT_ReceivePacket     rts

ACT_TerminalInput     rts

ACT_AbortServer       rts

ACT_GetServerType     moveq #32,d0
                        rts

ACT_Nop                       rts


ACT_FunctionsBegin
                        AJUMP GEN_AskAudioPass                  ;-54
                        AJUMP ACT_AbortServer         ;-48
                        AJUMP ACT_GetServerType               ;-42
                        AJUMP ACT_TerminalInput               ;-36
                        AJUMP ACT_ReceivePacket               ;-30
                        AJUMP ACT_Nop                 ;-24
                        AJUMP ACT_ConnectProced               ;-18
                        AJUMP ACT_Cleanup             ;-12
                        AJUMP ACT_Init                        ;-6
ACT_Functions

                        even


                        rsreset
act_ThisQSO           rs.l 1
act_Channel           rs.l 1
act_OldServer         rs.l 1
act_QSOBase           rs.l 1
act_Parameter         rs.l 1
act_DateStamp         rs.b 16
act_DateStamp2        rs.b 16
act_Temporary         rs.b 1024
act_Size              rs.b 0



GEN_AskAudioPass move.l a6,-(sp)
                        move.l ver_OldServer(a6),a6
                        cmpa.l #0,a6
                        beq .NoServer
                        jsr _SVOAskAudio(a6)
.NoServer       move.l (sp)+,a6
                        rts


Get_Text                lea _MiscellaneousCatalog(pc),a0
                        move.l ver_ThisQSO(a6),a1
                        move.l a2,-(sp)
                        lea _MiscellaneousCatalogName(pc),a2
                        GOQSO GetText
                        move.l (sp)+,a2
                        rts

        

RTT_InvokeString        dc.b "//E //RTT PPRTT#%ld",$0d,0
COMP_Comp0              dc.b "//COMP 0",$0d,0
COMP_Comp1              dc.b "//COMP 1",$0d,0
                        even

                        include "/Catalogs/Sources/Miscellaneous.s"

