development:csdk:1.0:getting_started
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| development:csdk:1.0:getting_started [2024/11/08 01:57] – removed - external edit (Unknown date) 127.0.0.1 | development:csdk:1.0:getting_started [2024/11/08 01:57] (current) – ↷ Page moved from development:csdk:getting_started to development:csdk:1.0:getting_started clyde | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Getting started with the GameTank C SDK ====== | ||
| + | To start a new project you can use the template feature on github to create a new repository based on a snapshot of [[https:// | ||
| + | |||
| + | Along with the SDK itself you'll need to install some other tools: | ||
| + | |||
| + | ===cc65=== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | This should be built from source on a recent commit, or can be downloaded as a snapshot build for Windows. The last official release is currently quite dated, so you'll have trouble building the SDK if you install it with apt on Linux or use the " | ||
| + | |||
| + | ===NodeJS=== | ||
| + | |||
| + | Node is used for the sprite and music conversion scripts as well as the build config generator. Version 20 or newer should be used. | ||
| + | |||
| + | ===Zopfli=== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | ===Make (and a few other Unix tools)=== | ||
| + | |||
| + | If you already installed any tools for compiling C then make is probably also installed. This command will handle the numerous other commands you'd need to convert your collection of code files and art assets into a GameTank ROM file. | ||
| + | |||
| + | Some other GNU tools such as '' | ||
| + | |||
| + | ===Emulator=== | ||
| + | |||
| + | Finally you'll need the [[software: | ||
| + | |||
| + | =====First Build===== | ||
| + | |||
| + | A clean copy of the SDK will include the following folders: | ||
| + | |||
| + | * assets | ||
| + | * lib | ||
| + | * scripts | ||
| + | * src | ||
| + | |||
| + | //src// will be the home for your C code, and src/gt holds the library code provided to help with tasks like drawing images, reading controllers, | ||
| + | |||
| + | //assets// is where you'll place files such as bitmaps and midis to be picked up by conversion scripts. | ||
| + | |||
| + | //scripts// is where the conversion and build config scripts live. | ||
| + | |||
| + | //lib// contains prebuilt helper binaries and doesn' | ||
| + | |||
| + | To check that dependencies are installed and the SDK was pulled cleanly, build the starter code with the following commands. | ||
| + | |||
| + | < | ||
| + | make import | ||
| + | make | ||
| + | </ | ||
| + | |||
| + | The first command will check the assets folder and prepare generated code files as well as the linker config for your game. | ||
| + | |||
| + | The second command will start compiling all your code files and create a bin folder. Inside bin will be game.gtr, which can be opened in the GameTank Emulator. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | You should see an orange square bouncing around on a gray background. This behavior is defined in //main.c//, which is the starting point of your program as far as C code is concerned. | ||
| + | |||
| + | Let's take a look at this file! | ||
| + | |||
| + | <code c> | ||
| + | #include " | ||
| + | #include " | ||
| + | |||
| + | int main () { | ||
| + | char col = 30, row = 20; | ||
| + | int dx = 1, dy = 1; | ||
| + | |||
| + | init_graphics(); | ||
| + | |||
| + | flip_pages(); | ||
| + | clear_border(0); | ||
| + | await_draw_queue(); | ||
| + | flip_pages(); | ||
| + | await_draw_queue(); | ||
| + | clear_border(0); | ||
| + | |||
| + | while (1) { // | ||
| + | clear_screen(3); | ||
| + | draw_box(col, | ||
| + | col += dx; | ||
| + | row += dy; | ||
| + | if(col == 1) { | ||
| + | dx = 1; | ||
| + | } else if(col == 119) { | ||
| + | dx = -1; | ||
| + | } | ||
| + | if(row == 8) { | ||
| + | dy = 1; | ||
| + | } else if(row == 112) { | ||
| + | dy = -1; | ||
| + | } | ||
| + | | ||
| + | await_draw_queue(); | ||
| + | sleep(1); | ||
| + | flip_pages(); | ||
| + | | ||
| + | } | ||
| + | |||
| + | return (0); // | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | // | ||
| + | |||
| + | The GameTank has a double buffer, and typically you'll be drawing on one frame while the other is being presented to the television. // | ||
| + | |||
| + | A notable feature of the SDK is a queued drawing API. The GameTank' | ||
| + | |||
| + | // | ||
| + | |||
| + | //sleep// waits for a number of frames, but is also used for synchronizing with the television picture. // | ||
| + | |||
| + | ===== Testing on hardware ===== | ||
| + | |||
| + | See the [[development: | ||
| + | |||
| + | <code bash> | ||
| + | ./GTFO.exe -p COM3 ~/ | ||
| + | </ | ||
