diff options
| -rw-r--r-- | .editorconfig | 11 | ||||
| -rw-r--r-- | .vscode/c_cpp_properties.json | 9 | ||||
| -rw-r--r-- | .vscode/extensions.json | 7 | ||||
| -rw-r--r-- | .vscode/launch.json | 47 | ||||
| -rw-r--r-- | .vscode/settings.json | 12 | ||||
| -rw-r--r-- | .vscode/tasks.json | 77 | ||||
| -rw-r--r-- | src/ds.mk | 4 | ||||
| -rw-r--r-- | src/makefile | 3 | ||||
| -rw-r--r-- | src/ppusim/work.c | 5 | ||||
| -rw-r--r-- | src/ppusim/work.h | 1 | ||||
| -rw-r--r-- | src/stm32.mk | 3 | 
11 files changed, 178 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" +		} +	] +} @@ -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 |