;-----------------------------------------------------------PowerPPL v2.2á---
; File           : CONNECT.PPS
; Original by    : LONE RUNNER on 06/10/1995 at 15:16:31
; Last update by : LONE RUNNER on 02/22/1996 at 23:15:48
;----------------------------------------------------------------------------
;
;
;  This is a part of the Project Frontier's Source code.
;
;  Copyright (C) 1997-98 Francis Gastellu
;                    aka Lone Runner/Aegis
;
;  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.
;
; Connect status animation

;$USEFUNCS
;----------------------------------------------------------------------------
Integer a
Integer Hauteur
Integer Largeur
Int callnum_
int best
date callnumdate
boolean bestof
string temp
boolean alog

Integer v_int1, v_int2, v_int3, v_int4, v_int5, v_int6, v_int7
String v_str1

Declare Procedure PrintFade(String v_arg)
Declare Procedure PrintScramble(String v_arg)
Declare Procedure EffCurseur()
Declare Procedure Synchronize()


Begin

'if (!onlocal()) then

    Fopen 1, ppepath()+"best.dat",o_rd,s_dn
    fget 1, best
    fclose 1
    
    Fopen 1, ppepath()+"callnum.dat",o_rd,s_dn
    fget 1, callnumdate
    fget 1, callnum_
    fclose 1
    
    if (callnumdate != date()) then
    	fopen 1, ppepath()+"stats.dat",o_rw,s_dn
    	fseek 1, 0, seek_end
    	fwrite 1, date(), 2
        fwrite 1, callnum_, 2
    	fclose 1
        callnum_ = 1
    else
    	if (exist("LOGGED.")) then 
    		alog = true
    	else
                inc callnum_
    	endif
    endif
    
    FCreate 1, ppepath()+"callnum.dat",o_wr,s_dn
    fputln 1, date()
    fputln 1, callnum_
    fclose 1
    
    if (callnum_ > best) then
        best = callnum_
    	bestof = true
    	Fcreate 1, ppepath()+"best.dat",o_wr,s_dn
    	fputln 1, best
    	fclose 1
    endif

'endif

Hauteur = 7
Largeur = 24

Cls
'If (OnLocal()) End
StartDisp FNS

;----------------- 1er zigwigwi
AnsiPos 1,1
Print "@X0Fþ"
Gosub Waiting
AnsiPos 1,2
Print "@X07³"
Gosub Waiting
Color @X08
For a = 3 to hauteur-1
    AnsiPos 1,a
    Print "³"
    Gosub Waiting
Next

AnsiPos 1,Hauteur
Print "À"
Gosub Waiting

For a = 1 to Largeur/2
    Print "ÄÄ"
    Gosub Waiting
Next
Print "@X07Ä"
Gosub Waiting
Print "@X0Fþ"


;----------------- 2eme zigwigwi
AnsiPos 5,2
Print "@X0Fþ"
Gosub Waiting
AnsiPos 5,3
Print "@X07³"
Gosub Waiting

Color @X08
For a = 4 to hauteur
    AnsiPos 5,a
    Print "³"
    Gosub Waiting
Next

AnsiPos 5,Hauteur+1
Print "À"
Gosub Waiting

For a = 1 to Largeur/2
    Print "ÄÄ"
    Gosub Waiting
Next
Print "@X07Ä"
Gosub Waiting
Print "@X0Fþ"

AnsiPos 7,2
PrintFade("STaTUS")

AnsiPos 3, 3
Print "@X8Fþ"
AnsiPos 7, 3
Color @X03
PrintScramble(ReplaceStr(String(Date()), ".", "/"))
AnsiPos 3, 3
Print "@X0Fþ"
AnsiPos 3, 4
Print "@X8Fþ"
AnsiPos 7, 4
Color @X03
PrintScramble(String(Time()))
AnsiPos 3, 4
Print "@X0Fþ"
AnsiPos 3, 5
Print "@X8Fþ"
AnsiPos 7, 5
Color @X0B
if (onlocal()) then
	temp = "Local login"
else
	temp = String(Carrier())
endif
PrintScramble(temp)
AnsiPos 3, 5
Print "@X0Fþ"

AnsiPos 3, 6
Print "@X8Fþ"
AnsiPos 7, 6
Color @X03
PrintScramble("ANSi")
AnsiPos 3, 6
Print "@X0Fþ"

;AnsiPos 3, 7
;Print "@X8Fþ"
;AnsiPos 7, 7
;Color @X03
;if (onlocal()) then
;	temp = "Local login"
;else
;	if (alog) then
;		Temp = "Reseting..."
;	else
;               temp = "Caller #"+String(callnum_)+" of the day"
;	    if (bestof) temp = temp + " (BeST EVeR!)"
;	endif
;endif
;PrintScramble(temp)
;AnsiPos 3, 7
;Print "@X0Fþ"


AnsiPos 3, 1
Print "@X0Fþ"
Gosub Waiting
Print "@X07Ä"
Gosub Waiting
Print "@X08Ä"
Gosub Waiting

For a = 1 to Largeur - 12
	Print "ÄÄ"
	Gosub Waiting
Next
Print "@X07Ä"
Gosub Waiting
Print "@X0Fþ"

EffCurseur()
delay 10

AnsiPos 1,hauteur+4

Fcreate 1, "LOGGED.", O_WR, S_DN
FPutln 1, "A user has logged!"
Fclose 1

End



:Waiting
Delay 1
Return



;----------------------------------------------------------------------------
Procedure EffCurseur()
;
; This procedure remove the cursor by changing color to 0, printing a space
; at coordinates (1, 23) and move the cursor back to this position.
;

AnsiPos 1,23
Color 0
Print " "
Backup 1

EndProc

;----------------------------------------------------------------------------

Procedure Synchronize()
;
; This procedure waits for the receiver so the ppe will run exactly at the
; same speed on the remote screen than on the local screen. This is used to
; avoid full modem buffers
;
While (Outbytes() > 0) Do
EndWhile

EndProc

;----------------------------------------------------------------------------

Procedure PrintFade(String v_arg)
;
; This procedure writes a text in color 15 with a fading effect on every 
; character
;


For v_int1 = 1 to len(v_arg)                 ; for each character
	If (Mid(v_arg, v_int1, 1) = " ") Then    ; if this is a space, no fade
		Print "@X0F "
		Continue
	Endif
	Print "@X08" + Mid(v_arg, v_int1, 1)     ; print in color 8
	v_int2 = getX()                          ; backup position
	v_int3 = getY()
	EffCurseur()                             ; remove cursor
	Delay 1                                  ; wait one tick
	AnsiPos v_int2, v_int3                   ; restore position
	Backup 1                                 ; move cursor back 1 char
	Print "@X07" + Mid(v_arg, v_int1, 1)     ; print in color 7
	v_int2 = getX()
	v_int3 = getY()
	EffCurseur()
	Delay 1
	AnsiPos v_int2, v_int3
	Backup 1
	Print "@X0F" + Mid(v_arg, v_int1, 1)     ; print in color 15
	v_int2 = getX()
	v_int3 = getY()
	EffCurseur()
	Delay 1
	Synchronize()                            ; wait for other end
	AnsiPos v_int2, v_int3
Next

Endproc

;----------------------------------------------------------------------------

Procedure PrintScramble(String v_arg)
;
; This procedure writes a string with a random scramble effect
;

v_int4 = getx()     ; backup position
v_int5 = gety()     ;
v_int7 = curcolor() ; backup color

v_int2 = len(v_arg) ; length of string -> v_int2

While (1) Do
	v_int1 = random(v_int2-1)+1 ; we randomly generate a number depending on
                                ; v_int2 (witch begins with the string len)
	v_int3 = 0
	v_int6 = 0
	While (1) do                ; do until v_int6 is not v_int1 (random number)
		inc v_int3
		v_str1 = ScrText(v_int4+v_int3-1,v_int5, 1, False)
		if (v_str1 = " ") inc v_int6 ; if char pointed is a space, inc v_int6
		if (v_int6 = v_int1) Break
	Endwhile
	AnsiPos v_int4+v_int3-1,v_int5 ; ok so we have now the nth space (n = random)
	v_str1 = Mid(v_arg, v_int3, 1) 
	if (v_str1 != " ") Then        ; if the char to print is a space, print 
		Print v_str1               ; a char 255, if not, print it...
	else
		Print chr(255)
	endif
	dec v_int2                     ; dec v_int2 so we cannot go over the 
	if (v_int2 = 0) Break          ; amount of spaces available
	EffCurseur()                   ; remove cursor
	Delay 1                        ; add some delay
	Synchronize()                  ; wait for other end
	Color v_int7                   ; restore color
Endwhile


; Warning : This procedure NEEDS to find spaces where the string will be
; printed... if not, a endless loop will occur...
; To ensure taht everything is ok, you should add a CLS before or someting
; like :
; Print Space(len(v_arg))
; Backup len(v_arg)

EndProc
