aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig11
-rw-r--r--.vscode/c_cpp_properties.json9
-rw-r--r--.vscode/extensions.json7
-rw-r--r--.vscode/launch.json47
-rw-r--r--.vscode/settings.json12
-rw-r--r--.vscode/tasks.json77
-rw-r--r--docs/state-diagram-game-engine.drawio1
-rw-r--r--src/ds.mk4
-rw-r--r--src/makefile3
-rw-r--r--src/ppusim/work.c5
-rw-r--r--src/ppusim/work.h1
-rw-r--r--src/stm32.mk3
12 files changed, 179 insertions, 1 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..fece754
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,11 @@
+root = true
+
+[*]
+indent_style = tab
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+
+[*.md]
+indent_style = space
+indent_size = 2
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000..51f5ad0
--- /dev/null
+++ b/.vscode/c_cpp_properties.json
@@ -0,0 +1,9 @@
+{
+ "configurations": [
+ {
+ "name": "src",
+ "compileCommands": "${workspaceFolder}/src/compile_commands.json"
+ }
+ ],
+ "version": 4
+} \ No newline at end of file
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..f4800ac
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,7 @@
+{
+ "recommendations": [
+ "marus25.cortex-debug",
+ "ms-vscode.cpptools-extension-pack",
+ "EditorConfig.EditorConfig"
+ ]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..2f7561c
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,47 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "ppusim debug",
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "${workspaceFolder}/src/main",
+ "windows": { "program": "${workspaceFolder}/src/main.exe" },
+ "args": [],
+ "cwd": "${fileDirname}",
+ "environment": [],
+ "externalConsole": false,
+ "MIMode": "gdb",
+ "preLaunchTask": "client/build",
+ "setupCommands": [
+ {
+ "description": "Enable pretty-printing for gdb",
+ "text": "-enable-pretty-printing",
+ "ignoreFailures": true
+ },
+ {
+ "description": "Set Disassembly Flavor to Intel",
+ "text": "-gdb-set disassembly-flavor intel",
+ "ignoreFailures": true
+ }
+ ]
+ },
+ {
+ "name": "stm32 debug",
+ "cwd": "${workspaceFolder}",
+ "executable": "${workspaceFolder}/src/main.elf",
+ "request": "launch",
+ "type": "cortex-debug",
+ "servertype": "stlink",
+ "preLaunchTask": "stm32/flash",
+ "linux": {
+ "stlinkPath": "/usr/bin/st-util"
+ },
+ "windows": {
+ "armToolchainPath": "C:/msys64/mingw64/bin",
+ "stlinkPath": "C:/msys64/mingw64/bin/st-util.exe",
+ "gdbPath": "C:/msys64/mingw64/bin/gdb-multiarch.exe"
+ }
+ }
+ ]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..d027762
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,12 @@
+{
+ "terminal.integrated.defaultProfile.windows": "MSYS2 MinGW x64",
+ "terminal.integrated.profiles.windows": {
+ "MSYS2 MinGW x64": {
+ "path": [ "C:/msys64/msys2_shell.cmd" ],
+ "args": [ "-defterm", "-no-start", "-mingw64", "-shell", "sh", "-here" ],
+ "icon": "terminal-bash"
+ }
+ },
+ "cmake.configureOnOpen": false,
+ "files.eol": "\n"
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..53a235e
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,77 @@
+{
+ "version": "2.0.0",
+ "windows": {
+ "options": {
+ "cwd": "${workspaceFolder}",
+ "shell": {
+ "executable": "C:/msys64/msys2_shell.cmd",
+ "args": [ "-defterm", "-no-start", "-mingw64", "-shell", "sh", "-here", "-c" ]
+ },
+ },
+ },
+ "tasks": [
+ {
+ "label": "build",
+ "group": {
+ "isDefault": false,
+ "kind": "build"
+ },
+ "options": { "cwd": "${workspaceFolder}/src" },
+ "windows": {
+ "command": "make -j",
+ "args": [ "" ],
+ },
+ "command": "make",
+ "args": [ "-j" ],
+ "type": "shell"
+ },
+ {
+ "label": "flash",
+ "detail": "build and upload to stm32",
+ "group": {
+ "isDefault": false,
+ "kind": "test"
+ },
+ "options": { "cwd": "${workspaceFolder}/src" },
+ "windows": {
+ "command": "make -j flash",
+ "args": [ "" ],
+ },
+ "command": "make",
+ "args": [ "-j", "flash" ],
+ "type": "shell"
+ },
+ {
+ "label": "compiledb",
+ "detail": "generate editor autocomplete files",
+ "group": {
+ "isDefault": false,
+ "kind": "test"
+ },
+ "options": { "cwd": "${workspaceFolder}/src" },
+ "windows": {
+ "command": "make compile_commands.json",
+ "args": [ "" ],
+ },
+ "command": "make",
+ "args": [ "compile_commands" ],
+ "type": "shell"
+ },
+ {
+ "label": "clean",
+ "detail": "remove binary files from working directory",
+ "group": {
+ "isDefault": false,
+ "kind": "test"
+ },
+ "options": { "cwd": "${workspaceFolder}" },
+ "windows": {
+ "command": "make clean",
+ "args": [ "" ],
+ },
+ "command": "make",
+ "args": [ "clean" ],
+ "type": "shell"
+ }
+ ]
+}
diff --git a/docs/state-diagram-game-engine.drawio b/docs/state-diagram-game-engine.drawio
new file mode 100644
index 0000000..7ec8604
--- /dev/null
+++ b/docs/state-diagram-game-engine.drawio
@@ -0,0 +1 @@
+<mxfile host="Electron" modified="2023-03-03T15:42:20.194Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.9.9 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36" etag="US9eJ7OLJRPnynqDQFcl" version="13.9.9" type="device"><diagram id="ASTeEJEp3BGPOZBVnUyx" name="Pagina-1">7Vzbdto4FP0aHttlWb7x2Fym6ZrJNNM8tH10QAFNjc0yIoF+/Ui2jLGOHdQELJnpE0i+amvrnH2OZI3w5WLzMY+X89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C44Te4rtON7kCNSOtSldOnyTAUNIdQQNq3HUneDiYx/gxjaISSOyNQKqsNMNbrTQwQdp/V7P42Nb1UWwcUJ9ga2YKc3ZHwvjMiFrJObPzmHDOXQQlxvrLGtzpGS37xYb/Rdqoh6v3R8/R8=</diagram></mxfile> \ No newline at end of file
diff --git a/src/ds.mk b/src/ds.mk
index f70c1c9..d4354a2 100644
--- a/src/ds.mk
+++ b/src/ds.mk
@@ -3,6 +3,10 @@ LD := gcc
LFLAGS += -lSDL2
+ifeq ($(HOST),Msys)
+SHARED_FLAGS += -I/mingw64/include
+endif
+
DESKTOP_SRCS += ppusim/sim.c \
ppusim/mem.c \
ppusim/pixel.c \
diff --git a/src/makefile b/src/makefile
index 1f1dc65..1115874 100644
--- a/src/makefile
+++ b/src/makefile
@@ -4,6 +4,7 @@ TARGET = main
# platform is ds (desktop) or stm (stm32)
PLATFORM = ds
+# if your editor uses compile_commands.json for autocomplete, you should run `make compile_commands.json` again
HOST=$(strip $(shell uname -o))
@@ -74,7 +75,7 @@ flash: $(TARGET).bin
$(TARGET): $(OBJS)
$(LD) $^ $(LFLAGS) -o $@
-compile_commands.json:
+compile_commands.json: makefile stm32.mk ds.mk
compiledb make -Bn
../scripts/compiledb-full-path-mingw.sh compile_commands.json
diff --git a/src/ppusim/work.c b/src/ppusim/work.c
index fcb80ca..3b9cee6 100644
--- a/src/ppusim/work.c
+++ b/src/ppusim/work.c
@@ -11,6 +11,10 @@ pthread_t* g_hh_ppusim_threads;
unsigned g_hh_ppusim_core_count;
hh_s_ppusim_screen g_hh_ppusim_screen;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
+#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
+
void* hh_ppusim_draw_thread(void* arg) {
unsigned core = (unsigned long) arg;
for (unsigned y = core; y < HH_PPU_SCREEN_HEIGHT; y += g_hh_ppusim_core_count)
@@ -38,3 +42,4 @@ void hh_ppusim_draw_frame(SDL_Renderer* renderer) {
}
}
+#pragma GCC diagnostic pop
diff --git a/src/ppusim/work.h b/src/ppusim/work.h
index 6f72357..3a165ff 100644
--- a/src/ppusim/work.h
+++ b/src/ppusim/work.h
@@ -1,6 +1,7 @@
#pragma once
#include <SDL2/SDL.h>
+#include <pthread.h>
#include "ppu/consts.h"
diff --git a/src/stm32.mk b/src/stm32.mk
index e41bcf9..6926dea 100644
--- a/src/stm32.mk
+++ b/src/stm32.mk
@@ -17,6 +17,9 @@ SHARED_FLAGS += -I./stm32
ifeq ($(HOST),GNU/Linux)
SHARED_FLAGS += -I/usr/arm-none-eabi/include/
endif
+ifeq ($(HOST),Msys)
+SHARED_FLAGS += -I/mingw64/arm-none-eabi/include/
+endif
SHARED_FLAGS += -ffunction-sections
SHARED_FLAGS += -fdata-sections
SHARED_FLAGS += -Wl,--gc-sections