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

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
 ROMU := $(GBDK_HOME)/bin/romusage
41
 ROMU := $(GBDK_HOME)/bin/romusage
42
 GB_EMU := gearboy
42
 GB_EMU := gearboy
43
 SGB_EMU := sameboy
43
 SGB_EMU := sameboy
44
+BGB_EMU := wine ~/bin/bgb/bgb.exe
44
 FLASHER := flashgbx
45
 FLASHER := flashgbx
45
 
46
 
46
 LCCFLAGS := -Wa-l -Wl-m -Wp-MMD -Wf--opt-code-speed
47
 LCCFLAGS := -Wa-l -Wl-m -Wp-MMD -Wf--opt-code-speed
48
 LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1B -Wm-yoA -Wm-ya1 -Wm-yc -Wm-ys
49
 LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1B -Wm-yoA -Wm-ya1 -Wm-yc -Wm-ys
49
 LCCFLAGS += -autobank -Wb-ext=.rel -Wb-v -Wf-bo255
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
 ifndef GBDK_RELEASE
56
 ifndef GBDK_RELEASE
54
 	LCCFLAGS += -debug -DDEBUG -Wa-j -Wa-y -Wa-s -Wl-j -Wl-y -Wl-u -Wm-yS
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
 	BUILD_TYPE = Debug
59
 	BUILD_TYPE = Debug
57
 else
60
 else
58
 	BUILD_TYPE = Release
61
 	BUILD_TYPE = Release
65
 DEPS=$(OBJS:%.o=%.d)
68
 DEPS=$(OBJS:%.o=%.d)
66
 -include $(DEPS)
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
 .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
72
 .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
70
 
73
 
71
 all: $(BIN)
74
 all: $(BIN)
74
 	@echo "Cleaning old build"
77
 	@echo "Cleaning old build"
75
 	@make clean
78
 	@make clean
76
 	@echo "Preparing bear.cfg"
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
 	@echo "Running full build within bear"
81
 	@echo "Running full build within bear"
79
 	@bear --config bear.cfg -- make -j4
82
 	@bear --config bear.cfg -- make -j4
80
 	@rm -rf bear.cfg
83
 	@rm -rf bear.cfg
89
 
92
 
90
 run: $(BIN)
93
 run: $(BIN)
91
 	@echo Emulating $<
94
 	@echo Emulating $<
92
-	@$(GB_EMU) $(EMUFLAGS)
95
+	@$(GB_EMU) $(GB_EMUFLAGS)
93
 
96
 
94
 sgb_run: $(BIN)
97
 sgb_run: $(BIN)
95
 	@echo Emulating $<
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
 flash: $(BIN)
105
 flash: $(BIN)
99
 	@echo Flasing $<
106
 	@echo Flasing $<

+ 39
- 0
README.md View File

22
     make clean
22
     make clean
23
     make GBDK_RELEASE=1 run
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
 ## License
64
 ## License
26
 
65
 
27
 The source code of this Duality GameBoy clone is licensed as GPLv3.
66
 The source code of this Duality GameBoy clone is licensed as GPLv3.

Loading…
Cancel
Save