home *** CD-ROM | disk | FTP | other *** search
- (*A$+*)
- MODULE Behrens;
- (* Behrens' Puzzle Written by Jeremmy Thorne, David Siebert, and Tim Smith
- April 22 1987 for the Amiga in TDI Modula II V 3.0.
- Thanks to Richie Bielak for his Mondrian and WBStart programs. With out those
- Examples this program would have taken much longer.
- Please use this game any way you see fit to help you write your own
- Modula progams on the Amiga . You may freely copy and distribute this progam
- but please distribute all of and you don't sell it. ! This Game was written
- to give us something to do while linking long progams Hope you enjoy it.
- IF you do please send $5.00 or what ever you like to
-
- CENTUARI SYSTEMS DEVELOPMENT
- P.O. Box 2016
- Sebastian,FL 32958-2016
-
- This is our first Sharware product if we get a good response we have
- many other games and utilities planned for ShareWare.*)
-
-
- FROM SYSTEM IMPORT NULL,ADDRESS,ADR;
- FROM Intuition IMPORT Window,WindowPtr,Gadget,GadgetPtr,GadgetFlags,
- GadgetFlagSet,IntuitionName,IntuitionBase,IntuiMessagePtr,
- IDCMPFlagSet,IDCMPFlags,IntuiMessage,Image,ImagePtr,FreeRemember;
- FROM Ports IMPORT WaitPort,GetMsg,ReplyMsg,MessagePtr;
- FROM SetBoard IMPORT PlaceBoard,PlaceType;
- FROM Windows IMPORT CloseWindow;
- FROM GraphicsLibrary IMPORT GraphicsName,GraphicsBase;
- FROM Libraries IMPORT OpenLibrary,CloseLibrary;
- FROM Gadgets IMPORT RefreshGadgets,RemoveGadget;
- FROM WBStart IMPORT GetWBStartUpMsg,ReturnWBStartUpMsg;
-
- VAR
- Reverse:ARRAY [1..9],[1..4] OF INTEGER;
- GameWindow:WindowPtr;
- Places:PlaceType;
- Playing:BOOLEAN;
- PosGad,
- PieceID:INTEGER;
- MsgPtr:IntuiMessagePtr;
- GadList,
- NextGad,
- PieceGadget:GadgetPtr;
- ImageList:ImagePtr;
- Width,
- Height:CARDINAL;
- WBMsg:ADDRESS;
-
- PROCEDURE FlipPieces(); (*This Procedure does the playing of the game*)
-
- VAR
- T:INTEGER;
- CurrentID:INTEGER;
- CurrentGadget:GadgetPtr;
-
- BEGIN
- IF Playing = TRUE THEN
- INCL(Places[PieceID]^.Flags,Disabled);
- FOR T:=1 TO 4 DO
- CurrentID:=Reverse[PieceID,T];
- IF CurrentID<>0 THEN
- CurrentGadget:=Places[CurrentID];
- IF Selected IN CurrentGadget^.Flags THEN
- EXCL(CurrentGadget^.Flags,Selected);
- INCL(CurrentGadget^.Flags,Disabled);
- ELSE
- EXCL(CurrentGadget^.Flags,Disabled);
- INCL(CurrentGadget^.Flags,Selected);
- END;
- END;
- END;
- END;
- END FlipPieces;
-
- PROCEDURE SetUp():BOOLEAN;
-
- VAR
- T:INTEGER;
-
- BEGIN
- FOR T:=1 TO 9 DO
- EXCL(Places[T]^.Flags,Disabled);
- END;
- RETURN FALSE
- END SetUp;
-
- PROCEDURE PlayTheGame():BOOLEAN;
-
- VAR
- T:INTEGER;
-
- BEGIN
- FOR T:=1 TO 9 DO
- IF NOT(Selected IN Places[T]^.Flags) THEN
- INCL(Places[T]^.Flags,Disabled);
- END;
- END;
- RETURN TRUE
- END PlayTheGame;
-
- BEGIN
- WBMsg:=GetWBStartUpMsg();
- IntuitionBase:=OpenLibrary(IntuitionName,0);
- GraphicsBase:=OpenLibrary(GraphicsName,0);
- PlaceBoard(GameWindow,Places); (*Set up playing board*)
- Playing:=FALSE;
- Reverse[1,1]:=2;
- Reverse[1,2]:=4;
- Reverse[1,3]:=5;
- Reverse[1,4]:=0;
- Reverse[2,1]:=1;
- Reverse[2,2]:=3;
- Reverse[2,3]:=0;
- Reverse[2,4]:=0;
- Reverse[3,1]:=2;
- Reverse[3,2]:=5;
- Reverse[3,3]:=6;
- Reverse[3,4]:=0;
- Reverse[4,1]:=1;
- Reverse[4,2]:=7;
- Reverse[4,3]:=0;
- Reverse[4,4]:=0;
- Reverse[5,1]:=1;
- Reverse[5,2]:=3;
- Reverse[5,3]:=7;
- Reverse[5,4]:=9;
- Reverse[6,1]:=3;
- Reverse[6,2]:=9;
- Reverse[6,3]:=0;
- Reverse[6,4]:=0;
- Reverse[7,1]:=4;
- Reverse[7,2]:=5;
- Reverse[7,3]:=8;
- Reverse[7,4]:=0;
- Reverse[8,1]:=7;
- Reverse[8,2]:=9;
- Reverse[8,3]:=0;
- Reverse[8,4]:=0;
- Reverse[9,1]:=5;
- Reverse[9,2]:=6;
- Reverse[9,3]:=8;
- Reverse[9,4]:=0;
- REPEAT
- MsgPtr:=WaitPort(GameWindow^.UserPort);(*Wait for a message from Intuition*)
- MsgPtr:=GetMsg(GameWindow^.UserPort); (* Get the message *)
- IF GadgetUp IN MsgPtr^.Class THEN (* if the message is that you clicked *)
- PieceGadget:=MsgPtr^.IAddress; (* on a gadget the call the flip procdure*)
- PieceID:=PieceGadget^.GadgetID;(* if in playing mode *)
- CASE PieceID OF (* or if the message is from the startup*)
- 10 : Playing:=SetUp(); | (* or play gadget set the game to that*)
- 11 : Playing:=PlayTheGame(); | (* mode *)
- 1..9: FlipPieces();
- END;
- RefreshGadgets(GameWindow^.FirstGadget,GameWindow,NULL);(* refresh *)
- ReplyMsg(MessagePtr(MsgPtr)); (* reply to intuiton so it will send the *)
- END; (* next message *)
- UNTIL CloseWindowFlag IN MsgPtr^.Class; (* Until you close the window *)
- ReplyMsg(MessagePtr(MsgPtr));(* clean up and end the program *)
- GadList:=GameWindow^.FirstGadget;
- (* REPEAT
- NextGad := GadList^.NextGadget;
- PosGad:= RemoveGadget(GameWindow,GadList);
- GadList:=NextGad;
- UNTIL GadList = NULL;*)
- FreeRemember(GadList,TRUE);
- CloseWindow(GameWindow);
- CloseLibrary(IntuitionBase);
- CloseLibrary(GraphicsBase);
- ReturnWBStartUpMsg();
- END Behrens.
-