home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
501-525
/
apd503
/
fabrizio_bazzo
/
hideandseek.amos
/
hideandseek.amosSourceCode
Wrap
AMOS Source Code
|
1986-08-03
|
13KB
|
478 lines
'
' SOLITAIRE PROJECT ***************
' by Fabrizio Bazzo * Hide'n'seek *
' 0481/22018 GO (I) ***************
'
' About SOLITAIRE PROJECT:
'
' SOME TIME AGO, I FOUND A LITTLE OLD BOOK WITH MORE THEN
' ONE HUNDRED SOLITAIRES INSIDE,SOME OF WHICH ASCRIBED TO
' NAPOLEON; I LIKE CARD GAMES VERY MUCH, SO I WROTE A FEW
' PROCEDURES IN AMIGABASIC, RECENTLY CONVERTED IN AMOS, TO
' DEAL WITH TYPICAL PROBLEMS OF THIS TYPE OF GAMES: PICK A
' CARD, PUT IT SOMEWHERE ELSE ,CHECK FOR CORRECT MOVES, ETC.
' HIDE 'N'SEEK IS THE SIMPLEST OF THE CARD GAMES THAT I KNOW,
' SO IT 'S GOOD FOR TEST THE CARD-GAME ENGINE; THIS IS ALSO
' THE REASON WHY IT LOOKS SO TRIVIAL.
' (NO,I 'M NOT GOING TO WRITE MORE THEN ONE HUNDRED CARD GAMES,
' MAY BE JUST FOUR OR FIVE, BUT ***YOU*** COULD WRITE THE OTHER
' 95 WITH VERY LITTLE EFFORT, IF YOU DECIDE TO HAVE A CLOSE LOOK
' AT THESE LISTINGS (THAT IS HIDE'N'SEEK, GALLERY AND MEFISTOFELE))
' AND IF YOU ALSO HAVE THAT BOOK, OF COURSE... SINCE YOU ARE READING
' THIS, YOU OBVIOUSLY ALREADY HAVE THE MAIN TOOL (THANKS, MR. LIONET)
'
' I DID MY BEST TO COMMENT THIS SOURCE, BUT UNFORTUNATLY THE ENGLISH
' IS NOT MY LANGUAGE (MAY BE AMOS IS), SO YOU'LL PROBABLY FIND
' THE CHOICE OF SOME WORDS UNUSUAL OR PRETTY SILLY; BE UNDERSTANDING.
'
' number of detect zones = number of heaps
NZONE=13
' card image width
CW=64
' card image height
CH=48
' number of cards (no jolly here)
NCARDS=52
'
'ZNDEF() holds x,y coords for each detect zone
'
'HOUSE() holds the full description for each heap; it is dimensioned
' (number_of_heaps,max_number_of_card_per_heap)
' each vector is structured as follows:
'
' HOUSE(Heap,0) : number of cards present
' HOUSE(Heap, 1..HOUSE(Heap,0) ) : every single card
'
' 1,..,13 Ace,..,King of Hearts
' 14,..,26 " " " Diamonds
' 27,..,39 " " " Clubs
' 40,..,52 " " " Spades
'
' To easily recognize every card two functions are defined:
'
' FN Suit(x) : returns 0 (Hearts) to 3 (Spades)
' FN Vlue(x) : returns 1 (Ace) to 13 (King)
'
' Seek for more info inside the procedures
'
'Load ":abk/cards1.abk"
Dim ZNDEF(NZONE*2),HOUSE(NZONE,5),HEAP(NCARDS)
'
Global ZNDEF(),HOUSE(),HEAP(),OBJ,CW,CH,NCARDS,ACTCARD,FINISHED
Global FIRSTTIME,NZONE,FROM,LAST,GRABBED,RELEASED,OK,UFFA,AGAIN
'
ENABLE
Repeat
NEWGAME
Repeat
If AGAIN=0 Then CHECKOPT
Until UFFA or AGAIN
Until UFFA
DISABLE
End
'
Procedure NEWGAME
'
' this is the main procedure of the program
'
INITHEAP
MIX
'
' this section may vary a lot from game to game, depending on the number
' and the content of every zone, and the global vars needed;
' in this case only FIRSTTIME is HideAndSeek-specific
'
For I=1 To NZONE
HOUSE(I,0)=4
For J=1 To 4
HOUSE(I,J)=(HEAP(J+4*(I-1)) or 128) : Rem distribution 128=covered
Next
DRWFIRST[I] : Rem draw the firts of the heap
Next
CLEAR[228,92,440,103]
GRABBED=0 : RELEASED=1 : FIRSTTIME=1 : FINISHED=0 : AGAIN=0
'
' this section require only minor changes, tipically for calls to game-
' specific procedures (compare with Gallery and/or Mefistofele sources)
'
While FINISHED=0
If GRABBED
While RELEASED=0
If OBJ
Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),ACTCARD
End If
If Mouse Click
If Mouse Key=1
ACTLIST=Mouse Zone
CHECKRULES[ACTLIST,0]
If OK
ADCARD[ACTLIST,1]
CHECKFINISH
GRABBED=0
RELEASED=1
End If
Else
CHECKOPT
End If
End If
Wend
Else
While RELEASED=1
If Mouse Click
If Mouse Key=1
ACTLIST=Mouse Zone
CHECKRULES[ACTLIST,1]
If OK
GRABCARD[ACTLIST]
GRABBED=1
RELEASED=0
End If
Else
CHECKOPT
End If
End If
Wend
End If
Wend
End Proc
Procedure MAKEZONE[NZONE]
'
' defines the detect zones, with standard size (CW,CH)
'
ZNEDATA:
Data 87,42,165,42,243,42,321,42,399,42,477,42
Data 87,106,165,106,243,106,321,106,399,106,477,106,87,170
Restore ZNEDATA
Reserve Zone NZONE+4
For I=1 To NZONE
Read C1,C2
J=I*2-1
ZNDEF(J)=C1 : ZNDEF(J+1)=C2
Set Zone I,C1,C2 To C1+CW,C2+CH
Next
For I=1 To 4
Set Zone NZONE+I,470+(I-1)*40,233 To 508+(I-1)*40,243 : Rem opts gadget
Next
End Proc
Procedure CLEARZONE[ZNE]
' this does not need any comment
I=ZNE*2-3
CLEAR[ZNDEF(I),ZNDEF(I+1),ZNDEF(I)+CW,ZNDEF(I+1)+CH]
End Proc
Procedure INITHEAP
' a very dull initialization
' note: if you use 104 cards You should modify it a little
For I=1 To NCARDS
HEAP(I)=I
Next
End Proc
Procedure MIX
' frrrrrr....
Randomize Timer
For I=1 To NCARDS
J=Rnd(NCARDS-1)+1
Swap HEAP(I),HEAP(J)
Next
End Proc
Procedure DRWFIRST[N]
'
' draws the first card of the heap N, if any;
' (covered cards have the bit number 7 set)
' if not, simply deletes the previous image
'
M=(N-1)*2+1 : Rem 1,2,3,4,.. => 1,3,5,7,...
If HOUSE(N,0) and 127 : Rem at least one card
If HOUSE(N,1) and 128 : Rem visible?
Paste Bob ZNDEF(M),ZNDEF(M+1),53 : Rem no
Else
IMAGE=(HOUSE(N,1) and 127) : Rem 1,..,52
Paste Bob ZNDEF(M),ZNDEF(M+1),IMAGE
End If
Else
CLEARZONE[N]
End If
End Proc
Procedure ADCARD[N,MDE]
'
' adds the grabbed card to the heap N;
' if MDE=0 at the top, otherwise at the bottom
'
LAST=N
M=(N-1)*2+1
If MDE : Rem bottom of list
Inc HOUSE(N,0) : Rem 1 card more
PS=(HOUSE(N,0) and 127) : Rem here
HOUSE(N,PS)=ACTCARD : Rem this one
Limit Bob 1,0,0 To 640,ZNDEF(M+1) : Rem sometimes is better to use
Bob 1,ZNDEF(M),ZNDEF(M+1)-CH,ACTCARD : Rem Bob 2 to hide the movement
For I=1 To 24
Bob 1,X Bob(1),Y Bob(1)+2,ACTCARD
Wait 1
Next
Limit Bob
Bob Off 1 : OBJ=0
Else
Inc HOUSE(N,0) : Rem=HOUSE(N,0)+1
For I=(HOUSE(N,0) and 127) To 2 Step -1
HOUSE(N,I)=HOUSE(N,I-1)
Next
HOUSE(N,1)=ACTCARD
Bob Off 1 : OBJ=0
DRWFIRST[N]
End If
End Proc
Procedure GRABCARD[N]
'
' grabs the first card from the heap N
' various global vars are set
'
If HOUSE(N,0) and 127 : Rem no empty list
FROM=N : Rem I came from here
Dec HOUSE(N,0) : Rem 1 card less
ACTCARD=HOUSE(N,1) : Rem this one
For I=1 To(HOUSE(N,0) and 127) : Rem scroll the other cards
HOUSE(N,I)=HOUSE(N,I+1)
Next
DRWFIRST[N]
If(ACTCARD and 128) : Rem turn it before
ACTCARD=ACTCARD and %1111111101111111
For I=53 To 57
Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),I
Wait 4
Next
End If
OBJ=1 : Rem bob-bing aroung
End If
End Proc
Procedure CHECKRULES[N,MDE]
'
' this is usually the most painful procedure to write; all the rules of the
' game are defined here, and there is very few room for mistakes;
' furthermore, You have to write it totally on you own (good work)
' FROM an LAST are very useful here, as well as VLUE and SUIT;
' (it seem necessary to re-DEF these functions every time the procedure
' is called; am I doing somethig wrong or it's an AMOS characteristic?)
' MDE=0 : droppin' a card
' MDE=1 : grabbin' a card
' return OK
'
Def Fn VLUE(X)=((X mod 13)-13*((X mod 13)=0))
Def Fn SUIT(X)=((X-1)/13)
OK=0
If N=0 Then Pop Proc
If MDE : Rem trying to grab
If FIRSTTIME
If N=13 : Rem you must start with the King
OK=1
FIRSTTIME=0
End If
Else
If N=LAST : Rem where you drop the last card
OK=1
End If
End If
Else
ACTVALUE= Fn VLUE(ACTCARD)
ACTSUIT= Fn SUIT(ACTCARD)
If N=ACTVALUE : Rem on the right list
OK=1
End If
End If
If OK=0 Then Bell : Rem what a hell are you doing?
End Proc
Procedure CHECKFINISH
'
' this is at least as nasty as CheckRules to write, and not reusable
' the global var FINISHED is set here
' (for the Def-Fn comments see the procedure above)
'
Def Fn VLUE(X)=((X mod 13)-13*((X mod 13)=0))
Def Fn SUIT(X)=((X-1)/13)
If FINISHED Then Pop Proc
If(HOUSE(13,0) and 127)=4
For I=1 To 4
If HOUSE(13,I) and 128
Pop Proc
End If
Next
If Fn VLUE(HOUSE(13,1))=13 : Rem all kings here?
If Fn VLUE(HOUSE(13,2))=13
If Fn VLUE(HOUSE(13,3))=13
If Fn VLUE(HOUSE(13,4))=13
Bob Off
N=1 : I=1 : FINISHED=1 : NOBBUONO=0
While N<=12 and NOBBUONO=0 : Rem all other heaps ok?
If Fn VLUE(HOUSE(N,I))<>N
NOBBUONO=1
End If
I=I+1
If I=5
I=1 : N=N+1
End If
Wend
If NOBBUONO : Rem if not, You'd better try again
For I=0 To 1
WRITE[5*I,0,0,246-2*I,102-I,"Sorry, try again!"]
Next
Else
For I=0 To 1
WRITE[5*I,0,0,230-2*I,102-I,"You are a VERY lucky man!"]
Next
End If
End If
End If
End If
End If
End If
End Proc
Procedure WRITE[PN,PAP,MD,X,Y,A$]
Ink PN,PAP : Gr Writing MD : Text X,Y,A$
End Proc
Procedure CLEAR[X1,Y1,X2,Y2]
Ink 7,4 : Gr Writing 1 : Set Pattern 13
Bar X1,Y1 To X2,Y2
End Proc
Procedure ENABLE
'
' draw the main board and greets
'
'Load "df1:sol/cards1.abk"
Screen Open 0,640,250,8,Hires : Screen Hide 0
Double Buffer : Autoback 1
MAKEZONE[NZONE]
Palette $0,$0,$0,$0,$0,$0,$0,$0
Change Mouse 2 : Curs Off : Flash Off : Limit Mouse
Set Pattern 13 : Ink 7,4 : Paint 10,10
Ink 4,7 : Bar 0,0 To 640,2 : Bar 0,2 To 3,250
Ink 4,2 : Bar 2,248 To 640,250 : Bar 636,1 To 640,248
Screen Show 0
Fade 3,$0,$C90,$333,$ECA,$262,$C00,$842,$C0 : Wait 45
HALLO
End Proc
Procedure INFO
'
' give some info about the rules of the game
'
Autoback 0 : Get Block 1,120,82,400,102
Gr Writing 1 : Set Pattern 0 : Set Paint 1 : Ink 5,0,1
Bar 120,82 To 506,182 : Set Paint 0
INFODATA:
Data 90," To pick a card just click on its heap"
Data 100," Dropping a card is a similar affair"
Data 110," Begin with the King's heap (the 13th)"
Data 120," If You find an ace, goto the first heap"
Data 130,"If You find a Two, goto the second, etc, etc.."
Data 140," When You pick the fourth king, all heaps"
Data 150," should be discovered, otherwise You failed"
Data 160," Less trivial games coming soon!!"
Data 180," Smash the rat to continue"
Restore INFODATA
For J=1 To 9
Read Y,A$
For I=0 To 1
WRITE[1*I,0,0,130-2*I,Y-I,A$]
Next
Next
Screen Swap : Wait Vbl
Repeat
Until Mouse Key
Screen Swap : Wait Vbl : Put Block 1,120,82 : Autoback 2
End Proc
Procedure ABOUT
'
' guess what there is here!
'
Autoback 0 : Get Block 1,120,82,400,102
Gr Writing 1 : Set Pattern 0 : Set Paint 1 : Ink 6,0,1
Bar 120,82 To 506,182 : Set Paint 0
WHODATA:
Data 95," Solitaire Project"
Data 105," Hide'n'Seek"
Data 117," by"
Data 130," Fabrizio Bazzo"
Data 140,"v.del Carso 29 - 34170 GO (I)"
Data 150," Tel. 0039-(0)481-22018"
Data 165," Smash the rat to resume"
Restore WHODATA
For J=1 To 7
Read Y,A$
For I=0 To 1
WRITE[1*I,0,0,200-2*I,Y-I,A$]
Next
Next
Screen Swap : Wait Vbl
Repeat
Until Mouse Key
Screen Swap : Wait Vbl : Put Block 1,120,82 : Autoback 2
End Proc
Procedure HALLO
'
' greets
'
HALLODATA:
Data 98," Hide'n'Seek by BZZ Soft 1992"
Data 110," RMB = options LMB = selection"
Data 120," Select NEW! to restart"
Data 130," Select INFO for brief instructions"
Data 140," Select WHO? to make me happy"
Data 150," Select BYE! to exit"
Data 160," Select by Kim Wilde is a nice album"
Data 175," Bash the rat to go ahead"
Autoback 0 : Get Block 1,120,82,400,102
Gr Writing 1 : Set Pattern 0 : Set Paint 1 : Ink 2,0,1
Bar 120,82 To 506,182 : Set Paint 0
Restore HALLODATA
For J=1 To 8
Read Y,A$
For I=0 To 1
WRITE[1*I,0,0,160-2*I,Y-I,A$]
Next
Next
Screen Swap : Wait Vbl
Repeat
Until Mouse Key
Screen Swap : Wait Vbl : Put Block 1,120,82 : Autoback 2
End Proc
Procedure CHECKOPT
'
' display the menu when the RMB is pressed
'
If OBJ Then Pop Proc : Rem not while grabbed
OPTDATA:
Data 472,"NEW!",512,"INFO",552,"WHO?",592,"BYE!"
Restore OPTDATA : Autoback 0
For J=1 To 4
Read X,A$
For I=0 To 1
WRITE[5*I,0,0,X-2*I,241-I,A$]
Next
Next
Screen Swap : Wait Vbl
Repeat
Z=Mouse Zone
Until Mouse Click
Screen Swap : Wait Vbl : CLEAR[470,233,630,243] : Autoback 2
If Z>13
On Z-13 Proc RESTART,INFO,ABOUT,QUIT
End If
End Proc
Procedure RESTART
'
' this may seem trivial, but I hate GOTO
'
GRABBED=1 : RELEASED=0 : FINISHED=1 : UFFA=0 : AGAIN=1
End Proc
Procedure QUIT
'
' see above
'
RESTART
UFFA=1
End Proc
Procedure DISABLE
'
' this is only to match the ENABLE, as suggested by the Amiga Rom Kernal Manual
'
Screen Close 0
'Erase 1
End Proc