I have a C p:rogram. It’s a game. I want to turn it in MIPS assembly code and try to add sound and bit map graphics. After you done with the MIPS assembly you have to do the final report.This final report will be the version with final details and code.
The Report :
This submission MUST include ALL of your final project code!
This submission should include:
Any supplementary files that would be needed to reproduce your test results. This should include anything you used to create and test your project and may include supporting .h files, supporting C code, spreadsheets, Matlab scripts, data files, etc.
Submit the current version of your code in .C and .asm file(s).
Your C and MIPS code should compile/assemble and execute without errors, even if it isn’t fully functional.
You are required to submit at least 3 files:
- The report in .doc .docx or .pdf file format including the file extensions in the name. The .c and .asm code MUST be pasted into the end of the report document to receive credit!
- The current version of your C code in .c and any optional .h files
- The current version of your MIPS assembly source code as one or more .asm file(s).
Any other files required to reproduce your results, such as spreadsheets, Matlab scripts, data files or anything else used to create and test your project code.
Your MIPS code must include at least the following items to receive a passing grade:
- Conditional branches, equivalent to C if-else
- Nested Loops equivalent to C while(), for() or do-while()
- Use of a 2-D array
- Use of the stack to store the $ra (return address) register
Additional methods and more extensive operations, the use of advanced features such as sound, floating point, bitmap graphics, and storing local variables on the stack or recursive functions will receive additional points.
The report must document the structure of your final project, written in C and assembly with comments and any prototype functions that define arguments and return values. List limitations due to I/O and other features that were not complete.
This report and code should include the high level definition and pseudocode plus your final project MIPS assembly code FORMATTED in the style used in the MIPS code examples. By the time you complete the MIPS code, it must embody the basic logic and algorithms described above.
Once you have submitted the final report here, please schedule your 10-minute one-on-one meeting to discuss your project with the instructor.
Please prepare for the meeting by making sure you:
- Have the development environment(s) you need to demo your program operation
- Have your final report open and ready to show
- Have your SDSU or other government issued Photo ID with you
Have a working webcam or phone camera that works with zoom
In the meeting you will be asked to describe and demonstrate your project operating, and to discuss your code.
*Please note that the final report and code will be subject to checks for plagiarism, so be sure to clearly mark anything you did not personally write, and include citations to indicate where that material came from to avoid the academic and punitive sanctions which are consequences of
plagiarismLinks to an external site.
as defined in the rules defined in the SDSU catalog, and
SDSU’s student rights and responsibilitiesLinks to an external site.
, as well as the student-teacher contract.
#include
#include
#include
#include
#include
#define ROWS 10
#define COLS 10
#define TIME_LIMIT_SECONDS 60 // Set your desired time limit in seconds
int posX, posY; // Character position
char gameMap[ROWS][COLS];
int score = 0; // Game score
struct termios originalTermios; // Store the original terminal settings
time_t startTime; // Store the start time
void clearScreen() {
printf(“\033[H\033[J”); // ANSI escape code to clear screen
}
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &originalTermios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &originalTermios);
atexit(disableRawMode);
struct termios raw = originalTermios;
raw.c_lflag &= ~(ECHO | ICANON); // Disable echo and canonical mode
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
void initializeGame() {
// Initialize the game map with empty spaces
for (int i = 0; i < ROWS; ++i) {
for (int j = 0; j < COLS; ++j) {
gameMap[i][j] = ' ';
}
}
// Place the character at the center
posX = ROWS / 2;
posY = COLS / 2;
gameMap[posX][posY] = '@';
// Place obstacles in random positions
for (int k = 0; k < 3; ++k) {
int obsX, obsY;
do {
obsX = rand() % ROWS;
obsY = rand() % COLS;
} while (gameMap[obsX][obsY] != ' '); // Find a new empty position
gameMap[obsX][obsY] = '#';
}
// Place the finish line at a random position
int finishX, finishY;
do {
finishX = rand() % ROWS;
finishY = rand() % COLS;
} while (gameMap[finishX][finishY] != ' ' && (finishX != posX ||
finishY != posY)); // Avoid player's position and obstacles
gameMap[finishX][finishY] = '$';
// Record the start time
startTime = time(NULL);
}
void printGame() {
clearScreen(); // Clear console screen
// Print the game map
for (int i = 0; i < ROWS; ++i) {
for (int j = 0; j < COLS; ++j) {
printf("%c ", gameMap[i][j]);
}
printf("\n");
}
// Print the current score and time remaining
time_t currentTime = time(NULL);
int timeRemaining = TIME_LIMIT_SECONDS - (int)(currentTime startTime);
printf("Score: %d
Time: %d seconds remaining\n", score,
timeRemaining);
}
void moveCharacter(char direction) {
// Move the character based on the direction
gameMap[posX][posY] = ' '; // Clear current position
switch (direction) {
case 'w':
posX--;
break;
case 's':
posX++;
break;
case 'a':
posY--;
break;
case 'd':
posY++;
break;
}
// Check for collisions with obstacles
if (gameMap[posX][posY] == '#') {
printf("Game Over! You collided with an obstacle.\n");
exit(0);
}
// Check for reaching the finish line
if (gameMap[posX][posY] == '$') {
printf("Congratulations! You reached the finish line.\n");
score++; // Increment the score
initializeGame(); // Reset the game for the next round
}
gameMap[posX][posY] = '@'; // Set new position
}
int main() {
char move;
srand(time(NULL));
initializeGame();
enableRawMode(); // Enable raw mode for non-blocking input
while (1) {
printGame();
// Non-blocking input without conio.h
if (read(STDIN_FILENO, &move, 1) == 1) {
// Check for quitting
if (move == 'q' || move == 'Q') {
break;
}
// Move the character
moveCharacter(move);
// Check for time limit
time_t currentTime = time(NULL);
if (currentTime - startTime >= TIME_LIMIT_SECONDS) {
printf(“Time’s up! Game Over.\n”);
break;
}
}
}
return 0;
}