home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1B
/
DATAFILE_PDCD1B.iso
/
_pocketbk
/
pocketbook
/
004
/
laptimer_z
/
LAPTIMER.OPL
< prev
next >
Wrap
Text File
|
1992-08-05
|
14KB
|
699 lines
REM -----------------------------
REM Author Jonathan Simpson
REM Date 17 April 1992
REM Version 1.00
REM Title Lap Timer
REM CIX User @jsimpsonb
REM Uses Utils.opl,jsname.pic
REM car1.pic
REM -----------------------------
PROC LapTimer:
REM Application
GLOBAL event%(6), filestr$(128)
GLOBAL lpathn%(128), spathn%(7)
REM small font
GLOBAL fsx%, fsy%
GLOBAL fsxpo%, fsypo%
GLOBAL driver%(10) :REM sorted driver order
GLOBAL lapcnt%(11) :REM lap count
GLOBAL split%(10) :REM split times
GLOBAL times%(10) :REM combined lap/split
GLOBAL vcl$(7,7)
GLOBAL nullstr$(30), bitname$(10)
REM Procedures
GLOBAL route$(30,8), k$(30)
REM Heats / Rounds / Names
GLOBAL noheat%, minheat%, maxheat%
GLOBAL nornd%, minrnd%, maxrnd%
GLOBAL maxnlen%
GLOBAL names$(150,12), maxname%,namect%
GLOBAL ftdl%(150),ftds%(150)
GLOBAL heatno%,rndno%
GLOBAL hclst%(15)
REM windows
GLOBAL carid%, gwindid%, maxw%
GLOBAL workid%,resid%
GLOBAL carw%, carh%, lcrxpos%
REM race control
GLOBAL cdown%
GLOBAL maxlaps% ,secdur%
GLOBAL maxsplt%, durn%
GLOBAL fonth%, fontw%
GLOBAL noprint
GLOBAL incr, carxpos
LOCAL k%, ps%, md%
Header:
Initial:
SetTimes:
k%=13
WHILE k%<>%x
k%=MainMnu%:
IF k%
ps%=LOC(k$,CHR$(k%))
IF ps% <> 0
@(route$(ps%)):
ENDIF
ENDIF
ENDWH
CLS
ENDP
PROC MainMnu%:
mINIt
mCARD "Main Menu","Start Race",%S,"Set All",%A,"Last Results",%L,"Overall",%O,"Terminate",%X
mCARD "Configure","No. of Heats",%H,"No. of Rounds",%R,"Edit Times",%T
mCARD "Names","Enter Names",%N,"Change Name",%C
RETURN MENU
ENDP
PROC Header:
CLS
SCREEN 40,8,1,1
gAT 80,30
gxPRINT "Stop Watch Timer",2
ENDP
PROC TestPr:
LOCAL ret%,err%
noprint=0
TRAP LOPEN "PAR:A"
err%=ERR
IF err%
noprint=1
ENDIF
ENDP
PROC Initial:
LOCAL hc%,dc%,t%
ESCAPE OFF
TestPr:
fsx%=3 : fsy%=5
fsxpo%=fsx%+1 : fsypo%=fsy%+1
resid%=gCREATE( 0, 0, gWIDTH,gHEIGHT,1)
workid%=gLOADBIT("smallfnt",0,0)
durn% = 5*60
maxsplt% = 25
cdown% = 5
maxlaps%=30
maxw%=240
nullstr$=REPT$("",maxlaps%)
noheat%=5
TrakInit:
minheat%=1
maxheat%=15
nornd%=4
minrnd%=1
maxrnd%=5
maxname%=150
maxnlen%=12
namect%=0
heatno%=0
rndno%=1
k$=""
k$=k$+"S" : route$(1)="RunRace"
k$=k$+"H" : route$(2)="SetHeats"
k$=k$+"R" : route$(3)="SetRnds"
k$=k$+"T" : route$(4)="SetTimes"
k$=k$+"N" : route$(5)="SetNames"
k$=k$+"A" : route$(6)="SetAll"
k$=k$+"C" : route$(7)="ChgName"
k$=k$+"L" : route$(8)="ShowRes"
k$=k$+"O" : route$(9)="SortOvr"
k$=k$+"X" : route$(10)="Exit"
vcl$(1)="Pro 10"
vcl$(2)="Buggy"
vcl$(3)="Mini"
vcl$(4)="Monster"
vcl$(5)="IC"
vcl$(6)="4_WD"
vcl$(7)="2_WD"
hc%=0
WHILE hc% < maxheat%
dc%=1
WHILE dc% <= 10
t%=(hc%*10)+dc%
names$(t%)="Dr_"+FIX$(dc%,0,2)+" Ht_"+FIX$(hc%+1,0,2)
ftdl%(t%)=0 : ftds%(t%)=59
dc%=dc%+1
ENDWH
hc%=hc%+1
ENDWH
ENDP
PROC SetHeats:
LOCAL ht,hb%,lc%,lhis%,lc2%,lcmo%
dINIT "Number of Heats"
ht=noheat%
dFLOAT ht,"No. ",minheat%,maxheat%
IF DIALOG
noheat%=ht
ENDIF
REM select class of heats
hb%=(noheat%/5)+1
lc%=1
WHILE lc% <= hb%
lcmo%=lc%-1
IF 5*lc% > noheat%
lhis%=noheat%-(5*lcmo%)
ELSE
lhis%=5
ENDIF
dINIT "Select Class Heats "+FIX$((lcmo%*5)+1,0,2)+" to "+FIX$((lcmo%*5)+lhis%,0,2)
lc2%=1
WHILE lc2% <= lhis%
dCHOICE hclst%((lcmo%*5)+lc2%),"Heat "+FIX$(((lcmo%*5)+lc2%),0,2), "Pro 10,Buggy,Mini,Monster,IC,2_WD,4_WD"
lc2%=lc2%+1
ENDWH
DIALOG
lc%=lc%+1
ENDWH
ENDP
PROC SetRnds:
LOCAL nr
nr=nornd%
dINIT "Number of Rounds"
dFLOAT nr,"No. ",minrnd%,maxrnd%
IF DIALOG
nornd%=nr
ENDIF
ENDP
PROC SetTimes:
LOCAL fd,fs,fc
fd=FLT(durn%)/60.0
fs=maxsplt%
fc=cdown%
dINIT "Race Times"
dFLOAT fd,"Minute Duration",1,10
dFLOAT fs,"Second Split Time",1,59
dFLOAT fc,"Second Countdown",1,30
DIALOG
durn%=60*fd
maxsplt%=fs
incr=FLT(maxw%)/FLT(durn%)
cdown%=fc
ENDP
PROC SetNames:
LOCAL hc%,pc%,nip%
hc%=0
WHILE hc%<noheat%
pc%=0
WHILE pc%<2
nip%=1
dINIT "Heat Number "+FIX$(hc%+1,0,2)
WHILE nip%<6
dEDIT names$((hc%*10)+(pc%*5)+nip%),"Name ",maxnlen%
nip%=nip%+1
ENDWH
DIALOG
pc%=pc%+1
ENDWH
hc%=hc%+1
ENDWH
ENDP
PROC SetAll:
SetTimes:
SetHeats:
SetRnds:
SetNames:
ENDP
PROC ChgName:
LOCAL ht,no,ht%,no%
dINIT "Change Driver Name"
dFLOAT ht,"Which Heat ",minheat%,maxheat%
dFLOAT no,"Car Number",1,10
IF DIALOG
ht%=ht : no%=no
dINIT "Edit Name for Heat "+FIX$( ht%,0,2 ) + " Car " + FIX$( no%,0,2 )
dEDIT names$(((ht%-1)*10)+no%),"New Name",maxnlen%
DIALOG
ENDIF
ENDP
PROC Exit:
ENDP
PROC RaceInit:
LOCAL lc1%
lc1%=1
WHILE lc1%<11
driver%( lc1% ) = lc1%
lapcnt%( lc1% ) = 0
split%( lc1% ) = 0
times%( lc1% ) = 0
lc1%=lc1%+1
ENDWH
lcrxpos%=0
carxpos=0.0
ENDP
PROC CntDown:(secdur%)
LOCAL timect%
gUSE 1
gFONT 1
gORDER 1,1
timect%=secdur%
gCLS
gAT 0,0
gBORDER 0,240,70
AT 12,4
PRINT "Countdown [ ]"
DO
AT 24,4
PRINT timect%;" "
timect%=timect%-1
BEEP 2,300-(20*timect%)
PAUSE 20
UNTIL timect% < 1
BEEP 2,100
ENDP
PROC RunRace:
LOCAL ch,cr
heatno%=heatno%+1
IF heatno%>noheat%
heatno%=1
rndno%=rndno%+1
ENDIF
ch=heatno%
cr=rndno%
dINIT "Next Race"
dFLOAT ch,"Heat Number",minheat%,maxheat%
dFLOAT cr,"Round Number",minrnd%,maxrnd%
IF DIALOG
heatno%=ch
rndno%=cr
CntDown:( cdown% )
SecTime:
SortArr:
ShowRes:
ENDIF
ENDP
PROC SecTime:
fonth%=10
fontw%=gTWIDTH("0")
CLS
gAT 0,0
gBORDER 0,240,70
RaceHdr:
RaceInit:
DrawTrak:( gwindid%, carh%+2, maxw%)
TimeRace:(durn%)
SplTime:(maxsplt%)
GetTimes:(maxsplt%)
ENDP
PROC RaceHdr:
LOCAL ct%
ct%=1
gUPDATE OFF
gUSE 1
gORDER 1,1
gAT 1*fontw%,1*fonth%
gPRINT "Time: M S Split:"
gAT 25*fontw%,1*fonth%
gPRINT "Heat "+FIX$( heatno%,0,2 )+" Round "+FIX$( rndno%,0,2)
gAT 11*fontw%,2*fonth%
gXPRINT " D r i v e r N a m e s ",5
gFONT 3
DO
SmlTxtAt:(2+((ct%-1)*6*fsxpo%),3*fonth%,LEFT$(names$(((heatno%-1)*10)+ct%),5))
SmlTxtAt:(2+((ct%-1)*6*fsxpo%),(3*fonth%)+fsypo%,"No."+FIX$(ct%,0,2))
gAT 2+((ct%-1)*4*fontw%),5*fonth%
gPRINT "0"
ct%=ct%+1
UNTIL ct%>10
gUPDATE ON
ENDP
PROC DrawTrak:(windid%, height%, width%)
LOCAL lc1%
lc1%=0
gORDER windid%,1
gUSE windid%
gAT 0,height%
gLINEBY width%, 0
WHILE lc1% < width%
gAT lc1%,height%-2
gLINEBY 0,2
lc1%=lc1%+10
ENDWH
gUSE 1
ENDP
PROC MoveCar:(windid%, carx%,carid%,carw%,carh%)
gUSE windid%
gAT carx%,1
gCOPY carid%,0,0,carw%,carh%,3
gUSE 1
ENDP
PROC TrakInit:
maxw%=240
bitname$="car1"
carw%=20 : carh%=6
carid%=gLOADBIT( bitname$, 0 )
gwindid%=gCREATE( 0, 70, maxw%, carh%+3,1)
ENDP
PROC TimeRace:(maxtime%)
LOCAL timect%, last%, start%, lc%, big%
LOCAL sectik%, lockey%,txpos%,lhp%
sectik% = 0 : timect% = 0 : lhp%=0
last% = 0 : start% = SECOND
gTMODE 3
DO
DO
timect%=start%-SECOND
lockey%=GetKey%:
IF lockey%<>999
lapcnt%(lockey%)=lapcnt%(lockey%)+1
lc%=1
WHILE (lc% < lockey%) AND (lapcnt%(lockey%) > lapcnt%(lc%))
lc%=lc%+1
ENDWH
IF lc%=lockey%
lc%=lc%+1
WHILE (lc% < 11) AND (lapcnt%(lockey%) > lapcnt%(lc%))
lc%=lc%+1
ENDWH
ENDIF
IF lc% < 11
gAT ((lockey%-1)*4*fontw%)+2,5*fonth%
gXPRINT FIX$(lapcnt%(lockey%),0,2),5
ELSE
IF lhp% <> 0
gAT ((lhp%-1)*4*fontw%)+2,5*fonth%
gXPRINT FIX$(lapcnt%(lhp%),0,2),5
ENDIF
lhp%=lockey%
gAT ((lockey%-1)*4*fontw%)+2,5*fonth%
gXPRINT FIX$(lapcnt%(lockey%),0,2),2
ENDIF
BEEP 1,(lockey%*10)+70
ENDIF
UNTIL timect%<>last%
last% =timect%
sectik%=sectik%+1
carxpos=carxpos+incr
txpos%=INT(carxpos)
WHILE lcrxpos% < txpos%
MoveCar:( gwindid%, lcrxpos% , carid%, carw%,carh%)
lcrxpos%=lcrxpos%+