mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-06-03 14:29:33 +00:00
Work on ChrisV C demo
This commit is contained in:
parent
1a7fe4bd1a
commit
10729c59a9
5
demos/chrisv/.gitignore
vendored
Normal file
5
demos/chrisv/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
App
|
||||||
|
main
|
||||||
|
*.root
|
||||||
|
*.sym
|
||||||
|
*.a
|
1
demos/chrisv/_FileInformation.txt
Normal file
1
demos/chrisv/_FileInformation.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
App=Type(B3),AuxType(0000),VersionCreate(70),MinVersion(BE),Access(E3)
|
BIN
demos/chrisv/assets/tileset.png
Normal file
BIN
demos/chrisv/assets/tileset.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 992 B |
17
demos/chrisv/build-image.bat
Normal file
17
demos/chrisv/build-image.bat
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
echo off
|
||||||
|
|
||||||
|
REM Copy all of the assets into the ProDOS image for emulator testing
|
||||||
|
REM
|
||||||
|
REM Pass the path of the Cadius tool as the first argument (%1)
|
||||||
|
|
||||||
|
set CADIUS="%1"
|
||||||
|
set IMAGE="..\\..\\emu\\Target.2mg"
|
||||||
|
set FOLDER="/GTEDEV/ChrisV"
|
||||||
|
|
||||||
|
REM Cadius does not overwrite files, so clear the root folder first
|
||||||
|
%CADIUS% DELETEFOLDER %IMAGE% %FOLDER%
|
||||||
|
%CADIUS% CREATEFOLDER %IMAGE% %FOLDER%
|
||||||
|
|
||||||
|
REM Now copy files and folders as needed
|
||||||
|
%CADIUS% ADDFILE %IMAGE% %FOLDER% .\App
|
||||||
|
%CADIUS% ADDFILE %IMAGE% %FOLDER% ..\..\src\Tool160
|
122
demos/chrisv/gte.h
Normal file
122
demos/chrisv/gte.h
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
/* ********************************************************************
|
||||||
|
|
||||||
|
GTE is copyright Lucas Scharenbroich and licensed under the Apache-2.0
|
||||||
|
License.
|
||||||
|
|
||||||
|
The following GTE function definitions are taken from the GTE Toolbox
|
||||||
|
documentation:
|
||||||
|
https://lscharen.github.io/iigs-game-engine/toolboxref.html
|
||||||
|
|
||||||
|
And from the GTE Macros:
|
||||||
|
https://github.com/lscharen/iigs-game-engine/blob/d7be9f1be44748b0180c930b1f90b144cda661ea/macros/GTE.Macs.s
|
||||||
|
|
||||||
|
The contents of this file are a derivite work from GTE intended to
|
||||||
|
ease the process of calling GTE / Tool 160 from ORCA/C and are believed
|
||||||
|
to be permitted under the terms of the Apache-2.0 License.
|
||||||
|
|
||||||
|
********************************************************************* */
|
||||||
|
|
||||||
|
#ifndef _GTE_HEADER_INCLUDE_
|
||||||
|
#define _GTE_HEADER_INCLUDE_
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
GTE_IS_SYSTEM_TOOLS_INSTALL is a boolean toggle for controlling what the application assumes about the location of the GTE tool.
|
||||||
|
|
||||||
|
If GTE is installed in System:Tools, GTE_IS_SYSTEM_TOOLS_INSTALL must be defined.
|
||||||
|
Otherwise, GTE_IS_SYSTEM_TOOLS_INSTALL must be undefined.
|
||||||
|
|
||||||
|
This will control which header file is used as well as the calls used to load the tool during application startup.
|
||||||
|
*/
|
||||||
|
// #define GTE_IS_SYSTEM_TOOLS_INSTALL 1
|
||||||
|
|
||||||
|
#ifdef GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
#define tool_dispatcher dispatcher
|
||||||
|
#else
|
||||||
|
#define tool_dispatcher 0xE10008L
|
||||||
|
#endif // GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
|
||||||
|
/* GTE Housekeeping Routines */
|
||||||
|
extern pascal void GTEBootInit(void) inline(0x01A0, tool_dispatcher);
|
||||||
|
extern pascal void GTEStartUp(Word dPageAddr, Word capFlags, Word userID) inline(0x02A0, tool_dispatcher);
|
||||||
|
extern pascal void GTEShutDown(void) inline(0x03A0, tool_dispatcher);
|
||||||
|
extern pascal Word GTEVersion(void) inline(0x04A0, tool_dispatcher);
|
||||||
|
extern pascal void GTEReset(void) inline(0x05A0, tool_dispatcher);
|
||||||
|
extern pascal Word GTEStatus(void) inline(0x06A0, tool_dispatcher);
|
||||||
|
|
||||||
|
|
||||||
|
/* GTE Sprite Routines */
|
||||||
|
extern pascal void GTECreateSpriteStamp(Word spriteDescriptor, Word vBuffAddr) inline(0x0FA0, tool_dispatcher);
|
||||||
|
extern pascal void GTEAddSprite(Word spriteSlot, Word spriteFlags, Word vBuffAddr, Word x, Word y) inline(0x10A0, tool_dispatcher);
|
||||||
|
extern pascal void GTEMoveSprite(Word spriteSlot, Word x, Word y) inline(0x11A0, tool_dispatcher);
|
||||||
|
extern pascal void GTEUpdateSprite(Word spriteSlot, Word spriteFlags, Word vBuffAddr) inline(0x12A0, tool_dispatcher);
|
||||||
|
extern pascal void GTERemoveSprite(Word spriteSlot) inline(0x13A0, tool_dispatcher);
|
||||||
|
|
||||||
|
|
||||||
|
/* GTE Tile Routines */
|
||||||
|
extern pascal void GTELoadTileSet(Pointer tileSetPtr) inline(0x0EA0, tool_dispatcher);
|
||||||
|
extern pascal void GTEFillTileStore(Word tileID) inline(0x25A0, tool_dispatcher);
|
||||||
|
extern pascal void GTESetTile(Word xTile, Word yTile, Word tileID) inline(0x0BA0, tool_dispatcher);
|
||||||
|
|
||||||
|
/* GTE Primary Background Routines */
|
||||||
|
extern pascal void GTESetBG0Origin(Word x, Word y) inline(0x0CA0, tool_dispatcher);
|
||||||
|
extern pascal void GTERender(Word flags) inline(0x0DA0, tool_dispatcher);
|
||||||
|
|
||||||
|
|
||||||
|
/* GTE Global State Functions */
|
||||||
|
extern pascal void GTESetScreenMode(Word width, Word height) inline(0x0AA0, tool_dispatcher);
|
||||||
|
extern pascal void GTESetPalette(Word palNum, Pointer palettePtr) inline(0x16A0, tool_dispatcher);
|
||||||
|
|
||||||
|
|
||||||
|
/* GTE Misc. Functions */
|
||||||
|
extern pascal Word GTEReadControl(void) inline(0x09A0, tool_dispatcher);
|
||||||
|
extern pascal Word GTEGetSeconds(void) inline(0x14A0, tool_dispatcher);
|
||||||
|
|
||||||
|
/* ReadControl return value bits */
|
||||||
|
#define PAD_BUTTON_B 0x0100
|
||||||
|
#define PAD_BUTTON_A 0x0200
|
||||||
|
#define PAD_KEY_DOWN 0x0400
|
||||||
|
|
||||||
|
/* GTE EngineMode definitions */
|
||||||
|
#define ENGINE_MODE_TWO_LAYER 0x0001
|
||||||
|
#define ENGINE_MODE_DYN_TILES 0x0002
|
||||||
|
#define ENGINE_MODE_BNK0_BUFF 0x0004
|
||||||
|
#define ENGINE_MODE_USER_TOOL 0x8000 /* Communicate if GTE is loaded as a system tool, or a user tool */
|
||||||
|
|
||||||
|
/* GTE Render Flags */
|
||||||
|
#define RENDER_ALT_BG1 0x0001
|
||||||
|
#define RENDER_BG1_HORZ_OFFSET 0x0002
|
||||||
|
#define RENDER_BG1_VERT_OFFSET 0x0004
|
||||||
|
#define RENDER_BG1_ROTATION 0x0008
|
||||||
|
|
||||||
|
/* GTE Tile Constants */
|
||||||
|
#define TILE_PRIORITY_BIT 0x4000 /* Put tile on top of sprite */
|
||||||
|
#define TILE_FRINGE_BIT 0x2000 /* Unused */
|
||||||
|
#define TILE_SOLID_BIT 0x1000 /* Hint bit used in TWO_LAYER_MODE to optimize rendering */
|
||||||
|
#define TILE_DYN_BIT 0x0800 /* Is this a Dynamic Tile? */
|
||||||
|
#define TILE_VFLIP_BIT 0x0400
|
||||||
|
#define TILE_HFLIP_BIT 0x0200
|
||||||
|
#define TILE_ID_MASK 0x01FF
|
||||||
|
#define TILE_CTRL_MASK 0xFE00
|
||||||
|
|
||||||
|
/* GTE Sprite Constants */
|
||||||
|
#define GTE_SPRITE_HIDE 0x2000
|
||||||
|
#define GTE_SPRITE_16X16 0x1800
|
||||||
|
#define GTE_SPRITE_16X8 0x1000
|
||||||
|
#define GTE_SPRITE_8X16 0x0800
|
||||||
|
#define GTE_SPRITE_8X8 0x0000
|
||||||
|
#define GTE_SPRITE_VFLIP 0x0400
|
||||||
|
#define GTE_SPRITE_HFLIP 0x0200
|
||||||
|
|
||||||
|
|
||||||
|
/* GTE Sprint Stamp Storage Parameters */
|
||||||
|
#define GTE_VBUFF_STRIDE_BYTES (12 * 4) /* Each line has 4 slots of 16 pixels + 8 buffer pixels */
|
||||||
|
#define GTE_VBUFF_TILE_ROW_BYTES (8 * GTE_VBUFF_STRIDE_BYTES) /* Each row is comprised of 8 lines */
|
||||||
|
#define GTE_VBUFF_TILE_COL_BYTES (4)
|
||||||
|
#define GTE_VBUFF_SPRITE_STEP (GTE_VBUFF_TILE_ROW_BYTES*3) /* Allocate space for 16 rows + 8 rows of buffer */
|
||||||
|
#define GTE_VBUFF_SPRITE_START (GTE_VBUFF_TILE_ROW_BYTES+4) /* Start at an offset so $0000 can be used as an empty value */
|
||||||
|
#define GTE_VBUFF_SLOT_COUNT (48) /* Have space for this many stamps */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _GTE_HEADER_INCLUDE_ */
|
21
demos/chrisv/package.json
Normal file
21
demos/chrisv/package.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "chrisv-c-demo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Using GTE from C",
|
||||||
|
"main": "index.js",
|
||||||
|
"config": {
|
||||||
|
"merlin32": "C:\\Programs\\IIgsXDev\\bin\\Merlin32-1.1.10.exe",
|
||||||
|
"cadius": "C:\\Programs\\IIgsXDev\\bin\\Cadius.exe",
|
||||||
|
"gsport": "C:\\Programs\\gsport\\gsport_0.31\\GSPort.exe",
|
||||||
|
"macros": "../../macros",
|
||||||
|
"crossrunner": "C:\\Programs\\Crossrunner\\Crossrunner.exe"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"gsport": "%npm_package_config_gsport%",
|
||||||
|
"test": "npm run build && build-image.bat %npm_package_config_cadius% && %npm_package_config_gsport%",
|
||||||
|
"build": "npm run build:tool && npm run build:sys16",
|
||||||
|
"build:sys16": "iix compile tileData.c test.c && iix -DKeepType=S16 link test tileData keep=App",
|
||||||
|
"build:tool": "%npm_package_config_merlin32% -V %npm_package_config_macros% ../../src/Master.s",
|
||||||
|
"debug": "%npm_package_config_crossrunner% ./App -Debug -CompatibilityLayer"
|
||||||
|
}
|
||||||
|
}
|
117
demos/chrisv/test.c
Normal file
117
demos/chrisv/test.c
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
#include <types.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <loader.h>
|
||||||
|
#include <locator.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
/* #define GTE_IS_SYSTEM_TOOLS_INSTALL 1 */
|
||||||
|
#include "gte.h"
|
||||||
|
|
||||||
|
#ifdef GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
#define ENGINE_STARTUP_MODE 0x0000
|
||||||
|
#else
|
||||||
|
#define ENGINE_STARTUP_MODE ENGINE_MODE_USER_TOOL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* toolbox fail handler */
|
||||||
|
#define TOOLFAIL(string) if (toolerror()) SysFailMgr(toolerror(), "\p" string "\n\r Error Code -> $");
|
||||||
|
|
||||||
|
/* path to the local GTE toolset */
|
||||||
|
Str32 toolPath = {9, "1/Tool160" };
|
||||||
|
|
||||||
|
/* Helper function to load GTE as a user tool or system tool */
|
||||||
|
#ifdef GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
void LoadGTEToolSet(Word unused) {
|
||||||
|
LoadOneTool(160, 0);
|
||||||
|
TOOLFAIL("Unable to load GTE toolset");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void LoadGTEToolSet(Word userId) {
|
||||||
|
InitialLoadOutputRec loadRec;
|
||||||
|
|
||||||
|
// Load the tool from the local directory
|
||||||
|
loadRec = InitialLoad(userId, (Pointer) (&toolPath), 1);
|
||||||
|
TOOLFAIL("Unable to load Tool160 from local path");
|
||||||
|
|
||||||
|
// Install the tool using the user tool vector
|
||||||
|
SetTSPtr(0x8000, 160, loadRec.startAddr);
|
||||||
|
TOOLFAIL("Could not install tool");
|
||||||
|
}
|
||||||
|
#endif // GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
|
||||||
|
#ifdef GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
void UnloadGTEToolSet() {
|
||||||
|
UnloadOneTool(160);
|
||||||
|
TOOLFAIL("Unable to unload GTE toolset");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void UnloadGTEToolSet() {
|
||||||
|
}
|
||||||
|
#endif // GTE_IS_SYSTEM_TOOLS_INSTALL
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
char i;
|
||||||
|
Word userId;
|
||||||
|
Word controlMask, keyPress;
|
||||||
|
Handle dpHandle;
|
||||||
|
Word dpAddr;
|
||||||
|
extern Pointer tiles;
|
||||||
|
extern Pointer tilesPalette;
|
||||||
|
int a, b;
|
||||||
|
|
||||||
|
TLStartUp();
|
||||||
|
/* Get the program memory ID */
|
||||||
|
userId = MMStartUp();
|
||||||
|
MTStartUp();
|
||||||
|
|
||||||
|
dpHandle = NewHandle(0x200L, userId, attrBank + attrPage + attrFixed + attrLocked + attrNoCross, 0);
|
||||||
|
TOOLFAIL("Could not allocate direct page memory for GTE");
|
||||||
|
dpAddr = (Word) (*dpHandle);
|
||||||
|
|
||||||
|
printf("dpAddr: %x\n", (int)dpAddr);
|
||||||
|
printf("engineMode: %x", (int)ENGINE_STARTUP_MODE);
|
||||||
|
|
||||||
|
GTEStartUp(dpAddr, (Word) ENGINE_STARTUP_MODE, userId);
|
||||||
|
goto out;
|
||||||
|
/*
|
||||||
|
GTESetScreenMode(160, 200);
|
||||||
|
GTESetPalette(0, tilesPalette);
|
||||||
|
GTELoadTileSet(tiles);
|
||||||
|
|
||||||
|
GTEFillTileStore(1);
|
||||||
|
GTERender(0);
|
||||||
|
|
||||||
|
for (a = 3; a < 18; a++) {
|
||||||
|
GTESetTile(5, a, a);
|
||||||
|
}
|
||||||
|
GTESetTile(1, 0, 34);
|
||||||
|
GTESetTile(2, 0, 33);
|
||||||
|
GTERender(0);
|
||||||
|
|
||||||
|
GTESetTile(0, 3, 3);
|
||||||
|
GTESetTile(0, 4, 4);
|
||||||
|
for (b = 4; b < 6; b++) {
|
||||||
|
for (a = 1; a < 10; a++) {
|
||||||
|
GTESetBG0Origin(a, b);
|
||||||
|
i = (((b - 1) * 10) + a) | TILE_SOLID_BIT | TILE_HFLIP_BIT;
|
||||||
|
GTESetTile(a, b, i);
|
||||||
|
GTERender(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
do {
|
||||||
|
controlMask = GTEReadControl();
|
||||||
|
keyPress = controlMask & 0x007F;
|
||||||
|
} while (toupper(keyPress) != 'Q');
|
||||||
|
|
||||||
|
out:
|
||||||
|
GTEShutDown();
|
||||||
|
UnloadGTEToolSet();
|
||||||
|
|
||||||
|
DisposeHandle(dpHandle);
|
||||||
|
MTShutDown();
|
||||||
|
MMShutDown(userId);
|
||||||
|
TLShutDown();
|
||||||
|
}
|
1874
demos/chrisv/tileData.c
Normal file
1874
demos/chrisv/tileData.c
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -183,7 +183,9 @@ _TSShutDown
|
||||||
jsr _CoreShutDown ; Shut down the library
|
jsr _CoreShutDown ; Shut down the library
|
||||||
plb
|
plb
|
||||||
|
|
||||||
pea $8000
|
lda EngineMode
|
||||||
|
and #$8000
|
||||||
|
pha
|
||||||
pei ToolNum
|
pei ToolNum
|
||||||
pea $0000 ; Set WAP to null
|
pea $0000 ; Set WAP to null
|
||||||
pea $0000
|
pea $0000
|
||||||
|
|
Loading…
Reference in New Issue
Block a user