Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
de07054
Delete src/utils/aux.c
NathielleA Jun 25, 2024
36f11d1
Delete src/utils/aux.h
NathielleA Jun 25, 2024
c710a2e
feat: new sprite
NathielleA Jun 25, 2024
f336a08
Update GraphSync.c
NathielleA Jun 25, 2024
058a3af
Update Makefile
NathielleA Jun 26, 2024
0cc8685
Update GraphSync.c
NathielleA Jun 26, 2024
5f5e40c
Update GraphSync.h
NathielleA Jun 26, 2024
dd39de8
Create makingSprite.py
NathielleA Jun 27, 2024
c22a584
Update makingSprite.py
NathielleA Jun 27, 2024
6c57d6e
Update makingSprite.py
NathielleA Jun 28, 2024
857b5dd
Merge branch 'main' of https://github.com/NathielleA/GraphicsProcesso…
NathielleA Jul 1, 2024
b819d03
feat: making sprite
NathielleA Jul 1, 2024
557d148
Update makingSprite.py
NathielleA Jul 1, 2024
9de1a03
Update GraphSync.c
NathielleA Jul 1, 2024
2642af3
Create frog.png
NathielleA Jul 1, 2024
4ebfa3d
Update main.c
NathielleA Jul 3, 2024
97a0462
Update GraphSync.c
NathielleA Jul 3, 2024
2045618
Update makingSprite.py
NathielleA Jul 3, 2024
7f9e147
Update main.c
NathielleA Jul 4, 2024
cb7acd1
Update GraphSync.c
NathielleA Jul 4, 2024
35fa92c
Update GraphSync.h
NathielleA Jul 4, 2024
42d71c7
Update gpp_data_bus.c
NathielleA Jul 4, 2024
9f3f5be
feat: sprites font images
NathielleA Jul 5, 2024
3a1818e
Update GraphSync.c
NathielleA Jul 5, 2024
a293e00
Add files via upload
yasmincsme Jul 6, 2024
47dadf1
Sprites Images
NathielleA Jul 6, 2024
514b3e0
Update main.c
NathielleA Jul 6, 2024
b0d8081
Update main.c
NathielleA Jul 6, 2024
7320713
feat: create Device_manager
yasmincsme Jul 8, 2024
0845413
feat: update main.c
yasmincsme Jul 8, 2024
ee427fb
feat: update GraphSync
yasmincsme Jul 8, 2024
f3b8d80
feat: update Makefile
yasmincsme Jul 8, 2024
1c17e60
feat: Create State_machine
yasmincsme Jul 8, 2024
b00897c
feat: update json
yasmincsme Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"ui.h": "c",
"DATA_A.C": "cpp",
"data.C": "cpp",
"stdlib.h": "c"
"stdlib.h": "c",
"mman.h": "c",
"device_manager.h": "c"
}
}
Binary file added docs/a-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/c-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/cactus-sprite-pixilart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/frog-back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/frog-front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/h-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/k-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lilypad1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lilypad2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 0 additions & 48 deletions docs/notes.txt

This file was deleted.

Binary file added docs/o-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/r-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/s-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/truck-back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/truck-front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/truck-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/trunktree-back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/trunktree-front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/trunktree-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/u-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions src/Device_manager.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include "Device_manager.h"

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

void read_mouse(mouse_t* mouse) {
u8_t data[3] = {0};

if (read(mouse->fd, data, sizeof(data))) {
mouse->left = (data[0] & 0x1) ? 1 : 0;
mouse->right = (data[0] & 0x02) ? 1 : 0;
mouse->middle = (data[0] & 0x04) ? 1 : 0;

mouse->x += (data[1] / ((SENSIBILITY > 0) ? SENSIBILITY : 1));

if (mouse->x < 0) {
mouse->x = 0;
}
if (mouse->x > WIDTH) {
mouse->x = WIDTH;
}

mouse->y += ((data[2] * -1) / ((SENSIBILITY > 0) ? SENSIBILITY : 1));

if (mouse->y < 0) {
mouse->y = 0;
}
if (mouse->y > HEIGHT) {
mouse->y = HEIGHT;
}
}
}

mouse_t init_mouse(u64_t fd_mouse) {
fd_mouse = open("/dev/input/event0", O_RDONLY);

if (fd_mouse == -1) {
perror("Erro ao abrir o dispositivo de memória");
exit(EXIT_FAILURE);
}

return (mouse_t){
.fd = fd_mouse,
.x = 50,
.y = 50,
.left = 0,
.right = 0,
.middle = 0,
.read = read_mouse,
};
}

u64_t* read_KEY(u64_t fd_map, void* LW_virtual) {
fd_map = open("/dev/mem", (O_RDWR | O_SYNC));
if (fd_map == -1) {
perror("Erro ao abrir o dispositivo de memória");
exit(EXIT_FAILURE);
}

LW_virtual = mmap(NULL, LW_BRIDGE_SPAN, (PROT_READ | PROT_WRITE), MAP_SHARED, fd_map, LW_BRIDGE_BASE);
if (LW_virtual == MAP_FAILED) {
perror("Erro ao mapear memória");
exit(EXIT_FAILURE);
}

u64_t* KEY_ptr = (u64_t*)(LW_virtual + KEY_BASE);
return KEY_ptr;
}

void close_KEY(u64_t fd_map, void* LW_virtual) {
if (munmap(LW_virtual, LW_BRIDGE_SPAN) == -1) {
perror("Erro ao desmapear memória");
exit(EXIT_FAILURE);
}

if (close(fd_map) == -1) {
perror("Erro ao fechar dispositivo de memória");
exit(EXIT_FAILURE);
}
}
37 changes: 37 additions & 0 deletions src/Device_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef DEVICE_MANAGER_H_
#define DEVICE_MANAGER_H_

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

#include "utils/types.h"
#include "utils/ui.h"

#define KEY_BASE 0x0
#define LW_BRIDGE_SPAN 0x00005000
#define LW_BRIDGE_BASE 0xff200000

#define HEIGHT 360
#define WIDTH 480
#define SENSIBILITY 2

typedef struct mouse_t {
u64_t fd;
u32_t x;
u32_t y;
u8_t left;
u8_t middle;
u8_t right;

void (*read)(struct mouse_t* mouse);
} mouse_t;

void read_mouse(mouse_t* mouse);
mouse_t init_mouse(u64_t fd_mouse);
u64_t* read_KEY(u64_t fd_map, void* LW_virtual);
void close_KEY(u64_t fd_map, void* LW_virtual);

#endif // DEVICE_MANAGER_H_
Loading