From 38e242939162713eb54f3179d1d64d28f9ce9b4e Mon Sep 17 00:00:00 2001 From: Cuptain Date: Fri, 30 Aug 2024 09:51:49 +1000 Subject: [PATCH] inital commit --- .gitignore | 2 ++ .vscode/c_cpp_properties.json | 20 ++++++++++++ .vscode/launch.json | 24 ++++++++++++++ .vscode/settings.json | 61 +++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 46 ++++++++++++++++++++++++++ README.adoc | 27 ++++++++++++++++ src/main.c | 44 +++++++++++++++++++++++++ 7 files changed, 224 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 README.adoc create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..111bd14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/out +/src/boot \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..ca8568a --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x64", + "includePath": [ + "${workspaceFolder}/**", + "${GDK}/inc" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "cStandard": "${default}", + "cppStandard": "${default}", + "compilerPath": "gcc", + "intelliSenseMode": "windows-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..340da64 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "c:/Users/ldsja/Documents/SegaDev/SEGA_VSCode_Template-master/src", + "program": "c:/Users/ldsja/Documents/SegaDev/SEGA_VSCode_Template-master/src/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..78a421c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,61 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [ + "${GDK}/inc" + ], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b1f8734 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,46 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "command": "cmd", + "type": "shell", + "args": ["/C"], + "tasks": [ + { + "group": "build", + "label": "make", + "command": "${env:GDK}\\bin\\make", + "args": [ + "-f", + "${env:GDK}\\makefile.gen" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "problemMatcher": [] + }, + { + "label": "clean", + "command": "${env:GDK}\\bin\\make", + "args": [ + "clean", + "-f", + "${env:GDK}\\makefile.gen" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "problemMatcher": [] + } + ] +} diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..b99f58b --- /dev/null +++ b/README.adoc @@ -0,0 +1,27 @@ +== Setting up SGDK with Visual Studio Code + +This small project will help to setup a working environment (tested in Windows) for Sega Mega Drive developing with SGDK toolchain and Visual Studio Code as prefered editor. Visual Studio Code will be setup with c/cpp code extension and tasks to build and clean the workspace. + + +=== Prerequisites + +. Download link:https://github.com/Stephane-D/SGDK[SGDK] +. Download link:https://code.visualstudio.com/[Visual Studio Code] + + +=== Setup + +* Extract SGDK to a prefered directory. +* Create an environment variable `GDK` pointing to the SGDK directory (e.g. "C:/dev/sgdk"). +* Install Visual Studio Code. +* Install the following extensions in vsCode: `C/C++ for Visual Studio Code` +* Clone this github repo: `git clone https://github.com/pleft/SEGA_VSCode_Template.git`. + +=== Usage + +* Open `VSCode` and `File->Open Folder...` and choose the folder of the checked out repository. +* Folder `.vscode` contains two files: `c_cpp_properties.json` and `tasks.json` + * In `c_cpp_properties.json` it is added the include folder of the `SGDK`: `"includePath": ["${GDK}/inc"]` + * In `tasks.json` there are 2 tasks to help build and clean the project, `make` and `clean`. + - To run `make` task press `Ctrl-Shift-B`. + - To run `make` or `clean` press `Ctrl-P` then write `task make` or `task clean`. diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..d601373 --- /dev/null +++ b/src/main.c @@ -0,0 +1,44 @@ +#include + +int main() +{ + + //Initialise the bitmap engine + BMP_init(TRUE, BG_A, PAL0, FALSE); + + //Set the colour of the line. We are using pallete 0 for the bitmap, so we have 0->15. 15 is used for white text, so we set an unused pallet colour, 14 to blue - RGB 0000FF. + u16 colour_blue = RGB24_TO_VDPCOLOR(0x0000ff); + VDP_setPaletteColor(14, colour_blue); + //VDP_setBackgroundColor(14); + + //A line needs a source coordinate x,y and a destination coordinate x,y along with a pallete colour. + Line l; + l.pt1.x = 0; + l.pt1.y = 0; + l.pt2.x = 255; + l.pt2.y = 0; + l.col = 0x0000ff; + l.col |= l.col << 4; // if we do not left shift the colour, we get gaps in the line + + while(TRUE) + { + //Clear the bitmap + BMP_clear(); + + //Draw the line defined above (in the background, hidden) + BMP_drawLine(&l); + + //Flip the data to the screen - i.e. actually draw the complete image on screen + BMP_flip(1); + + //Increment the destination y coordinate + l.pt2.y = l.pt2.y + 2; + + //Reset the destination y coordinate if it hits 160 + if (l.pt2.y == 160) + { + l.pt2.y = 0; + } + } + return 0; +} \ No newline at end of file