Program Description
Programming Challenges
There were many challenges I faced while programming The TWIGZ Engine including: QBasic's limitations in speed, memory, and graphics, little to no knowledge of how the SCUMM Engine actually works, developing a project of this size with little prior experience.The first challenge involving QBasic's serious graphical, memory, and speed issues led to my development of T*LiB, a QBasic graphics, memory and mouse library written completely in x86 Assembly. This library gave me the speed, memory and graphical abilities that QBasic was lacking and without it The TWIGZ Engine could never have been developed.
As for having little to no knowledge of how the SCUMM Engine actually worked, I had to do a lot of research. The greatest asset I had to aid me in my understanding of the inner-workings of the SCUMM Engine was SCUMM Revisited, a SCUMM file viewer which gave me a deeper look into the file structure of SCUMM games. After that, I simply built the engine the way I thought best.
This project took about two years to complete and as of right now this is the longest project I have ever worked on. The project was an excellent learning experience and gave me a better understanding of structuring a game and organizing its development.
Features
For more detailed information about The TWIGZ Engine please visit ShatteredRealmProductions.com
- Full EMS & XMS memory support
- Large room maps (960 pixels wide x 144 pixels high)
- Costume files (*.cos) for all Actors (used for on-the-fly animation changes)
- A full custom scripting language (used for in-game animations and special Actor & Engine cues)
- Level files (*.lvl) with ALL Room data
- Room image masks for three dimensional effects
- Dialogue & Verb Engine (for talking to Actors & interacting with Hot-Spots)
- Script Engine (support for 25 simultaneous scripts)
- Actor Engine (support for 25 simultaneous actors with various costumes)
- Inventory Engine
- Convex Polygon Shortest-Path Finding Algorithm (using specialized connectivity matrix)
- Fully customizable GUI (including mouse cursors, buttons, and fonts)
- Flicker-less animations and remarkably quick speed
- Palette cycling for lighting and water effects
- On-the-fly sprite scaling for added three dimensional effects
Screenshots
Shattered Realm Productions splash screen |
The main menu |
A conversation with Guybrush Threepwood himself |
The player's feet are hidden by the mask layer |
The player has picked up a shovel and it is now displayed in his inventory |
Code Sample
The ScaleCharacter subroutine scales the Actor's sprite based on its position in the walking box. Walking boxes are the only areas where Actors can walk. The bottom and top of a walking box are given scaling values. The Actor is scaled based on these values.
SUB ScaleCharacter
CalculateYs
Distance = Actor(1).Y - Scale.YMin
Scale.X = BoxParameters(Actor(1).CurrentPoly).EndScaleIndex + (Distance * Scale.BlendValue)
IF Scale.X < .15 THEN Scale.X = .15
Scale.Y = Scale.X
Scale.StepSkip = (6.5 * Scale.X) / .5
DEF SEG = VARSEG(SaveTile(0))
W = PEEK(VARPTR(SaveTile(0)) + 0)
H = PEEK(VARPTR(SaveTile(0)) + 2)
DEF SEG
DEF SEG = VARSEG(ScaleArray(0))
POKE VARPTR(ScaleArray(0)), INT(W * Scale.X)
POKE VARPTR(ScaleArray(0)) + 2, INT(H * Scale.Y) + R
DEF SEG
W = W \ 8
NewWidth = INT(W * Scale.X)
Actor(1).CharWidth = NewWidth
Actor(1).CharHeight = INT(H * Scale.Y)
FOR Y = 0 TO H - 1
FOR X = 0 TO W - 1
XNew = INT(X * Scale.X)
YNew = INT(Y * Scale.Y)
DEF SEG = VARSEG(SaveTile(0))
A = PEEK(VARPTR(SaveTile(0)) + (Y * W + X + 4))
DEF SEG = VARSEG(ScaleArray(0))
POKE VARPTR(ScaleArray(0)) + (YNew * NewWidth + XNew + 4), A
NEXT X
NEXT Y
DEF SEG
END SUB
The UpdateObjects subroutine uses T*LiB functions to read state information for each object in the game. Once the information is read, the appropriate images are drawn to the screen.
SUB UpdateObjects
FOR i = 1 TO Level.TotalObjects
TwigzMoveFromXMS VARSEG(A), VARPTR(A), BinVarHandle&, Object(i).BinVar * 4, 4
IF A > 0 THEN
Bytes = (Object(i).ImageWidth * Object(i).ImageHeight) + 5
TwigzMoveFromXMS VARSEG(SaveTile(0)), VARPTR(SaveTile(0)), XMSObjects&, Object(i).StartOffset + ((A - 1) * Bytes), Bytes
TwigzClipPut Layer%, 0, VARSEG(SaveTile(0)), VARPTR(SaveTile(0)), Object(i).X - TopX, Object(i).Y, 255
END IF
NEXT
END SUB
Downloads
WARNING: The TWIGZ SDK requires EMS and XMS memory which may not be supported on modern systems. If you cannot get The TWIGZ SDK to run, please download Setup.zip, a program which will verify that your system supports EMS and XMS memory.
The TWIGZ Engine.exe - This is a self-extracting version of the above file.
