mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-01-13 19:29:52 +00:00
Start of additional tutorials and samples
This commit is contained in:
parent
89a56d479e
commit
3c4cf89ecf
@ -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
|
||||
|
@ -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
|
||||
|
107
docs/getting_started.markdown
Normal file
107
docs/getting_started.markdown
Normal file
@ -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 <loader.h>
|
||||
#include <locator.h>
|
||||
#include <memory.h>
|
||||
#include <misctool.h>
|
||||
#include <gte.h>
|
||||
|
||||
/* 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();
|
||||
}
|
||||
```
|
@ -5,6 +5,4 @@
|
||||
layout: home
|
||||
---
|
||||
|
||||
* Live Samples
|
||||
* Tutorials
|
||||
* Examples
|
||||
* [Getting Started]({{ site.baseurl }}/getting-started.html)
|
||||
|
17
docs/live.markdown
Normal file
17
docs/live.markdown
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
layout: page
|
||||
---
|
||||
|
||||
<script>
|
||||
var emulator = new Emulator(document.querySelector("#canvas"),
|
||||
null,
|
||||
new MAMELoader(MAMELoader.driver("1943"),
|
||||
MAMELoader.nativeResolution(224, 256),
|
||||
MAMELoader.scale(3),
|
||||
MAMELoader.emulatorJS("emulators/mess1943.js"),
|
||||
MAMELoader.mountFile("1943.zip",
|
||||
MAMELoader.fetchFile("Game File",
|
||||
"examples/1943.zip"))))
|
||||
emulator.start({ waitAfterDownloading: true });
|
||||
</script>
|
||||
<canvas id="canvas" width="800" height="600"></canvas>
|
118
docs/samples/basic_c_sample.markdown
Normal file
118
docs/samples/basic_c_sample.markdown
Normal file
@ -0,0 +1,118 @@
|
||||
---
|
||||
layout: page
|
||||
style: sample
|
||||
---
|
||||
|
||||
```c
|
||||
#include <loader.h>
|
||||
#include <locator.h>
|
||||
#include <memory.h>
|
||||
#include <misctool.h>
|
||||
#include <types.h>
|
||||
|
||||
#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");
|
||||
}
|
||||
```
|
5
docs/tutorials.markdown
Normal file
5
docs/tutorials.markdown
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
layout: page
|
||||
title: Examples
|
||||
---
|
||||
|
Loading…
x
Reference in New Issue
Block a user