void handleTD(){ /* Touchdown */ int i; extern int TouchdownID; extern int ScreenBitMap0; extern int ScreenBitMap1; extern int ScreenBitMap2; extern int ScreenBitMap3; extern int ScreenBitMap4; extern int ScreenBitMap5; StatArray[nextStat].type = TD; StatArray[nextStat].sbm0 = ScreenBitMap0; StatArray[nextStat].sbm1 = ScreenBitMap1; StatArray[nextStat].sbm2 = ScreenBitMap2; StatArray[nextStat].sbm3 = ScreenBitMap3; StatArray[nextStat].sbm4 = ScreenBitMap4; StatArray[nextStat].sbm5 = ScreenBitMap5; for(i = 0; i < 16; i++){ if(ScreenBitMap0 & (1<<i)) break; } spaces = 15-i+1; /* Puts information on StatQ */ if(YKQPost(StatQPtr, (void *) &(StatArray[nextStat])) == 0) printString(" TouchdownISR: queue overflow ! \n"); else if (++ nextStat >= STATARRAYSIZE) nextStat = 0; }
void newPieceHandler(void) { /* This function needs to get the details of the new simptris piece and place a new piece on the piece queue. It obtains the next piece from the piece array using a static counter. */ static unsigned int nextPiece; int temp; //Build new piece YKEnterMutex(); //printString("NewPieceHandler\n"); /*printInt(NewPieceID); printNewLine(); printInt(NewPieceType); printNewLine(); printInt(NewPieceOrientation); printNewLine(); printInt(NewPieceColumn);*/ PiecesArray[nextPiece].id = NewPieceID; PiecesArray[nextPiece].type = NewPieceType; PiecesArray[nextPiece].orientation = NewPieceOrientation; PiecesArray[nextPiece].column = NewPieceColumn; YKExitMutex(); YKQPost(PiecesQPtr, &PiecesArray[nextPiece]); if (nextPiece+1 < MSGQSIZE) { nextPiece++; } else { nextPiece = 0; } return; }
void sendCommand(int id1, int command1, int parameter1) { scmd* cmpPtr1; cmpPtr1 = &scmdarr[scmdarrIdx]; incSCmdIdx(); cmpPtr1->id = id1; cmpPtr1->command = command1; cmpPtr1->parameter = parameter1; YKQPost(CmdQPtr, (void*) cmpPtr1); }
void handleLC(){ /* Line Clear */ /* Puts information on StatQ */ StatArray[nextStat].type = CLEAR; // if(spaces > MAXSPACES) // spaces--; // else // spaces-=2; // if(spaces < 0) // spaces = 0; /* Puts information on StatQ */ if(YKQPost(StatQPtr, (void *) &(StatArray[nextStat])) == 0) printString(" LineClearISR: queue overflow ! \n"); else if (++ nextStat >= STATARRAYSIZE) nextStat = 0; }
void handleNP(){ /* New Piece */ extern int NewPieceID; extern int NewPieceType; extern int NewPieceOrientation; extern int NewPieceColumn; static int next = 0; NPArray[next].id = NewPieceID; NPArray[next].type = NewPieceType; NPArray[next].rot = NewPieceOrientation; NPArray[next].col = NewPieceColumn; /* Puts information on NPQ */ if(YKQPost(NPQPtr, (void *) &(NPArray[next])) == 0) printString(" NewPieceISR: queue overflow ! \n"); else if (++ next >= NPARRAYSIZE) next = 0; }
void newPieceHandler(void) { static int next = 0; YKEnterMutex(); PieceArray[next].ID = NewPieceID; PieceArray[next].Type = NewPieceType; PieceArray[next].Orientation = NewPieceOrientation; PieceArray[next].Column = NewPieceColumn; if (YKQPost(PieceQPtr, (void *) &(PieceArray[next])) == 0) printString(" PieceISR: queue overflow! \n"); else if (++next >= PIECEQ_SIZE) next = 0; //printString("new piece arrived\n"); YKExitMutex(); }
void postSimptrisMsg(int id, int slide, int rotate) { YKEnterMutex(); MsgArray[next].id = id; MsgArray[next].slide = slide; MsgArray[next].rotate = rotate; /*printString("post id = "); printInt(id); printString(" slide = "); printInt(slide); printString(" rotate = "); printInt(rotate); printNewLine();//*/ if(YKQPost(MsgQPtr, (void *) &(MsgArray[next])) == 0) printString("MSGQ OVERFLOW!!!!!!!!!!!\n\r"); else if (++next >= MSGQSIZE) { next = 0; //printString("**********MSGQUEUEWRAP*************"); } YKExitMutex(); }