void handleSendMovementTask() { struct movement *tmp; //movement vs Movement capitalized -> don't know which while(1) { YKSemPend(receivedSEM); tmp = (struct movement*) YKQPend(MsgQPtr); // get next msg /*printString("send id = "); printInt(tmp->id); printString(" slide = "); printInt(tmp->slide); printString(" rotate = "); printInt(tmp->rotate); printNewLine();//*/ if(tmp->slide > -1) //slide the piece { SlidePiece(tmp->id, tmp->slide); } else // rotate the piece { RotatePiece(tmp->id, tmp->rotate); } } }
/* * Handles the arrival of new pieces and then calls a placement function for * new corner pieces and a different placement function for new straight pieces */ void ArrivalTask(void) { piece* newPiece; while (1) { // YKSemPend(touchdownSem); newPiece = (piece *) YKQPend(NewPieceQPtr); if (newPiece->type == STRAIGHTPIECE) { placeStraightPiece(newPiece); } else if (newPiece->type == CORNERPIECE) { placeCornerPiece(newPiece); } } }
/* * Communicates with simptris */ void CommunicationTask(void) { scmd* ncmd; SeedSimptris((long) SEED); StartSimptris(); printString("\nSimptris Started!\n"); while(1) { ncmd = (scmd*) YKQPend(CmdQPtr); if (ncmd->command == ROTATE) { RotatePiece(ncmd->id, ncmd->parameter); } else { SlidePiece(ncmd->id, ncmd->parameter); } YKSemPend(commandReceivedSem); } }