home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1B
/
DATAFILE_PDCD1B.iso
/
_pocketbk
/
pocketbook
/
003
/
solo_zip
/
opl
/
solo.opl
next >
Wrap
Text File
|
1993-01-05
|
20KB
|
1,107 lines
REM Solo 1.0 : Solitaire Card game
REM (c) 1993 Steve Hawtin
REM This game may be freely
REM distributed provided
REM 1) All the files are copied
REM unmodified
REM 2) The distributor charges no more
REM than a reasonable copy fee
APP solo
TYPE 3
ICON "\OPD\SOLO.PIC"
PATH "\APP\SOLO"
EXT "SOL"
ENDA
PROC solo:
REM Reserve some space
GLOBAL filName$(128),saveIt%
GLOBAL space%(300)
GLOBAL img%,game%
REM Symbolic names for offsets
GLOBAL ofSeed%,oUsTime%,ofTurn%
GLOBAL oDrSuit%,ofdrNum%,oDrPict%
GLOBAL ofLeft%,oftLft%,oPileSz%
GLOBAL ofState%,ofKings%,ofMatch%
GLOBAL offPack%,offSuit%,offPile%
GLOBAL offSrc%,offHide%,offEnd%
LOCAL k%
game% = ADDR(space%())
REM ONERR errLab
init:
DO
CLS
runProg:
DO
k% = mGET%:
UNTIL k%=%q OR k%=% OR k%=%o
UNTIL 0
REM Error handling
errLab::
ONERR OFF
msgPrep:
PRINT "Error - ";err$(err)
msgAck%:
ENDP
PROC init:
filName$ = "\APP\SOLO\*.sol"
oDrSuit% = 8
ofdrNum% = 9
oDrPict% = 10
oUsTime% = 11
ofSeed% = 12
ofTurn% = 14
ofLeft% = 15
oftLft% = 16
oPileSz% = 17
ofMatch% = 18
ofKings% = 19
ofState% = 20
offPack% = 22
POKEB game%+offPack%,52
POKEB game%+ofState%,1
POKEB game%,7
POKEB game%+ofTurn%,3
POKEB game%+ofLeft%,255
POKEB game%+oPileSz%,255
POKEB game%+ofMatch%,1
POKEB game%+ofKings%,1
POKEB game%+oUsTime%,1
POKEW game%+ofSeed%,1
POKEB game%+oDrSuit%,1
POKEB game%+ofdrNum%,0
POKEB game%+oDrPict%,1
ONERR errEnd
img% = gLOADBIT("\app\solo\images.pic")
ONERR OFF
gUSE 1
STATUSWIN OFF
SCREEN 40,9,1,1
gSETWIN 0,0,240,80
filName$ = CMD$(2)
IF CMD$(3)="O"
openF:
saveIt% = 0
ELSEIF CMD$(2)="C"
saveIt% = 1
ENDIF
RETURN
errEnd::
IF ERR = -33
img% = 0
ENDIF
ONERR OFF
ENDP
PROC msgPrep:
gAT 0,0
gFILL 25*6-1,2*9-1,1
AT 1,1
ENDP
PROC msgAck%:
LOCAL k%
k% = mGET%:
msgPrep:
RETURN k%
ENDP
PROC mGET%:
LOCAL chr%
LOCAL a%(6),cmdStr$(255)
DO
GETEVENT a%()
IF (a%(1) AND $400)=0
chr% = a%(1)
ELSEIF a%(1)=$401 OR a%(1)=$402 OR a%(1)=$403
chr% = 0
ELSEIF a%(1)=$404
cmdStr$ = GETCMD$
IF LEFT$(cmdStr$,1)="C"
saveF:
filName$=MID$(cmdStr$,2,128)
saveIt%=1
chr%=%A
ELSEIF LEFT$(cmdStr$,1)="O"
saveF:
filName$=MID$(cmdStr$,2,128)
openF:
chr%=%O
ELSEIF LEFT$(cmdStr$,1)="X"
saveF:
STOP
ELSE
msgPrep:
PRINT "File event ";cmdStr$
chr%=0
ENDIF
ELSE
msgPrep:
PRINT "Event ";a%(1);" ?"
chr%=0
ENDIF
IF chr%=$122
mINIT
IF PEEKB(game%+ofState%)=1
mCARD "File","Open",%O,"Save As",%A,"About",%B,"Help",%?,"Seed",%S,"Start",%Q
mCARD "Special","Drawing",%I,"Options",%P,"Exit",%X
ELSE
mCARD "File","Open",%O,"Save As",%A,"About",%B,"Help",%?,"Stop",%Q
mCARD "Play","Turn",%T,"To Spades",%S,"To Diamonds",%D,"To Hearts",%H,"To Clubs",%C
mCARD "Pile","One",%1,"Two",%2,"Three",%3,"Four",%4,"Five",%5,"Six",%6
mCARD "Special","Drawing",%I,"Refresh",%R,"Exit",%X
ENDIF
chr%=MENU+512
IF chr%=512
chr%=0
ENDIF
ENDIF
IF chr%=(512+%b)
dINIT "About Game"
dTEXT "Solitaire","1.0 (Jan 1993)"
dTEXT "Author","Steve Hawtin"
dTEXT "Tested by","Angela Beasley"
DIALOG
chr%=0
ELSEIF chr%=(512+%i)
setDraw:
ELSEIF chr%=(512+%o)
openD:
ELSEIF chr%=(512+%a)
saveD:
chr%=0
ELSEIF chr%=(512+%x)
STOP
ELSEIF chr%=(512+%?) OR chr%=291
doHelp:
chr% = 0
ENDIF
IF PEEKB(game%+ofState%)=1
IF chr%=(512+%p)
setOpts:
chr%=0
ELSEIF chr%=(512+%s)
setSOpts:
chr%=0
ENDIF
ENDIF
UNTIL chr%<>0
IF chr%>=512
chr% = chr%-512
ENDIF
RETURN chr%
ENDP
PROC saveD:
dINIT "Save as"
dFILE filName$,"File",$11
IF DIALOG=0
RETURN
ENDIF
saveF:
ENDP
PROC saveF:
LOCAL file%,ret%
BUSY "Saving..."
ret%=IOOPEN(file%,filName$,$0102)
IF fileErr%:(ret%)
BUSY OFF
RETURN
ENDIF
ret%=IOWRITE(file%,game%,offEnd%)
IF fileErr%:(ret%)
BUSY OFF
RETURN
ENDIF
ret%=IOCLOSE(file%)
IF fileErr%:(ret%)
BUSY OFF
RETURN
ENDIF
BUSY OFF
ENDP
PROC openD:
LOCAL c%
dINIT "Load game"
dFILE filName$,"File",$10
c% = 1
dCHOICE c%,"Current Game","Abandon,Save"
IF DIALOG=0
RETURN
ENDIF
IF c%=2
saveD:
ENDIF
openF:
ENDP
PROC openF:
LOCAL file%,ret%,c%,g%(10)
BUSY "Loading..."
ret%=IOOPEN(file%,filName$,$0000)
IF fileErr%:(ret%)
BUSY OFF
RETURN
ENDIF
c%=0
DO
ret%=IOREAD(file%,ADDR(g%()),1)
POKEB game%+c%,PEEKB(ADDR(g%()))
c%=c%+1
UNTIL ret%<0
IF ret%<>-36
IF fileErr%:(ret%)
BUSY OFF
RETURN
ENDIF
ENDIF
ret%=IOCLOSE(file%)
IF fileErr%:(ret%)
BUSY OFF
RETURN
ENDIF
initOffs:
BUSY OFF
ENDP
PROC fileErr%:(r%)
IF r%>=0
RETURN 0
ENDIF
GIPRINT ERR$(r%),1
RETURN -1
ENDP
PROC doHelp:
LOCAL n%,c%
LOCAL l1$(80),l2$(80),l3$(80),l4$(80)
LOCAL title$(80),link$(255)
LOCAL t$(255)
ONERR errEnd1
OPEN "\app\solo\help.dbf",A,title$,l1$,l2$,l3$,l4$,link$
ONERR OFF
title$ = "PgIntroduction"
DO
FIRST
IF FIND(title$)=0
l1$="Missing page "+title$
t$ = "Return to game,Introduction"
ELSE
l1$= A.l1$
t$ = "Return to game,"+A.link$
ENDIF
title$ = "Soliaire help : "+MID$(title$,3,255)
dINIT title$
dTEXT ""," "
IF l1$<>""
dTEXT "",l1$
ENDIF
IF A.l2$<>""
dTEXT "",A.l2$
ENDIF
IF A.l3$<>""
dTEXT "",A.l3$
ENDIF
IF A.l4$<>""
dTEXT "",A.l4$
ELSE
dTEXT ""," "
ENDIF
n%=2
dCHOICE n%,"<Enter> for ",t$
IF DIALOG=0
BREAK
ENDIF
IF n%>1
c%=1
DO
IF MID$(t$,c%,1)=","
n% = n%-1
ENDIF
c%=c%+1
UNTIL n%=1
link$ = MID$(t$,c%,255)
c%=1
DO
c%=c%+1
UNTIL c%=LEN(link$) OR MID$(link$,c%,1)=","
IF c%=LEN(link$)
title$ = "Pg"+LEFT$(link$,c%)
ELSE
title$ = "Pg"+LEFT$(link$,c%-1)
ENDIF
n%=5
ENDIF
UNTIL n%=1
CLOSE
RETURN
errEnd1::
IF ERR = -33
dINIT "Soliaire help"
dTEXT "","Help file missing"
DIALOG
ELSE
dINIT "Soliaire help"
dTEXT "","Problem with help file"
DIALOG
ENDIF
ONERR OFF
ENDP
PROC setSOpts:
LOCAL l&,a%
dINIT "Seed Options"
a% = PEEKB(game%+oUsTime%)
dCHOICE a%,"Use","Time,Seed"
l& = PEEKB(game%+ofSeed%)
dLONG l&,"Seed",1,9999
DIALOG
POKEB game%+oUsTime%,a%
POKEW game%+ofSeed%,l&
ENDP
PROC setDraw:
LOCAL a%,b%
dINIT "Drawing options"
b% = PEEKB(game%+oDrSuit%)
dCHOICE b%,"Suits","Image,Text"
a% = 1+PEEKB(game%+ofdrNum%)+2*PEEKB(game%+oDrPict%)
dCHOICE a%,"Numbers","Text,Numbers,Pictures,Both"
IF DIALOG=0
RETURN 0
ENDIF
POKEB game%+oDrSuit%,b%
a% = a%-1
POKEB game%+oDrPict%,a%/2
POKEB game%+ofdrNum%,a%-2*PEEKB(game%+oDrPict%)
ENDP
PROC setOpts:
LOCAL a%,b%,c%,d%,e%,f%
dINIT "Solitaire Options"
a% = PEEKB(game%)-4
dCHOICE a%,"Piles","5,6,7,8,9"
d% = PEEKB(game%+ofTurn%)
dCHOICE d%,"Cards","1,2,3,4"
IF PEEKB(game%+ofLeft%)=255
b%=1
ELSE
b%=(PEEKB(game%+ofLeft%)-1)/2+1
ENDIF
dCHOICE b%,"Packs","Unlimited,1,3,5,7"
IF PEEKB(game%+oPileSz%)=255
c%=1
ELSE
c%=PEEKB(game%+oPileSz%)+1
ENDIF
dCHOICE c%,"Pile Size","Ascending,1,2,3,4,5"
e% = PEEKB(game%+ofMatch%)
dCHOICE e%,"Colours","Alternate,Any,Same Colour,Same Suit"
f% = PEEKB(game%+ofKings%)
dCHOICE f%,"Empty piles","Kings,Any"
IF DIALOG=0
RETURN 0
ENDIF
POKEB game%,a%+4
POKEB game%+ofMatch%,e%
POKEB game%+ofTurn%,d%
POKEB game%+ofKings%,f%
IF b%=1
POKEB game%+ofLeft%,255
ELSE
POKEB game%+ofLeft%,(b%-1)*2+1
ENDIF
IF c%=1
POKEB game%+oPileSz%,255
ELSE
POKEB game%+oPileSz%,c%-1
ENDIF
ENDP
PROC setSeed%:
LOCAL s&
IF PEEKB(game%+oUsTime%)=1
s& = 60*SECOND + MINUTE + RND*24*60
ELSE
s& = PEEKW(game%+ofSeed%)
ENDIF
RANDOMIZE s&
ENDP
PROC initOffs:
LOCAL ps%,numPile%
ps% = PEEKB(game%+offPack%)
numPile% = PEEKB(game%)
offHide% = offPack%+ps%+2
offSuit% = offHide%+(numPile%+2)*numPile%
offPile% = offS