;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+
                nolist
			SECTION ".text",CODE


;BBS_DEBUG               EQU 1

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"

                        XDEF _freq
                        XDEF _prnt
                        XDEF _son
                        XDEF _getbuf
                        XDEF _getlen
                        XDEF _DOSBase
                        XDEF _SysBase
                        XDEF _UtilityBase
                        XDEF _infile
                        XDEF _outfile
                        XDEF _in_memory
                        XDEF _out_memory
                        XDEF _textsize
                        XDEF _codesize
                        XDEF _srcbuf
                        XDEF _destbuf
                        XDEF _srcbufptr
                        XDEF _destbufptr
                        XDEF _srclen
                        XDEF _destlen
                        XDEF _srcbuflen
                        XDEF _destbuflen
                        XDEF _text_buf
                        XDEF _match_position
                        XDEF _match_length
                        XDEF _dad
                        XDEF _same
                        XDEF _putbuf
                        XDEF _putlen
                        XDEF _lson
                        XDEF _rson


                        XREF _GetBuffers
                        XREF _FreeBuffers
                        XREF _enchuf
                        XREF _dechuf

                        XREF _crcthp_buf
                        XREF _crcfbb_buf

_Nil                    moveq #0,d0
                        rts
                        dc.b "ProfServ"
                
                
                        dc.l BBS_Name
                        dc.l 1
                        dc.l BBS_Init
                        dc.l 0
                        dc.l 0                  ;Subtype (0=General)
                                                ;Subtype (9=Mailing in FWD)

BBS_Name                dc.b "BBS",0
                        even


BBS_Init                movem.l a6/a4/d5-d7,-(sp)
                        move.l a0,a4
                        move.l a1,d7
                        move.l d0,d6
                        move.l a3,a6
                        move.l #BBS_Functions-BBS_FunctionsBegin,d0
                        move.l #bbs_Size,d1
                        lea BBS_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,bbs_QSOBase(a6)
                        move.l d7,bbs_OldServer(A6)
                        move.l d6,bbs_Channel(a6)
                        move.l a4,bbs_ThisQSO(a6)
                        clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        clr.l bbs_ForwardMode(a6)
                        clr.l bbs_ForwardType(a6)
                        clr.l bbs_IAmConnected(a6)
                        clr.l bbs_ConnectStep(a6)
                        clr.l bbs_MailHandle(a6)
                        clr.l bbs_MailHandle+4(a6)
                        clr.l bbs_MailHandle+8(a6)
                        clr.l bbs_MailHandle+12(a6)
                        clr.l bbs_MailHandle+16(a6)
                        clr.l bbs_FileHandle(a6)
                        clr.l bbs_MailIncomplete(a6)
                        clr.l bbs_PseudoBBS(a6)
                        clr.l bbs_LZHBufferFlag(a6)
                        clr.l bbs_ResumeMode(a6)
                        clr.l bbs_DeferOffset(a6)
                        move.l #2,bbs_FBBReturn(a6)
                        move.l a6,qso_Server(a4)
                        clr.l qso_SendPrompt(a4)
                        lea qso_Call(a4),a0
                        lea bbs_FWDCall(a6),a1
.Copy_Call              move.b (a0)+,d0
                        cmp.b #"-",d0
                        beq .Copy_Call_End
                        tst.b d0
                        beq .Copy_Call_End
                        cmp.b #"a",d0
                        blt .Copy_Call_Good
                        cmp.b #"z",d0
                        bgt .Copy_Call_Good
                        sub.b #32,d0
.Copy_Call_Good         move.b d0,(a1)+
                        bra .Copy_Call
.Copy_Call_End          clr.b (a1)
                        move.l bbs_ThisQSO(a6),a0
         move.l qso_User(a0),a0
         cmpa.l #0,a0
         beq .No_Silly_Sys
         lea user_CipherKey(a0),a0
         cmp.l #$53494c4c,(a0)
         bne .No_Silly_Sys
         cmp.l #$59535953,4(a0)
         bne .No_Silly_Sys          ;SILLYSYSOPOFBBS!
         cmp.l #$4f504f46,8(a0)     ;in cipher key
         bne .No_Silly_Sys          ;means "Roman Mode"
         cmp.l #$42425321,12(a0)
         bne .No_Silly_Sys
         move.l #1,bbs_PseudoBBS(a6)
.No_Silly_Sys
         bsr BBS_PresetSID

         move.l ppb_ExecBase(a5),_SysBase(a6)
         move.l ppb_DosBase(a5),_DOSBase(a6)
         move.l ppb_UtilityBase(a5),_UtilityBase(a6)
         movem.l (sp)+,a6/a4/d5-d7
                        moveq #0,d0
                        rts


.Cannot_Serve           movem.l (sp)+,a6/a4/d5-d7
                        moveq #0,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l d0,-(sp)
                        movem.l d2-d3,-(sp)
                        moveq #0,d1
                        moveq #0,d2
                        move.l a3,a6
                        jsr _QVOTransmitText(a6)
                        movem.l (sp)+,d2-d3
                        move.l (sp)+,d0
                        jsr _QVOForceTransmit(A6)
                        moveq #-1,d0
                        rts

BBS_Cleanup             tst.l bbs_FileHandle(A6)
                        beq .No_OpenFile
                        move.l bbs_FileHandle(a6),d1
                        move.l a6,-(sp)
                        clr.l bbs_FileHandle(a6)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
.No_OpenFile            tst.l bbs_ResumeMode(a6)
                        beq .No_ResumeMode
                        move.l bbs_MailHandle(a6),a0
                        cmpa.l #0,a0
                        beq .No_ResumeMode
                        bsr BBS_SaveResume
.No_ResumeMode          tst.l bbs_MailHandle(a6)
                        beq .No_OpenMail
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteTemporary
                        tst.l bbs_MailIncomplete(a6)
                        beq .No_Incomplete
                        move.l bbs_MailHandle(a6),a0
                        clr.l bbs_MailIncomplete(a6)
                        GOQSO MarkAsIncomp
.No_Incomplete          move.l bbs_MailHandle(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle(a6)
.No_OpenMail            tst.l bbs_MailHandle+4(a6)
                        beq .No_OpenMail2
                        move.l bbs_MailHandle+4(a6),a0
                        bsr BBS_DeleteTemporary
                        move.l bbs_MailHandle+4(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle+4(a6)
.No_OpenMail2           tst.l bbs_MailHandle+8(a6)
                        beq .No_OpenMail3
                        move.l bbs_MailHandle+8(a6),a0
                        bsr BBS_DeleteTemporary
                        move.l bbs_MailHandle+8(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle+8(a6)
.No_OpenMail3           tst.l bbs_MailHandle+12(a6)
                        beq .No_OpenMail4
                        move.l bbs_MailHandle+12(a6),a0
                        bsr BBS_DeleteTemporary
                        move.l bbs_MailHandle+12(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle+12(a6)
.No_OpenMail4           tst.l bbs_MailHandle+16(a6)
                        beq .No_OpenMail5
                        move.l bbs_MailHandle+16(a6),a0
                        bsr BBS_DeleteTemporary
                        move.l bbs_MailHandle+16(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle+16(a6)
.No_OpenMail5           tst.l bbs_LZHBufferFlag(a6)
                        beq .No_LZHBuffers
                        exg a4,a6
                        jsr _FreeBuffers
                        exg a4,a6
                        clr.l bbs_LZHBufferFlag(a6)
.No_LZHBuffers
                        move.l bbs_OldServer(a6),d0
                        move.l bbs_ThisQSO(a6),a0
                        move.l d0,qso_Server(a0)
                        move.l a6,a1
                        move.l ppb_ExecBase(a5),a6
                        sub.l #BBS_Functions-BBS_FunctionsBegin,a1
                        jsr _LVOFreeVec(A6)
                        moveq #0,d0
                        rts

BBS_HandshakeSID        lea bbs_OwnSID(a6),a0
                        lea bbs_PartnerSID(a6),a1

                        move.b sid_AVersion(a1),d0
                        cmp.b sid_AVersion(a0),d0
                        bgt .A_Older
                        move.b d0,sid_AVersion(a0)
.A_Older                move.b sid_BVersion(a1),d0
                        cmp.b sid_BVersion(a0),d0
                        bgt .B_Older
                        move.b d0,sid_BVersion(a0)
.B_Older                move.b sid_DVersion(a1),d0
                        cmp.b sid_DVersion(a0),d0
                        bgt .D_Older
                        move.b d0,sid_DVersion(a0)
.D_Older                move.b sid_FVersion(a1),d0
                        cmp.b sid_FVersion(a0),d0
                        bgt .F_Older
                        move.b d0,sid_FVersion(a0)
.F_Older                move.b sid_HVersion(a1),d0
                        cmp.b sid_HVersion(a0),d0
                        bgt .H_Older
                        move.b d0,sid_HVersion(a0)
.H_Older                move.b sid_MVersion(a1),d0
                        cmp.b sid_MVersion(a0),d0
                        bgt .M_Older
                        move.b d0,sid_MVersion(a0)
.M_Older                move.b sid_RVersion(a1),d0
                        cmp.b sid_RVersion(a0),d0
                        bgt .R_Older
                        move.b d0,sid_RVersion(a0)
.R_Older                move.b sid_DollarVersion(a1),d0
                        cmp.b sid_DollarVersion(a0),d0
                        bgt .Dol_Older
                        move.b d0,sid_DollarVersion(a0)
.Dol_Older

                        cmp.b #-1,sid_FVersion(a0)
                        beq .No_FBB_Forward
                        tst.l bbs_PseudoBBS(a6)
                        bne .No_FBB_Forward
                        exg a4,a6
                        jsr _GetBuffers
                        exg a4,a6
                        tst.l d0
                        beq .No_FBB_Forward
                        move.l #1,bbs_LZHBufferFlag(a6)
                        move.l #1,bbs_ForwardType(a6)
.No_FBB_Forward         rts


BBS_OutputSID           lea bbs_OwnSID(a6),a0
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitSID
                        rts

BBS_PresetSID           lea bbs_OwnSID(a6),a0
                        moveq #sid_Size-1,d0
.Clear_XX               move.b #-1,(a0)+
                        dbf d0,.Clear_XX
                        lea bbs_OwnSID(a6),a0
                        move.l #1,sid_Program(a0)
                        move.l #-1,sid_Version(a0)
                        move.l #-1,sid_Revision(a0)
                        move.l #-1,sid_Subrevision(a0)
                        move.l #1,sid_SystemType(a0)


                        move.b #0,sid_AVersion(a0)
                        move.b #1,sid_BVersion(a0)
                        move.b #1,sid_DVersion(a0)
                        move.b #0,sid_FVersion(a0)
                        move.b #0,sid_HVersion(a0)
                        move.b #0,sid_MVersion(a0)
                        move.b #0,sid_RVersion(a0)
                        move.b #0,sid_DollarVersion(a0)
                        rts

BBS_ConnectProced       tst.l bbs_ConnectStep(a6)
                        bne .Force_Step2
                        move.l #1,bbs_IAmConnected(a6)
                        bsr BBS_OutputSID
                        move.l #1,bbs_ConnectStep(a6)
                        move.l bbs_ThisQSO(A6),a0
                        move.l qso_User(a0),a0
                        cmpa.l #0,a0
                        beq .No_Password
                        cmp.b #1,user_LPType(a0)
                        blt .No_Password

                        lea BBS_Sysop(pc),a1
                        move.l a1,a0
                        GOQSO SearchSpecialServer
                        tst.l d0
                        beq .No_Password

                        move.l d0,a0
                        move.l bbs_Channel(a6),d0
                        sub.l a1,a1
                        GOQSO StartServer
                        tst.l d0
                        bne .No_Password
                        rts

.No_Password
.Force_Step2            cmp.l #2,bbs_ConnectStep(a6)
                        beq .Force_Step3
                        move.l #2,bbs_ConnectStep(a6)
                        sub.l #16,a7
                        move.l bbs_ThisQSO(a6),a0
                        lea qso_Call(a0),a0
                        move.l a7,a1
                        move.b #"B",(a1)+
                        move.b #"B",(a1)+
                        move.b #"S",(a1)+
                        move.b #"_",(a1)+
                        move.b #"C",(a1)+
                        move.b #"_",(a1)+
.Copy_ConnectCall       cmp.b #"-",(a0)
                        beq .Copy_ConnectEnd
                        tst.b (a0)
                        beq .Copy_ConnectEnd
                        move.b (A0)+,(A1)+
                        bra .Copy_ConnectCall
.Copy_ConnectEnd        clr.b (a1)+
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroFile
                        tst.l d0
                        beq .CText_Dumped
                        move.l a7,a1
                        move.b #"B",(a1)+
                        move.b #"B",(a1)+
                        move.b #"S",(a1)+
                        move.b #"_",(a1)+
                        move.b #"C",(a1)+
                        move.b #"_",(a1)+
                        move.b #"G",(a1)+
                        move.b #"L",(a1)+
                        move.b #"O",(a1)+
                        move.b #"B",(a1)+
                        move.b #"A",(a1)+
                        move.b #"L",(a1)+
                        clr.b (a1)+
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroFile
.CText_Dumped           add.l #16,a7
                        move.l bbs_ThisQSO(a6),a0
                        move.l qso_User(a0),a0
                        cmpa.l #0,a0
                        beq .Force_Step3
                        tst.l user_Datacollector(a0)
                        beq .Force_Step3
                        lea Serv_Datacollector,a0
                        GOQSO SearchSpecialServer
                        tst.l d0
                        beq .Force_Step3
                        move.l d0,a0
                        move.l bbs_Channel(a6),d0
                        lea BBS_Name(pc),a1
                        GOQSO StartServer
                        move.l bbs_ThisQSO(a6),a0
                        cmp.l qso_Server(a0),a6
                        beq .Force_Step3
                        rts
.Force_Step3            clr.l bbs_ConnectStep(a6)
                        bsr BBS_Prompt
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        rts

BBS_ReceivePacket       tst.l bbs_ConnectStep(a6)
                        beq .Good_Connect
                        bsr BBS_ConnectProced
.Good_Connect           movem.l d2-d7/a2-a6,-(sp)
                        move.l bbs_ThisQSO(a6),a0
                        tst.l qso_SendPrompt(a0)
                        beq .ReceivePacketRedo
                        clr.l qso_SendPrompt(a0)
                        bsr BBS_Prompt
.ReceivePacketRedo      cmp.l #8,bbs_ForwardMode(a6)
                        beq .FBB_ReceiveMe
                        cmp.l #9,bbs_ForwardMode(A6)
                        beq .FBB_TransmitMe
                        cmp.l #10,bbs_ForwardMode(a6)
                        beq .Exit
                        cmp.l #11,bbs_ForwardMode(a6)
                        beq .YAPP_ReceiveHead
                        cmp.l #12,bbs_ForwardMode(a6)
                        beq .YAPP_ReceiveData
                        cmp.l #14,bbs_ForwardMode(a6)
                        beq .Exit
                        move.l bbs_ThisQSO(A6),a0
                        GOQSO TestServBufferLin
                        tst.l d0
                        beq .Exit
                        move.l bbs_ServerInLine(a6),d1
                        cmp.l #250,d1
                        bge .Dump_Line
                        move.l #250,d2
                        sub.l d1,d2
                        cmp.l d2,d0
                        ble .No_Overmaxim
                        move.l d2,d0
.No_Overmaxim           lea bbs_ServerLine(a6),a0
                        add.l d1,a0
                        move.l d1,d2
                        move.l bbs_ThisQSO(a6),a1
                        GOQSO ReadServBuffer
                        add.l d0,bbs_ServerInLine(a6)
                        lea bbs_ServerLine(a6),a0
                        add.l d0,a0
                        add.l d2,a0
                        clr.b (a0) 
                        cmp.b #$0d,-1(a0)
                        bne .ReceivePacketRedo
                        clr.b -1(a0)
                        sub.l #1,bbs_ServerInLine(a6)
                        cmp.l #6,bbs_ForwardMode(a6)
                        bge .No_SID

                        sub.l a1,a1
                        lea bbs_ServerLine(a6),a0
                        cmp.b #"[",(a0)
                        bne .No_SID
.Search_ESID            tst.b (a0)+
                        bne .Search_ESID
                        cmp.b #"]",-2(a0)
                        bne .No_SID
                        lea bbs_ServerLine(a6),a0
                        lea bbs_PartnerSID(a6),a1
                        GOQSO ParseSID
                        tst.l d0
                        beq .No_SID
                        move.l bbs_ThisQSO(a6),a0
                        lea bbs_PartnerSID(a6),a1
                        GOQSO HandleSID
                        lea bbs_PartnerSID(a6),a0

                        move.l sid_Program(a0),d0
                        cmp.l #1,d0
                        beq .PPXPSid
                        cmp.l #10,d0
                        beq .PPXPSid
                        cmp.l #2,d0
                        bne .No_PPXPSid
.PPXPSid                move.l bbs_Channel(a6),d0
                        GOQSO TestNameRequest


.No_PPXPSid             lea bbs_PartnerSID(a6),a0
                        move.l sid_SystemType(a0),d0
                        cmp.l #1,d0
                        bne .Line_Handled

                        bsr BBS_HandshakeSID

                        ;SID accepted - switch to waiting for Prompt
                        ;             / passive forwarding
                        tst.l bbs_IAmConnected(a6)
                        bne .SID_Acknowledge
                        move.l #1,bbs_ForwardMode(a6)
                        bra .Line_Handled
.SID_Acknowledge
                        tst.l bbs_ForwardType(a6)
                        bne .FBB_ItsYourTurn
                        move.l #2,bbs_ForwardMode(a6)
                        lea BBS_ShortPrompt(pc),a0
                        moveq #2,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        bra .Line_Handled
.FBB_ItsYourTurn        clr.l bbs_FBBCounter(a6)
                        clr.l bbs_FBBChecksum(a6)
                        move.l #7,bbs_ForwardMode(a6)
                        bra .Line_Handled






.No_SID                 cmp.l #1,bbs_ForwardMode(a6)
                        bne .No_Wait_XPrompt


                        ;waiting for connecttext with prompt
                        ;check for sysop login

                        move.l bbs_Channel(A6),d0
                        lea bbs_ServerLine(a6),a0
                        GOQSO TestPasswordString
                        move.l bbs_Channel(A6),d0
                        lea bbs_ServerLine(a6),a0
                        GOQSO TestForwardConnect
                        tst.l d0
                        bne .Forward_Error_Immed
                        lea bbs_ServerLine(a6),a0
.Check_Password         cmp.b #" ",(a0)
                        bne .Check_Pass_NoSP
                        cmp.b #"P",1(a0)
                        beq .Check_PW
                        cmp.b #"S",1(a0)
                        beq .Check_SYS
                        bra .Check_Pass_NoSP
.Check_PW               cmp.b #"W",2(a0)
                        bne .Check_Pass_NoSP
                        cmp.b #" ",3(a0)
                        bne .Check_Pass_NoSP
                        moveq #0,d0
                        bra .Pass_Aquired
.Check_SYS              cmp.b #"Y",2(a0)
                        bne .Check_Pass_NoSP
                        cmp.b #"S",3(a0)
                        bne .Check_Pass_NoSP
                        cmp.b #" ",4(a0)
                        bne .Check_Pass_NoSP
                        moveq #1,d0
                        bra .Pass_Aquired
.Check_Pass_NoSP        tst.b (a0)++
                        bne .Check_Password
                        bra .No_PassSend
.Pass_Aquired           move.l bbs_ThisQSO(a6),a0
                        move.l qso_User(a0),a0
                        cmpa.l #0,a0
                        beq .No_PassSend
                        cmp.b #2,user_RPType(a0)
                        blt .No_PassSend

                        move.l bbs_Channel(a6),d0
                        sub.l a0,a0
                        GOQSO SendPassword
                        bra .Line_Handled

.No_PassSend            lea bbs_ServerLine(a6),a0
.XPrompt_End            tst.b (a0)+
                        bne .XPrompt_End
                        subq.l #1,a0
                        cmp.b #">",-1(a0)
                        beq .X_Prompt
                        cmp.b #" ",-1(a0)
                        bne .No_Wait_XPrompt
                        cmp.b #">",-2(a0)
                        bne .No_Wait_XPrompt
.X_Prompt
                        ;Prompt accepted - switch to waiting for F-Prompt
                        move.l #3,bbs_ForwardMode(a6)
                        tst.l bbs_PseudoBBS(A6)
                        bne .Active_Forward
                        bsr BBS_OutputSID
                        tst.l bbs_ForwardType(a6)
                        bne .FBB_ItsMyTurn
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        bra .Line_Handled


.FBB_ItsMyTurn
                        lea bbs_FWDCall(a6),a0
                        GOQSO TestForwardTime
                        tst.l d0
                        bne .FBB_ItsMyTurn_NoTimeo
                        clr.l -(a7)
                        move.l a7,a0
                        move.b #"F",(a0)
                        move.b #"F",1(a0)
                        move.b #$0d,2(a0)
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l (sp)+,d0
                        bra .Forward_Error_Immed

.FBB_ItsMyTurn_NoTimeo  moveq #0,d7
.FBB_ItsMyTurnCollectL  lea bbs_FWDCall(a6),a0
                        move.l d7,d0
                        add.l bbs_DeferOffset(a6),d0
                        GOQSO GetNextFMail
                        tst.l d0
                        beq .FBB_MyTurn_NoMoreMail
                        sub.l a0,a0
                        GOQSO OpenMail
                        tst.l d0
                        beq .FBB_MyTurn_NoMoreMail
                        cmp.l #-1,d0
                        beq .FBB_MyTurn_NoMoreMail
                        cmp.l #-2,d0
                        beq .FBB_MyTurn_NoMoreMail
                        move.l d0,a0
                        move.l d0,-(sp)
                        GOQSo GetMailStatus
                        move.l d0,d1
                        move.l (sp)+,d0
                        btst #30,d1
                        beq .No_FBB_SkipAutoBin
                        lea bbs_OwnSID(a6),a0
                        cmp.b #-1,sid_DVersion(a0)
                        bne .No_FBB_SkipAutoBin
                        move.l d0,a0
                        move.l a0,-(sp)
                        GOQSO GetNumberMail
                        lea bbs_FWDCall(a6),a0
                        GOQSO RemoveFMail
                        move.l (sp)+,a0
                        GOQSO CloseMail
                        bra .FBB_ItsMyTurnCollectL
.No_FBB_SkipAutoBin     btst #0,d1
                        bne .No_FBB_Skip_Bulletin
                        move.l d0,-(sp)
                        move.l bbs_ThisQSO(a6),a0
                        lea qso_Call(a0),a0
                        GOQSO TestPrivateMail
                        move.l d0,d1
                        move.l (sp)+,d0
                        tst.l d1
                        beq .No_FBB_Skip_Bulletin
                        add.l #1,bbs_DeferOffset(a6)
                        bra .FBB_ItsMyTurnCollectL
.No_FBB_Skip_Bulletin   move.l d7,d1
                        asl.l #2,d1
                        lea bbs_MailHandle(a6),a0
                        add.l d1,a0
                        move.l d0,(a0)
                        move.l d0,a0
                        bsr BBS_TranslateMailTX
                        cmp.l #-1,d0
                        beq .Forward_Error
                        lea bbs_PropBytes(a6),a0
                        move.l d7,d1
                        asl.l #2,d1
                        add.l d1,a0
                        move.l d0,(a0)
                        addq.l #1,d7
                        cmp.l #5,d7
                        blt .FBB_ItsMyTurnCollectL
.FBB_MyTurn_NoMoreMail  tst.l d7
                        beq .FBB_MyTurn_LastMailed
                        ;DO A FBB-STYLE FWD MODE
                        moveq #0,d6
                        moveq #0,d5
.FBB_MyTurn_OutputLine  move.l d6,d0
                        bsr FBB_MakeProposalLine
                        move.l d0,d4
                        lea bbs_OwnSID(a6),a0
                        cmp.b #-1,sid_DVersion(a0)
                        bne .FBB_MyTurn_ProposeD
                        move.l d4,d0
                        tst.l d0
                        beq .FBB_MyTurn_ProposeE
                        lea bbs_ServerLine(a6),a0
.FBB_MyTurn_ProposeF_L  moveq #0,d1
                        move.b (a0)+,d1
                        add.l d1,d5
                        subq.l #1,d0
                        tst.l d0
                        bgt .FBB_MyTurn_ProposeF_L
                        bra .FBB_MyTurn_ProposeE
.FBB_MyTurn_ProposeD    move.l d4,d0
                        subq.l #1,d0
                        tst.l d0
                        ble .FBB_MyTurn_ProposeE
                        move.l d5,-(sp)
                        lea 2(sp),a0
                        move.l a0,-(sp)
                        move.l d0,-(sp)
                        lea bbs_ServerLine(a6),a0
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcthp_buf
                        exg a4,a6
                        add.l #12,sp
                        move.l (sp)+,d5
.FBB_MyTurn_ProposeE    move.l bbs_Channel(a6),d1
                        lea bbs_ServerLine(a6),a0
                        move.l d4,d0
                        GOQSO TransmitData
                        addq.l #1,d6
                        cmp.l d7,d6
                        blt .FBB_MyTurn_OutputLine
                        lea bbs_ServerLine(a6),a4
                        move.b #"F",(a4)+
                        move.b #">",(a4)+
                        move.b #" ",(a4)+
                        lea bbs_OwnSID(a6),a0
                        cmp.b #-1,sid_DVersion(a0)
                        bne .FBB_MyTurn_CRCDBox
                        move.l d5,d0
                        neg.l d0
                        move.l a4,a0
                        bsr BBS_PutHexa
                        move.l a0,a4
                        bra .FBB_MyTurn_CRCAdded
.FBB_MyTurn_CRCDBox     cmp.l #12,sid_Program(a0)
                        bne .No_STOPFix2
                        move.l d5,d0
                        lsr.l #8,d0
                        and.l #$ff,d0
                        bsr BBS_PutHexa
                        move.l d5,d0
                        and.l #$ff,d0
                        move.l a4,a0
                        bsr BBS_PutHexa
                        move.l a0,a4
                        bra .FBB_MyTurn_CRCAdded

.No_STOPFix2            move.l d5,d0
                        and.l #$ff,d0
                        move.l a4,a0
                        bsr BBS_PutHexa
                        move.l d5,d0
                        lsr.l #8,d0
                        and.l #$ff,d0
                        bsr BBS_PutHexa
                        move.l a0,a4

.FBB_MyTurn_CRCAdded    move.b #$0d,(a4)+
                        move.l a4,d0
                        lea bbs_ServerLine(a6),a0
                        sub.l a0,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l #6,bbs_ForwardMode(a6)
                        bra .Line_Handled
.FBB_MyTurn_LastMailed

                        clr.l -(a7)
                        move.l a7,a0
                        move.b #"F",(a0)
                        move.b #"F",1(a0)
                        move.b #$0d,2(a0)
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l (sp)+,d0
                        move.l #7,bbs_ForwardMode(a6)
                        clr.l bbs_FBBCounter(a6)
                        clr.l bbs_FBBChecksum(a6)
                        bra .Line_Handled
.No_Wait_XPrompt
                        cmp.l #3,bbs_ForwardMode(a6)
                        bne .No_Wait_FWDPrompt
                        tst.l bbs_PseudoBBS(A6)
                        beq .No_Pseudo_Prompt
                        lea bbs_ServerLine(a6),a0
.Scan_Pseudo_Prompt     tst.b (a0)+
                        bne .Scan_Pseudo_Prompt
                        cmp.b #">",-2(a0)
                        bne .No_Wait_FWDPrompt
                        bra .Active_Forward
.No_Pseudo_Prompt       lea bbs_ServerLine(a6),a0
                        cmp.b #">",(a0)
                        bne .No_Wait_FWDPrompt
                        tst.b 1(a0)
                        bne .No_Wait_FWDPrompt

                        ;FWD - DO ACTIVE COMMAND !!!!
.Active_Forward         tst.l bbs_MailHandle(a6)
                        beq .Active_Forward_GM
                        move.l bbs_MailHandle(a6),a0
                        GOQSO MarkAsForward
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteTemporary
                        move.l bbs_MailHandle(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle(a6)
                        lea bbs_FWDCall(a6),a0
                        move.l bbs_ActiveMail(a6),d0
                        GOQSO RemoveFMail
.Active_Forward_GM

                        ;Standard protocol

                        lea bbs_FWDCall(a6),a0
                        GOQSO TestForwardTime
                        tst.l d0
                        bne .AFor_NoTimeout
                        clr.l -(a7)
                        move.l a7,a0
                        move.b #"F",(a0)
                        move.b #"F",1(a0)
                        move.b #$0d,2(a0)
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l (sp)+,d0
                        bra .Forward_Error_Immed

.AFor_NoTimeout
                        move.l bbs_DeferOffset(a6),d0
                        lea bbs_FWDCall(a6),a0
                        GOQSO GetNextFMail
                        tst.l d0
                        beq .Make_Me_Reverse

                        move.l d0,bbs_ActiveMail(a6)
                        sub.l a0,a0
                        GOQSO OpenMail
                        tst.l d0
                        beq .Skip_OpenErrMail
                        move.l d0,bbs_MailHandle(a6)


                        move.l bbs_MailHandle(a6),a0
                        GOQSO GetMailStatus
                        btst #30,d0
                        beq .No_Skip_AutoBin
                        lea bbs_OwnSID(A6),a0
                        cmp.b #-1,sid_DVersion(a0)
                        bne .No_Skip_AutoBin
                        move.l bbs_MailHandle(a6),a0
                        GOQSO GetNumberMail
                        lea bbs_FWDCall(a6),a0
                        GOQSO RemoveFMail
                        move.l bbs_MailHandle(a6),a0
                        GOQSO CloseMail
                        clr.l bbs_MailHandle(a6)
                        bra .Active_Forward_GM
.No_Skip_AutoBin        btst #0,d1
                        bne .No_Skip_Bulletin
                        move.l d0,-(sp)
                        move.l bbs_ThisQSO(a6),a0
                        lea qso_Call(a0),a0
                        GOQSO TestPrivateMail
                        move.l d0,d1
                        move.l (sp)+,d0
                        tst.l d1
                        beq .No_FBB_Skip_Bulletin
                        add.l #1,bbs_DeferOffset(a6)
                        bra .Active_Forward_GM
.No_Skip_Bulletin
                        clr.l bbs_MailHandleOffset(a6)

                        bsr BBS_OutputSLine
                        move.l #4,bbs_ForwardMode(a6)
                        bra .Line_Handled

.Skip_OpenErrMail       lea bbs_FWDCall(a6),a0
                        move.l bbs_ActiveMail(a6),d0
                        GOQSO RemoveFMail
                        tst.l d0
                        beq .Make_Me_Reverse

.Make_Me_Reverse        
                        tst.l bbs_PseudoBBS(a6)
                        bne .Make_Pseudo_Bye
                        ;FWD - DO REVERSE FOWARD !!!!
                        subq.l #4,a7
                        move.l #$463e0d00,(a7)
                        move.l a7,a0
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        addq.l #4,a7
                        move.l #2,bbs_ForwardMode(a6)
                        bra .Line_Handled
.Make_Pseudo_Bye        subq.l #4,a7
                        move.l #$420d0000,(a7)
                        move.l a7,a0
                        moveq #2,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        addq.l #4,a7
                        move.l #3,bbs_ForwardMode(a6)
                        bra .Line_Handled
.No_Wait_FWDPrompt
                        move.l bbs_Channel(A6),d0
                        lea bbs_ServerLine(a6),a0
                        GOQSO TestForwardConnect
                        tst.l d0
                        bne .Forward_Error_Immed
                        tst.l bbs_ForwardMode(a6)
                        beq .Yes_Remote
                        cmp.l #2,bbs_ForwardMode(a6)
                        beq .Yes_Remote
                        cmp.l #4,bbs_ForwardMode(a6)
                        beq .Std_Fwd_YESNO
                        cmp.l #6,bbs_ForwardMode(a6)
                        beq .FBB_Fwd_ParseFS
                        cmp.l #7,bbs_ForwardMode(a6)
                        beq .FBB_Fwd_Receive
                        bra .Line_Handled
.FBB_Fwd_ParseFS        lea bbs_ServerLine(a6),a0
                        cmp.b #"F",(a0)
                        bne .Forward_Error
                        cmp.b #"S",1(a0)
                        bne .Forward_Error
                        cmp.b #" ",2(a0)
                        bne .Forward_Error
                        lea 3(a0),a4
                        lea bbs_MailHandle(a6),a3
                        moveq #5,d7
.FBB_Fwd_ParseFS_L      tst.b (a4)
                        beq .FBB_Fwd_ParseFS_Done
                        tst.l (A3)
                        beq .Forward_Error
                        tst.l d7
                        beq .Forward_Error
                        move.b (a4)+,d0
                        cmp.b #"-",d0
                        beq .Parse_FS_Reject
                        cmp.b #"=",d0
                        beq .Parse_FS_Defer
                        cmp.b #"+",d0
                        beq .Parse_FS_Want
                        cmp.b #"!",d0
                        beq .Parse_FS_Want_Resume
                        cmp.b #"H",d0
                        beq .Parse_FS_Want
                        cmp.b #"E",d0
                        beq .Parse_FS_Reject
                        cmp.b #"R",d0
                        beq .Parse_FS_Reject
                        bra .Forward_Error
.Parse_FS_Defer         subq.l #1,d7
                        add.l #1,bbs_DeferOffset(a6)
                        move.l (a3),a0
                        bsr BBS_DeleteTemporary
                        move.l (a3),a0
                        GOQSO CloseMail
                        clr.l (a3)
                        addq.l #4,a3
                        bra .FBB_Fwd_ParseFS_L
.Parse_FS_Reject        move.l (a3),a0
                        GOQSO GetNumberMail
                        lea bbs_FWDCall(a6),a0
                        GOQSO RemoveFMail
                        subq.l #1,d7
                        move.l (a3),a0
                        bsr BBS_DeleteTemporary
                        move.l (a3),a0
                        GOQSO CloseMail
                        clr.l (a3)
                        addq.l #4,a3
                        bra .FBB_Fwd_ParseFS_L
.Parse_FS_Want_Resume   move.l a4,d1
                        clr.l -(a7)
                        move.l a7,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 .Forward_Error
                        add.l d0,a4
                        moveq #5,d0
                        sub.l d7,d0
                        asl.l #2,d0
                        lea bbs_PropResume(a6),a0
                        add.l d0,a0
                        move.l d1,(a0)
                        addq.l #1,d7
                        addq.l #4,a3
                        bra .FBB_Fwd_ParseFS_L
.Parse_FS_Want          moveq #5,d0
                        sub.l d7,d0
                        asl.l #2,d0
                        lea bbs_PropResume(a6),a0
                        add.l d0,a0
                        clr.l (a0)
                        subq.l #1,d7
                        addq.l #4,a3
                        bra .FBB_Fwd_ParseFS_L
.FBB_Fwd_ParseFS_Done   tst.l d7
                        beq .FBB_Fwd_ParseFS_Good
                        tst.l (a3)
                        beq .FBB_Fwd_ParseFS_Good
                        bra .Forward_Error
.FBB_Fwd_ParseFS_Good
                        clr.l bbs_FBBCounter(a6)
                        clr.l bbs_FBBChecksum(a6)
                        lea bbs_MailHandle(a6),a0
                        tst.l (a0)
                        bne .FBB_FSWantAny
                        tst.l 4(a0)
                        bne .FBB_FSWantAny
                        tst.l 8(a0)
                        bne .FBB_FSWantAny
                        tst.l 12(a0)
                        bne .FBB_FSWantAny
                        tst.l 16(a0)
                        bne .FBB_FSWantAny
                        move.l #7,bbs_ForwardMode(a6)
                        clr.b bbs_ServerLine(A6)
                        clr.l bbs_ServerInLine(a6)
                        bra .Line_Handled
.FBB_FSWantAny          clr.l bbs_FBBCounter(a6)
                        clr.l bbs_FBBChecksum(a6)
                        bra .FBB_TransmitMe
.FBB_Fwd_Receive        lea bbs_ServerLine(a6),a0
                        cmp.b #"*",(a0)
                        beq .Line_Handled
                        cmp.b #"F",(a0)
                        bne .Forward_Error
                        move.b 1(a0),d0
                        cmp.b #"A",d0
                        beq .FBB_ASCII
                        cmp.b #"B",d0
                        beq .FBB_Binary
                        cmp.b #"D",d0
                        beq .FBB_DieBox
                        cmp.b #"F",d0
                        beq .FBB_Reverse
                        cmp.b #"Q",d0
                        beq .FBB_Quit
                        cmp.b #">",d0
                        beq .FBB_MakeMe
                        bra .Forward_Error
.FBB_ASCII              moveq #0,d0
                        bra .FBB_ParseProposal
.FBB_Binary             moveq #1,d0
                        bra .FBB_ParseProposal
.FBB_DieBox             moveq #2,d0
.FBB_ParseProposal      bsr .FBB_TestGoodMail
                        move.l bbs_FBBCounter(a6),d1
                        cmp.l #5,d1
                        beq .Forward_Error
                        bsr BBS_ParseProposalLine
                        tst.l d0
                        bne .Forward_Error
                        lea bbs_ServerLine(a6),a0
                        lea bbs_OwnSID(a6),a1
                        cmp.b #-1,sid_DVersion(a1)
                        bne .FBB_PCheckDBox
                        move.l bbs_FBBChecksum(a6),d1
.FBB_PCheckFBB          moveq #0,d0
                        move.b (a0)+,d0
                        beq .FBB_PCheckFBB_NL
                        add.l d0,d1
                        bra .FBB_PCheckFBB
.FBB_PCheckFBB_NL       add.l #$0d,d1
                        move.l d1,bbs_FBBChecksum(a6)
                        bra .FBB_PChecked
.FBB_PCheckDBox         moveq #-1,d0
.FBB_PCheckDCount       addq.l #1,d0
                        tst.b (a0)+
                        bne .FBB_PCheckDCount
                        lea bbs_FBBChecksum(a6),a0
                        lea 2(a0),a0
                        move.l a0,-(sp)
                        move.l d0,-(sp)
                        lea bbs_ServerLine(a6),a0
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcthp_buf
                        exg a4,a6
                        add.l #12,sp
.FBB_PChecked           add.l #1,bbs_FBBCounter(a6)
                        bra .Line_Handled

.FBB_MakeMe             tst.l bbs_FBBCounter(a6)
                        beq .Forward_Error
                        lea bbs_ServerLine(a6),a0
                        tst.b 2(a0)
                        beq .FBB_MakeMe_OKChecksum
                        cmp.b #" ",2(a0)
                        bne .Forward_Error
                        lea 3(a0),a0
                        lea bbs_OwnSID(a6),a1
                        cmp.b #-1,sid_DVersion(A1)
                        bne .FBB_MakeMeDBox
                        bsr BBS_GetHexa
                        cmp.l #-1,d0
                        beq .Forward_Error_Check
                        add.l bbs_FBBChecksum(a6),d0
                        and.l #$ff,d0
                        tst.l d0
                        bne .Forward_Error_Check
                        bra .FBB_MakeMe_OKChecksum
.FBB_MakeMeDBox         cmp.l #12,sid_Program(A1)
                        bne .FBB_NoSTOPFix1
                        asl.l #8,d0
                        move.l d0,-(sp)
                        bsr BBS_GetHexa
                        move.l (sp)+,d1
                        cmp.l #-1,d0
                        beq .Forward_Error_Check
                        or.l d1,d0
                        cmp.l bbs_FBBChecksum(a6),d0
                        bne .Forward_Error_Check
                        bra .FBB_MakeMe_OKChecksum
.FBB_NoSTOPFix1         bsr BBS_GetHexa
                        cmp.l #-1,d0
                        beq .Forward_Error_Check
                        move.l d0,-(sp)
                        bsr BBS_GetHexa
                        move.l (sp)+,d1
                        cmp.l #-1,d0
                        beq .Forward_Error_Check
                        asl.l #8,d0
                        or.l d1,d0
                        cmp.l bbs_FBBChecksum(a6),d0
                        bne .Forward_Error_Check
.FBB_MakeMe_OKChecksum  ;Compile FS line
                        lea bbs_OutputLine(a6),a4
                        move.b #"F",(a4)+
                        move.b #"S",(a4)+
                        move.b #" ",(A4)+
                        moveq #0,d7
                        moveq #0,d6
.FBB_MakeMe_FS          cmp.l bbs_FBBCounter(a6),d7
                        beq .FBB_MakeMe_FS_End

                        lea bbs_PropType(a6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        tst.l (a0)
                        bne .FBB_MakeMe_Personal
                        move.l bbs_ThisQSO(a6),a0
                        lea qso_Call(a0),a0
                        GOQSO TestPrivateMail
                        tst.l d0
                        beq .FBB_MakeMe_Personal
                        cmp.l #1,d0
                        beq .FBB_MakeMe_Skipme
                        cmp.l #2,d0
                        beq .FBB_MakeMe_SkipMe_Rej
                        cmp.l #3,d0
                        beq .FBB_MakeMe_SkipMe_Def
.FBB_MakeMe_Personal    lea bbs_PropBid(a6),a0
                        move.l d7,d0
                        asl.l #4,d0
                        add.l d0,a0
                        move.l a0,a3

                        ifd BBS_DEBUG
                        lea DEBUG_CheckingBID(pc),a1
                        bsr DEBUG_OutputFormat
                        move.l a3,a0
                        endif

                        move.l a0,-(sp)
.illitest               move.b (a0)+,d0
                        beq .noilli
                        cmp.b #":",d0
                        beq .illi
                        cmp.b #"/",d0
                        bne .illitest
.illi                   move.l (sp)+,a0
                        bra .FBB_MakeMe_SkipMe_Rej
.noilli                 move.l (sp)+,a0

                        GOQSO SearchMailBid
                        tst.l d0
                        bne .FBB_MakeMe_Skipme
                        bra .FBB_MakeMe_Takeme

.FBB_MakeMe_Takeme      move.l a3,a0
                        lea bbs_PropBytes(a6),a1
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a1
                        move.l (a1),d0
                        bsr BBS_TestResume
                        tst.l d0
                        bne .FBB_MakeMe_Takeme_Res
                        move.b #"+",(a4)+
                        lea bbs_PropTaken(a6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        move.l #1,(a0)
                        addq.l #1,d7
                        addq.l #1,d6
                        bra .FBB_MakeMe_FS
.FBB_MakeMe_Takeme_Res  move.b #"!",(A4)+
                        move.l d0,-(sp)
                        move.l a7,a1
                        move.l a4,a3
                        lea .PutChar(pc),a2
                        move.l #$256c6400,-(sp)
                        move.l a7,a0
                        move.l a6,-(sp)
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(a6)
                        move.l (sp)+,a6
                        addq.l #8,a7
.FBB_MakeMe_Takeme_ReL  tst.b (a4)+
                        bne .FBB_MakeMe_Takeme_ReL
                        subq.l #1,a4
                        lea bbs_PropTaken(a6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        move.l #1,(a0)
                        addq.l #1,d7
                        addq.l #1,d6
                        bra .FBB_MakeMe_FS
.FBB_MakeMe_SkipMe_Def  move.b #"=",(a4)+
                        bra .FBB_MakeMe_Skipme_Com
.FBB_MakeMe_SkipMe_Rej  move.b #"R",(a4)+
                        bra .FBB_MakeMe_Skipme_Com
.FBB_MakeMe_Skipme      move.b #"-",(a4)+
.FBB_MakeMe_Skipme_Com  lea bbs_PropTaken(A6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        clr.l (a0)
                        addq.l #1,d7
                        bra .FBB_MakeMe_FS
.FBB_MakeMe_FS_End      move.b #$0d,(a4)+
                        lea bbs_OutputLine(A6),a0
                        sub.l a0,a4
                        move.l a4,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        tst.l d6
                        beq .FBB_MakeMe_FS_None
                        move.l bbs_Channel(A6),d0
                        GOQSO ForceTransmit
                        move.l #2,bbs_FBBReturn(a6)
                        bra .FBB_ReceiveMe
.FBB_MakeMe_FS_None     clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        bra .FBB_ItsMyTurn
.FBB_Quit               tst.l bbs_FBBCounter(a6)
                        bne .Forward_Error
                        bsr .FBB_TestGoodMail
                        clr.l bbs_ForwardMode(a6)
                        clr.l bbs_ForwardType(a6)
                        move.l #"DDDD",-(a7)
                        move.l a7,a0
                        moveq #1,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitCommand
                        addq.l #4,a7
                        bra .Line_Handled
.FBB_Reverse            tst.l bbs_FBBCounter(a6)
                        bne .Forward_Error
                        bsr .FBB_TestGoodMail
                        lea bbs_FWDCall(a6),a0
                        move.l bbs_DeferOffset(a6),d0
                        GOQSO GetNextFMail
                        tst.l d0
                        beq .FBB_ReverseQuit
                        clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        bra .FBB_ItsMyTurn

.FBB_ReverseQuit        clr.l -(a7)
                        move.l a7,a0
                        move.b #"F",(a0)
                        move.b #"Q",1(a0)
                        move.b #$0d,2(a0)
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l (sp)+,d0
                        clr.l bbs_ForwardMode(a6)
                        clr.l bbs_ForwardType(a6)
                        bra .Line_Handled
.Std_Fwd_YESNO          tst.l bbs_PseudoBBS(a6)
                        beq .Real_Std_Fwd_YESNO
                        lea PseudoStr_OK1,a0
                        bsr .ScanLine_Pseudo
                        tst.l d0
                        bne .Pseudo_Forward_OK
                        lea PseudoStr_NO1,a0
                        bsr .ScanLine_Pseudo
                        tst.l d0
                        bne .Std_Fwd_RejectMe
                        bra .Line_Handled
.ScanLine_Pseudo        movem.l a2/a3,-(sp)
                        move.l a0,a2
                        lea bbs_ServerLine(a6),a3
.ScanLine_Pseudo_L1     move.l a2,a0
                        move.l a3,a1
                        tst.b (a3)
                        beq .Scanline_Pseudo_Dif
                        addq.l #1,a3
.ScanLine_Pseudo_L2     move.b (a0)+,d0
                        tst.b d0
                        beq .Scanline_Pseudo_Equ
                        cmp.b (a1)+,d0
                        bne .ScanLine_Pseudo_L1
                        bra .ScanLine_Pseudo_L2
.Scanline_Pseudo_Equ    movem.l (sp)+,a2/a3
                        moveq #1,d0
                        rts
.Scanline_Pseudo_Dif    movem.l (sp)+,a2/a3
                        moveq #0,d0
                        rts
.Real_Std_Fwd_YESNO     lea bbs_ServerLine(a6),a0
                        cmp.w #"NO",(a0)
                        beq .Std_Fwd_RejectMe
                        cmp.w #"OK",(a0)
                        bne .Forward_Error

                        ;Really forward mail - standard protocol
.Pseudo_Forward_OK      move.l #5,bbs_ForwardMode(a6)
                        bsr BBS_OutputSHead

                        bra .Line_Handled
.Std_Fwd_RejectMe       move.l bbs_ActiveMail(a6),d0
                        lea bbs_FWDCall(a6),a0
                        GOQSO RemoveFMail
                        move.l #3,bbs_ForwardMode(a6)
                        bra .Line_Handled


.Forward_Error_Immed    sub.l #4,a7
                        move.l #"DDDD",(a7)
                        move.l a7,a0
                        moveq #1,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitCommand
                        addq.l #4,a7
                        move.l #14,bbs_ForwardMode(a6)
                        bra .Exit
.Forward_Error          sub.l #16,a7
                        move.l #"***e",(a7)
                        move.l #"rror",4(a7)
                        move.b #$0d,8(a7)
                        clr.b 9(a7)
                        move.l a7,a0
                        moveq #9,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l #"DDDD",(a7)
                        move.l a7,a0
                        moveq #1,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitCommand
                        add.l #16,a7
                        move.l #14,bbs_ForwardMode(a6)
                        bra .Exit

.Forward_Error_Check    sub.l #32,a7
                        move.l #"*** ",(a7)
                        move.l #"Chec",4(a7)
                        move.l #"ksum",8(a7)
                        move.l #" err",12(a7)
                        move.w #"or",16(a7)
                        move.b #$0d,18(a7)
                        clr.b 19(a7)
                        move.l a7,a0
                        moveq #19,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l #"DDDD",(a7)
                        move.l a7,a0
                        moveq #1,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitCommand
                        add.l #32,a7
                        move.l #14,bbs_ForwardMode(a6)
                        bra .Exit

.Yes_Remote
                        cmp.l #2,bbs_ForwardMode(a6)
                        bne .Yes_Remote_NoTimeo
                        lea bbs_FWDCall(a6),a0
                        GOQSO TestForwardTime
                        tst.l d0
                        bne .Yes_Remote_NoTimeo
                        clr.l -(a7)
                        move.l a7,a0
                        move.b #"F",(a0)
                        move.b #"F",1(a0)
                        move.b #$0d,2(a0)
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l (sp)+,d0
                        bra .Forward_Error_Immed

.Yes_Remote_NoTimeo

                        move.l bbs_Channel(a6),d0
                        lea bbs_ServerLine(a6),a0
                        cmp.b #"#",(a0)
                        bne .No_XPLineCommand
                        GOQSO HandleXPLine
                        bra .Line_Handled
.No_XPLineCommand

                        move.l bbs_ThisQSO(a6),a0
                        move.l bbs_ForwardMode(a6),qso_ForwardFlag(a0)
                        sub.l a1,a1
                        lea bbs_ServerLine(a6),a0
.Enlarge_Command        move.b (a0),d0
                        tst.l d0
                        beq .Enlarged
                        cmp.b #$20,d0
                        beq .Enlarged_DoSpace
                        cmp.b #$61,d0
                        blt .No_EnlargeCom
                        cmp.b #$7a,d0
                        bgt .No_EnlargeCom
                        sub.b #$20,d0
.No_EnlargeCom          move.b d0,(a0)+
                        bra .Enlarge_Command
.Enlarged_DoSpace       clr.b (a0)
                        move.l a0,a1
                        addq.l #1,a1
.Enlarged
                        tst.l bbs_ForwardMode(a6)
                        bne .Forward_SkipRemote

                        lea bbs_ServerLine(a6),a0
                        cmp.b #"I",(a0)
                        bne .No_InfoRemote
                        tst.b 1(a0)
                        beq .Info_Remote
                        cmp.b #"N",1(a0)
                        bne .No_InfoRemote
                        tst.b 2(a0)
                        beq .Info_Remote
                        cmp.b #"F",2(a0)
                        bne .No_InfoRemote
                        tst.b 3(a0)
                        beq .Info_Remote
                        cmp.b #"O",3(a0)
                        bne .No_InfoRemote
                        tst.b 4(a0)
                        bne .No_InfoRemote
.Info_Remote            sub.l #16,a7
                        move.l a7,a1
                        move.b #"B",(a1)+
                        move.b #"B",(a1)+
                        move.b #"S",(a1)+
                        move.b #"_",(a1)+
                        move.b #"I",(a1)+
                        clr.b (a1)+
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroFile
                        add.l #16,a7
                        tst.l d0
                        beq .Info_Success
                        moveq #2,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l bbs_Channel(a6),d0
                        moveq #1,d1
                        moveq #1,d2
                        GOQSO TransmitText
.Info_Success           bsr BBS_Prompt
                        bra .Line_Handled
.No_InfoRemote          lea bbs_ServerLine(a6),a0
                        cmp.b #"B",(a0)
                        bne .No_ByeRemote
                        tst.b 1(a0)
                        beq .Quit_Remote
                        cmp.b #"Y",1(a0)
                        bne .No_ByeRemote
                        tst.b 2(a0)
                        beq .Quit_Remote
                        cmp.b #"E",2(a0)
                        beq .Quit_Remote
.No_ByeRemote           cmp.b #"Q",(a0)
                        bne .No_QuitRemote
                        tst.b 1(a0)
                        beq .Quit_Remote
                        cmp.b #"U",1(a0)
                        bne .No_QuitRemote
                        tst.b 2(a0)
                        beq .Quit_Remote
                        cmp.b #"I",2(a0)
                        bne .No_QuitRemote
                        tst.b 3(a0)
                        beq .Quit_Remote
                        cmp.b #"T",3(a0)
                        bne .No_QuitRemote
                        tst.b 4(a0)
                        bne .No_QuitRemote
.Quit_Remote            sub.l #16,a7
                        move.l bbs_ThisQSO(a6),a0
                        lea qso_Call(a0),a0
                        move.l a7,a1
                        move.b #"B",(a1)+
                        move.b #"B",(a1)+
                        move.b #"S",(a1)+
                        move.b #"_",(a1)+
                        move.b #"Q",(a1)+
                        move.b #"_",(a1)+
.Q_Copy_ConnectCall     cmp.b #"-",(a0)
                        beq .Q_Copy_ConnectEnd
                        tst.b (a0)
                        beq .Q_Copy_ConnectEnd
                        move.b (A0)+,(A1)+
                        bra .Q_Copy_ConnectCall
.Q_Copy_ConnectEnd      clr.b (a1)+
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroFile
                        tst.l d0
                        beq .QText_Dumped
                        move.l a7,a1
                        move.b #"B",(a1)+
                        move.b #"B",(a1)+
                        move.b #"S",(a1)+
                        move.b #"_",(a1)+
                        move.b #"Q",(a1)+
                        move.b #"_",(a1)+
                        move.b #"G",(a1)+
                        move.b #"L",(a1)+
                        move.b #"O",(a1)+
                        move.b #"B",(a1)+
                        move.b #"A",(a1)+
                        move.b #"L",(a1)+
                        clr.b (a1)+
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroFile
.QText_Dumped           move.l bbs_Channel(A6),d0
                        GOQSO ForceTransmit
                        move.l a7,a0
                        move.b #"D",(a0)
                        moveq #1,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitCommand
                        add.l #16,a7
                        bra .Line_Handled
                        
.No_QuitRemote          lea bbs_ServerLine(a6),a0
                        cmp.b #"H",(a0)
                        bne .No_HelpRemote
                        tst.b 1(a0)
                        beq .Help_Remote
                        cmp.b #"E",1(a0)
                        bne .No_HelpRemote
                        tst.b 2(a0)
                        beq .Help_Remote
                        cmp.b #"L",2(a0)
                        bne .No_HelpRemote
                        tst.b 3(a0)
                        beq .Help_Remote
                        cmp.b #"P",3(a0)
                        bne .No_HelpRemote
                        tst.b 4(a0)
                        bne .No_HelpRemote
.Help_Remote            move.l a1,-(sp)
                        sub.l #256,a7
                        move.l a7,a0
                        move.l #"Text",(a0)+
                        move.l #"/Hel",(a0)+
                        move.l #"p/BB",(a0)+
                        move.l #"S_H_",(a0)+
                        movem.l a0/a1/d1,-(sp)
                        move.l bbs_ThisQSO(a6),a0
                        GOQSO GetLanguageNode
                        movem.l (sp)+,a0/a1/d1
                        move.l a1,-(sp)
                        move.l d0,a1
                        move.l 16(a1),a1
.Copy_Language_Short    tst.b (a1)
                        beq .Language_Short_Coped
                        move.b (a1)+,(a0)+
                        bra .Copy_Language_Short
.Language_Short_Coped   move.l (sp)+,a1
                        cmp.l #0,a1
                        beq .Help_NoParam
                        move.b #"_",(a0)+
                        tst.b (a1)
                        beq .Help_NoParam
.Copy_HelpParam         move.b (a1)+,d0
                        cmp.b #$61,d0
                        blt .No_EnlargeHelp
                        cmp.b #$7a,d0
                        bgt .No_EnlargeHelp
                        sub.b #$20,d0
.No_EnlargeHelp         move.b d0,(a0)+
                        tst.b -1(a0)
                        bne .Copy_HelpParam
.Help_NoParam           clr.b (a0)+
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroDirect
                        add.l #256,a7
                        move.l (sp)+,a1
                        tst.l d0
                        beq .Help_Success

                        sub.l #256,a7
                        move.l a7,a0
                        move.l #"Text",(a0)+
                        move.l #"/Hel",(a0)+
                        move.l #"p/BB",(a0)+
                        move.l #"S_H_",(a0)+
                        move.w #"EN",(a0)+
                        cmp.l #0,a1
                        beq .Help_NoParam_2
                        move.b #"_",(a0)+
                        tst.b (a1)
                        beq .Help_NoParam_2
.Copy_HelpParam_2       move.b (a1)+,d0
                        cmp.b #$61,d0
                        blt .No_EnlargeHelp_2
                        cmp.b #$7a,d0
                        bgt .No_EnlargeHelp_2
                        sub.b #$20,d0
.No_EnlargeHelp_2       move.b d0,(a0)+
                        tst.b -1(a0)
                        bne .Copy_HelpParam_2
.Help_NoParam_2         clr.b -1(a0)
                        move.l a7,a0
                        moveq #0,d1
                        move.l bbs_Channel(a6),d0
                        GOQSO TransmitMacroDirect
                        add.l #256,a7
                        tst.l d0
                        beq .Help_Success

                        moveq #3,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l bbs_Channel(a6),d0
                        moveq #0,d1
                        moveq #1,d2
                        GOQSO TransmitText
.Help_Success           
                        bsr BBS_Prompt
                        bra .Line_Handled
                        
.Forward_SkipRemote

                        lea bbs_ServerLine(a6),a0
                        cmp.l #$2a2a2a00,(a0)
                        bne .No_DoneRemote_1
                        cmp.l #"Done",4(a0)
                        bne .No_DoneRemote_1
                        bra .Done_Remote
.No_DoneRemote_1        cmp.l #"***D",(a0)
                        bne .No_DoneRemote
                        cmp.l #$4f4e4500,4(a0)
                        bne .No_DoneRemote
                        bra .Done_Remote
.Done_Remote            clr.l bbs_ForwardMode(a6)
                        move.l #"DDDD",-(sp)
                        move.l sp,a0
                        moveq #1,d0
                        move.l bbs_Channel(A6),d1
                        GOQSO TransmitCommand
                        move.l (sp)+,a0
                        bra .Exit
.No_DoneRemote          lea bbs_ServerLine(a6),a0
                        cmp.l #"*** ",(a0)
                        bne .No_DoneRemote2
                        cmp.l #"DONE",4(a0)
                        beq .Done_Remote
.No_DoneRemote2         lea bbs_ServerLine(a6),a0
                        cmp.b #"F",(a0)
                        bne .No_FWDRemote
                        cmp.b #">",1(a0)
                        bne .No_FWDRemote
                        ;SWITCH TO ACTIVE FORWARDING!!!!
                        lea bbs_FWDCall(a6),a0
                        move.l bbs_DeferOffset(a6),d0
                        GOQSO GetNextFMail
                        tst.l d0
                        beq .Done_Forward
                        clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        move.l #3,bbs_ForwardMode(a6)
                        bra .Active_Forward
.Done_Forward           sub.l #16,a7
                        move.l #"*** ",(a7)
                        move.l #"Done",4(a7)
                        move.b #$0d,8(a7)
                        clr.b 9(a7)
                        move.l a7,a0
                        moveq #9,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        add.l #16,a7
                        move.l bbs_Channel(A6),d0
                        GOQSO ForceTransmit
                        bra .Line_Handled

.No_FWDRemote
.No_HelpRemote          move.l a1,a3
                        lea bbs_ServerLine(a6),a0
                        tst.b (a0)
                        beq .Line_Handled
                        lea BBS_CommandList,a0
.Search_BBSCommand      tst.b (a0)
                        beq .Unknown_Command
                        move.l a0,a1
                        lea bbs_ServerLine(a6),a2
.Compare_BBSCommand     move.b (a1)+,d0
                        cmp.b (a2)+,d0
                        bne .Next_BBSCommand
                        tst.b d0
                        bne .Compare_BBSCommand
.Found_BBSCommand       tst.b (a0)+
                        bne .Found_BBSCommand
                        bra .Call_BBSCommand
                        
.Next_BBSCommand        tst.b (a0)+
                        bne .Next_BBSCommand
.Next_BBSCommand_2      tst.b (a0)+
                        bne .Next_BBSCommand_2
                        bra .Search_BBSCommand
                        
.Call_BBSCommand
                        move.l a3,a1
                        movem.l a0/a1,-(sp)
                        GOQSO SearchSpecialServer
                        movem.l (sp)+,a0/a1
                        tst.l d0
                        beq .Unknown_Command
                        move.l bbs_ThisQSO(a6),a0
                        move.l #1,qso_SendPrompt(a0)
                        move.l d0,a0
                        move.l bbs_Channel(a6),d0
                        move.l a1,-(sp)
                        lea bbs_ServerLine(a6),a1
                        clr.l bbs_ServerInLine(a6)
                        clr.b (a1)
                        move.l (sp)+,a1
                        GOQSO StartServer
                        move.l bbs_ThisQSO(a6),a0
                        cmp.l qso_Server(a0),a6
                        beq .Equal_Handler
                        clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        bra .Exit
.Equal_Handler          tst.l qso_SendPrompt(a0)
                        beq .Line_Handled
                        clr.l qso_SendPrompt(A0)
                        bsr BBS_Prompt
                        bra .Line_Handled                       
.Unknown_Command        moveq #1,d0
                        bsr Get_Text
                        move.l d0,a0
                        move.l bbs_Channel(A6),d0
                        moveq #0,d1
                        moveq #0,d2
                        GOQSO TransmitText
                        cmp.l #2,bbs_ForwardMode(a6)
                        beq .Do_Disconnect
                        bsr BBS_Prompt
.Line_Handled           clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        bra .ReceivePacketRedo
.Do_Disconnect          move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        sub.l #4,a7
                        move.l #"DDDD",(a7)
                        move.l a7,a0
                        moveq #1,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitCommand
                        add.l #4,a7
                        bra .Exit

.Dump_Line              clr.b bbs_ServerLine(a6)
                        clr.l bbs_ServerInLine(a6)
                        bra .ReceivePacketRedo
                        
.Exit                   movem.l (Sp)+,d2-d7/a2-a6
                        rts

                        ;****************FBB TRANSMIT CODE
.FBB_TransmitMe         cmp.l #5,bbs_FBBCounter(a6)
                        bge .FBB_TransmitEnd
                        move.l bbs_FBBCounter(a6),d0
                        asl.l #2,d0
                        lea bbs_MailHandle(a6),a0
                        add.l d0,a0
                        tst.l (a0)
                        bne .FBB_Transmit_Valid
                        add.l #1,bbs_FBBCounter(a6)
                        bra .FBB_TransmitMe
.FBB_Transmit_Valid     move.l bbs_FBBCounter(a6),d0
                        asl.l #2,d0
                        move.l d0,bbs_MailHandleOffset(a6)
                        lea bbs_OwnSID(a6),a0
                        cmp.b #-1,sid_BVersion(a0)
                        beq .FBB_Transmit_ASCII
                        clr.l bbs_YAPPCRC(a6)
                        lea bbs_MailHandle(a6),a0
                        add.l bbs_MailHandleOffset(a6),a0
                        move.l (a0),a4
                        move.l a4,a0
                        bsr BBS_CompressMailTX
                        tst.l d0
                        bne .Forward_Error_Immed
                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempTxc
                        move.l a7,d1
                        move.l #1005,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(A6)
                        move.l (sp)+,a6
                        move.l d0,bbs_FileHandle(a6)
                        add.l #64,a7
                        tst.l d0
                        beq .Forward_Error_Immed
                        lea bbs_OutputLine(a6),a3
                        move.b #$01,(a3)+
                        clr.b (a3)+
                        move.l a4,a0
                        GOQSO GetMailTitle
                        move.l d0,a0
.FBB_Transmit_YAPPTitle tst.b (a0)
                        beq .FBB_Transmit_YAPPTtld
                        move.b (a0)+,(a3)+
                        bra .FBB_Transmit_YAPPTitle
.FBB_Transmit_YAPPTtld  clr.b (a3)+


                        move.l bbs_FBBCounter(a6),d0
                        asl.l #2,d0
                        lea bbs_PropResume(a6),a0
                        add.l d0,a0
                        move.l (a0),d0
                        move.l d0,-(sp)
                        move.l a7,a1
                        lea .YAPPHead_Format(pc),a0
                        movem.l a2/a3/a6,-(sp)
                        lea .PutChar(pc),a2
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(a6)
                        movem.l (sp)+,a2/a6/a3
                        move.l (sp)+,d0

.Search_RawFmt_2        tst.b (a3)+
                        bne .Search_RawFmt_2

                        lea bbs_OutputLine(a6),a0
                        sub.l a0,a3
                        move.l a3,d0
                        move.l d0,d1
                        subq.l #2,d1
                        move.b d1,1(a0)
                        lea bbs_OwnSID(a6),a1
                        cmp.b #-1,sid_DVersion(a1)
                        beq .FBB_SkipTitleCRC
                        cmp.b #1,sid_BVersion(a1)
                        bge .FBB_SkipTitleCRC
                        move.l d0,-(sp)
                        subq.l #2,d0
                        lea 2(a0),a0
                        lea bbs_YAPPCRC(a6),a1
                        lea 2(a1),a1
                        move.l a1,-(sp)
                        move.l d0,-(sp)
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcthp_buf
                        exg a4,a6
                        add.l #12,a7
                        move.l (sp)+,d0
.FBB_SkipTitleCRC       lea bbs_OutputLine(a6),a0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        move.l bbs_FBBCounter(a6),d0
                        asl.l #2,d0
                        lea bbs_PropResume(a6),a0
                        add.l d0,a0
                        move.l (a0),d0
                        tst.l d0
                        beq .No_ResumeOffset
                        move.l d0,-(sp)
                        lea bbs_OutputLine(a6),a0
                        move.b #$2,(a0)+
                        move.b #$6,(a0)+
                        move.l a0,d2
                        move.l bbs_FileHandle(a6),d1
                        moveq #6,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVORead(A6)
                        move.l (sp)+,a6
                        move.l (sp)+,d1
                        cmp.l #6,d0
                        bne .Forward_Error_Immed

                        move.l d1,-(sp)
                        moveq #0,d0
                        move.l bbs_YAPPCRC(a6),d1
                        lea bbs_OutputLine(a6),a0
                        move.b 2(a0),d0
                        add.l d0,d1
                        move.b 3(a0),d0
                        add.l d0,d1
                        move.b 4(a0),d0
                        add.l d0,d1
                        move.b 5(a0),d0
                        add.l d0,d1
                        move.b 6(a0),d0
                        add.l d0,d1
                        move.b 7(a0),d0
                        add.l d0,d1
                        and.l #$ff,d1
                        move.l d1,bbs_YAPPCRC(a6)
                        move.l (sp)+,d1

                        move.l d1,-(sp)
                        lea bbs_OutputLine(a6),a0
                        moveq #8,d0
                        move.l bbs_Channel(a6),d1
                        bsr TransmitData_YAPP
                        move.l (sp)+,d0
                        move.l bbs_FileHandle(a6),d1
                        move.l d0,d2
                        moveq #-1,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOSeek(a6)
                        move.l (sp)+,a6
                        cmp.l #-1,d0
                        beq .Forward_Error_Immed

.No_ResumeOffset        ;move.l bbs_Channel(a6),d0
                        ;GOQSO ForceTransmit
                        add.l #1,bbs_FBBCounter(a6)
                        move.l #10,bbs_ForwardMode(a6)
                        bra .Line_Handled
.YAPPHead_Format        dc.b "%6ld",0
                        even
.PutChar                move.b d0,(a3)+
                        rts

.FBB_Transmit_ASCII     add.l #1,bbs_FBBCounter(a6)
                        move.l #5,bbs_ForwardMode(a6)
                        bsr BBS_OutputSHead
                        bra .Line_Handled


.FBB_TransmitEnd        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        move.l #7,bbs_ForwardMode(a6)
                        clr.l bbs_FBBCounter(a6)
                        clr.l bbs_FBBChecksum(a6)
                        bra .Line_Handled

                        ;****************FBB RECEIVE CODE
.FBB_ReceiveMe          cmp.l #2,bbs_FBBReturn(a6)
                        beq .Next_Mail
                        tst.l bbs_FBBReturn(a6)
                        beq .Next_Mail
                        cmp.l #1,bbs_FBBReturn(a6)
                        bra .Forward_Error
                        bra .Exit

.Next_Mail              moveq #0,d0
                        lea bbs_PropTaken(a6),a0
                        tst.l (a0)+
                        bne .Next_Mail_Found
                        moveq #1,d0
                        tst.l (a0)+
                        bne .Next_Mail_Found
                        moveq #2,d0
                        tst.l (a0)+
                        bne .Next_Mail_Found
                        moveq #3,d0
                        tst.l (a0)+
                        bne .Next_Mail_Found
                        moveq #4,d0
                        tst.l (a0)+
                        bne .Next_Mail_Found
                        bra .FBB_ItsMyTurn

.Next_Mail_Found        cmp.l bbs_FBBCounter(a6),d0
                        bge .FBB_ItsMyTurn
                        move.l d0,d7
                        clr.l -4(a0)
                        move.l d7,d0
                        lea bbs_PropType(a6),a0
                        asl.l #2,d0
                        add.l d0,a0
                        move.l (a0),bbs_FBBPersonal(a6)
                        lea bbs_PropBytes(a6),a0
                        add.l d0,a0
                        move.l (a0),bbs_FBBBytes(a6)
                        lea bbs_PropLifetime(a6),a0
                        add.l d0,a0
                        move.l (a0),bbs_FBBLifetime(a6)
                        lea bbs_PropFrom(a6),a0
                        move.l d7,d0
                        mulu #12,d0
                        add.l d0,a0
                        move.l a0,bbs_FBBFrom(a6)
                        lea bbs_PropTo(a6),a0
                        add.l d0,a0
                        move.l a0,bbs_FBBTo(a6)
                        lea bbs_PropAt(a6),a0
                        move.l d7,d0
                        mulu #80,d0
                        add.l d0,a0
                        move.l a0,bbs_FBBAt(a6)
                        lea bbs_PropBid(a6),a0
                        move.l d7,d0
                        mulu #16,d0
                        add.l d0,a0
                        move.l a0,bbs_FBBBid(a6)
                        IFD BBS_DEBUG
                        lea DEBUG_ReceivingBID(pc),a1
                        bsr DEBUG_OutputFormat
                        ENDIF
                        move.l #8,bbs_ForwardMode(a6)
                        lea bbs_OwnSID(A6),a0
                        cmp.b #-1,sid_BVersion(a0)
                        beq .ASCII_FBB_Receive

                        move.l bbs_FBBFrom(a6),a0
                        move.l bbs_FBBTo(a6),a1
                        move.l bbs_FBBAt(a6),a2
                        move.l bbs_FBBPersonal(a6),d0
                        move.l bbs_FBBBid(a6),d1
                        GOQSO SendMail
                        tst.l d0
                        beq .Forward_Error_Immed
                        move.l d0,bbs_MailHandle(a6)
                        clr.l bbs_MailHandleOffset(a6)
                        move.l #1,bbs_MailIncomplete(a6)
                        move.l d0,a4

                        move.l a4,a0
                        move.l bbs_ThisQSO(a6),a1
                        lea qso_Call(A1),a1
                        GOQSO SetNotForward

                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempRxc
                        move.l a7,d1
                        move.l #1006,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(a6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        move.l d0,bbs_FileHandle(a6)
                        tst.l d0
                        beq .Forward_Error_Immed
                        clr.l bbs_YAPPCRC(a6)
                        clr.l bbs_YAPPHeader(a6)
                        move.l #11,bbs_ForwardMode(a6)
                        move.l #1,bbs_ResumeMode(a6)
                        move.l bbs_FBBBytes(a6),bbs_ResumeBytes(a6)
                        clr.l bbs_ResumeHeader(a6)
                        bra .Line_Handled
.ASCII_FBB_Receive      lea BBS_FBBBatch(pc),a0
                        GOQSO SearchSpecialServer
                        tst.l d0
                        beq .Forward_Error
                        move.l d0,a0
                        move.l bbs_Channel(a6),d0
                        lea bbs_FBBPersonal(a6),a1
                        GOQSO StartServer
                        move.l bbs_ThisQSO(a6),a0
                        cmp.l qso_Server(a0),a6
                        bne .Exit
                        move.l bbs_FBBReturn(a6),d0
                        tst.l d1
                        beq .Forward_Error
                        move.l #2,bbs_FBBReturn(a6)
                        bra .FBB_ReceiveMe


                        ;********YAPP Receive Header
.YAPP_ReceiveHead       move.l bbs_ThisQSO(A6),a0
                        GOQSO TestServBuffer
                        cmp.l #2,d0
                        blt .Exit
                        lea bbs_ServerLine(a6),a0
                        moveq #2,d0
                        move.l bbs_ThisQSO(a6),a1
                        GOQSO ReadServBuffer
                        cmp.l #2,d0
                        bne .Forward_Error_Immed
                        lea bbs_ServerLine(a6),a0
                        moveq #0,d0
                        move.b (a0),d0
                        move.l d0,bbs_YAPPType(a6)
                        move.b 1(a0),d0
                        move.l d0,bbs_YAPPLength(a6)
                        move.l bbs_YAPPType(a6),d0
                        cmp.b #$1,d0
                        beq .YAPP_RecHeader
                        cmp.b #$2,d0
                        beq .YAPP_RecData
                        cmp.b #$4,d0
                        beq .YAPP_RecEnd
                        bra .Forward_Error_Immed
.YAPP_RecHeader         move.l #1,bbs_YAPPHeader(a6)
                        move.l #12,bbs_ForwardMode(a6)
                        bra .YAPP_ReceiveData
.YAPP_RecData           tst.l bbs_YAPPHeader(a6)
                        beq .Forward_Error_Immed
                        tst.l bbs_YAPPLength(A6)
                        beq .Exit
                        move.l #12,bbs_ForwardMode(a6)
                        bra .YAPP_ReceiveData
.YAPP_RecEnd            tst.l bbs_YAPPHeader(a6)
                        beq .Forward_Error_Immed
                        lea bbs_OwnSID(a6),a0
                        move.l #12,bbs_ForwardMode(A6)
                        cmp.b #1,sid_BVersion(a0)
                        bge .YAPP_RecEndDBoxNew
                        cmp.b #-1,sid_DVersion(a0)
                        bne .YAPP_ReceiveData           ;Receive DBox Fend
.YAPP_RecEndDBoxNew     move.l bbs_YAPPCRC(a6),d0
                        add.l bbs_YAPPLength(A6),d0
                        and.l #$ff,d0
                        tst.l d0
                        bne .YAPP_Receive_CRC_Err
.YAPP_Terminate_Good    move.l bbs_FileHandle(a6),d1
                        clr.l bbs_FileHandle(A6)
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        sub.l #128,a7
                        move.l bbs_MailHandle(a6),a0
                        move.l a7,a1
                        bsr BBS_MakeTempRxc
                        move.l bbs_MailHandle(a6),a0
                        lea 64(a7),a1
                        bsr BBS_MakeTempRxf
                        move.l bbs_MailHandle(a6),a0
                        GOQSO GetMailTitle
                        move.l d0,-(sp)
                        moveq #0,d0
                        lea bbs_OwnSID(a6),a0
                        cmp.b #1,sid_BVersion(a0)
                        blt .YAPP_Terminate_Mode
                        moveq #1,d0
                        cmp.b #-1,sid_DVersion(a0)
                        beq .YAPP_Terminate_Mode
                        moveq #2,d0
.YAPP_Terminate_Mode    move.l d0,-(sp)
                        lea 0+8(a7),a0
                        lea 64+8(a7),a1
                        move.l a1,-(sp)
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _dechuf
                        exg a4,a6
                        add.l #16,a7
                        add.l #128,a7
                        tst.l d0
                        bne .YAPP_Receive_CRC_Err
                        clr.l bbs_ResumeMode(a6)
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteResume
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_TranslateFileRX
                        tst.l d0
                        bne .Forward_Error_Immed
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteTemporary
                        clr.l bbs_MailIncomplete(a6)
                        move.l bbs_MailHandle(a6),a0
                        clr.l bbs_MailHandle(a6)
                        GOQSO CloseMail
                        clr.l bbs_FBBReturn(a6)
                        move.l #8,bbs_ForwardMode(A6)
                        bra .FBB_ReceiveMe
                        ;*********YAPP Receive Data
.YAPP_Receive_CRC_Err   clr.l bbs_ResumeMode(a6)
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteResume
                        bra .Forward_Error_Check

.YAPP_ReceiveData       move.l bbs_YAPPType(a6),d0
                        cmp.l #4,d0
                        beq .YAPP_ReceiveDataCRC
                        move.l bbs_ThisQSO(A6),a0
                        GOQSO TestServBuffer
                        move.l d0,-(sp)
                        bsr BBS_TestBlockCRC
                        move.l bbs_YAPPLength(a6),d1
                        cmp.l #2,bbs_YAPPType(a6)
                        bne .YAPP_ReceiveSkipBCRC
                        add.l d0,d1
.YAPP_ReceiveSkipBCRC   move.l (sp)+,d0
                        cmp.l d1,d0
                        blt .Exit
                        move.l d1,d0
                        lea bbs_ServerLine(a6),a0
                        move.l bbs_ThisQSO(a6),a1
                        move.l d1,-(sp)
                        GOQSO ReadServBuffer
                        move.l (sp)+,d1
                        cmp.l d1,d0
                        bne .Forward_Error_Immed

                        cmp.l #2,bbs_YAPPType(a6)
                        bne .No_BlockCRC
                        bsr BBS_TestBlockCRC
                        tst.l d0
                        beq .No_BlockCRC
                        clr.l -(sp)
                        lea 2(a7),a0
                        move.l a0,-(sp)
                        move.l bbs_YAPPLength(a6),-(sp)
                        lea bbs_ServerLine(a6),a0
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcfbb_buf
                        exg a4,a6
                        add.l #12,a7
                        move.l (sp)+,d0
                        lea bbs_ServerLine(a6),a0
                        add.l bbs_YAPPLength(a6),a0
                        moveq #0,d1
                        move.b 1(a0),d1
                        asl.l #8,d1
                        move.b (a0),d1
                        cmp.w d0,d1
                        bne .Forward_Error_Immed
.No_BlockCRC
                        lea bbs_OwnSID(a6),a0
                        cmp.b #1,sid_BVersion(a0)
                        bge .YAPP_ReceiveData_NewBin
                        cmp.b #-1,sid_DVersion(a0)
                        bne .YAPP_ReceiveData_DoCRC
.YAPP_ReceiveData_NewBin cmp.l #1,bbs_YAPPType(a6)
                        beq .YAPP_ReceiveData_SkipC
.YAPP_ReceiveData_DoCRC
                        lea bbs_OwnSID(a6),a0
                        cmp.b #1,sid_BVersion(a0)
                        bge .YAPP_ReceiveData_FBBC
                        cmp.b #-1,sid_DVersion(a0)
                        beq .YAPP_ReceiveData_FBBC
                        lea bbs_ServerLine(a6),a0
                        lea bbs_YAPPCRC(a6),a1
                        lea 2(a1),a1
                        move.l a1,-(sp)
                        move.l bbs_YAPPLength(a6),-(sp)
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcthp_buf
                        exg a4,a6
                        add.l #12,a7
                        bra .YAPP_ReceiveData_SkipC
.YAPP_ReceiveData_FBBC  lea bbs_ServerLine(A6),a0
                        move.l bbs_YAPPCRC(a6),d1
                        move.l bbs_YAPPLength(a6),d0
.YAPP_ReceiveData_FBBL  moveq #0,d2
                        move.b (a0)+,d2
                        add.l d2,d1
                        subq.l #1,d0
                        tst.l d0
                        bgt .YAPP_ReceiveData_FBBL
                        move.l d1,bbs_YAPPCRC(a6)
.YAPP_ReceiveData_SkipC cmp.l #1,bbs_YAPPType(a6)
                        bne .YAPP_ReceiveData_Dat
                        clr.l bbs_ResumeHeader(a6)
                        lea bbs_ServerLine(a6),a1
                        move.l bbs_MailHandle(a6),a0
                        GOQSO SetMailTitle
                        lea bbs_ServerLine(a6),a0
.YAPP_ScanOffsetString  tst.b (a0)+
                        bne .YAPP_ScanOffsetString
                        move.l a0,d1
                        clr.l -(a7)
                        move.l a7,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 .Forward_Error_Immed
                        tst.l d0
                        beq .Forward_Error_Immed
                        tst.l d1
                        beq .YAPP_Receive_NoResume
                        move.l d1,d0
                        move.l bbs_MailHandle(a6),a0
                        move.l bbs_FileHandle(a6),a1
                        bsr BBS_LoadResume
                        tst.l d0
                        beq .YAPP_Receive_YesResume
                        clr.l bbs_ResumeMode(a6)
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteResume
                        bra .Forward_Error_Immed
.YAPP_Receive_YesResume move.l #1,bbs_ResumeHeader(a6)
.YAPP_Receive_NoResume  move.l #11,bbs_ForwardMode(a6)
                        bra .YAPP_ReceiveHead
.YAPP_ReceiveData_Dat   tst.l bbs_ResumeHeader(a6)
                        bne .YAPP_ReceiveResume


                        move.l bbs_YAPPLength(a6),d3
                        move.l bbs_FileHandle(a6),d1
                        lea bbs_ServerLine(a6),a0
                        move.l a0,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOWrite(a6)
                        move.l (sp)+,a6
                        cmp.l bbs_YAPPLength(a6),d0
                        bne .Forward_Error
                        move.l #11,bbs_ForwardMode(A6)
                        bra .YAPP_ReceiveHead
.YAPP_ReceiveResume     cmp.l #6,bbs_YAPPLength(a6)
                        bne .YAPP_Receive_ResumeInv
                        lea bbs_ServerLine(a6),a0
                        lea bbs_ResumeChecker(a6),a1
                        move.l (a0),d0
                        cmp.l (a1),d0
                        bne .YAPP_Receive_ResumeInv
                        move.w 4(a0),d0
                        cmp.w 4(a1),d0
                        bne .YAPP_Receive_ResumeInv
                        move.l #11,bbs_ForwardMode(a6)
                        clr.l bbs_ResumeHeader(a6)
                        bra .YAPP_ReceiveHead
.YAPP_Receive_ResumeInv clr.l bbs_ResumeMode(a6)
                        move.l bbs_MailHandle(a6),a0
                        bsr BBS_DeleteResume
                        bra .Forward_Error_Immed
.YAPP_ReceiveDataCRC    move.l bbs_ThisQSO(A6),a0
                        GOQSO TestServBufferLin
                        cmp.l #1,d0
                        blt .Exit
                        lea bbs_ServerLine(a6),a0
                        move.l bbs_ThisQSO(a6),a1
                        GOQSO ReadServBuffer
                        cmp.l #1,d0
                        bne .Forward_Error_Immed
                        moveq #0,d0
                        move.b bbs_ServerLine(a6),d0
                        asl.l #8,d0
                        or.l bbs_YAPPLength(a6),d0
                        cmp.l bbs_YAPPCRC(a6),d0
                        bne .YAPP_Receive_CRC_Err
                        bra .YAPP_Terminate_Good


.FBB_TestGoodMail       movem.l d0-d7/a0-a6,-(sp)
                        moveq #0,d7
.FBB_TGM_Loop           cmp.l #5,d7
                        bge .FBB_TGM_Exit
                        lea bbs_MailHandle(a6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        addq.l #1,d7
                        move.l (a0),a4
                        cmpa.l #0,a4
                        beq .FBB_TGM_Loop
                        clr.l (a0)
                        move.l a4,a0
                        GOQSO GetNumberMail
                        lea bbs_FWDCall(a6),a0
                        GOQSO RemoveFMail
                        move.l a4,a0
                        GOQSO MarkAsForward
                        move.l a4,a0
                        bsr BBS_DeleteTemporary
                        move.l a4,a0
                        GOQSO CloseMail
                        bra .FBB_TGM_Loop
.FBB_TGM_Exit           movem.l (sp)+,d0-d7/a0-a6
                        rts

BBS_TerminalInput       moveq #0,d0
                        rts

BBS_Prompt              tst.l bbs_ForwardMode(a6)
                        beq .Yes_Prompt
                        lea BBS_ShortPrompt,a0
                        move.l bbs_Channel(a6),d1
                        moveq #2,d0
                        GOQSO TransmitData
                        move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        rts







.Yes_Prompt             lea BBS_PromptText,a0
                        move.l bbs_Channel(a6),d0
                        moveq #0,d1
                        move.l d2,-(sp)
                        moveq #1,d2
                        GOQSO TransmitText
                        move.l (sp)+,d2
.No_Prompt              rts

BBS_Nop         moveq #0,d0
                        rts

                        
BBS_AskAudio    moveq #-1,d0
                                rts


BBS_OutputSHead   lea bbs_MailHandle(a6),a0
                  add.l bbs_MailHandleOffset(a6),a0
                  move.l (a0),a0
                  GOQSO GetMailTitle
                  move.l d0,a0
                  lea bbs_OutputLine(a6),a1
.Copy_Title       move.b (a0)+,(A1)+
                  tst.b -1(a0)
                  bne .Copy_Title
                  move.b #$0d,-1(a1)
                  clr.b (a1)
                  move.l d2,-(sp)
                  move.l bbs_Channel(a6),d0
                  moveq #0,d1
                  moveq #0,d2
                  lea bbs_OutputLine(a6),a0
                  GOQSO TransmitText
                  move.l (sp)+,d2
                  lea bbs_MailHandle(a6),a0
                  add.l bbs_MailHandleOffset(a6),a0
                  move.l (a0),a0
                  lea bbs_OutputLine(a6),a1
                  GOQSO ComposeRLine
                  tst.l d0
                  beq .No_RLine
                  move.l bbs_Channel(A6),d1
                  lea bbs_OutputLine(a6),a0
                  GOQSO TransmitData
.No_RLine


                  move.l bbs_Channel(A6),d0
                  GOQSO ForceTransmit
                  rts

BBS_OutputSLine   movem.l a3-a4/d7,-(sp)
                  lea bbs_MailHandle(a6),a4
                  add.l bbs_MailHandleOffset(a6),a4
                  move.l (a4),a4

                  lea bbs_OutputLine(a6),a3

                  move.l a4,a0
                  GOQSO GetMailStatus
                  move.l d0,d7
                  btst #0,d0
                  beq .Bullmail
                  lea bbs_OwnSID(a6),a0
                  cmp.b #-1,sid_AVersion(a0)
                  beq .AVersion_NoPers
                  btst #4,d0
                  beq .AVersion_NoPers
                  move.w #"SA",(a3)+
                  bra .Persmail
.AVersion_NoPers  move.w #"SP",(a3)+
                  bra .Persmail
.Bullmail         move.w #"SB",(a3)+
.Persmail         move.b #" ",(a3)+

                  move.l a4,a0
                  GOQSO GetMailTo
                  tst.l d0
                  beq .Error
                  move.l d0,a0
                  moveq #8,d0
                  move.l bbs_OwnSID(a6),a1
                  cmp.b #-1,sid_DVersion(a1)
                  bne .CopyTo
                  moveq #6,d0
.CopyTo           tst.l d0
                  beq .CopyToEnd
                  subq.l #1,d0
                  move.b (a0)+,(a3)+
                  tst.b -1(a0)
                  bne .CopyTo
.CopyToEnd        move.b #" ",-1(a3)
                  move.l a4,a0
                  GOQSO GetMailAt
                  tst.l d0
                  beq .No_At
                  move.l d0,a0
                  tst.b (a0)
                  beq .No_At
                  move.b #"@",(a3)+
                  move.b #" ",(A3)+
.CopyAt           move.b (a0)+,(a3)+
                  tst.b -1(a0)
                  bne .CopyAt
                  move.l a4,a0
                  GOQSO GetMailHRoute
                  tst.l d0
                  beq .No_HRoute
                  move.l d0,a0
                  tst.b (a0)
                  beq .No_HRoute
                  move.b #".",-1(a3)
.CopyHRoute       move.b (a0)+,(a3)+
                  tst.b -1(a0)
                  bne .CopyHRoute
.No_HRoute        move.b #" ",-1(a3)
.No_At            move.l a4,a0
                  GOQSO GetMailFm
                  tst.l d0
                  beq .No_Fm
                  move.l d0,a0
                  tst.b (a0)
                  beq .No_Fm
                  move.b #"<",(a3)+
                  move.b #" ",(A3)+
.CopyFm           move.b (a0)+,(a3)+
                  tst.b -1(a0)
                  bne .CopyFm
                  move.b #" ",-1(a3)
.No_Fm            lea bbs_OwnSID(a6),a0
                  cmp.b #-1,sid_DollarVersion(a0)
                  beq .No_Bid
                  move.l a4,a0
                  GOQSO GetMailStatus
                  lea bbs_OwnSID(a6),a0
                  cmp.b #-1,sid_MVersion(a0)
                  bne .Supports_MID
                  btst #0,d0
                  bne .No_Bid
.Supports_MID     move.l a4,a0
                  GOQSO GetMailBid
                  tst.l d0
                  beq .No_Bid
                  move.l d0,a0
                  tst.b (a0)
                  beq .No_Bid
                  move.b #"$",(a3)+
                  move.b #" ",(a3)+
.Copy_Bid         move.b (a0)+,(a3)+
                  tst.b -1(a0)
                  bne .Copy_Bid
                  move.b #" ",-1(a3)
.No_Bid
.Done_Line        move.b #$0d,-1(a3)
                  clr.b (a3)
                  lea bbs_OutputLine(a6),a0
                  move.l bbs_Channel(a6),d0
                  moveq #0,d1
                  moveq #0,d2
                  GOQSO TransmitText
                  move.l bbs_Channel(a6),d0
                  GOQSO ForceTransmit
.Error            movem.l (sp)+,a3-a4/d7
                  rts


BBS_DoPoll              movem.l d2-d7/a2-a6,-(sp)
.Retest                 moveq #0,d5
                        move.l bbs_Channel(a6),d0
                        GOQSO GetOutstanding
                        move.l d0,d7

                        move.l bbs_Channel(a6),d0
                        GOQSO GetMaxFrame
                        asl.l #1,d0
                        move.l d0,d5
                        sub.l d7,d5
                        tst.l d5
                        ble .Exit

                        cmp.l #10,bbs_ForwardMode(a6)
                        beq .YAPP_Transmit
                        cmp.l #5,bbs_ForwardMode(a6)
                        bne .Exit

                        move.l bbs_Channel(a6),d0
                        GOQSO GetPacLen
                        lea bbs_OutputLine(a6),a1
                        lea bbs_MailHandle(a6),a0
                        add.l bbs_MailHandleOffset(a6),a0
                        move.l (a0),a0
                        GOQSO ReadMail
                        cmp.l #-1,d0
                        beq .Exit
                        tst.l d0
                        beq .EndofFile
                        move.l bbs_Channel(a6),d1
                        lea bbs_OutputLine(a6),a0
                        GOQSO TransmitData
                        bra .Retest
.EndofFile              lea bbs_MailHandle(a6),a0
                        add.l bbs_MailHandleOffset(a6),a0
                        move.l (a0),a0
                        GOQSO GetMailStatus
                        btst #30,d0
                        bne .EOFFT
                        subq.l #4,a7
                        move.l #$1a0d0000,(a7)
                        moveq #2,d0
                        move.l bbs_Channel(a6),d1
                        move.l a7,a0
                        GOQSO TransmitData
                        addq.l #4,a7
.EOFFT                  move.l bbs_Channel(a6),d0
                        GOQSO ForceTransmit
                        tst.l bbs_ForwardType(a6)
                        bne .FBB_Forwarded
                        move.l #3,bbs_ForwardMode(a6)
                        bra .Exit
.FBB_Forwarded          move.l #9,bbs_ForwardMode(A6)
                        movem.l (sp)+,d2-d7/a2-a6
                        moveq #0,d0
                        bsr BBS_ReceivePacket
                        rts
.Exit                   movem.l (sp)+,d2-d7/a2-a6
                        rts

.YAPP_Transmit          move.l bbs_Channel(a6),d0
                        GOQSO GetPacLen
                        move.l d0,d7
                        bsr BBS_TestBlockCRC
                        sub.l d0,d7

                        lea bbs_OutputLine(a6),a0
                        move.l a0,d2
                        move.l bbs_FileHandle(a6),d1
                        move.l d7,d3
                        subq.l #2,d3
                        addq.l #2,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVORead(a6)
                        move.l (Sp)+,a6
                        cmp.l #-1,d0
                        beq .Exit
                        tst.l d0
                        beq .YAPP_EOF
                        move.l d0,d7
                        addq.l #2,d7
                        lea bbs_OwnSID(a6),a0
                        cmp.b #1,sid_BVersion(a0)
                        bge .FBB_Check
                        cmp.b #-1,sid_DVersion(a0)
                        beq .FBB_Check

                        lea bbs_OutputLine(a6),a0
                        lea bbs_YAPPCRC(a6),a1
                        lea 2(a1),a1
                        lea 2(a0),a0
                        move.l a1,-(sp)
                        move.l d0,-(sp)
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcthp_buf
                        exg a4,a6
                        add.l #12,a7
                        bra .DBox_Check
.FBB_Check              lea bbs_OutputLine(a6),a0
                        lea 2(a0),a0
                        move.l bbs_YAPPCRC(a6),d1
.FBB_CheckL             tst.l d0
                        beq .FBB_CheckE
                        moveq #0,d2
                        move.b (a0)+,d2
                        add.l d2,d1
                        subq.l #1,d0
                        bra .FBB_CheckL
.FBB_CheckE             and.l #$ff,d1
                        move.l d1,bbs_YAPPCRC(a6)
.DBox_Check             lea bbs_OutputLine(a6),a0
                        move.b #$02,(a0)
                        move.l d7,d0
                        subq.l #2,d0
                        move.b d0,1(a0)
                        move.l d7,d0
                        move.l bbs_Channel(a6),d1
                        bsr TransmitData_YAPP
                        ;move.l bbs_Channel(a6),d0
                        ;GOQSO ForceTransmit
                        bra .Retest
.YAPP_EOF               lea bbs_OwnSID(A6),a0
                        cmp.b #1,sid_BVersion(a0)
                        bge .YAPP_OutputFBB
                        cmp.b #-1,sid_DVersion(a0)
                        beq .YAPP_OutputFBB
                        lea bbs_OutputLine(a6),a0
                        move.b #$04,(a0)
                        move.l bbs_YAPPCRC(a6),d0
                        move.b d0,1(a0)
                        lsr.l #8,d0
                        move.b d0,2(a0)
                        moveq #3,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
                        bra .YAPP_OutputDBox
.YAPP_OutputFBB         lea bbs_OutputLine(a6),a0
                        move.b #$04,(a0)
                        move.l bbs_YAPPCRC(a6),d0
                        neg.l d0
                        move.b d0,1(a0)
                        moveq #2,d0
                        move.l bbs_Channel(a6),d1
                        GOQSO TransmitData
.YAPP_OutputDBox        ;move.l bbs_Channel(a6),d0
                        ;GOQSO ForceTransmit

                        move.l bbs_FileHandle(a6),d1
                        clr.l bbs_FileHandle(a6)
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        move.l bbs_MailHandleOffset(a6),d0
                        lea bbs_MailHandle(a6),a1
                        add.l d0,a1
                        move.l (a1),a0
                        move.l a0,-(sp)
                        bsr BBS_DeleteTemporary
                        move.l (sp)+,a0
                        move.l #9,bbs_ForwardMode(a6)
                        movem.l (sp)+,d2-d7/a2-a6
                        moveq #0,d0
                        bsr BBS_ReceivePacket
                        rts

TransmitData_YAPP       movem.l d2-d3/a2,-(sp)
                        move.l d0,d2
                        move.l d1,d3
                        move.l a0,a2
                        bsr BBS_TestBlockCRC
                        tst.l d0
                        beq .No_BCRC

                        clr.l -(sp)
                        lea 2(a7),a0
                        move.l a0,-(sp)
                        move.l d2,d0
                        subq.l #2,d0
                        move.l d0,-(sp)
                        move.l a2,a0
                        addq.l #2,a0
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _crcfbb_buf
                        exg a4,a6
                        add.l #12,a7
                        move.l (sp)+,d0
                        move.l a2,a0
                        add.l d2,a0
                        move.b d0,(a0)
                        lsr.l #8,d0
                        move.b d0,1(a0)
                        addq.l #2,d2
.No_BCRC                move.l d2,d0
                        move.l d3,d1
                        move.l a2,a0
                        GOQSO TransmitData
                        movem.l (sp)+,d2-d3/a2
                        rts

FBB_MakeProposalLine    movem.l d2-d7/a2-a6,-(sp)
                        move.l d0,d7
                        lea bbs_OwnSID(A6),a4
                        lea bbs_ServerLine(a6),a3
                        lea bbs_MailHandle(a6),a0
                        asl.l #2,d0
                        add.l d0,a0
                        move.l (a0),a2

                        move.b #"F",(A3)+
                        cmp.b #-1,sid_DVersion(a4)
                        bne .Output_DieBox
                        cmp.b #-1,sid_BVersion(a4)
                        bne .Output_FBBMail
                        move.b #"B",(A3)+
                        bra .Output_RightBoxproto
.Output_FBBMail         move.b #"A",(A3)+
                        bra .Output_RightBoxproto
.Output_DieBox          move.b #"D",(a3)+
.Output_RightBoxproto   move.b #$20,(a3)+
                        move.l a2,a0
                        GOQSO GetMailStatus
                        btst #0,d0
                        beq .Bulletin_Mail
                        lea bbs_OwnSID(a6),a0
                        cmp.b #-1,sid_AVersion(a0)
                        beq .Always_Personal
                        btst #4,d0
                        beq .Always_Personal
                        move.b #"A",(a3)+
                        bra .Personal_Mail
.Always_Personal        move.b #"P",(a3)+
                        bra .Personal_Mail
.Bulletin_Mail          move.b #"B",(a3)+
.Personal_Mail          move.b #" ",(A3)+
                        move.l a2,a0
                        GOQSO GetMailFm
                        move.l d0,a0
.Copy_MailFM            tst.b (a0)
                        beq .FM_Coped
                        move.b (a0)+,(a3)+
                        bra .Copy_MailFM
.FM_Coped               move.b #" ",(A3)+
                        move.l a2,a0
                        GOQSO GetMailAt
                        move.l d0,a0
.Copy_MailAt            tst.b (a0)
                        beq .At_Coped
                        move.b (a0)+,(a3)+
                        bra .Copy_MailAt
.At_Coped               cmp.b #-1,sid_HVersion(a4)
                        beq .HRoute_Coped
                        move.l a2,a0
                        GOQSO GetMailHRoute
                        tst.l d0
                        beq .HRoute_Coped
                        move.l d0,a0
                        tst.b (a0)
                        beq .HRoute_Coped
                        move.b #".",(a3)+
.Copy_HRoute            tst.b (a0)
                        beq .HRoute_Coped
                        move.b (a0)+,(a3)+
                        bra .Copy_HRoute
.HRoute_Coped           move.b #" ",(A3)+
                        move.l a2,a0
                        GOQSO GetMailTo
                        move.l d0,a0
.Copy_To                tst.b (a0)
                        beq .To_Coped
                        move.b (a0)+,(a3)+
                        bra .Copy_To
.To_Coped               move.b #" ",(A3)+
                        move.l a2,a0
                        GOQSO GetMailBid
                        move.l d0,a0
.Copy_BID               tst.b (a0)
                        beq .BID_Coped
                        move.b (a0)+,(a3)+
                        bra .Copy_BID
.BID_Coped              move.b #" ",(a3)+
                        move.l a2,a0
                        GOQSO GetMailBytes
                        move.l d0,-(Sp)
                        lea bbs_OutputLine(a6),a1
                        move.l a2,a0
                        GOQSO ComposeRLine
                        move.l (sp)+,d1
                        add.l d1,d0
                        move.l d0,-(sp)
                        move.l a7,a1
                        lea .DFormat(pc),a0
                        movem.l a2/a6,-(sp)
                        lea .PutChar(pc),a2
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(a6)
                        movem.l (sp)+,a2/a6
                        move.l (sp)+,d0
                        lea bbs_ServerLine(a6),a3
.Search_RawFmt          tst.b (a3)+
                        bne .Search_RawFmt
                        subq.l #1,a3


                        bra .Exit

.PutChar                move.b d0,(a3)+
                        rts


.Exit                   move.b #$0d,(a3)+
                        lea bbs_ServerLine(a6),a0
                        sub.l a0,a3
                        move.l a3,d0
                        movem.l (sp)+,d2-d7/a2-a6
                        rts

.DFormat                dc.b "%ld",0
                        even

BBS_ParseProposalLine   movem.l d2-d7/a2-a6,-(sp)
                        move.l d0,d6
                        move.l d1,d7
                        lea bbs_ServerLine(a6),a4
                        lea bbs_OwnSID(a6),a3
                        cmp.b #-1,sid_DVersion(a3)
                        beq .No_DieBox
                        bra .DieBox_Good
.No_DieBox              cmp.l #2,d0
                        beq .BadLine
                        cmp.b #-1,sid_BVersion(a3)
                        beq .DieBox_Good
                        tst.l d0
                        bne .BadLine
.DieBox_Good            move.l d7,d0
                        asl.l #2,d0
                        lea bbs_PropProtocol(a6),a0
                        add.l d0,a0
                        move.l d6,(a0)
                        cmp.b #" ",2(a4)
                        bne .BadLine
                        lea 3(a4),a4
                        move.b (a4)+,d0
                        cmp.b #"B",d0
                        beq .Type_Bull
                        cmp.b #"P",d0
                        beq .Type_Personal
                        cmp.b #"A",d0
                        beq .Type_Acknow
                        bra .BadLine
.Type_Bull              moveq #0,d0
                        bra .Type_Clear

.Type_Acknow            moveq #2,d0
                        bra .Type_Clear

.Type_Personal          moveq #1,d0
.Type_Clear             lea bbs_PropType(a6),a0
                        move.l d7,d1
                        asl.l #2,d1
                        add.l d1,a0
                        move.l d0,(a0)
                        move.b (a4)+,d0
                        cmp.b #" ",d0
                        bne .BadLine
                        lea bbs_PropFrom(a6),a0
                        move.l d7,d0
                        mulu #12,d0
                        add.l d0,a0
                        moveq #12,d0
                        bsr .Get_Prop_String
                        tst.l d0
                        bne .BadLine
                        lea bbs_PropAt(a6),a0
                        move.l d7,d0
                        mulu #80,d0
                        add.l d0,a0
                        moveq #80,d0
                        bsr .Get_Prop_String
                        tst.l d0
                        bne .BadLine
                        lea bbs_PropTo(a6),a0
                        move.l d7,d0
                        mulu #12,d0
                        add.l d0,a0
                        moveq #12,d0
                        bsr .Get_Prop_String
                        tst.l d0
                        bne .BadLine
                        lea bbs_PropBid(a6),a0
                        move.l d7,d0
                        asl.l #4,d0
                        add.l d0,a0
                        moveq #16,d0
                        bsr .Get_Prop_String
                        tst.l d0
                        bne .BadLine
                        IFD BBS_DEBUG
                        lea bbs_PropBid(a6),a0
                        move.l d7,d0
                        asl.l #4,d0
                        add.l d0,a0
                        lea DEBUG_ParsedBID(pc),a1
                        bsr DEBUG_OutputFormat
                        ENDIF
                        lea bbs_PropBytes(a6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        bsr .Get_Prop_Long
                        tst.l d0
                        bne .BadLine
                        lea bbs_PropLifetime(a6),a0
                        move.l d7,d0
                        asl.l #2,d0
                        add.l d0,a0
                        clr.l (a0)
                        tst.b (a4)
                        beq .GoodLine
                        bsr .Get_Prop_Long
                        tst.l d0
                        bne .BadLine
                        bra .GoodLine



.Get_Prop_Long          move.l a0,-(sp)
                        move.l a4,d1
                        clr.l -(sp)
                        move.l a7,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOStrToLong(a6)
                        move.l (sp)+,a6
                        move.l (sp)+,d1
                        move.l (sp)+,a0
                        cmp.l #-1,d0
                        beq .Get_Prop_Long_Bad
                        tst.l d0
                        beq .Get_Prop_Long_Bad
                        move.l d1,(a0)
                        moveq #0,d0
                        rts
.Get_Prop_Long_Bad      moveq #-1,d0
                        rts
.Get_Prop_String        moveq #0,d1
.Get_Prop_String_L      cmp.b #" ",(A4)
                        beq .Get_Prop_String_End
                        tst.b (a4)
                        beq .Get_Prop_String_Error
                        tst.l d0
                        beq .Get_Prop_String_Error
                        move.b (a4)+,(a0)+
                        subq.l #1,d0
                        addq.l #1,d1
                        bra .Get_Prop_String_L
.Get_Prop_String_End    cmp.b #" ",1(a4)
                        bne .Get_Prop_String_EndSOK
                        addq.l #1,a4
                        bra .Get_Prop_String_End
.Get_Prop_String_EndSOK tst.l d0
                        beq .Get_Prop_String_Error
                        addq.l #1,a4
                        clr.b (a0)+
                        tst.l d1
                        beq .Get_Prop_String_Error
                        moveq #0,d0
                        rts
.Get_Prop_String_Error  moveq #-1,d0
                        rts
.GoodLine               moveq #0,d0
.Exit                   movem.l (sp)+,d2-d7/a2-a6
                        rts
                        
.BadLine                moveq #-1,d0
                        bra .Exit

BBS_PutHexa             move.l d0,-(sp)
                        and.l #$f0,d0
                        lsr.l #4,d0
                        bsr .PutHexNibble
                        move.l (sp)+,d0
                        and.l #$f,d0
                        bsr .PutHexNibble
                        rts
.PutHexNibble           add.b #$30,d0
                        cmp.b #$39,d0
                        ble .PutHexNibble_OK
                        add.b #$7,d0
.PutHexNibble_OK        move.b d0,(a0)+
                        rts

BBS_GetHexa             move.b (a0)+,d0
                        bsr .GetHexNibble
                        cmp.l #-1,d0
                        beq .Error
                        and.l #$f,d0
                        asl.l #4,d0
                        move.l d0,-(sp)
                        move.b (a0)+,d0
                        bsr .GetHexNibble
                        cmp.l #-1,d0
                        beq .Error2
                        and.l #$f,d0
                        or.l (sp)+,d0
                        rts
.Error2                 move.l (sp)+,d0
.Error                  moveq #-1,d0
                        rts
.GetHexNibble           cmp.b #$30,d0
                        blt .Invalid_Nibble
                        cmp.b #$39,d0
                        ble .Number_Nibble
                        cmp.b #$41,d0
                        blt .Invalid_Nibble
                        cmp.b #$46,d0
                        ble .Large_Nibble
                        cmp.b #$61,d0
                        blt .Invalid_Nibble
                        cmp.b #$66,d0
                        ble .Lower_Nibble
.Invalid_Nibble         moveq #-1,d0
                        rts
.Number_Nibble          and.l #$f,d0
                        rts
.Large_Nibble           sub.b #$7,d0
                        and.l #$f,d0
                        rts
.Lower_Nibble           sub.b #$27,d0
                        and.l #$f,d0
                        rts


;>A0 Mailhandle

BBS_CompressMailTX      move.l a4,-(sp)
                        sub.l #128,a7
                        move.l a0,a4


                        move.l a7,a1
                        move.l a4,a0
                        bsr BBS_MakeTempTxf

                        lea 64(a7),a1
                        move.l a4,a0
                        bsr BBS_MakeTempTxc
                        move.l a4,a0
                        GOQSO GetMailTitle
                        move.l d0,-(sp)
                        lea bbs_OwnSID(a6),a0
                        moveq #0,d0
                        cmp.b #1,sid_BVersion(a0)
                        blt .Mode_IsOK
                        moveq #1,d0
                        cmp.b #-1,sid_DVersion(a0)
                        beq .Mode_IsOK
                        moveq #2,d0
.Mode_IsOK              move.l d0,-(sp)
                        lea 64+8(a7),a1
                        lea 0+8(a7),a0
                        move.l a1,-(sp)
                        move.l a0,-(sp)
                        exg a4,a6
                        jsr _enchuf
                        exg a4,a6
                        add.l #16,a7
                        add.l #128,a7
                        move.l (sp)+,a4
                        rts

;>A0 Mailhandle

BBS_TranslateMailTX     movem.l d2-d7/a2-a6,-(Sp)
                        move.l a0,a4
                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempTxf
                        move.l a7,d1
                        move.l #1006,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(A6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        tst.l d0
                        beq .Error
                        moveq #0,d7
                        move.l d0,d6

                        move.l a4,a0
                        lea bbs_ServerLine(a6),a1
                        GOQSO ComposeRLine
                        tst.l d0
                        beq .No_RLine
                        move.l d0,d3
                        move.l d6,d1
                        lea bbs_ServerLine(A6),a0
                        move.l a0,d2
                        add.l d3,a0
                        move.b #$a,(a0)
                        addq.l #1,d3
                        move.l d3,-(sp)
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOWrite(a6)
                        move.l (sp)+,a6
                        move.l (sp)+,d3
                        cmp.l d0,d3
                        bne .Error_2
                        add.l d0,d7
.No_RLine               moveq #0,d4
.Main_Converting        move.l a4,a0
                        lea bbs_ServerLine(a6),a1
                        move.l #1020,d0
                        GOQSO ReadMailLine
                        cmp.l #-1,d0
                        beq .Error_2
                        tst.l d0
                        beq .Mail_EOF
                        move.l d0,d5
                        lea bbs_ServerLine(a6),a0
                        add.l d5,a0
                        subq.l #1,a0
                        cmp.b #$0d,(a0)
                        bne .Main_WriteTLine
                        move.b #$0a,1(a0)
                        addq.l #1,d5
                        cmp.l #8,d5
                        blt .Main_WriteTLine
                        lea bbs_ServerLine(a6),a0
                        cmp.l #"#BIN",(a0)
                        bne .Main_WriteTLine
                        cmp.b #"#",4(a0)
                        bne .Main_WriteTLine
                        move.b 5(a0),d0
                        cmp.b #$30,d0
                        blt .Main_WriteTLine
                        cmp.b #$39,d0
                        bgt .Main_WriteTLine
                        moveq #1,d4
.Main_WriteTLine        move.l d5,d3
                        move.l d6,d1
                        lea bbs_ServerLine(a6),a0
                        move.l a0,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOWrite(a6)
                        move.l (Sp)+,a6
                        cmp.l d0,d5
                        bne .Error_2
                        add.l d0,d7
                        tst.l d4
                        bne .Main_BinLoop
                        bra .Main_Converting

.Main_BinLoop           move.l a4,a0
                        lea bbs_ServerLine(a6),a1
                        move.l #1024,d0
                        GOQSO ReadMail
                        cmp.l #-1,d0
                        beq .Error_2
                        tst.l d0
                        beq .Mail_EOF
                        move.l d0,d5
                        lea bbs_ServerLine(a6),a0
                        move.l a0,d2
                        move.l d6,d1
                        move.l d5,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOWrite(a6)
                        move.l (sp)+,a6
                        cmp.l d0,d5
                        bne .Error_2
                        add.l d0,d7
                        bra .Main_BinLoop
.Mail_EOF               move.l d6,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        move.l d7,d0
.Exit                   movem.l (sp)+,d2-d7/a2-a6
                        rts
.Error                  moveq #-1,d0
                        bra .Exit
.Error_2                move.l d6,d1
                        move.l a6,-(Sp)
                        move.l ppb_DosBase(A5),a6
                        jsr _LVOClose(A6)
                        move.l (sp)+,a6
                        bra .Error

;>A0 Mailhandle
BBS_TranslateFileRX     movem.l d2-d7/a2-a6,-(sp)
                        move.l a0,a4

                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempRxf
                        move.l a7,d1
                        move.l #1005,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(A6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        tst.l d0
                        beq .Error
                        move.l d0,d7
                        moveq #0,d5
.Text_Loop              move.l #1020,d3
                        move.l d7,d1
                        lea bbs_ServerLine(a6),a0
                        move.l a0,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOFGets(a6)
                        move.l (sp)+,a6
                        tst.l d0
                        beq .Exit_Translated
                        lea bbs_ServerLine(a6),a0
                        moveq #-1,d6
.Text_Copy_Count        addq.l #1,d6
                        tst.b (a0)+
                        bne .Text_Copy_Count
                        tst.l d6
                        beq .Text_Loop
                        cmp.b #$0a,-2(a0)
                        bne .Text_Outputmail
                        subq.l #1,d6

                        lea bbs_ServerLine(a6),a0
                        cmp.b #"#",(a0)
                        bne .Standard_Line
                        cmp.b #"B",1(a0)
                        bne .Standard_Line
                        cmp.b #"I",2(a0)
                        bne .Standard_Line
                        cmp.b #"N",3(a0)
                        bne .Standard_Line
                        cmp.b #"#",4(a0)
                        bne .Standard_Line
                        move.b 5(a0),d0
                        cmp.b #$30,d0
                        blt .Standard_Line
                        cmp.b #$39,d0
                        bgt .Standard_Line
                        moveq #1,d5
                        bra .Text_Outputmail
.Standard_Line          lea bbs_ServerLine(a6),a0
                        cmp.l #" go_",(a0)
                        beq .7plus_line
                        cmp.l #" sto",(a0)
                        bne .No_7plus_line
                        cmp.w #"p_",4(a0)
                        bne .No_7plus_line
.7plus_line             move.l a4,a0
                        GOQSO MarkAs7Plus
                        bra .Text_Outputmail
.No_7plus_line          lea bbs_ServerLine(a6),a0
                        cmp.l #"/ACK",(a0)
                        beq .Ack_Line
                        cmp.l #"/ack",(a0)
                        bne .No_AckLine
.Ack_Line               cmp.b #$0d,4(a0)
                        bne .No_AckLine
                        move.l a4,a0
                        GOQSO MarkAsWantAck
.No_AckLine
.Text_Outputmail        move.l a4,a0
                        lea bbs_ServerLine(a6),a1
                        move.l d6,d0
                        GOQSO WriteMail
                        tst.l d0
                        bne .Error_2
                        tst.l d5
                        beq .Text_Loop
.Binary_Loop            move.l d7,d1
                        lea bbs_ServerLine(a6),a0
                        move.l a0,d2
                        moveq #1,d3
                        move.l #1024,d4
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOFRead(A6)
                        move.l (sp)+,a6
                        cmp.l #-1,d0
                        beq .Error_2
                        tst.l d0
                        beq .Exit_Translated
                        lea bbs_ServerLine(a6),a1
                        move.l a4,a0
                        GOQSO WriteMail
                        tst.l d0
                        bne .Error_2
                        bra .Binary_Loop
.Exit_Translated        move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        moveq #0,d0
.Exit                   movem.l (sp)+,d2-d7/a2-a6
                        rts
.Error                  moveq #-1,d0
                        bra .Exit
.Error_2                move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        bra .Error

BBS_DeleteTemporary     move.l a4,-(sp)
                        sub.l #64,a7
                        move.l a0,a4

                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempTxf
                        move.l a7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODeleteFile(a6)
                        move.l (sp)+,a6

                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempTxc
                        move.l a7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODeleteFile(a6)
                        move.l (sp)+,a6

                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempRxf
                        move.l a7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODeleteFile(a6)
                        move.l (sp)+,a6

                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempRxc
                        move.l a7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODeleteFile(a6)
                        move.l (sp)+,a6

                        add.l #64,a7
                        move.l (sp)+,a4
                        rts

BBS_DeleteResume        sub.l #64,a7
                        move.l a7,a1
                        bsr BBS_MakeResumeFile
                        move.l a7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVODeleteFile(a6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        rts


BBS_TestResume          movem.l d2-d7/a2-a6,-(sp)
                        move.l d0,d6
                        move.l a0,a4
                        lea bbs_OwnSID(a6),a0
                        cmp.b #1,sid_BVersion(a0)
                        blt .No_Resume
                        cmp.b #-1,sid_FVersion(a0)
                        beq .No_Resume
                        sub.l #64,a7
                        move.l a7,a1
                        move.l a4,a0
                        bsr BBS_MakeResumeBID
                        move.l a7,d1
                        move.l #1005,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(a6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        tst.l d0
                        beq .No_Resume
                        move.l d0,d7
                        sub.l #20,a7
                        move.l d7,d1
                        move.l a7,d2
                        moveq #20,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVORead(a6)
                        move.l (sp)+,a6
                        cmp.l #20,d0
                        bne .No_Resume_Stack
                        move.l a7,a0
                        cmp.l (a0),d6
                        bne .No_Resume_Stack
                        lea 4(a0),a0
                        lea bbs_FWDCall(a6),a1
.Compare_Call           move.b (a0)+,d0
                        cmp.b (a1)+,d0
                        bne .No_Resume_Stack
                        tst.b d0
                        bne .Compare_Call
                        add.l #20,a7

                        move.l d7,d1
                        moveq #0,d2
                        moveq #1,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOSeek(a6)
                        move.l (sp)+,a6
                        cmp.l #-1,d0
                        beq .No_Resume_Close

                        move.l d7,d1
                        moveq #0,d2
                        moveq #0,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOSeek(a6)
                        move.l (sp)+,a6
                        cmp.l #-1,d0
                        beq .No_Resume_Close
                        sub.l #20,d0
                        tst.l d0
                        ble .No_Resume_Close
                        move.l d0,d6
                        move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        move.l d6,d0
.Exit                   movem.l (sp)+,d2-d7/a2-a6
                        rts
.No_Resume              moveq #0,d0
                        bra .Exit
.No_Resume_Stack        add.l #20,a7
.No_Resume_Close        move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        bra .No_Resume


;>A0 Mailhandle
;>A1 Filehandle
;>D0 Bytes
BBS_LoadResume          movem.l d2-d7/a2-a6,-(sp)
                        move.l a1,d4
                        move.l a0,a4
                        move.l d0,d6
                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeResumeFile
                        move.l a7,d1
                        move.l #1005,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(a6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        tst.l d0
                        beq .Error_0
                        move.l d0,d7
                        move.l d7,d1
                        moveq #20,d2
                        moveq #-1,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOSeek(a6)
                        move.l (sp)+,a6
                        moveq #0,d5
                        cmp.l #-1,d0
                        beq .Error_1
.Main_Loop              lea bbs_OutputLine(a6),a0
                        move.l a0,d2
                        move.l d7,d1
                        move.l d6,d0
                        sub.l d5,d0
                        tst.l d0
                        ble .Good_File
                        cmp.l #1024,d0
                        blt .Short_File
                        move.l #1024,d0
.Short_File             move.l d0,d3
                        movem.l a6/d3,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVORead(a6)
                        movem.l (sp)+,a6/d3
                        cmp.l d0,d3
                        bne .Error_1
                        lea bbs_OutputLine(a6),a0
                        move.l d4,d1
                        move.l a0,d2
                        movem.l a6/d3,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOWrite(a6)
                        movem.l (sp)+,a6/d3
                        cmp.l d0,d3
                        bne .Error_1
                        add.l d0,d5
                        cmp.l d0,d5
                        bne .Main_Loop
                        lea bbs_OutputLine(a6),a0
                        lea bbs_ResumeChecker(a6),a1
                        move.l (a0),(a1)
                        move.w 4(a0),4(a1)
                        bra .Main_Loop
.Good_File              move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        moveq #0,d0
.Exit                   movem.l (sp)+,d2-d7/a2-a6
                        rts
.Error_0                moveq #-1,d0
                        bra .Exit
.Error_1                move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        moveq #-1,d0
                        bra .Exit
;>A0 Mailhandle
BBS_SaveResume          movem.l d2-d7/a2-a6,-(sp)
                        move.l a0,a4
                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeResumeFile
                        move.l a7,d1
                        move.l #1006,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(a6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        tst.l d0
                        beq .Exit
                        move.l d0,d7
                        sub.l #64,a7
                        move.l a4,a0
                        move.l a7,a1
                        bsr BBS_MakeTempRxc
                        move.l a7,d1
                        move.l #1005,d2
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOOpen(a6)
                        move.l (sp)+,a6
                        add.l #64,a7
                        tst.l d0
                        beq .Exit_2
                        move.l d0,d6

                        sub.l #20,a7
                        move.l a7,a0
                        move.l bbs_ResumeBytes(a6),(a0)
                        move.l bbs_FWDCall(a6),4(a0)
                        move.l bbs_FWDCall+4(a6),8(a0)
                        move.l bbs_FWDCall+8(a6),12(a0)
                        move.l bbs_FWDCall+12(a6),16(a0)
                        move.l a7,d2
                        moveq #20,d3
                        move.l d7,d1
                        move.l a6,-(sp)
                        move.l ppb_DosBase(A5),a6
                        jsr _LVOWrite(a6)
                        move.l (sp)+,a6
                        add.l #20,a7
                        cmp.l #20,d0
                        bne .Exit_3
                        moveq #0,d5
.Main_Loop              lea bbs_OutputLine(a6),a0
                        move.l a0,d2
                        move.l d6,d1
                        move.l #1024,d3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVORead(a6)
                        move.l (sp)+,a6
                        cmp.l #-1,d0
                        beq .Exit_3
                        tst.l d0
                        beq .Exit_Good
                        move.l d0,d3
                        move.l d7,d1
                        lea bbs_OutputLine(a6),a0
                        move.l a0,d2
                        movem.l a6/d3,-(sp)
                        move.l ppb_DosBase(a5),a6
                        jsr _LVOWrite(a6)
                        movem.l (sp)+,a6/d3
                        cmp.l d0,d3
                        bne .Exit_3
                        add.l d0,d5
                        bra .Main_Loop
.Exit_Good              tst.l d5
                        beq .Exit_3
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        move.l d6,d1
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        move.l d7,d1
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        move.l a4,a0
                        bra .Exit
.Exit_3                 move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        move.l d6,d1
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
.Exit_2                 move.l a6,-(sp)
                        move.l ppb_DosBase(a5),a6
                        move.l d7,d1
                        jsr _LVOClose(a6)
                        move.l (sp)+,a6
                        move.l a4,a0
                        bsr BBS_DeleteResume
.Exit                   clr.l bbs_ResumeMode(a6)
                        movem.l (sp)+,d2-d7/a2-a6
                        rts

BBS_MakeResumeFile      move.l a1,-(sp)
                        GOQSO GetMailBid
                        move.l d0,a0
                        move.l (sp)+,a1
                        bsr BBS_MakeResumeBID
                        rts
BBS_MakeResumeBID       move.l #"Data",(a1)+
                        move.l #"/BBS",(a1)+
                        move.l #"/Res",(a1)+
                        move.l #"ume/",(a1)+
.Copy_FName             tst.b (a0)
                        beq .Copy_FNameEnd
                        move.b (a0)+,(A1)+
                        bra .Copy_FName
.Copy_FNameEnd          move.b #".",(a1)+
                        move.b #"r",(a1)+
                        move.b #"e",(a1)+
                        move.b #"s",(a1)+
                        clr.b (a1)+
                        rts

BBS_MakeTempTxf         move.l a1,-(sp)
                        GOQSO GetMailBid
                        move.l d0,a0
                        move.l (sp)+,a1
                        move.w #"T:",(a1)+
.Copy_FName             tst.b (a0)
                        beq .Copy_FNameEnd
                        move.b (a0)+,(a1)+
                        bra .Copy_FName
.Copy_FNameEnd          move.b #".",(a1)+
                        move.b #"t",(a1)+
                        move.b #"x",(a1)+
                        move.b #"f",(a1)+
                        clr.b (a1)+
                        rts

BBS_MakeTempTxc         move.l a1,-(sp)
                        GOQSO GetMailBid
                        move.l d0,a0
                        move.l (sp)+,a1
                        move.w #"T:",(a1)+
.Copy_FName             tst.b (a0)
                        beq .Copy_FNameEnd
                        move.b (a0)+,(a1)+
                        bra .Copy_FName
.Copy_FNameEnd          move.b #".",(a1)+
                        move.b #"t",(a1)+
                        move.b #"x",(a1)+
                        move.b #"c",(a1)+
                        clr.b (a1)+
                        rts

BBS_MakeTempRxf         move.l a1,-(sp)
                        GOQSO GetMailBid
                        move.l d0,a0
                        move.l (sp)+,a1
                        move.w #"T:",(a1)+
.Copy_FName             tst.b (a0)
                        beq .Copy_FNameEnd
                        move.b (a0)+,(a1)+
                        bra .Copy_FName
.Copy_FNameEnd          move.b #".",(a1)+
                        move.b #"r",(a1)+
                        move.b #"x",(a1)+
                        move.b #"f",(a1)+
                        clr.b (a1)+
                        rts

BBS_MakeTempRxc         move.l a1,-(sp)
                        GOQSO GetMailBid
                        move.l d0,a0
                        move.l (sp)+,a1
                        move.w #"T:",(a1)+
.Copy_FName             tst.b (a0)
                        beq .Copy_FNameEnd
                        move.b (a0)+,(a1)+
                        bra .Copy_FName
.Copy_FNameEnd          move.b #".",(a1)+
                        move.b #"r",(a1)+
                        move.b #"x",(a1)+
                        move.b #"c",(a1)+
                        clr.b (a1)+
                        rts

BBS_TestBlockCRC        lea bbs_OwnSID(a6),a0
                        cmp.b #1,sid_DVersion(a0)
                        blt .No_BlockCRC
                        cmp.b #-1,sid_FVersion(a0)
                        beq .No_BlockCRC
                        cmp.b #1,sid_BVersion(a0)
                        blt .No_BlockCRC
                        moveq #2,d0
                        rts
.No_BlockCRC            moveq #0,d0
                        rts


BBS_GetServerType       tst.l bbs_ForwardMode(a6)
                        beq .No_Fwd
                        move.l #512,d0          ;Mailing Server Type
                        rts
.No_Fwd                 moveq #0,d0
                        rts



                        ifd BBS_DEBUG
DEBUG_OutputString      movem.l d0-d1/a1,-(sp)
                        lea BBS_DebugStringFmt(pc),a1
                        bsr DEBUG_OutputFormat
                        movem.l (sp)+,d0-d1/a1
                        rts
DEBUG_OutputHexa        movem.l d0-d1/a1,-(sp)
                        move.l d0,a0
                        lea BBS_DebugHexaFmt(pc),a1
                        bsr DEBUG_OutputFormat
                        movem.l (sp)+,d0-d1/a1
                        rts
BBS_DebugStringFmt      dc.b "%s",$0d,0
                        even
BBS_DebugHexaFmt        dc.b "%08lx",$0d,0
                        even
DEBUG_OutputFormat
                        movem.l d0-d7/a0-a6,-(sp)
                        sub.l #128,a7
                        move.l a0,-(sp)
                        move.l a1,a0
                        move.l a7,a1
                        lea .Debug_Proc(pc),a2
                        lea 4(a7),a3
                        move.l a6,-(sp)
                        move.l ppb_ExecBase(a5),a6
                        jsr _LVORawDoFmt(a6)
                        move.l (sp)+,a6
                        move.l (sp)+,d0
                        move.l a7,a0
                        moveq #-1,d0
.Count_Chars            addq.l #1,d0
                        tst.b (a0)+
                        bne .Count_Chars
                        move.l bbs_Channel(a6),d1
                        moveq #$3,d2
                        move.l a7,a0
                        GOQSO WriteTerminal
                        add.l #128,a7
                        movem.l (sp)+,d0-d7/a0-a6
                        rts
.Debug_Proc             move.b d0,(a3)+
                        rts

DEBUG_ParsedBID         dc.b "BID parsed : %s",$0d,0
DEBUG_CheckingBID       dc.b "BID checked : %s",$0d,0
DEBUG_ReceivingBID      dc.b "BID receiving : %s",$0d,0
                        even
                        endif

BBS_FunctionsBegin      
                        AJUMP BBS_AskAudio              ;-54 surpress Audio
                        AJUMP BBS_Cleanup               ;-48 really Abort
                        AJUMP BBS_GetServerType         ;-42
                        AJUMP BBS_TerminalInput         ;-36
                        AJUMP BBS_ReceivePacket         ;-30
                        AJUMP BBS_DoPoll                ;-24
                        AJUMP BBS_ConnectProced         ;-18
                        AJUMP BBS_Cleanup               ;-12
                        AJUMP BBS_Init                  ;-6

BBS_Functions           



Get_Text                lea _BBSCatalog(pc),a0
                        move.l bbs_ThisQSO(a5),a1
                        move.l a2,-(sp)
                        lea _BBSCatalogName(pc),a2
                        GOQSO GetText
                        move.l (sp)+,a2
                        rts



                        include "/Catalogs/Sources/BBS.s"


                        
BBS_PromptText          dc.b $0d,"%c de %m %d %z>",$0d,0
BBS_ShortPrompt         dc.b ">",$0d,0
BBS_Sysop               dc.b "Sysop_BBS",0
BBS_FBBBatch            dc.b "bbs_FBBBatch",0
Serv_Datacollector      dc.b "Datacollector",0

                        ;Hard implemented
                        ;H    Help
                        ;B    Bye
                        ;Q    Quit
                        ;I    Info

PseudoStr_OK1     dc.b "Titel der Nachricht",0
PseudoStr_NO1     dc.b "wurde nicht gespeichert",0
         even

BBS_CommandList         dc.b "S",0,"bbs_SP",0
                        dc.b "SP",0,"bbs_SP",0
                        dc.b "SB",0,"bbs_SB",0
                        dc.b "SA",0,"bbs_SA",0
                        dc.b "L",0,"bbs_L",0
                        dc.b "LB",0,"bbs_LB",0
                        dc.b "LM",0,"bbs_LM",0
                        dc.b "LN",0,"bbs_LN",0
                        dc.b "LL",0,"bbs_LL",0      ;NOT YET SUPPORTED
                        dc.b "LS",0,"bbs_LS",0      ;NOT YET SUPPORTED
                        dc.b "LU",0,"bbs_LN",0
                        dc.b "L<",0,"bbs_L<",0
                        dc.b "L>",0,"bbs_L>",0
                        dc.b "L@",0,"bbs_L@",0      ;NOT YET SUPPORTED
                        dc.b "R",0,"bbs_R",0
                        dc.b "RM",0,"bbs_RM",0
                        dc.b "RN",0,"bbs_RN",0
                        dc.b "RU",0,"bbs_RN",0
                        dc.b "R>",0,"bbs_R>",0
                        dc.b "R<",0,"bbs_R<",0
                        dc.b "K",0,"bbs_K",0
                        dc.b "KM",0,"bbs_KM",0
                        dc.b "KN",0,"bbs_KN",0
                        dc.b "KU",0,"bbs_KN",0
                        dc.b "K>",0,"bbs_K>",0
                        dc.b "K<",0,"bbs_K<",0
                
                        even
                                                
                        
                        rsreset
bbs_ThisQSO             rs.l 1
bbs_Channel             rs.l 1
bbs_OldServer           rs.l 1
bbs_QSOBase             rs.l 1
bbs_ForwardType         rs.l 1          ;0=Standard forwarding
                                        ;1=FBB / DPBOX forwarding

bbs_ServerInLine        rs.l 1
bbs_PseudoBBS           rs.l 1
bbs_LZHBufferFlag       rs.l 1
bbs_ServerLine          rs.b 1024
bbs_OutputLine          rs.b 1024
bbs_FWDCall             rs.b 16
bbs_ConnectStep         rs.l 1
bbs_ForwardMode         rs.l 1          ;0= No forward mode
                                        ;1= Wait for forward-init prompt
                                        ;2= Passive forward - wait command
                                        ;3= Active forward - wait > prompt
                                        ;4= Active forward - wait std YES/NO
                                        ;5= Active forward - transmit mail
                                        ;6= FBB active  - wait for FS
                                        ;7= FBB passive - wait for FA/FB/FD/FF/FQ
                                        ;8= FBB passive - receive a mail
                                        ;9= FBB active  - transmit a mail
                                        ;10=FBB active  - transmit YAPP
                                        ;11=FBB passive - receive YAPP
                                        ;12=FBB passive - receive YAPP data
                                        ;13=WAITING FOR DISCONNECT

bbs_ResumeMode          rs.l 1
bbs_ResumeBytes         rs.l 1
bbs_ResumeHeader        rs.l 1
bbs_ResumeChecker       rs.b 8
bbs_IAmConnected        rs.l 1
bbs_PartnerSID          rs.b sid_Size
bbs_OwnSID              rs.b sid_Size
bbs_MailHandle          rs.l 5
bbs_MailHandleOffset    rs.l 1
bbs_MailIncomplete      rs.l 1
bbs_FileHandle          rs.l 1
bbs_DeferOffset         rs.l 1
bbs_FBBCounter          rs.l 1
bbs_FBBChecksum         rs.l 1
bbs_YAPPCRC             rs.l 1
bbs_YAPPHeader          rs.l 1
bbs_YAPPType            rs.l 1
bbs_YAPPLength          rs.l 1
bbs_ActiveMail          rs.l 1
bbs_PropFrom            rs.b 12*5
bbs_PropTo              rs.b 12*5
bbs_PropAt              rs.b 80*5
bbs_PropBid             rs.b 16*5
bbs_PropType            rs.l 5
bbs_PropBytes           rs.l 5
bbs_PropProtocol        rs.l 5
bbs_PropLifetime        rs.l 5
bbs_PropTaken           rs.l 5
bbs_PropResume          rs.l 5

bbs_FBBPersonal         rs.l 1
bbs_FBBFrom             rs.l 1
bbs_FBBAt               rs.l 1
bbs_FBBTo               rs.l 1
bbs_FBBBid              rs.l 1
bbs_FBBBytes            rs.l 1
bbs_FBBLifetime         rs.l 1
bbs_FBBReturn           rs.l 1

_SysBase                rs.l 1
_DOSBase                rs.l 1
_UtilityBase            rs.l 1
_infile                 rs.l 1
_outfile                rs.l 1
_in_memory              rs.l 1
_out_memory             rs.l 1
_textsize               rs.l 1
_codesize               rs.l 1
_srcbuf                 rs.l 1
_destbuf                rs.l 1
_srcbufptr              rs.l 1
_destbufptr             rs.l 1
_srclen                 rs.l 1
_destlen                rs.l 1
_srcbuflen              rs.l 1
_destbuflen             rs.l 1
_text_buf               rs.l 1
_match_position         rs.l 1
_match_length           rs.l 1
_lson                   rs.l 1
_rson                   rs.l 1
_dad                    rs.l 1
_same                   rs.l 1
_putbuf                 rs.l 1
_putlen                 rs.l 1
_freq                   rs.l 1
_prnt                   rs.l 1
_son                    rs.l 1
_getbuf                 rs.l 1
_getlen                 rs.l 1
bbs_Size                rs.b 0
                                
