inital commit

This commit is contained in:
Cuptain 2024-08-30 09:51:49 +10:00
commit 38e2429391
7 changed files with 224 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/out
/src/boot

20
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -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
}

24
.vscode/launch.json vendored Normal file
View File

@ -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
}
]
}
]
}

61
.vscode/settings.json vendored Normal file
View File

@ -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
}

46
.vscode/tasks.json vendored Normal file
View File

@ -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": []
}
]
}

27
README.adoc Normal file
View File

@ -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`.

44
src/main.c Normal file
View File

@ -0,0 +1,44 @@
#include <genesis.h>
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;
}