23 May 2020, 12:38 | #1 |
Registered User
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
|
Four In A Row code - "Complete Amiga C"
Just wondered if anyone has successfully got the the Four in a Row code to work in Cliff Ramshaw's Amiga Shopper Complete Amiga C book?
I've got the other codes in the book to compile using Lattice C, but this one is eluding me. I've just got one "warning" left when to resolve concerning the reply(message) at the end of the code. The compiler says it expects struct message* and found struct IntuiMessage*. |
23 May 2020, 12:47 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,001
|
I don't know this book and you didn't post any code, but I can tell you the typical message loop for a window looks like this:
Code:
struct IntuiMessage *imsg; while ((imsg = (struct IntuiMessage *) GetMsg (window->UserPort))) { switch (imsg->Class) { case IDCMP_CLOSEWINDOW: finish = TRUE; break; } ReplyMsg ((struct Message *) imsg); } |
23 May 2020, 13:01 | #3 |
Registered User
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
|
Thanks for the suggestion.
The code finishes with the following (it's the two "ReplyMsg(message)" functions which the compiler has the warning about). The program still compiles, and the window opens fine but the games doesn't play. Here's how the code finishes with the two ReplyMsg(message) functions. I could copy and paste the entire code, but it might be too large to post: Code:
do { do{ /* put up message telling player it's their turn */ SetAPen(rp,4); /* pen colour */ Move(rp,283,18); Text(rp,"Your Move",9); Wait(1L<< CurrentWindow->UserPort->mp_SigBit); /* wait until we receive message */ /* find out the kind of message received */ message+(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); class=message->Class; Humansmove=getmove(class,message); ReplyMsg(message); if (class!=CLOSEWINDOW) { /* if user hasnit closed the window , then wait for and get next message */ /* This absorbs the mouse button release message Intuition fives after the user clicks the mouse */ Wait(1L<< CurrentWindow->UserPort->mp_SigBit); /* wait for message */ message = (struct IntuiMessage *)GetMsg( CurrentWindow->UserPort); ReplyMsg(message); } } while (class!=CLOSEWINDOW && HumansMove<0); /* repeat until user selects close or enters a valis move */ if (class ==CLOSEWINDOW) TimeToQuit=true; else { drawpieces(Human,HumansMove,NextFree[HumansMove]); AlterBoard(TheBoard,Human,Humansmove); /* let player know computer is thinking */ SetAPen(rp,4); /* set pen colur */ Move(rp,283,18); Text(rp,"My move ",9); ComputersMove = BestMove(TheBoard,Computer,LookAhead,&ComputersScore); drawpiece(Computer,ComputersMove,NextFree[ComputersMove]); AlterBoard(TheBoard,Computer,ComputersMove); } } while (TimeToQuit==false); /* repeat until user asks to close the window */ } void main(void) { PlayGame(); ReleaseResources(); } |
23 May 2020, 13:35 | #4 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
Code:
// message+(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); message=(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); |
23 May 2020, 14:21 | #5 |
Registered User
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
|
Thanks. I swapped "message=" with "message+" as you've suggested. This time it's saying "operation cannot be performed on a pointer".
and it's still got the original warning about expecting "struct Message *" found "struct IntuiMessage". |
23 May 2020, 15:14 | #6 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
Not sure if that's a typo in your actual code or only the snippet you posted, but this line you posted is wrong:
Code:
message+(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); Code:
message=(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); > and it's still got the original warning about expecting "struct Message *" found "struct IntuiMessage". Found "struct IntuiMessage" or found "struct IntuiMessage *"? That's a big difference. How is message declared? I pressume it's a pointer (struct IntuiMessage*), otherwise the compiler would complain about a lot of other stuff. Replace all Code:
ReplyMsg(message); Code:
ReplyMsg((struct Message *)message); |
23 May 2020, 15:46 | #7 |
Registered User
Join Date: Feb 2016
Location: Birmingham
Age: 60
Posts: 107
|
Thanks, this has helped, thanks very much.
The program compiles now with no errors. However on loading the program it still doesn't run properly. It loads a the window with the board, click on the board and a circle appears on the grid , but nothing else. Here is the code at the end of the full code, now with your suggestions. I'm now not sure if the code in this book ever worked. Code:
do { do{ /* put up message telling player it's their turn */ SetAPen(rp,4); /* pen colour */ Move(rp,283,18); Text(rp,"Your Move",9); Wait(1L<< CurrentWindow->UserPort->mp_SigBit); /* wait */ /* until we receive message */ /* find out the kind of message received */ message=(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); class=message->Class; HumansMove=GetMove(class, message); ReplyMsg((struct Message *)message); if (class!=CLOSEWINDOW) { /* if user hasn't closed the window, then wait forR and get next message */ /* This absorbs the mouse button release message Intuition fives after the user clicks the mouse */ Wait(1L<< CurrentWindow->UserPort->mp_SigBit); /* wait for message */ message=(struct IntuiMessage *)GetMsg(CurrentWindow->UserPort); ReplyMsg((struct Message *)message); } } while (class!=CLOSEWINDOW && HumansMove<0); /* repeat until user selects close or enters a valis move */ if (class ==CLOSEWINDOW) TimeToQuit=true; else { drawpiece(Human,HumansMove,NextFree[HumansMove]); AlterBoard(TheBoard,Human,HumansMove); /* let player know computer is thinking */ SetAPen(rp,4); /* set pen colur */ Move(rp,283,18); Text(rp,"My move ",9); ComputersMove = BestMove(TheBoard,Computer,LookAhead,&ComputersScore); drawpiece(Computer,ComputersMove,NextFree[ComputersMove]); AlterBoard(TheBoard,Computer,ComputersMove); } } while (TimeToQuit==false); /* repeat until user asks to close the window */ } void main(void) { PlayGame(); ReleaseResources(); } |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Skid Row Crackintro "Lemmings" way too slow | 1988 | support.WinUAE | 5 | 08 May 2015 17:58 |
Companion Disks "Complete Amiga C" from Cliff Ramshaw | Dwyloc | request.Apps | 9 | 11 May 2014 02:25 |
Companion Disks "Complete Amiga C" by Cliff Ramshaw | W4r3DeV1L | request.Apps | 14 | 24 April 2013 01:43 |
Companion Disks "Complete Amiga C" from Cliff Ramshaw | Herpes | Coders. General | 5 | 28 March 2010 14:03 |
Unknown "Skid Row" module | Old Fool | request.Modules | 3 | 11 September 2009 14:22 |
|
|