From 3c4cf89ecf9a1b8b0e5e94810a4b3bdf3507c169 Mon Sep 17 00:00:00 2001 From: Lucas Scharenbroich Date: Tue, 2 May 2023 16:06:57 -0500 Subject: [PATCH] Start of additional tutorials and samples --- docs/Gemfile | 1 + docs/_config.yml | 4 + docs/getting_started.markdown | 107 ++++++++++++++++++++++++ docs/index.markdown | 4 +- docs/live.markdown | 17 ++++ docs/samples/basic_c_sample.markdown | 118 +++++++++++++++++++++++++++ docs/tutorials.markdown | 5 ++ 7 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 docs/getting_started.markdown create mode 100644 docs/live.markdown create mode 100644 docs/samples/basic_c_sample.markdown create mode 100644 docs/tutorials.markdown diff --git a/docs/Gemfile b/docs/Gemfile index 85a57bf..f5e9418 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -11,6 +11,7 @@ source "https://rubygems.org" gem "github-pages", "~> 223", group: :jekyll_plugins # This is the default theme for new Jekyll sites. You may change this to anything you like. gem "minima", "~> 2.5" + # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. # gem "github-pages", group: :jekyll_plugins diff --git a/docs/_config.yml b/docs/_config.yml index 6f5bf7f..e7f2997 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -33,6 +33,10 @@ theme: minima #plugins: # - jekyll-feed +markdown: kramdown +highlighter: rogue +input: GFM + # Exclude from processing. # The following items will not be processed, by default. # Any item listed under the `exclude:` key here will be automatically added to diff --git a/docs/getting_started.markdown b/docs/getting_started.markdown new file mode 100644 index 0000000..75b0ab6 --- /dev/null +++ b/docs/getting_started.markdown @@ -0,0 +1,107 @@ +--- +permalink: /getting-started +layout: page +--- + +# Getting Started +* Set Up + * Windows + * Linux + * Native + + +This tutorial page will walk through the process of setting up your computer to build Apple IIgs applications +that leverage the GTE toolset. +## Set Up + +### Windows + +### Linux + +### Native + +If you are developing directly on an Apple IIgs machine, dowload the GTE-1.0.shk archive into your GS/OS environment. There +are several ways of getting the file onto your system. + + 1. Use the [NetDisk](https://sheumann.github.io/NetDisk/) utility to mount to the remote disk image directly from GS/OS and copy the Tool160 file + 1. Use [ADTPro](https://adtpro.com/index.html) to transfer the disk image to the apple IIgs and write it onto a physical floppy disk + +## Your First Program + +```c +#include +#include +#include +#include +#include + +/* tile data stored in tiles.c */ +extern Byte tiles[]; + +/* define a couple of key codes for the arrow keys */ +#define LEFT_ARROW 0x08 +#define RIGHT_ARROW 0x15 +#define UP_ARROW 0x0B +#define DOWN_ARROW 0x0A + +Word userId; +Handle dpHandle; + +void startUp(void) { + TLStartUp(); + userId = MMStartUp(); + MTStartUp(); + + LoadOneTool(160, 0x0100); + dpHandle = NewHandle(0x200L, userId, attrBank + attrPage + attrFixed + attrLocked + attrNoCross, 0); + GTEStartUp((Word) *dpHandle, (Word) 0, userId); +} + +void shutDown(void) { + GTEShutDown(); + DisposeHandle(dpHandle); + UnloadOneTool(160); + MTShutDown(); + MMShutDown(userId); + TLShutDown(); +} + +void main(void) { + Word keyPress; + int x, y; + + /* Start up GTE and its dependencies */ + startUp(); + + /* Create a 256x160 playfield (128 bytes x 160 lines) */ + GTESetScreenMode(128, 160); + + /* Load in two tiles */ + GTELoadTileSet(0, 2, tiles); + + /* Fill the tile store with a checkerboard pattern */ + for (y = 0; y < GTE_TILE_STORE_HEIGHT; y++) { + for (x = 0; x < GTE_TILE_STORE_WIDTH; x++) { + GTESetTile(x, y, (x + y) & 1); + } + } + + /* Enter into the main loop */ + x = y = 0; + do { + keyPress = GTEReadControl() & PAD_KEY_CODE; + + if (keyPress == LEFT_ARROW && x > 0) x--; + if (keyPress == RIGHT_ARROW && x < 1000) x++; + if (keyPress == UP_ARROW && y > 0) y--; + if (keyPress == DOWN_ARROW && y < 1000) y++; + + /* Position the screen and render */ + GTESetBG0Origin(x, y); + GTERender(0); + } + while (keyPress != 'Q' && keyPress != 'q'); + + shutDown(); +} +``` \ No newline at end of file diff --git a/docs/index.markdown b/docs/index.markdown index 910382c..e632f65 100644 --- a/docs/index.markdown +++ b/docs/index.markdown @@ -5,6 +5,4 @@ layout: home --- -* Live Samples -* Tutorials -* Examples \ No newline at end of file +* [Getting Started]({{ site.baseurl }}/getting-started.html) diff --git a/docs/live.markdown b/docs/live.markdown new file mode 100644 index 0000000..1665bb8 --- /dev/null +++ b/docs/live.markdown @@ -0,0 +1,17 @@ +--- +layout: page +--- + + + \ No newline at end of file diff --git a/docs/samples/basic_c_sample.markdown b/docs/samples/basic_c_sample.markdown new file mode 100644 index 0000000..8465543 --- /dev/null +++ b/docs/samples/basic_c_sample.markdown @@ -0,0 +1,118 @@ +--- +layout: page +style: sample +--- + +```c +#include +#include +#include +#include +#include + +#include "gte.h" +#include "demo_data.h" + +#define TOOLFAIL(string) if (toolerror()) SysFailMgr(toolerror(), "\p" string "\n\r Error Code -> $"); + +#define SPRITE_START_TILE 2 +#define SPRITE_SLOT 0 +#define SPRITE_VBUFF (GTE_VBUFF_SPRITE_START+0*GTE_VBUFF_SPRITE_STEP) + +int main (void) { + Word controlMask; + Word keyPress; + Word userId; + Handle dpHndl; + Word dpWord; + Word x = 0, y = 0; + Word px = 0, py = 0; + Word sec; + + TLStartUp(); + TOOLFAIL("Unable to start tool locator"); + + userId = MMStartUp(); + TOOLFAIL("Unable to start memory manager"); + + MTStartUp(); + TOOLFAIL("Unable to start misc tools"); + + LoadGTEToolSet(userId); + + dpHndl = NewHandle(0x0200, userId, 0x4015, 0); + if (dpHndl == NULL) { + TOOLFAIL("Unable to allocate page 0 memory"); + } + dpWord = (Word)(*dpHndl); + if ((dpWord & 0x00FF) != 0x0000) { + TOOLFAIL("Allocated page 0 memory is not aligned"); + } + + GTEStartUp(dpWord, 0x0000, userId); + TOOLFAIL("Unable to start GTE"); + + GTESetScreenMode(160, 200); + GTELoadTileSet(tiles); + GTESetPalette(0, (Pointer)palette); + GTEFillTileStore(1); + + GTECreateSpriteStamp(GTE_SPRITE_8X8 | SPRITE_START_TILE, SPRITE_VBUFF); + GTEAddSprite(SPRITE_SLOT, 0, SPRITE_VBUFF, px, py); + + do { + controlMask = GTEReadControl(); + keyPress = controlMask & 0x007F; + + switch (keyPress) { + case ' ': // Toggle background + sec = GTEGetSeconds(); + GTEFillTileStore(1 + (sec & 1)); + break; + + case 'a': if (x > 0) { x--; } + break; + + case 'd': if (x < 1000) { x++; } + break; + + case 'w': if (y > 0) { y--; } + break; + + case 's': if (y < 1000) { y++; } + break; + + + case 'j': if (px > 0) { px--; } + break; + + case 'l': if (px < 154) { px++; } + break; + + case 'i': if (py > 0) { py--; } + break; + + case 'k': if (py < 192) { py++; } + break; + } + + GTESetBG0Origin(x, y); + GTEMoveSprite(SPRITE_SLOT, px, py); + GTERender(0); + + } while (keyPress != 'q' && keyPress != 'Q'); + + GTEShutDown(); + + DisposeHandle(dpHndl); + + MTShutDown(); + TOOLFAIL("Unable to shutdown misc tool"); + + MMShutDown(userId); + TOOLFAIL("Unable to shutdown memory manager"); + + TLShutDown(); + TOOLFAIL("Unable to shutdown tool locator"); +} +``` \ No newline at end of file diff --git a/docs/tutorials.markdown b/docs/tutorials.markdown new file mode 100644 index 0000000..7635b2d --- /dev/null +++ b/docs/tutorials.markdown @@ -0,0 +1,5 @@ +--- +layout: page +title: Examples +--- +