-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,224 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
delay.S.o: delay.S | ||
delay.S : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
game.c.o: game.c /opt/mcb32tools/include/stdint.h \ | ||
/opt/mcb32tools/lib/gcc/mipsel-mcb32-elf/4.9.2/include/stdint-gcc.h \ | ||
/opt/mcb32tools/include/pic32mx.h snake.h | ||
game.c /opt/mcb32tools/include/stdint.h : | ||
/opt/mcb32tools/lib/gcc/mipsel-mcb32-elf/4.9.2/include/stdint-gcc.h : | ||
/opt/mcb32tools/include/pic32mx.h snake.h : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
labwork.S.o: labwork.S | ||
labwork.S : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
snake.c.o: snake.c | ||
snake.c : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# labwork.S | ||
# Written 2015-2017 by F Lundevall | ||
# Skeleton file for IS1200/IS1500 lab 1. | ||
# The macros PUSH and POP are in the public domain. | ||
# Please add your own code at the end of the file. | ||
|
||
# | ||
# Please keep the two macros PUSH and POP unchanged | ||
# | ||
.macro PUSH reg | ||
addi $sp,$sp,-4 | ||
sw \reg,0($sp) | ||
.endm | ||
|
||
.macro POP reg | ||
lw \reg,0($sp) | ||
addi $sp,$sp,4 | ||
.endm | ||
# | ||
# Please add your own code below this line | ||
# | ||
.global delay | ||
.global time2string | ||
.data | ||
.text | ||
|
||
hexasc: | ||
andi $a0,$a0, 0xf #Checks 4 LSB | ||
addi $v0,$a0,0x30 | ||
jr $ra | ||
nop | ||
|
||
delay: | ||
PUSH $s3 | ||
li $s3, 47000 | ||
li $t6, 0 | ||
li $t7, 0 | ||
j loop | ||
nop | ||
loop: | ||
beq $t7, $a0, end | ||
nop | ||
sub $a0, $a0, 1 | ||
j loop2 | ||
nop | ||
loop2: | ||
beq $t6, $s3, loop | ||
nop | ||
addi $t6, $t6, 1 | ||
j loop2 | ||
nop | ||
end: | ||
|
||
POP $s3 | ||
|
||
jr $ra | ||
nop | ||
|
||
time2string: | ||
PUSH $s0 | ||
PUSH $s1 | ||
PUSH $ra | ||
PUSH $a0 | ||
add $s0,$a1,$0 #Saves time info to t0 | ||
add $s1,$a0,$0 #Saves time info address to t1 | ||
|
||
srl $a0,$s0,12 # Första minut-talet | ||
jal hexasc | ||
nop | ||
sb $v0, 0($s1) | ||
|
||
srl $a0,$s0,8 # Andra minut-talet | ||
jal hexasc | ||
nop | ||
sb $v0, 1($s1) | ||
|
||
li $t4, 0x3A #Contains ":" | ||
nop | ||
sb $t4, 2($s1) # Lägger till kolon | ||
|
||
srl $a0,$s0,4 # första sekund-talet | ||
jal hexasc | ||
nop | ||
sb $v0, 3($s1) | ||
|
||
add $a0, $s0, $zero # andra sekund-talet | ||
jal hexasc | ||
nop | ||
sb $v0, 4($s1) | ||
|
||
li $t5,0x00 | ||
nop | ||
sb $t5, 5($s1) | ||
|
||
POP $a0 | ||
POP $ra | ||
POP $s1 | ||
POP $s0 | ||
|
||
jr $ra | ||
nop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*Written by Fredrik Lundström and Michell Dib 2021 (c)*/ | ||
|
||
#include <stdint.h> | ||
#include <pic32mx.h> | ||
#include "snake.h" //Project header file | ||
|
||
int score = 0; | ||
int speed = 20; | ||
|
||
|
||
int snake_length; | ||
int snake_width = 1; | ||
int snake_x = 64; | ||
int snake_y = 16; | ||
|
||
int apple_x; | ||
int apple_y; | ||
|
||
void snake(){ | ||
snake_create(); | ||
apple_create(); | ||
|
||
if(snake_x == apple_x && snake_y == apple_y){ | ||
apple_eat(); | ||
} | ||
delay(speed); | ||
snake_move(); | ||
} | ||
|
||
void snake_create(){ | ||
snake_length = 5; | ||
create_object(snake_x, snake_y, snake_length, snake_width); | ||
} | ||
|
||
void snake_move(){ | ||
if(snake_x > 128){ | ||
snake_x = 0; | ||
}else{ | ||
snake_x++; | ||
} | ||
} | ||
|
||
void apple_create(){ | ||
//Randomize | ||
create_object(apple_x, apple_y, 1, 1); | ||
} | ||
|
||
void apple_eat(){ | ||
display[apple_x][apple_y] = 0; //Clear apple pixel | ||
apple_x = 5; | ||
apple_y = 5; | ||
apple_create(); | ||
score++; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.