Browse Source

add emulicious and debugging support for kate

Thomas B 1 month ago
parent
commit
700908725d
3 changed files with 67 additions and 6 deletions
  1. 15
    0
      .vscode/launch.json
  2. 13
    6
      Makefile
  3. 39
    0
      README.md

+ 15
- 0
.vscode/launch.json View File

@@ -0,0 +1,15 @@
1
+{
2
+  "version": "0.2.0",
3
+  "configurations": [
4
+    {
5
+      "type": "emulicious",
6
+      "request": "launch",
7
+      "name": "Emulicious Duality",
8
+      "program": "/home/thomas/Projekte/gb/duality/build/duality.gb",
9
+      "args": [],
10
+      "cwd": "${workspaceFolder}",
11
+      "additionalSrcFolders": "/home/thomas/Projekte/gb/duality/src",
12
+      "postRestartCommands": ["break main", "continue"]
13
+    }
14
+  ]
15
+}

+ 13
- 6
Makefile View File

@@ -41,6 +41,7 @@ PNGA := $(GBDK_HOME)/bin/png2asset
41 41
 ROMU := $(GBDK_HOME)/bin/romusage
42 42
 GB_EMU := gearboy
43 43
 SGB_EMU := sameboy
44
+BGB_EMU := wine ~/bin/bgb/bgb.exe
44 45
 FLASHER := flashgbx
45 46
 
46 47
 LCCFLAGS := -Wa-l -Wl-m -Wp-MMD -Wf--opt-code-speed
@@ -48,11 +49,13 @@ LCCFLAGS += -I$(SRC_DIR) -I$(BUILD_DIR)/$(DATA_DIR)
48 49
 LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1B -Wm-yoA -Wm-ya1 -Wm-yc -Wm-ys
49 50
 LCCFLAGS += -autobank -Wb-ext=.rel -Wb-v -Wf-bo255
50 51
 
51
-EMUFLAGS := $(BIN)
52
+GB_EMUFLAGS := $(BIN)
53
+SGB_EMUFLAGS := $(BIN)
54
+BGB_EMUFLAGS := $(BUILD_DIR)/$(BIN)
52 55
 
53 56
 ifndef GBDK_RELEASE
54 57
 	LCCFLAGS += -debug -DDEBUG -Wa-j -Wa-y -Wa-s -Wl-j -Wl-y -Wl-u -Wm-yS
55
-	EMUFLAGS += $(BUILD_DIR)/$(BIN:.gb=.sym)
58
+	GB_EMUFLAGS += $(BUILD_DIR)/$(BIN:.gb=.sym)
56 59
 	BUILD_TYPE = Debug
57 60
 else
58 61
 	BUILD_TYPE = Release
@@ -65,7 +68,7 @@ $(info BUILD_TYPE is $(BUILD_TYPE))
65 68
 DEPS=$(OBJS:%.o=%.d)
66 69
 -include $(DEPS)
67 70
 
68
-.PHONY: all run sgb_run flash clean compile_commands.json usage $(GIT)
71
+.PHONY: all run sgb_run bgb_run flash clean compile_commands.json usage $(GIT)
69 72
 .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
70 73
 
71 74
 all: $(BIN)
@@ -74,7 +77,7 @@ compile_commands.json:
74 77
 	@echo "Cleaning old build"
75 78
 	@make clean
76 79
 	@echo "Preparing bear.cfg"
77
-	@echo '{"compilation":{"compilers_to_recognize":[{"executable":"$(GBDK_HOME)/bin/sdcc","flags_to_add":[""],"flags_to_remove":[""]}]}}' > bear.cfg
80
+	@echo '{"compilation":{"compilers_to_recognize":[{"executable":"$(GBDK_HOME)/bin/sdcc","flags_to_add":["-D__PORT_sm83", "-D__TARGET_gb" ],"flags_to_remove":[""]}]}}' > bear.cfg
78 81
 	@echo "Running full build within bear"
79 82
 	@bear --config bear.cfg -- make -j4
80 83
 	@rm -rf bear.cfg
@@ -89,11 +92,15 @@ usage: $(BUILD_DIR)/$(BIN)
89 92
 
90 93
 run: $(BIN)
91 94
 	@echo Emulating $<
92
-	@$(GB_EMU) $(EMUFLAGS)
95
+	@$(GB_EMU) $(GB_EMUFLAGS)
93 96
 
94 97
 sgb_run: $(BIN)
95 98
 	@echo Emulating $<
96
-	@$(SGB_EMU) $(BIN)
99
+	@$(SGB_EMU) $(SGB_EMUFLAGS)
100
+
101
+bgb_run: $(BUILD_DIR)/$(BIN)
102
+	@echo Emulating $<
103
+	@$(BGB_EMU) $(BGB_EMUFLAGS)
97 104
 
98 105
 flash: $(BIN)
99 106
 	@echo Flasing $<

+ 39
- 0
README.md View File

@@ -22,6 +22,45 @@ For the release build, simply add `GBDK_RELEASE=1` to your make invocation after
22 22
     make clean
23 23
     make GBDK_RELEASE=1 run
24 24
 
25
+## IDE Integration
26
+
27
+I'm using [https://kate-editor.org/] which supports VSCode-style LSP and debugging with integrated plugins.
28
+
29
+To generate a `compile_commands.json` for LSPs using `bear` run:
30
+
31
+    make compile_commands.json
32
+
33
+You can also debug using [Emulicious](https://emulicious.net/).
34
+Add something like the following to your Kate Debugger user configuration:
35
+
36
+    {
37
+        "dap": {
38
+            "emulicious": {
39
+                "url": "https://emulicious.net/",
40
+                "run": {
41
+                    "command": ["emulicious", "-remotedebug", "${#run.port}"],
42
+                    "port": 0,
43
+                    "redirectStderr": true,
44
+                    "redirectStdout": true,
45
+                    "supportsSourceRequest": true
46
+                },
47
+                "configurations": {
48
+                    "launch (debug)": {
49
+                        "request": {
50
+                            "command": "launch",
51
+                            "mode": "debug",
52
+                            "program": "${file}",
53
+                            "cwd": "${workdir}",
54
+                            "stopOnEntry": true
55
+                        }
56
+                    }
57
+                }
58
+            }
59
+        }
60
+    }
61
+
62
+Unfortunately you will have to edit the hard-coded paths in `.vscode/launch.json`, I haven't been able to use variables there for some reason.
63
+
25 64
 ## License
26 65
 
27 66
 The source code of this Duality GameBoy clone is licensed as GPLv3.

Loading…
Cancel
Save