Lots of stuff

This commit is contained in:
elasota
2019-11-11 00:11:59 -05:00
parent 49a35bb15b
commit c8472f7295
406 changed files with 58313 additions and 88 deletions

19
.gitignore vendored Normal file
View File

@@ -0,0 +1,19 @@
*.suo
*.db
*.opendb
*.ipch
*.pch
*.user
*.mcp
*.obj
*.log
*.tlog
*.lastbuildstate
*.dll
*.exe
*.exp
*.ilk
*.lib
*.pdb
.vs/*
Packaged/*

12
Common.props Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

34
Common/CoreDefs.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#ifndef __PL_COREDEFS_H__
#define __PL_COREDEFS_H__
#if __cplusplus >= 199711L
#define PL_IS_CPP11 1
#else
#define PL_IS_CPP11 0
#endif
#if PL_IS_CPP11
#define PL_DELETED = delete
#else
#ifndef nullptr
#define nullptr 0
#endif
#ifndef override
#define override
#endif
#ifndef final
#define final
#endif
#define PL_DELETED
#endif
static const size_t PL_SYSTEM_MEMORY_ALIGNMENT = 16;
#endif

81
GlidePort.sln Normal file
View File

@@ -0,0 +1,81 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2020
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hqx2bin", "hqx2bin\hqx2bin.vcxproj", "{45B1B18C-C846-4044-9206-74F58DFC5E88}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PortabilityLayer", "PortabilityLayer\PortabilityLayer.vcxproj", "{6EC62B0F-9353-40A4-A510-3788F1368B33}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MiniRez", "MiniRez\MiniRez.vcxproj", "{2FF15659-5C72-48B8-B55B-3C658E4125B5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GpApp", "GpApp\GpApp.vcxproj", "{6233C3F2-5781-488E-B190-4FA8836F5A77}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GpD3D", "GpD3D\GpD3D.vcxproj", "{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hqx2gp", "hqx2gp\hqx2gp.vcxproj", "{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Debug|x64.ActiveCfg = Debug|x64
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Debug|x64.Build.0 = Debug|x64
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Debug|x86.ActiveCfg = Debug|Win32
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Debug|x86.Build.0 = Debug|Win32
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Release|x64.ActiveCfg = Release|x64
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Release|x64.Build.0 = Release|x64
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Release|x86.ActiveCfg = Release|Win32
{45B1B18C-C846-4044-9206-74F58DFC5E88}.Release|x86.Build.0 = Release|Win32
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Debug|x64.ActiveCfg = Debug|x64
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Debug|x64.Build.0 = Debug|x64
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Debug|x86.ActiveCfg = Debug|Win32
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Debug|x86.Build.0 = Debug|Win32
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Release|x64.ActiveCfg = Release|x64
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Release|x64.Build.0 = Release|x64
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Release|x86.ActiveCfg = Release|Win32
{6EC62B0F-9353-40A4-A510-3788F1368B33}.Release|x86.Build.0 = Release|Win32
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Debug|x64.ActiveCfg = Debug|x64
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Debug|x64.Build.0 = Debug|x64
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Debug|x86.ActiveCfg = Debug|Win32
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Debug|x86.Build.0 = Debug|Win32
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Release|x64.ActiveCfg = Release|x64
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Release|x64.Build.0 = Release|x64
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Release|x86.ActiveCfg = Release|Win32
{2FF15659-5C72-48B8-B55B-3C658E4125B5}.Release|x86.Build.0 = Release|Win32
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Debug|x64.ActiveCfg = Debug|x64
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Debug|x64.Build.0 = Debug|x64
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Debug|x86.ActiveCfg = Debug|Win32
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Debug|x86.Build.0 = Debug|Win32
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Release|x64.ActiveCfg = Release|x64
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Release|x64.Build.0 = Release|x64
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Release|x86.ActiveCfg = Release|Win32
{6233C3F2-5781-488E-B190-4FA8836F5A77}.Release|x86.Build.0 = Release|Win32
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Debug|x64.ActiveCfg = Debug|x64
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Debug|x64.Build.0 = Debug|x64
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Debug|x86.ActiveCfg = Debug|Win32
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Debug|x86.Build.0 = Debug|Win32
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Release|x64.ActiveCfg = Release|x64
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Release|x64.Build.0 = Release|x64
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Release|x86.ActiveCfg = Release|Win32
{0E383EF0-CEF7-4733-87C6-5AC9844AA1EF}.Release|x86.Build.0 = Release|Win32
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Debug|x64.ActiveCfg = Debug|x64
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Debug|x64.Build.0 = Debug|x64
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Debug|x86.ActiveCfg = Debug|Win32
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Debug|x86.Build.0 = Debug|Win32
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Release|x64.ActiveCfg = Release|x64
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Release|x64.Build.0 = Release|x64
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Release|x86.ActiveCfg = Release|Win32
{5FDE4822-C771-46A5-B6B2-FD12BACE86BF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0D6869A7-07EB-400F-B2AD-48531564555A}
EndGlobalSection
EndGlobal

122
GlidePort/GlidePort.vcxproj Normal file
View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{69C3CD2A-3114-4181-884A-C09A4C62FBE0}</ProjectGuid>
<RootNamespace>GlidePort</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

258
GpApp/About.cpp Normal file
View File

@@ -0,0 +1,258 @@
//============================================================================
//----------------------------------------------------------------------------
// About.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLResources.h"
#include "PLSound.h"
#include "PLPasStr.h"
#include "About.h"
#include "DialogUtils.h"
#include "Environ.h"
#include "Externs.h"
static void HiLiteOkayButton (void);
static void UnHiLiteOkayButton (void);
static void UpdateMainPict (DialogPtr);
static Boolean AboutFilter (DialogPtr, EventRecord *theEvent, short *hit);
static RgnHandle okayButtRgn;
static Rect okayButtonBounds, mainPICTBounds;
static Boolean okayButtIsHiLit, clickedDownInOkay;
//============================================================== Functions
//-------------------------------------------------------------- DoAbout
// Brings up the About dialog box.
void DoAbout (void)
{
#define kAboutDialogID 150 // res ID of About dialog
#define kTextItemVers 2 // item number of version text
#define kPictItemMain 4 // item number of main PICT
DialogPtr aboutDialog;
Str255 longVersion;
StringPtr messagePtr;
VersRecHndl version;
Handle itemHandle;
short itemType, hit, wasResFile;
ModalFilterUPP aboutFilterUPP;
aboutFilterUPP = NewModalFilterUPP(AboutFilter);
wasResFile = CurResFile();
UseResFile(thisMac.thisResFile);
aboutDialog = GetNewDialog(kAboutDialogID, nil, (WindowRef)-1L);
// if (aboutDialog == nil)
// RedAlert(kErrDialogDidntLoad);
version = (VersRecHndl)GetResource('vers', 1);
if (version != nil)
{
messagePtr = (**version).shortVersion + 1 + (**version).shortVersion[0];
BlockMove((Ptr)messagePtr, &longVersion, ((UInt8)*messagePtr) + 1);
SetDialogString(aboutDialog, kTextItemVers, longVersion);
}
GetDialogItem(aboutDialog, kOkayButton, &itemType, &itemHandle, &okayButtonBounds);
okayButtRgn = NewRgn(); // Create diagonal button region
OpenRgn();
MoveTo(okayButtonBounds.left + 1, okayButtonBounds.top + 45);
Line(44, -44); // These lines define the region
Line(16, 16);
Line(-44, 44);
Line(-16, -16);
CloseRgn(okayButtRgn);
okayButtIsHiLit = false; // Initially, button is not hilit
clickedDownInOkay = false; // Initially, didn't click in okay button
GetDialogItem(aboutDialog, kPictItemMain, &itemType, &itemHandle, &mainPICTBounds);
do // Loop until user wants to exit
{
ModalDialog(aboutFilterUPP, &hit);
}
while ((hit != kOkayButton) && (okayButtRgn != nil));
if (okayButtRgn != nil)
DisposeRgn(okayButtRgn); // Clean up!
DisposeDialog(aboutDialog);
DisposeModalFilterUPP(aboutFilterUPP);
UseResFile(wasResFile);
}
//============================================================== Static Functions
//-------------------------------------------------------------- HiLiteOkayButton
// Draws my pseudo-button to appear as though it is clicked on.
static void HiLiteOkayButton (void)
{
#define kOkayButtPICTHiLit 151 // res ID of unhilit button PICT
PicHandle thePict;
if (!okayButtIsHiLit)
{
thePict = GetPicture(kOkayButtPICTHiLit);
if (thePict != nil)
{
DrawPicture(thePict, &okayButtonBounds);
ReleaseResource((Handle)thePict);
okayButtIsHiLit = true;
}
}
}
//-------------------------------------------------------------- UnHiLiteOkayButton
// Draws my pseudo-button normal (not clicked on).
static void UnHiLiteOkayButton (void)
{
#define kOkayButtPICTNotHiLit 150 // res ID of hilit button PICT
PicHandle thePict;
if (okayButtIsHiLit)
{
thePict = GetPicture(kOkayButtPICTNotHiLit);
if (thePict != nil)
{
DrawPicture(thePict, &okayButtonBounds);
ReleaseResource((Handle)thePict);
okayButtIsHiLit = false;
}
}
}
//-------------------------------------------------------------- UpdateMainPict
// Redraws the main graphic in the dialog (in response to an update event).
static void UpdateMainPict (DialogPtr theDial)
{
Str255 theStr, theStr2;
long totalSize, contigSize;
DrawDialog(theDial);
PasStringCopy(PSTR("Memory: "), theStr); // display free memory
PurgeSpace(&totalSize, &contigSize);
totalSize /= 1024;
NumToString(totalSize, theStr2);
PasStringConcat(theStr, theStr2);
PasStringConcat(theStr, PSTR("K"));
DrawDialogUserText2(theDial, 7, theStr);
PasStringCopy(PSTR("Screen: "), theStr); // display screen size/depth
NumToString((long)(thisMac.screen.right - thisMac.screen.left), theStr2);
PasStringConcat(theStr, theStr2);
PasStringConcat(theStr, PSTR("x"));
NumToString((long)(thisMac.screen.bottom - thisMac.screen.top), theStr2);
PasStringConcat(theStr, theStr2);
PasStringConcat(theStr, PSTR("x"));
NumToString((long)thisMac.isDepth, theStr2);
PasStringConcat(theStr, theStr2);
DrawDialogUserText2(theDial, 8, theStr);
}
//-------------------------------------------------------------- AboutFilter
// Dialog filter for the About dialog.
static Boolean AboutFilter (DialogPtr theDial, EventRecord *theEvent, short *hit)
{
Point mousePt;
UInt32 dummyLong;
Boolean handledIt;
if (Button() && clickedDownInOkay)
{
GetMouse(&mousePt);
if(PtInRgn(mousePt, okayButtRgn))
HiLiteOkayButton();
else
UnHiLiteOkayButton();
}
switch (theEvent->what)
{
case keyDown:
switch ((theEvent->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
HiLiteOkayButton();
Delay(8, &dummyLong);
UnHiLiteOkayButton();
*hit = kOkayButton;
handledIt = true;
break;
default:
handledIt = false;
}
break;
case mouseDown:
mousePt = theEvent->where;
GlobalToLocal(&mousePt);
if(PtInRgn(mousePt, okayButtRgn))
{
clickedDownInOkay = true;
handledIt = false;
}
else
handledIt = false;
break;
case mouseUp:
mousePt = theEvent->where;
GlobalToLocal(&mousePt);
if(PtInRgn(mousePt, okayButtRgn) && clickedDownInOkay)
{
UnHiLiteOkayButton();
*hit = kOkayButton;
handledIt = true;
}
else
{
clickedDownInOkay = false;
handledIt = false;
}
break;
case updateEvt:
if ((WindowPtr)theEvent->message == mainWindow)
{
SetPort((GrafPtr)mainWindow);
BeginUpdate((WindowPtr)theEvent->message);
UpdateMainWindow();
EndUpdate((WindowPtr)theEvent->message);
SetPortDialogPort(theDial);
handledIt = true;
}
else if ((WindowPtr)theEvent->message == (WindowPtr)theDial)
{
SetPortDialogPort(theDial);
BeginUpdate((WindowPtr)theEvent->message);
UpdateMainPict(theDial);
EndUpdate((WindowPtr)theEvent->message);
handledIt = false;
}
break;
default:
handledIt = false;
break;
}
return (handledIt);
}

10
GpApp/About.h Normal file
View File

@@ -0,0 +1,10 @@
//============================================================================
//----------------------------------------------------------------------------
// About.h
//----------------------------------------------------------------------------
//============================================================================
void DoAbout (void);

286
GpApp/AnimCursor.cpp Normal file
View File

@@ -0,0 +1,286 @@
//============================================================================
//----------------------------------------------------------------------------
// AnimCursor.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLBigEndian.h"
#include "Externs.h"
#include "Environ.h"
#define rAcurID 128
#define rHandCursorID 1000
typedef struct
{
BEInt16_t n;
BEInt16_t index;
struct
{
BEInt16_t resID;
BEInt16_t reserved;
} frame[1];
} acurRec, *acurPtr, **acurHandle;
typedef struct
{
struct
{
Handle cursorHdl;
} frame[1];
} compiledAcurRec, *compiledAcurPtr, **compiledAcurHandle;
Boolean GetMonoCursors (acurHandle, compiledAcurHandle);
Boolean GetColorCursors (acurHandle, compiledAcurHandle);
void InitAnimatedCursor (acurHandle);
acurHandle animCursorH = nil;
compiledAcurHandle compiledAnimCursorH = nil;
Boolean useColorCursor = false;
//============================================================== Functions
//-------------------------------------------------------------- GetMonoCursors
// Loads b&w cursors (for animated beach ball).
Boolean GetMonoCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCursH)
{
short i, j;
CursHandle cursHdl;
if (ballCursH) // Were we passed a legit acur handle?
{
j = (*ballCursH)->n; // Get number of 'frames' in the acur
for (i = 0; i < j; i++) // Start walking the frames
{
cursHdl = GetCursor((*ballCursH)->frame[i].resID);
if (cursHdl == nil) // Did the cursor load? It didn't?...
{ // Well then, toss what we got.
for (j = 0; j < i; j++)
DisposeHandle((*compiledBallCursH)->frame[j].cursorHdl);
return(false); // And report this to mother.
} // However!...
else // If cursor loaded ok...
{ // Detach it from the resource map...
DetachResource((Handle)cursHdl); // And assign to our struct
(*compiledBallCursH)->frame[i].cursorHdl = (Handle)cursHdl;
}
}
}
return(true);
}
//-------------------------------------------------------------- GetColorCursors
// Loads color cursors (for animated beach ball).
Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCursH)
{
short i, j;
CCrsrHandle cursHdl;
Boolean result = true;
if (ballCursH)
{
j = (*ballCursH)->n; // Get the number of cursors
HideCursor(); // Hide the cursor
for (i = 0; i < j; i++) // Walk through the acur resource
{
cursHdl = GetCCursor((*ballCursH)->frame[i].resID); // Get the cursor
if (cursHdl == nil) // Make sure a real cursor was returned
{ // If not, trash all cursors loaded
for (j = 0; j < i; j++)
DisposeCCursor((CCrsrHandle)(*compiledBallCursH)->frame[j].cursorHdl);
result = false; // Tell calling proc we failed
break; // And break out of the loop
}
else // But, if the cursor loaded ok
{ // add it to our list or cursor handles
(*compiledBallCursH)->frame[i].cursorHdl = (Handle)cursHdl;
SetCCursor((CCrsrHandle)(*compiledBallCursH)->frame[i].cursorHdl);
}
}
InitCursor(); // Show the cursor again (as arrow)
}
return(result); // Return to calling proc w/ results
}
//-------------------------------------------------------------- InitAnimatedCursor
// Loads and sets up animated beach ball cursor structures.
void InitAnimatedCursor (acurHandle ballCursH)
{
Boolean useColor;
compiledAcurHandle compiledBallCursorH;
useColor = thisMac.hasColor;
if (ballCursH == nil)
ballCursH = reinterpret_cast<acurHandle>(GetResource('acur', 128));
if (ballCursH && ballCursH != animCursorH)
{
compiledBallCursorH = (compiledAcurHandle)NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n);
if (!compiledBallCursorH)
RedAlert(kErrFailedResourceLoad);
HNoPurge((Handle)ballCursH);
MoveHHi((Handle)ballCursH);
HLock((Handle)ballCursH);
if (useColor)
useColor = GetColorCursors(ballCursH, compiledBallCursorH);
if (!useColor && !GetMonoCursors(ballCursH, compiledBallCursorH))
RedAlert(kErrFailedResourceLoad);
DisposCursors();
animCursorH = ballCursH;
compiledAnimCursorH = compiledBallCursorH;
useColorCursor = useColor;
(*ballCursH)->index = 0;
}
else
RedAlert(kErrFailedResourceLoad);
}
//-------------------------------------------------------------- LoadCursors
// Just calls the above function. Other code could be added here though<67>
// to add additional cursors.
void LoadCursors (void)
{
InitAnimatedCursor((acurHandle)GetResource('acur', rAcurID));
}
//-------------------------------------------------------------- DisposCursors
// Disposes of all memory allocated by anaimated beach ball cursors.
void DisposCursors (void)
{
register short i, j;
if (compiledAnimCursorH != nil)
{
j = (*animCursorH)->n;
if (useColorCursor)
{
for (i = 0; i < j; i++)
{
if ((*compiledAnimCursorH)->frame[i].cursorHdl != nil)
DisposeCCursor((CCrsrHandle)(*compiledAnimCursorH)->frame[i].cursorHdl);
}
}
else
{
for (i = 0; i < j; i++)
{
if ((*compiledAnimCursorH)->frame[i].cursorHdl != nil)
DisposeHandle((Handle)(*compiledAnimCursorH)->frame[i].cursorHdl);
}
}
DisposeHandle((Handle)compiledAnimCursorH);
compiledAnimCursorH = nil;
}
if (animCursorH != nil)
{
ReleaseResource((Handle)animCursorH);
animCursorH = nil;
}
}
//-------------------------------------------------------------- IncrementCursor
// Advances the beach ball cursor one frame.
void IncrementCursor (void)
{
if (animCursorH == 0)
InitAnimatedCursor(nil);
if (animCursorH)
{
(*animCursorH)->index++;
(*animCursorH)->index %= (*animCursorH)->n;
if (useColorCursor)
{
SetCCursor((CCrsrHandle)(*compiledAnimCursorH)->
frame[(*animCursorH)->index].cursorHdl);
}
else
{
SetCursor((CursPtr)*(*compiledAnimCursorH)->
frame[(*animCursorH)->index].cursorHdl);
}
}
else
SetCursor((CursPtr)*GetCursor(watchCursor));
}
//-------------------------------------------------------------- DecrementCursor
// Reverses the beach ball cursor one frame.
void DecrementCursor (void)
{
if (animCursorH == 0)
InitAnimatedCursor(nil);
if (animCursorH)
{
(*animCursorH)->index--;
if (((*animCursorH)->index) < 0)
(*animCursorH)->index = ((*animCursorH)->n) - 1;
if (useColorCursor)
{
SetCCursor((CCrsrHandle)(*compiledAnimCursorH)->
frame[(*animCursorH)->index].cursorHdl);
}
else
{
SetCursor((CursPtr)*(*compiledAnimCursorH)->
frame[(*animCursorH)->index].cursorHdl);
}
}
else
SetCursor((CursPtr)*GetCursor(watchCursor));
}
//-------------------------------------------------------------- SpinCursor
// Advances the beach ball cursor the number of frames specified.
void SpinCursor (short incrementIndex)
{
UInt32 dummyLong;
short i;
for (i = 0; i < incrementIndex; i++)
{
IncrementCursor();
Delay(1, &dummyLong);
}
}
//-------------------------------------------------------------- BackSpinCursor
// Reverses the beach ball cursor the number of frames specified.
void BackSpinCursor (short decrementIndex)
{
UInt32 dummyLong;
short i;
for (i = 0; i < decrementIndex; i++)
{
DecrementCursor();
Delay(1, &dummyLong);
}
}

202
GpApp/AppleEvents.cpp Normal file
View File

@@ -0,0 +1,202 @@
//============================================================================
//----------------------------------------------------------------------------
// AppleEvents.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLAppleEvents.h"
#include "Externs.h"
#include "House.h"
#define kNoPrintingAlert 1031
OSErr DoOpenAppAE (const AppleEvent *, AppleEvent *, UInt32);
OSErr DoOpenDocAE (const AppleEvent *, AppleEvent *, UInt32);
OSErr DoPrintDocAE (const AppleEvent *, AppleEvent *, UInt32);
OSErr DoQuitAE (const AppleEvent *, AppleEvent *, UInt32);
OSErr MyGotRequiredParams (const AppleEvent *);
AEEventHandlerUPP openAppAEUPP, openDocAEUPP, printDocAEUPP, quitAEUPP;
extern FSSpecPtr theHousesSpecs;
extern long incrementModeTime;
extern short thisHouseIndex, splashOriginH, splashOriginV;
extern Boolean quitting;
//============================================================== Functions
//-------------------------------------------------------------- DoOpenAppAE
// Handles an "Open Application" Apple Event.
OSErr DoOpenAppAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
{
OSErr theErr;
theErr = MyGotRequiredParams(theAE);
return (theErr);
}
//-------------------------------------------------------------- DoOpenDocAE
// Handles an "Open Document" Apple Event.
OSErr DoOpenDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
{
FSSpec oneFSS;
FInfo finderInfo;
AEDescList docList;
long itemsInList;
Size actualSize;
AEKeyword keywd;
DescType returnedType;
OSErr theErr, whoCares;
short i;
theErr = AEGetParamDesc(theAE, keyDirectObject, typeAEList, &docList);
if (theErr != noErr)
{
YellowAlert(kYellowAppleEventErr, theErr);
return (theErr);
}
theErr = MyGotRequiredParams(theAE);
if (theErr != noErr)
{
whoCares = AEDisposeDesc(&docList);
return (theErr);
}
theErr = AECountItems(&docList, &itemsInList);
if (theErr != noErr)
{
whoCares = AEDisposeDesc(&docList);
return (theErr);
}
#ifndef COMPILEDEMO
for (i = 1; i <= itemsInList; i++)
{
theErr = AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
&oneFSS, sizeof(oneFSS), &actualSize);
if (theErr == noErr)
{
theErr = FSpGetFInfo(&oneFSS, &finderInfo);
if ((theErr == noErr) && (finderInfo.fdType == 'gliH'))
AddExtraHouse(&oneFSS);
}
}
if (itemsInList > 0)
{
theErr = AEGetNthPtr(&docList, 1, typeFSS, &keywd, &returnedType,
&oneFSS, sizeof(oneFSS), &actualSize);
if (theErr == noErr)
{
theErr = FSpGetFInfo(&oneFSS, &finderInfo);
if ((theErr == noErr) && (finderInfo.fdType == 'gliH'))
{
whoCares = CloseHouse();
PasStringCopy(oneFSS.name, thisHouseName);
BuildHouseList();
if (OpenHouse())
whoCares = ReadHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].name, thisHouseName);
OpenCloseEditWindows();
incrementModeTime = TickCount() + kIdleSplashTicks;
if ((theMode == kSplashMode) || (theMode == kPlayMode))
{
Rect updateRect;
SetRect(&updateRect, splashOriginH + 474, splashOriginV + 304, splashOriginH + 474 + 166, splashOriginV + 304 + 12);
InvalWindowRect(mainWindow, &updateRect);
}
}
}
InitCursor();
}
#endif
whoCares = AEDisposeDesc(&docList);
return theErr;
}
//-------------------------------------------------------------- DoPrintDocAE
// Handles a "Print Document" Apple Event.
OSErr DoPrintDocAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
{
short hitWhat;
// CenterAlert(kNoPrintingAlert);
hitWhat = Alert(kNoPrintingAlert, nil);
return errAEEventNotHandled;
}
//-------------------------------------------------------------- DoQuitAE
// Handles a "Quit Application" Apple Event.
OSErr DoQuitAE (const AppleEvent *theAE, AppleEvent *reply, UInt32 ref)
{
OSErr isHuman;
isHuman = MyGotRequiredParams(theAE);
if (isHuman == noErr)
quitting = true;
return isHuman;
}
//-------------------------------------------------------------- MyGotRequiredParams
// Have no clue! :)
OSErr MyGotRequiredParams (const AppleEvent *theAE)
{
DescType returnedType;
Size actualSize;
return (AEGetAttributePtr(theAE, keyMissedKeywordAttr, typeWildCard,
&returnedType, 0L, 0, &actualSize) == errAEDescNotFound) ? noErr :
errAEParamMissed;
}
//-------------------------------------------------------------- SetUpAppleEvents
// Initializes all handlers, etc. for dealing with Apple Events.
void SetUpAppleEvents (void)
{
OSErr theErr;
openAppAEUPP = NewAEEventHandlerProc(DoOpenAppAE);
openDocAEUPP = NewAEEventHandlerProc(DoOpenDocAE);
printDocAEUPP = NewAEEventHandlerProc(DoPrintDocAE);
quitAEUPP = NewAEEventHandlerProc(DoQuitAE);
theErr = AEInstallEventHandler(kCoreEventClass, // install oapp
kAEOpenApplication, openAppAEUPP, 0, false);
if (theErr != noErr)
YellowAlert(kYellowAppleEventErr, theErr);
theErr = AEInstallEventHandler(kCoreEventClass, // install odoc
kAEOpenDocuments, openDocAEUPP, 0, false);
if (theErr != noErr)
YellowAlert(kYellowAppleEventErr, theErr);
theErr = AEInstallEventHandler(kCoreEventClass, // install pdoc
kAEPrintDocuments, printDocAEUPP, 0, false);
if (theErr != noErr)
YellowAlert(kYellowAppleEventErr, theErr);
theErr = AEInstallEventHandler(kCoreEventClass, // install quit
kAEQuitApplication, quitAEUPP, 0, false);
if (theErr != noErr)
YellowAlert(kYellowAppleEventErr, theErr);
theErr = AESetInteractionAllowed(kAEInteractWithAll);
if (theErr != noErr)
YellowAlert(kYellowAppleEventErr, theErr);
}

238
GpApp/Banner.cpp Normal file
View File

@@ -0,0 +1,238 @@
//============================================================================
//----------------------------------------------------------------------------
// Banner.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "Room.h"
#include "Utilities.h"
#define kBannerPageTopPICT 1993
#define kBannerPageBottomPICT 1992
#define kBannerPageBottomMask 1991
#define kStarsRemainingPICT 1017
#define kStarRemainingPICT 1018
void DrawBanner (Point *);
void DrawBannerMessage (Point);
short numStarsRemaining;
Boolean bannerStarCountOn;
extern Rect justRoomsRect;
extern Boolean quickerTransitions, demoGoing, isUseSecondScreen;
//============================================================== Functions
//-------------------------------------------------------------- DrawBanner
// Displays opening banner (when a new game is begun). The banner looks<6B>
// like a sheet of notebook paper. The text printed on it is specified<65>
// by the author of the house.
void DrawBanner (Point *topLeft)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
Rect wholePage, partPage, mapBounds;
GWorldPtr tempMap;
GWorldPtr tempMask;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&wholePage, 0, 0, 330, 220);
mapBounds = thisMac.screen;
ZeroRectCorner(&mapBounds);
CenterRectInRect(&wholePage, &mapBounds);
topLeft->h = wholePage.left;
topLeft->v = wholePage.top;
partPage = wholePage;
partPage.bottom = partPage.top + 190;
SetGWorld(workSrcMap, nil);
LoadScaledGraphic(kBannerPageTopPICT, &partPage);
partPage = wholePage;
partPage.top = partPage.bottom - 30;
mapBounds = partPage;
ZeroRectCorner(&mapBounds);
theErr = CreateOffScreenGWorld(&tempMap, &mapBounds, kPreferredDepth);
SetGWorld(tempMap, nil);
LoadGraphic(kBannerPageBottomPICT);
theErr = CreateOffScreenGWorld(&tempMask, &mapBounds, 1);
SetGWorld(tempMask, nil);
LoadGraphic(kBannerPageBottomMask);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
(BitMap *)*GetGWorldPixMap(tempMask),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&mapBounds, &mapBounds, &partPage);
SetPort((GrafPtr)workSrcMap);
SetGWorld(wasCPort, wasWorld);
DisposeGWorld(tempMap);
DisposeGWorld(tempMask);
}
//-------------------------------------------------------------- CountStarsInHouse
// Goes through the current house and counts the total number of stars within.
short CountStarsInHouse (void)
{
short i, h, numRooms, numStars;
char wasState;
numStars = 0;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++)
{
if ((*thisHouse)->rooms[i].suite != kRoomIsEmpty)
for (h = 0; h < kMaxRoomObs; h++)
{
if ((*thisHouse)->rooms[i].objects[h].what == kStar)
numStars++;
}
}
HSetState((Handle)thisHouse, wasState);
return (numStars);
}
//-------------------------------------------------------------- DrawBannerMessage
// This function prints the author's message acorss the notebook paper banner.
void DrawBannerMessage (Point topLeft)
{
Str255 bannerStr, subStr;
short count;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
PasStringCopy((*thisHouse)->banner, bannerStr);
HSetState((Handle)thisHouse, wasState);
TextFont(applFont);
TextFace(bold);
TextSize(12);
ForeColor(blackColor);
count = 0;
do
{
GetLineOfText(bannerStr, count, subStr);
MoveTo(topLeft.h + 16, topLeft.v + 32 + (count * 20));
DrawString(subStr);
count++;
}
while (subStr[0] > 0);
if (bannerStarCountOn)
{
if (numStarsRemaining != 1)
GetLocalizedString(1, bannerStr);
else
GetLocalizedString(2, bannerStr);
NumToString((long)numStarsRemaining, subStr);
PasStringConcat(bannerStr, subStr);
if (numStarsRemaining != 1)
GetLocalizedString(3, subStr);
else
GetLocalizedString(4, subStr);
PasStringConcat(bannerStr, subStr);
ForeColor(redColor);
MoveTo(topLeft.h + 16, topLeft.v + 164);
DrawString(bannerStr);
MoveTo(topLeft.h + 16, topLeft.v + 180);
GetLocalizedString(5, subStr);
DrawString(subStr);
}
ForeColor(blackColor);
}
//-------------------------------------------------------------- BringUpBanner
// Handles bringing up displaying and disposing of the banner.
void BringUpBanner (void)
{
Rect wholePage;
Point topLeft;
DrawBanner(&topLeft);
DrawBannerMessage(topLeft);
// if (quickerTransitions)
// DissBitsChunky(&justRoomsRect); // was workSrcRect
// else
// DissBits(&justRoomsRect);
QSetRect(&wholePage, 0, 0, 330, 220);
QOffsetRect(&wholePage, topLeft.h, topLeft.v);
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&wholePage, &wholePage, srcCopy, nil);
if (demoGoing)
WaitForInputEvent(4);
else
WaitForInputEvent(15);
// if (quickerTransitions)
// DissBitsChunky(&justRoomsRect);
// else
// DissBits(&justRoomsRect);
}
//-------------------------------------------------------------- DisplayStarsRemaining
// This brings up a small message indicating the number of stars remaining<6E>
// in a house. It comes up when the player gets a star (the game is paused<65>
// and the user informed as to how many remain).
void DisplayStarsRemaining (void)
{
Rect src, bounds;
Str255 theStr;
SetPortWindowPort(mainWindow);
QSetRect(&bounds, 0, 0, 256, 64);
CenterRectInRect(&bounds, &thisMac.screen);
QOffsetRect(&bounds, -thisMac.screen.left, -thisMac.screen.top);
src = bounds;
InsetRect(&src, 64, 32);
TextFont(applFont);
TextFace(bold);
TextSize(12);
NumToString((long)numStarsRemaining, theStr);
QOffsetRect(&bounds, 0, -20);
if (numStarsRemaining < 2)
LoadScaledGraphic(kStarRemainingPICT, &bounds);
else
{
LoadScaledGraphic(kStarsRemainingPICT, &bounds);
MoveTo(bounds.left + 102 - (StringWidth(theStr) / 2), bounds.top + 23);
ColorText(theStr, 4L);
}
DelayTicks(60);
if (WaitForInputEvent(30))
RestoreEntireGameScreen();
CopyRectWorkToMain(&bounds);
}

225
GpApp/ColorUtils.cpp Normal file
View File

@@ -0,0 +1,225 @@
//============================================================================
//----------------------------------------------------------------------------
// ColorUtils.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "PLPalettes.h"
#include "PLPasStr.h"
//============================================================== Functions
//-------------------------------------------------------------- ColorText
// Given a string and a color index (index into the current palette),<2C>
// this function draws text in that color. It assumes the current port,<2C>
// the current font, the current pen location, etc.
void ColorText (StringPtr theStr, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
DrawString(theStr);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- ColorRect
// Given a rectangle and color index, this function draws a solid<69>
// rectangle in that color. Current port, pen mode, etc. assumed.
void ColorRect (Rect *theRect, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(theRect);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- ColorOval
// Given a rectangle and color index, this function draws a solid<69>
// oval in that color. Current port, pen mode, etc. assumed.
void ColorOval (Rect *theRect, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintOval(theRect);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- ColorRegion
// Given a region and color index, this function draws a solid<69>
// region in that color. Current port, pen mode, etc. assumed.
void ColorRegion (RgnHandle theRgn, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRgn(theRgn);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- ColorLine
// Given a the end points for a line and color index, this function<6F>
// draws a line in that color. Current port, pen mode, etc. assumed.
void ColorLine (short h0, short v0, short h1, short v1, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
MoveTo(h0, v0);
LineTo(h1, v1);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- HiliteRect
// Given a rect and two hilite colors, this function frames the top and<6E>
// left edges of the rect with color 1 and frames the bottom and right<68>
// sides with color 2. A rect can be made to appear "hi-lit" or "3D"<22>
// in this way.
void HiliteRect (Rect *theRect, short color1, short color2)
{
ColorLine(theRect->left, theRect->top, theRect->right - 2,
theRect->top, color1);
ColorLine(theRect->left, theRect->top, theRect->left,
theRect->bottom - 2, color1);
ColorLine(theRect->right - 1, theRect->top, theRect->right - 1,
theRect->bottom - 2, color2);
ColorLine(theRect->left + 1, theRect->bottom - 1, theRect->right - 1,
theRect->bottom - 1, color2);
}
//-------------------------------------------------------------- ColorFrameRect
// Given a rectangle and color index, this function frames a<>
// rectangle in that color. Current port, pen mode, etc. assumed.
void ColorFrameRect (Rect *theRect, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
FrameRect(theRect);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- ColorFrameWHRect
// Given a the top-left corner of a rectangle, its width and height,<2C>
// and a color index, this function frames a rectangle in that color.
// Current port, pen mode, etc. assumed.
void ColorFrameWHRect (short left, short top, short wide, short high, long color)
{
Rect theRect;
theRect.left = left;
theRect.top = top;
theRect.right = left + wide;
theRect.bottom = top + high;
ColorFrameRect(&theRect, color);
}
//-------------------------------------------------------------- ColorFrameOval
// Given a rectangle and color index, this function frames an<61>
// oval in that color. Current port, pen mode, etc. assumed.
void ColorFrameOval (Rect *theRect, long color)
{
RGBColor theRGBColor, wasColor;
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
FrameOval(theRect);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- LtGrayForeColor
// This function finds the closest match to a "light gray" in the<68>
// current palette and sets the pen color to that.
void LtGrayForeColor (void)
{
RGBColor color;
color.red = (unsigned short) 0xBFFF;
color.green = (unsigned short) 0xBFFF;
color.blue = (unsigned short) 0xBFFF;
RGBForeColor(&color);
}
//-------------------------------------------------------------- GrayForeColor
// This function finds the closest match to a "medium gray" in the<68>
// current palette and sets the pen color to that.
void GrayForeColor (void)
{
RGBColor color;
color.red = (unsigned short) 0x7FFF;
color.green = (unsigned short) 0x7FFF;
color.blue = (unsigned short) 0x7FFF;
RGBForeColor(&color);
}
//-------------------------------------------------------------- DkGrayForeColor
// This function finds the closest match to a "dark gray" in the<68>
// current palette and sets the pen color to that.
void DkGrayForeColor (void)
{
RGBColor color;
color.red = (unsigned short) 0x3FFF;
color.green = (unsigned short) 0x3FFF;
color.blue = (unsigned short) 0x3FFF;
RGBForeColor(&color);
}
//-------------------------------------------------------------- RestoreColorsSlam
// This function forces the Macintosh to rebuild the palette. It is<69>
// called to restore a sense or normality after some serious munging<6E>
// with the palette.
void RestoreColorsSlam (void)
{
RestoreDeviceClut(nil);
PaintBehind(nil, GetGrayRgn());
DrawMenuBar();
}

197
GpApp/Coordinates.cpp Normal file
View File

@@ -0,0 +1,197 @@
//============================================================================
//----------------------------------------------------------------------------
// Coordinates.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "Marquee.h"
#include "ObjectEdit.h"
#include "RectUtils.h"
Rect coordWindowRect;
WindowPtr coordWindow;
short isCoordH, isCoordV;
short coordH, coordV, coordD;
Boolean isCoordOpen;
//============================================================== Functions
//-------------------------------------------------------------- SetCoordinateHVD
// Given a horizontal, vertical and distance value, this function<6F>
// displays these values in the Coordinates window.
void SetCoordinateHVD (short h, short v, short d)
{
#ifndef COMPILEDEMO
if (h != -2)
coordH = h;
if (v != -2)
coordV = v;
if (d != -2)
coordD = d;
UpdateCoordWindow();
#endif
}
//-------------------------------------------------------------- DeltaCoordinateD
// When the user is dragging a handle (such as the height of a blower)<29>
// this function can be called and passed the amount by which the user<65>
// has changed the height (delta). This function then displays it in<69>
// the Coordinate window.
void DeltaCoordinateD (short d)
{
#ifndef COMPILEDEMO
coordD = d;
UpdateCoordWindow();
#endif
}
//-------------------------------------------------------------- UpdateCoordWindow
// Completely redraws and updates the Coordinate window.
void UpdateCoordWindow (void)
{
#ifndef COMPILEDEMO
Str255 tempStr, numStr;
GrafPtr wasPort;
if (coordWindow == nil)
return;
GetPort(&wasPort);
SetPort((GrafPtr)coordWindow);
EraseRect(&coordWindowRect);
PasStringCopy(PSTR("h: "), tempStr);
if (coordH != -1)
{
NumToString((long)coordH, numStr);
PasStringConcat(tempStr, numStr);
}
else
PasStringConcat(tempStr, PSTR("-"));
MoveTo(5, 12);
DrawString(tempStr);
PasStringCopy(PSTR("v: "), tempStr);
if (coordV != -1)
{
NumToString((long)coordV, numStr);
PasStringConcat(tempStr, numStr);
}
else
PasStringConcat(tempStr, PSTR("-"));
MoveTo(4, 22);
DrawString(tempStr);
ForeColor(blueColor);
PasStringCopy(PSTR("d: "), tempStr);
if (coordD != -1)
{
NumToString((long)coordD, numStr);
PasStringConcat(tempStr, numStr);
}
else
PasStringConcat(tempStr, PSTR("-"));
MoveTo(5, 32);
DrawString(tempStr);
ForeColor(blackColor);
SetPort((GrafPtr)wasPort);
#endif
}
//-------------------------------------------------------------- OpenCoordWindow
// Brings up the Coordinate window.
void OpenCoordWindow (void)
{
#ifndef COMPILEDEMO
Rect src, dest;
Point globalMouse;
short direction, dist;
if (coordWindow == nil)
{
QSetRect(&coordWindowRect, 0, 0, 50, 38);
if (thisMac.hasColor)
coordWindow = NewCWindow(nil, &coordWindowRect,
PSTR("Tools"), false, kWindoidWDEF, kPutInFront, true, 0L);
else
coordWindow = NewWindow(nil, &coordWindowRect,
PSTR("Tools"), false, kWindoidWDEF, kPutInFront, true, 0L);
if (coordWindow == nil)
RedAlert(kErrNoMemory);
// if (OptionKeyDown())
// {
// isCoordH = qd.screenBits.bounds.right - 55;
// isCoordV = 204;
// }
MoveWindow(coordWindow, isCoordH, isCoordV, true);
globalMouse = MyGetGlobalMouse();
QSetRect(&src, 0, 0, 1, 1);
QOffsetRect(&src, globalMouse.h, globalMouse.v);
GetWindowRect(coordWindow, &dest);
BringToFront(coordWindow);
ShowHide(coordWindow, true);
// FlagWindowFloating(coordWindow); TEMP - use flaoting windows
HiliteAllWindows();
coordH = -1;
coordV = -1;
coordD = -1;
TextFace(applFont);
TextSize(9);
if (objActive != kNoObjectSelected)
{
if (ObjectHasHandle(&direction, &dist))
coordD = dist;
SetCoordinateHVD(theMarquee.bounds.left, theMarquee.bounds.top, coordD);
}
}
UpdateCoordinateCheckmark(true);
#endif
}
//-------------------------------------------------------------- CloseCoordWindow
// Closes and disposes of the Coordinate window.
void CloseCoordWindow (void)
{
CloseThisWindow(&coordWindow);
UpdateCoordinateCheckmark(false);
}
//-------------------------------------------------------------- ToggleCoordinateWindow
// Toggles the Coordinate windows state between open and closed.
void ToggleCoordinateWindow (void)
{
#ifndef COMPILEDEMO
if (coordWindow == nil)
{
OpenCoordWindow();
isCoordOpen = true;
}
else
{
CloseCoordWindow();
isCoordOpen = false;
}
#endif
}

0
Sources/DebugUtilities.c → GpApp/DebugUtilities.c Executable file → Normal file
View File

807
GpApp/DialogUtils.cpp Normal file
View File

@@ -0,0 +1,807 @@
//============================================================================
//----------------------------------------------------------------------------
// DialogUtils.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLControlDefinitions.h"
#include "PLLowMem.h"
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "DialogUtils.h"
#include "Externs.h"
#define kActive 0
#define kInactive 255
//============================================================== Functions
//-------------------------------------------------------------- BringUpDialog
// Given a dialog pointer and a resource ID, this function brings it up<75>
// centered, visible, and with the default button outlined.
void BringUpDialog (DialogPtr *theDialog, short dialogID)
{
// CenterDialog(dialogID);
*theDialog = GetNewDialog(dialogID, nil, kPutInFront);
if (*theDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort((GrafPtr)*theDialog);
ShowWindow(GetDialogWindow(*theDialog));
DrawDefaultButton(*theDialog);
}
//-------------------------------------------------------------- GetPutDialogCorner
// Determines the upper left corner coordinates needed to properly center<65>
// the standard Mac PutFile dialog (when you save files).
/*
void GetPutDialogCorner (Point *theCorner)
{
DialogTHndl dlogHandle;
Rect theScreen, dlogBounds;
Byte wasState;
theCorner->h = 64;
theCorner->v = 64;
theScreen = qd.screenBits.bounds;
theScreen.top += LMGetMBarHeight();
OffsetRect(&theScreen, -theScreen.left, -theScreen.top);
dlogHandle = (DialogTHndl)GetResource('DLOG', sfPutDialogID);
if (dlogHandle != nil)
{
wasState = HGetState((Handle)dlogHandle);
HLock((Handle)dlogHandle);
dlogBounds = (**dlogHandle).boundsRect;
OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top);
theCorner->h = (theScreen.right - dlogBounds.right) / 2;
theCorner->v = (theScreen.bottom - dlogBounds.bottom) / 3;
HSetState((Handle)dlogHandle, wasState);
}
theCorner->v += LMGetMBarHeight();
}
*/
//-------------------------------------------------------------- GetPutDialogCorner
// Determines the upper left corner coordinates needed to properly center<65>
// the standard Mac GetFile dialog (when you open files).
/*
void GetGetDialogCorner (Point *theCorner)
{
DialogTHndl dlogHandle;
Rect theScreen, dlogBounds;
Byte wasState;
theCorner->h = 64;
theCorner->v = 64;
theScreen = qd.screenBits.bounds;
theScreen.top += LMGetMBarHeight();
OffsetRect(&theScreen, -theScreen.left, -theScreen.top);
dlogHandle = (DialogTHndl)GetResource('DLOG', sfGetDialogID);
if (dlogHandle != nil)
{
wasState = HGetState((Handle)dlogHandle);
HLock((Handle)dlogHandle);
dlogBounds = (**dlogHandle).boundsRect;
OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top);
theCorner->h = (theScreen.right - dlogBounds.right) / 2;
theCorner->v = (theScreen.bottom - dlogBounds.bottom) / 3;
HSetState((Handle)dlogHandle, wasState);
}
theCorner->v += LMGetMBarHeight();
}
*/
//-------------------------------------------------------------- CenterDialog
// Given a resource ID for a dialog, this function properly centers it.
/*
void CenterDialog (SInt16 dialogID)
{
DialogTHndl dlogHandle;
Rect theScreen, dlogBounds;
SInt16 hPos, vPos;
Byte wasState;
theScreen = qd.screenBits.bounds;
theScreen.top += LMGetMBarHeight();
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
if (dlogHandle != nil)
{
wasState = HGetState((Handle)dlogHandle);
HLock((Handle)dlogHandle);
dlogBounds = (**dlogHandle).boundsRect;
OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top);
hPos = ((theScreen.right - theScreen.left) - dlogBounds.right) / 2;
vPos = ((theScreen.bottom - theScreen.top) - dlogBounds.bottom) / 3;
OffsetRect(&dlogBounds, hPos, vPos + LMGetMBarHeight());
(**dlogHandle).boundsRect = dlogBounds;
HSetState((Handle)dlogHandle, wasState);
}
}
*/
//-------------------------------------------------------------- GetDialogRect
// Determines the bounding rectangle for a given dialog.
void GetDialogRect (Rect *bounds, short dialogID)
{
DialogTHndl dlogHandle;
Byte wasState;
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
if (dlogHandle != nil)
{
wasState = HGetState((Handle)dlogHandle);
HLock((Handle)dlogHandle);
*bounds = (**dlogHandle).boundsRect;
HSetState((Handle)dlogHandle, wasState);
}
}
//-------------------------------------------------------------- TrueCenterDialog
// Places a dialog DEAD CENTER (as opposed to 1/3 of the way down as<61>
// is common for Mac dialog centering).
/*
void TrueCenterDialog (short dialogID)
{
DialogTHndl dlogHandle;
Rect theScreen, dlogBounds;
short hPos, vPos;
Byte wasState;
theScreen = qd.screenBits.bounds;
theScreen.top += LMGetMBarHeight();
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
if (dlogHandle != nil)
{
wasState = HGetState((Handle)dlogHandle);
HLock((Handle)dlogHandle);
dlogBounds = (**dlogHandle).boundsRect;
OffsetRect(&dlogBounds, theScreen.left - dlogBounds.left,
theScreen.top - dlogBounds.top);
hPos = ((theScreen.right - theScreen.left) -
(dlogBounds.right - dlogBounds.left)) / 2;
vPos = ((theScreen.bottom - theScreen.top) -
(dlogBounds.bottom - dlogBounds.top)) / 2;
OffsetRect(&dlogBounds, hPos, vPos + LMGetMBarHeight());
(**dlogHandle).boundsRect = dlogBounds;
HSetState((Handle)dlogHandle, wasState);
}
}
*/
//-------------------------------------------------------------- CenterAlert
// Given an alert ID, this function properly centers it on the main monitor.
/*
void CenterAlert (short alertID)
{
AlertTHndl alertHandle;
Rect theScreen, alertRect;
short horiOff, vertOff;
Byte wasState;
theScreen = qd.screenBits.bounds;
theScreen.top += LMGetMBarHeight();
alertHandle = (AlertTHndl)GetResource('ALRT', alertID);
if (alertHandle != nil)
{
wasState = HGetState((Handle)alertHandle);
HLock((Handle)alertHandle);
alertRect = (**alertHandle).boundsRect;
OffsetRect(&alertRect, -alertRect.left, -alertRect.top);
horiOff = ((theScreen.right - theScreen.left) - alertRect.right) / 2;
vertOff = ((theScreen.bottom - theScreen.top) - alertRect.bottom) / 3;
OffsetRect(&alertRect, horiOff, vertOff + LMGetMBarHeight());
(**alertHandle).boundsRect = alertRect;
HSetState((Handle)alertHandle, wasState);
}
}
*/
//-------------------------------------------------------------- ZoomOutDialogRect
// Given a dialog, this function does the "zoom" animation to make the<68>
// the dialog appear to expand from nothingness or zoom in at you.
/*
void ZoomOutDialogRect (short dialogID)
{
#define kSteps 16
#define kZoomDelay 1
DialogTHndl dlogHandle;
GrafPtr wasPort, tempPort;
Rect dlogBounds, zoomRect;
UInt32 dummyLong;
Byte wasState;
short wideStep, highStep, i;
GetPort(&wasPort);
tempPort = (GrafPtr)NewPtrClear(sizeof(GrafPort));
OpenPort(tempPort);
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
if (dlogHandle != nil)
{
wasState = HGetState((Handle)dlogHandle);
HLock((Handle)dlogHandle);
dlogBounds = (**dlogHandle).boundsRect;
HSetState((Handle)dlogHandle, wasState);
}
wideStep = ((dlogBounds.right - dlogBounds.left) / 2) / kSteps;
highStep = ((dlogBounds.bottom - dlogBounds.top) / 2) / kSteps;
SetRect(&zoomRect, dlogBounds.left + (wideStep * kSteps),
dlogBounds.top + (highStep * kSteps),
dlogBounds.right - (wideStep * kSteps),
dlogBounds.bottom - (highStep * kSteps));
GlobalToLocalRect(&zoomRect);
PenPat(GetQDGlobalsGray(&dummyPattern));
PenMode(patXor);
for (i = 0; i < kSteps; i++)
{
FrameRect(&zoomRect);
Delay(kZoomDelay, &dummyLong);
FrameRect(&zoomRect);
InsetRect(&zoomRect, -wideStep, -highStep);
}
ClosePort(tempPort);
SetPort((GrafPtr)wasPort);
}
*/
//-------------------------------------------------------------- ZoomOutAlertRect
// Like the above funciton but zooms out alerts instead of dialogs.
/*
void ZoomOutAlertRect (short alertID)
{
#define kSteps 16
#define kZoomDelay 1
AlertTHndl alertHandle;
GrafPtr wasPort, tempPort;
Rect alertBounds, zoomRect;
UInt32 dummyLong;
Byte wasState;
short wideStep, highStep, i;
GetPort(&wasPort);
tempPort = (GrafPtr)NewPtrClear(sizeof(GrafPort));
OpenPort(tempPort);
alertHandle = (AlertTHndl)GetResource('ALRT', alertID);
if (alertHandle != nil)
{
wasState = HGetState((Handle)alertHandle);
HLock((Handle)alertHandle);
alertBounds = (**alertHandle).boundsRect;
HSetState((Handle)alertHandle, wasState);
}
wideStep = ((alertBounds.right - alertBounds.left) / 2) / kSteps;
highStep = ((alertBounds.bottom - alertBounds.top) / 2) / kSteps;
SetRect(&zoomRect, alertBounds.left + (wideStep * kSteps),
alertBounds.top + (highStep * kSteps),
alertBounds.right - (wideStep * kSteps),
alertBounds.bottom - (highStep * kSteps));
GlobalToLocalRect(&zoomRect);
PenPat(GetQDGlobalsGray(&dummyPattern));
PenMode(patXor);
for (i = 0; i < kSteps; i++)
{
FrameRect(&zoomRect);
Delay(kZoomDelay, &dummyLong);
FrameRect(&zoomRect);
InsetRect(&zoomRect, -wideStep, -highStep);
}
ClosePort(tempPort);
SetPort((GrafPtr)wasPort);
}
*/
//-------------------------------------------------------------- FlashDialogButton
// Flashes the default dialog button (item = 1) so as to make it appear<61>
// as though the user clicked on it.
void FlashDialogButton (DialogPtr theDialog, short itemNumber)
{
Rect itemRect;
Handle itemHandle;
UInt32 dummyLong;
short itemType;
GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemRect);
HiliteControl((ControlHandle)itemHandle, kControlButtonPart);
Delay(8, &dummyLong);
HiliteControl((ControlHandle)itemHandle, 0);
}
//-------------------------------------------------------------- DrawDefaultButton
// Draws a fat outline around the default item (item = 1). This is the<68>
// item that is selected if the user hits the Return key.
void DrawDefaultButton (DialogPtr theDialog)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, 1, &itemType, &itemHandle, &itemRect);
InsetRect(&itemRect, -4, -4);
PenSize(3, 3);
FrameRoundRect(&itemRect, 16, 16);
PenNormal();
}
//-------------------------------------------------------------- GetDialogString
// Returns a string from a specific dialog item.
void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetDialogItemText(itemHandle, theString);
}
//-------------------------------------------------------------- SetDialogString
// Sets a specific string to a specific dialog item.
void SetDialogString (DialogPtr theDialog, short item, const PLPasStr &theString)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
SetDialogItemText(itemHandle, theString);
}
//-------------------------------------------------------------- GetDialogStringLen
// Returns the length of a dialog item string (text).
short GetDialogStringLen (DialogPtr theDialog, short item)
{
Rect itemRect;
Str255 theString;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetDialogItemText(itemHandle, theString);
return (theString[0]);
}
//-------------------------------------------------------------- GetDialogItemValue
// Returns the value or "state" of a dialog item. For checkboxes and<6E>
// radio buttons, this may be a 1 or 0.
void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
*theState = GetControlValue((ControlHandle)itemHandle);
}
//-------------------------------------------------------------- SetDialogItemValue
// Sets a specific dialogf items value or state (can set or clear<61>
// checkboxes, radio buttons, etc.).
void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
SetControlValue((ControlHandle)itemHandle, theState);
}
//-------------------------------------------------------------- ToggleDialogItemValue
// If item is a checkbox or radio button, its state is toggled.
void ToggleDialogItemValue (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType, theState;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
theState = GetControlValue((ControlHandle)itemHandle);
if (theState == 0)
theState = 1;
else
theState = 0;
SetControlValue((ControlHandle)itemHandle, theState);
}
//-------------------------------------------------------------- SetDialogNumToStr
// Function accepts an integer, converts it to a string and sets a<>
// dialog items text to this string.
void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber)
{
Str255 theString;
Rect itemRect;
Handle itemHandle;
short itemType;
NumToString(theNumber, theString);
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
SetDialogItemText(itemHandle, theString);
}
//-------------------------------------------------------------- GetDialogNumFromStr
// Function extracts the text from a dialog item and converts it to an<61>
// integer for returning.
void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
{
Str255 theString;
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetDialogItemText(itemHandle, theString);
StringToNum(theString, theNumber);
}
//-------------------------------------------------------------- GetDialogItemRect
// Returns the bounding rectangle of the specified dialog item.
void GetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
{
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, theRect);
}
//-------------------------------------------------------------- SetDialogItemRect
// Sets the bounding rectangle of the specified dialog item. Used to<74>
// resize or move a control.
void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
{
Rect oldRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
OffsetRect(&oldRect, theRect->left - oldRect.left, theRect->top - oldRect.top);
SetDialogItem(theDialog, item, itemType, itemHandle, &oldRect);
}
//-------------------------------------------------------------- OffsetDialogItemRect
// Moves a dialog item by h and v.
void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
{
Rect oldRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
OffsetRect(&oldRect, h, v);
SetDialogItem(theDialog, item, itemType, itemHandle, &oldRect);
}
//-------------------------------------------------------------- SelectFromRadioGroup
// Assuming a series of consecutively numbered radio buttons, this function<6F>
// clears the whole range of them but sets the one specified (as though<67>
// the radio buttons are linked and only one can be set at a time).
void SelectFromRadioGroup (DialogPtr dial, short which, short first, short last)
{
Rect iRect;
Handle iHandle;
short iType, i;
for (i = first; i <= last; i++)
{
GetDialogItem(dial, i, &iType, &iHandle, &iRect);
SetControlValue((ControlHandle)iHandle, (short)false);
}
GetDialogItem(dial, which, &iType, &iHandle, &iRect);
SetControlValue((ControlHandle)iHandle, (short)true);
}
//-------------------------------------------------------------- AddMenuToPopUp
// Assigns a menu handle to a pop-up dialog item - thus, giving that<61>
// pop-up item something to pop up.
/*
void AddMenuToPopUp (DialogPtr theDialog, short whichItem, MenuHandle theMenu)
{
Rect iRect;
Handle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
(**(ControlHandle)iHandle).contrlRfCon = (long)theMenu;
}
*/
//-------------------------------------------------------------- GetPopUpMenuValu
// Returns which item is currently selected in a pop-up menu.
void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
{
Rect iRect;
Handle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
*value = GetControlValue((ControlHandle)iHandle);
}
//-------------------------------------------------------------- SetPopUpMenuValue
// Forces a specific item to be set (as though selected) in a pop-up menu.
void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
{
Rect iRect;
Handle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
SetControlValue((ControlHandle)iHandle, value);
}
//-------------------------------------------------------------- MyEnableControl
// "Un-grays" or enables a dialog item (usually a button).
void MyEnableControl (DialogPtr theDialog, short whichItem)
{
Rect iRect;
Handle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
HiliteControl((ControlHandle)iHandle, kActive);
}
//-------------------------------------------------------------- MyDisableControl
// "Grays out" or disables a dialog item (usually a button).
void MyDisableControl (DialogPtr theDialog, short whichItem)
{
Rect iRect;
Handle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
HiliteControl((ControlHandle)iHandle, kInactive);
}
//-------------------------------------------------------------- DrawDialogUserText
// Given a string of text and an item, this function draws the string<6E>
// within the bounding rect of the item. Dialog item assumed to be<62>
// a "user item" (invisible item with only bounds).
void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean invert)
{
Rect iRect;
Handle iHandle;
Str255 newString, stringCopy;
short iType, textLong, i, inset;
TextFont(applFont);
TextSize(9);
PasStringCopy(text, stringCopy);
GetDialogItem(dial, item, &iType, &iHandle, &iRect);
if ((StringWidth(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(stringCopy, iRect.right - iRect.left - 2);
textLong = stringCopy[0];
for (i = 0; i < textLong; i++)
newString[i] = stringCopy[i + 1];
OffsetRect(&iRect, 0, 1);
EraseRect(&iRect);
OffsetRect(&iRect, 0, -1);
inset = ((iRect.right - iRect.left) - (StringWidth(stringCopy) + 2)) / 2;
iRect.left += inset;
iRect.right -= inset;
TETextBox(newString, textLong, &iRect, teCenter);
if (invert)
{
OffsetRect(&iRect, 0, 1);
InvertRect(&iRect);
}
}
//-------------------------------------------------------------- DrawDialogUserText
// Similar to the above function but doesn't call TETextBox(). Instead,<2C>
// it truncates the string (and appends "<22>") to the end in order that<61>
// the string fits within the dialog item's bounds.
void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
{
Rect iRect;
Handle iHandle;
Str255 stringCopy;
short iType;
TextFont(applFont);
TextSize(9);
PasStringCopy(text, stringCopy);
GetDialogItem(dial, item, &iType, &iHandle, &iRect);
if ((StringWidth(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(stringCopy, iRect.right - iRect.left - 2);
MoveTo(iRect.left, iRect.bottom);
DrawString(stringCopy);
}
//-------------------------------------------------------------- LoadDialogPICT
// Draws a 'PICT' specified by ID within the bounds of the specified<65>
// dialog item.
void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
{
Rect iRect;
Handle iHandle;
PicHandle thePict;
short iType;
GetDialogItem(theDialog, item, &iType, &iHandle, &iRect);
thePict = GetPicture(theID);
if (thePict)
DrawPicture(thePict, &iRect);
}
//-------------------------------------------------------------- FrameDialogItem
// Given a dialog item, this function draws a box around it.
void FrameDialogItem (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
FrameRect(&itemRect);
}
//-------------------------------------------------------------- FrameDialogItemC
// Given a dialog item, this function draws a color (specified) box around it.
void FrameDialogItemC (DialogPtr theDialog, short item, long color)
{
RGBColor theRGBColor, wasColor;
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetForeColor(&wasColor);
Index2Color(color, &theRGBColor);
RGBForeColor(&theRGBColor);
FrameRect(&itemRect);
RGBForeColor(&wasColor);
}
//-------------------------------------------------------------- FrameOvalDialogItem
// Given a dialog item, this function draws an oval around it.
void FrameOvalDialogItem (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
FrameOval(&itemRect);
}
//-------------------------------------------------------------- BorderDialogItem
// Given a dialog item, this function draws any combination of 4 sides<65>
// of a box around it. Which sides get drawn is encoded in "sides".
void BorderDialogItem (DialogPtr theDialog, short item, short sides)
{
Rect itemRect;
Handle itemHandle;
short itemType;
// 1 = left
// 2 = top
// 4 = bottom
// 8 = right ... so 6 = top & bottom, 15 = all 4 sides
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
if (sides >= 8) // 8 = right
{
MoveTo(itemRect.right, itemRect.top);
LineTo(itemRect.right, itemRect.bottom);
sides -= 8;
}
if (sides >= 4) // 4 = bottom
{
MoveTo(itemRect.left, itemRect.bottom);
LineTo(itemRect.right, itemRect.bottom);
sides -= 4;
}
if (sides >= 2) // 2 = top
{
MoveTo(itemRect.left, itemRect.top - 1);
LineTo(itemRect.right, itemRect.top - 1);
sides -= 2;
}
if (sides >= 1) // 1 = left
{
MoveTo(itemRect.left - 1, itemRect.top);
LineTo(itemRect.left - 1, itemRect.bottom);
}
}
//-------------------------------------------------------------- ShadowDialogItem
// Draws a drop shadow to the right and below a specified dialog item.
void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
PenSize(thickness, thickness);
MoveTo(itemRect.left + thickness, itemRect.bottom);
Line(itemRect.right - itemRect.left - thickness, 0);
MoveTo(itemRect.right, itemRect.top + thickness);
Line(0, itemRect.bottom - itemRect.top - thickness);
PenNormal();
}
//-------------------------------------------------------------- EraseDialogItem
// Erases (but doesn't physically remove) a dialog item.
void EraseDialogItem (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
EraseRect(&itemRect);
}

47
GpApp/DialogUtils.h Normal file
View File

@@ -0,0 +1,47 @@
//============================================================================
//----------------------------------------------------------------------------
// DialogUtils.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLDialogs.h"
void BringUpDialog (DialogPtr *theDialog, short dialogID);
//void GetPutDialogCorner (Point *);
//void GetGetDialogCorner (Point *);
//void CenterDialog (short);
void GetDialogRect (Rect *, short);
//void TrueCenterDialog (short);
//void CenterAlert (short);
//void ZoomOutDialogRect (short);
//void ZoomOutAlertRect (short);
void FlashDialogButton (DialogPtr, short);
void DrawDefaultButton (DialogPtr);
void GetDialogString (DialogPtr, short, StringPtr);
void SetDialogString (DialogPtr, short, const PLPasStr&);
short GetDialogStringLen (DialogPtr, short);
void GetDialogItemValue (DialogPtr, short, short *);
void SetDialogItemValue (DialogPtr, short, short);
void ToggleDialogItemValue (DialogPtr, short);
void SetDialogNumToStr (DialogPtr, short, long);
void GetDialogNumFromStr (DialogPtr, short, long *);
void GetDialogItemRect (DialogPtr, short, Rect *);
void SetDialogItemRect (DialogPtr, short, Rect *);
void OffsetDialogItemRect (DialogPtr, short, short, short);
void SelectFromRadioGroup (DialogPtr, short, short, short);
//void AddMenuToPopUp (DialogPtr, short, MenuHandle);
void GetPopUpMenuValue (DialogPtr, short, short *);
void SetPopUpMenuValue (DialogPtr, short, short);
void MyEnableControl(DialogPtr, short);
void MyDisableControl(DialogPtr, short);
void DrawDialogUserText (DialogPtr, short, StringPtr, Boolean);
void DrawDialogUserText2 (DialogPtr, short, StringPtr);
void LoadDialogPICT (DialogPtr, short, short);
void FrameDialogItem (DialogPtr, short);
void FrameDialogItemC (DialogPtr, short, long);
void FrameOvalDialogItem (DialogPtr, short);
void BorderDialogItem (DialogPtr, short, short);
void ShadowDialogItem (DialogPtr, short, short);
void EraseDialogItem (DialogPtr, short);

798
GpApp/DynamicMaps.cpp Normal file
View File

@@ -0,0 +1,798 @@
//============================================================================
//----------------------------------------------------------------------------
// DynamicMaps.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "RectUtils.h"
#include "Room.h"
#include "Utilities.h"
void BackUpFlames (Rect *, short);
void BackUpTikiFlames (Rect *, short);
void BackUpBBQCoals (Rect *, short);
void BackUpPendulum (Rect *, short);
void BackUpStar (Rect *, short);
sparklePtr sparkles;
flyingPtPtr flyingPoints;
flamePtr flames, tikiFlames, bbqCoals;
pendulumPtr pendulums;
starPtr theStars;
shredPtr shreds;
Rect pointsSrc[15];
short numSparkles, numFlyingPts, numChimes;
short numFlames, numSavedMaps, numTikiFlames, numCoals;
short numPendulums, clockFrame, numStars, numShredded;
extern savedType savedMaps[];
extern Rect flame[], tikiFlame[], coals[], pendulumSrc[];
extern Rect starSrc[];
extern short numGrease, numDynamics;
//============================================================== Functions
//-------------------------------------------------------------- NilSavedMaps
// Deletes array of "dyanmics" offscreen pixmaps.
void NilSavedMaps (void)
{
short i;
for (i = 0; i < kMaxSavedMaps; i++)
{
if (savedMaps[i].map != nil)
{
DisposeGWorld(savedMaps[i].map);
// KillOffScreenPixMap(savedMaps[i].map);
savedMaps[i].map = nil;
}
savedMaps[i].where = -1;
savedMaps[i].who = -1;
}
numSavedMaps = 0;
}
//-------------------------------------------------------------- BackUpToSavedMap
// Saves a copy of the room behind an object to an array of pixmaps.
// Then when the object in question is drawn, there is a copy of the<68>
// room that it obscured so that, should the player get the object,<2C>
// it can be made to "disappear".
short BackUpToSavedMap (Rect *theRect, short where, short who)
{
Rect mapRect;
OSErr theErr;
if (numSavedMaps >= kMaxSavedMaps)
return(-1);
mapRect = *theRect;
ZeroRectCorner(&mapRect);
savedMaps[numSavedMaps].dest = *theRect;
// CreateOffScreenPixMap(&mapRect, &savedMaps[numSavedMaps].map);
theErr = CreateOffScreenGWorld(&savedMaps[numSavedMaps].map, &mapRect, kPreferredDepth);
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[numSavedMaps].map),
theRect, &mapRect, srcCopy, nil);
savedMaps[numSavedMaps].where = where;
savedMaps[numSavedMaps].who = who;
numSavedMaps++;
return (numSavedMaps - 1); // return array index
}
//-------------------------------------------------------------- ReBackUpSavedMap
// This function is similar to the above, but assumes there is already<64>
// a slot in the pixmap array for the object. It re-copies the background<6E>
// and is needed when the lights in the room go on or off.
short ReBackUpSavedMap (Rect *theRect, short where, short who)
{
Rect mapRect;
short i, foundIndex;
foundIndex = -1;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
{
foundIndex = i;
mapRect = *theRect;
ZeroRectCorner(&mapRect);
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[foundIndex].map),
theRect, &mapRect, srcCopy, nil);
return (foundIndex);
}
}
return (foundIndex);
}
//-------------------------------------------------------------- RestoreFromSavedMap
// This copies the saved background swatch to the screen - effectively<6C>
// covering up or "erasing" the object.
void RestoreFromSavedMap (short where, short who, Boolean doSparkle)
{
Rect mapRect, bounds;
short i;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who) &&
(savedMaps[i].map != nil))
{
mapRect = savedMaps[i].dest;
ZeroRectCorner(&mapRect);
CopyBits(GetPortBitMapForCopyBits(savedMaps[i].map),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&mapRect, &savedMaps[i].dest, srcCopy, nil);
CopyBits(GetPortBitMapForCopyBits(savedMaps[i].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&mapRect, &savedMaps[i].dest, srcCopy, nil);
AddRectToWorkRects(&savedMaps[i].dest);
if (doSparkle)
{
bounds = savedMaps[i].dest;
QOffsetRect(&bounds, -playOriginH, -playOriginV);
AddSparkle(&bounds);
PlayPrioritySound(kFadeOutSound, kFadeOutPriority);
}
break;
}
}
}
//-------------------------------------------------------------- AddSparkle
// This adds a "sparkle" object to the fixed array of sparkles.
void AddSparkle (Rect *theRect)
{
Rect centeredRect;
short i;
if (numSparkles < kMaxSparkles)
{
theRect->left += playOriginH;
theRect->right += playOriginH;
theRect->top += playOriginV;
theRect->bottom += playOriginV;
centeredRect = sparkleSrc[0];
CenterRectInRect(&centeredRect, theRect);
for (i = 0; i < kMaxSparkles; i++)
if (sparkles[i].mode == -1)
{
sparkles[i].bounds = centeredRect;
sparkles[i].mode = 0;
numSparkles++;
break;
}
}
}
//-------------------------------------------------------------- AddFlyingPoint
// This adds a "flying point" object to the array of flying points.
void AddFlyingPoint (Rect *theRect, short points, short hVel, short vVel)
{
Rect centeredRect;
short i;
if (numFlyingPts < kMaxFlyingPts)
{
theRect->left += playOriginH;
theRect->right += playOriginH;
theRect->top += playOriginV;
theRect->bottom += playOriginV;
centeredRect = pointsSrc[0];
CenterRectInRect(&centeredRect, theRect);
for (i = 0; i < kMaxFlyingPts; i++)
if (flyingPoints[i].mode == -1)
{
flyingPoints[i].dest = centeredRect;
flyingPoints[i].whole = centeredRect;
flyingPoints[i].loops = 0;
flyingPoints[i].hVel = hVel;
flyingPoints[i].vVel = vVel;
switch (points)
{
case 100:
flyingPoints[i].start = 12;
flyingPoints[i].stop = 14;
break;
case 250:
flyingPoints[i].start = 9;
flyingPoints[i].stop = 11;
break;
case 300:
flyingPoints[i].start = 6;
flyingPoints[i].stop = 8;
break;
case 500:
flyingPoints[i].start = 3;
flyingPoints[i].stop = 5;
break;
default:
flyingPoints[i].start = 0;
flyingPoints[i].stop = 2;
break;
}
flyingPoints[i].mode = flyingPoints[i].start;
numFlyingPts++;
break;
}
}
}
//-------------------------------------------------------------- BackUpFlames
// This makes copies of the area of the room behind a flame. The flame<6D>
// graphic can be "copy masked" to this pixmap then and then simple<6C>
// CopyBits() calls will properly draw the flame on screen with the<68>
// proper background.
void BackUpFlames (Rect *src, short index)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 16, 15);
for (i = 0; i < kNumCandleFlames; i++)
{
// Copy background to map.
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
src, &dest, srcCopy, nil);
// Copy flame to map.
CopyMask((BitMap *)*GetGWorldPixMap(blowerSrcMap),
(BitMap *)*GetGWorldPixMap(blowerMaskMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
&flame[i], &flame[i], &dest);
QOffsetRect(&dest, 0, 15);
}
}
//-------------------------------------------------------------- ReBackUpFlames
// Like the above function but this is called when the lighting changes<65>
// in a room (lights go on or off).
void ReBackUpFlames (short where, short who)
{
short i, f;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
{
for (f = 0; f < numFlames; f++)
{
if (flames[f].who == i)
{
BackUpFlames(&flames[f].dest, i);
return;
}
}
}
}
}
//-------------------------------------------------------------- AddCandleFlame
// This adds a candle flame to tha array of flames.
void AddCandleFlame (short where, short who, short h, short v)
{
Rect src, bounds;
short savedNum;
if ((numFlames >= kMaxCandles) || (h < 16) || (v < 15))
return;
QSetRect(&src, 0, 0, 16, 15);
QOffsetRect(&src, h - 8, v - 15);
if ((thisMac.isDepth == 4) && ((src.left % 2) == 1))
{
QOffsetRect(&src, -1, 0);
if (src.left < 0)
QOffsetRect(&src, 2, 0);
}
QSetRect(&bounds, 0, 0, 16, 15 * kNumCandleFlames);
savedNum = BackUpToSavedMap(&bounds, where, who);
if (savedNum != -1)
{
BackUpFlames(&src, savedNum);
flames[numFlames].dest = src;
flames[numFlames].mode = RandomInt(kNumCandleFlames);
QSetRect(&flames[numFlames].src, 0, 0, 16, 15);
QOffsetRect(&flames[numFlames].src, 0, flames[numFlames].mode * 15);
flames[numFlames].who = savedNum;
numFlames++;
}
}
//-------------------------------------------------------------- BackUpTikiFlames
// This is like the function BackUpFlames() but customized for Tiki torches.
void BackUpTikiFlames (Rect *src, short index)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 8, 10);
for (i = 0; i < kNumTikiFlames; i++)
{
// copy background to map
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
src, &dest, srcCopy, nil);
// copy flame to map
CopyMask((BitMap *)*GetGWorldPixMap(blowerSrcMap),
(BitMap *)*GetGWorldPixMap(blowerMaskMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
&tikiFlame[i], &tikiFlame[i], &dest);
QOffsetRect(&dest, 0, 10);
}
}
//-------------------------------------------------------------- ReBackUpTikiFlames
// This is like the function ReBackUpFlames() but customized for Tiki torches.
void ReBackUpTikiFlames (short where, short who)
{
short i, f;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
{
for (f = 0; f < numTikiFlames; f++)
{
if (tikiFlames[f].who == i)
{
BackUpTikiFlames(&tikiFlames[f].dest, i);
return;
}
}
}
}
}
//-------------------------------------------------------------- AddTikiFlame
// This adds a tiki flame to the array of tiki flames.
void AddTikiFlame (short where, short who, short h, short v)
{
Rect src, bounds;
short savedNum;
if ((numTikiFlames >= kMaxTikis) || (h < 8) || (v < 10))
return;
QSetRect(&src, 0, 0, 8, 10);
if ((thisMac.isDepth == 4) && ((h % 2) == 1))
{
h--;
if (h < 0)
h += 2;
}
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 8, 10 * kNumTikiFlames);
savedNum = BackUpToSavedMap(&bounds, where, who);
if (savedNum != -1)
{
BackUpTikiFlames(&src, savedNum);
tikiFlames[numTikiFlames].dest = src;
tikiFlames[numTikiFlames].mode = RandomInt(kNumTikiFlames);
QSetRect(&tikiFlames[numTikiFlames].src, 0, 0, 8, 10);
QOffsetRect(&tikiFlames[numTikiFlames].src, 0,
tikiFlames[numTikiFlames].mode * 10);
tikiFlames[numTikiFlames].who = savedNum;
numTikiFlames++;
}
}
//-------------------------------------------------------------- BackUpBBQCoals
// Another one - but for BBQ coals.
void BackUpBBQCoals (Rect *src, short index)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 32, 9);
for (i = 0; i < kNumBBQCoals; i++)
{
// copy background to map
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
src, &dest, srcCopy, nil);
// copy flame to map
CopyMask((BitMap *)*GetGWorldPixMap(blowerSrcMap),
(BitMap *)*GetGWorldPixMap(blowerMaskMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
&coals[i], &coals[i], &dest);
QOffsetRect(&dest, 0, 9);
}
}
//-------------------------------------------------------------- ReBackUpBBQCoals
// Sense a pattern here?
void ReBackUpBBQCoals (short where, short who)
{
short i, f;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
{
for (f = 0; f < numCoals; f++)
{
if (bbqCoals[f].who == i)
{
BackUpBBQCoals(&bbqCoals[f].dest, i);
return;
}
}
}
}
}
//-------------------------------------------------------------- AddBBQCoals
// Adds BBQ coals to the array of BBQ coals.
void AddBBQCoals (short where, short who, short h, short v)
{
Rect src, bounds;
short savedNum;
if ((numCoals >= kMaxCoals) || (h < 32) || (v < 9))
return;
QSetRect(&src, 0, 0, 32, 9);
if ((thisMac.isDepth == 4) && ((h % 2) == 1))
{
h--;
if (h < 0)
h += 2;
}
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 32, 9 * kNumBBQCoals);
savedNum = BackUpToSavedMap(&bounds, where, who);
if (savedNum != -1)
{
BackUpBBQCoals(&src, savedNum);
bbqCoals[numCoals].dest = src;
bbqCoals[numCoals].mode = RandomInt(kNumBBQCoals);
QSetRect(&bbqCoals[numCoals].src, 0, 0, 32, 9);
QOffsetRect(&bbqCoals[numCoals].src, 0, bbqCoals[numCoals].mode * 9);
bbqCoals[numCoals].who = savedNum;
numCoals++;
}
}
//-------------------------------------------------------------- BackUpPendulum
// Just like many of the previous functions, but for the pendulum on the<68>
// cuckoo clock.
void BackUpPendulum (Rect *src, short index)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 32, 28);
for (i = 0; i < kNumPendulums; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
src, &dest, srcCopy, nil);
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap *)*GetGWorldPixMap(bonusMaskMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
&pendulumSrc[i], &pendulumSrc[i], &dest);
QOffsetRect(&dest, 0, 28);
}
}
//-------------------------------------------------------------- ReBackUpPendulum
// Backs up the pendulums in the event of lights going on or off.
void ReBackUpPendulum (short where, short who)
{
short i, f;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
{
for (f = 0; f < numPendulums; f++)
{
if (pendulums[f].who == i)
{
BackUpPendulum(&pendulums[f].dest, i);
return;
}
}
}
}
}
//-------------------------------------------------------------- AddPendulum
// Adds a pendulum to the array of pendulums.
void AddPendulum (short where, short who, short h, short v)
{
Rect src, bounds;
short savedNum;
if ((numPendulums >= kMaxPendulums) || (h < 32) || (v < 28))
return;
clockFrame = 10;
QSetRect(&bounds, 0, 0, 32, 28 * kNumPendulums);
savedNum = BackUpToSavedMap(&bounds, where, who);
if (savedNum != -1)
{
QSetRect(&src, 0, 0, 32, 28);
if ((thisMac.isDepth == 4) && ((h % 2) == 1))
{
h--;
if (h < 0)
h += 2;
}
QOffsetRect(&src, h, v);
BackUpPendulum (&src, savedNum);
pendulums[numPendulums].dest = src;
pendulums[numPendulums].mode = 1;
if (RandomInt(2) == 0)
pendulums[numPendulums].toOrFro = true;
else
pendulums[numPendulums].toOrFro = false;
pendulums[numPendulums].active = true;
QSetRect(&pendulums[numPendulums].src, 0, 0, 32, 28);
QOffsetRect(&pendulums[numPendulums].src, 0, 28);
pendulums[numPendulums].who = savedNum;
pendulums[numPendulums].where = where;
pendulums[numPendulums].link = who;
numPendulums++;
}
}
//-------------------------------------------------------------- BackUpStar
// Makes a copy of background beneath a star.
void BackUpStar (Rect *src, short index)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 32, 31);
for (i = 0; i < 6; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
src, &dest, srcCopy, nil);
// copy flame to map
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap *)*GetGWorldPixMap(bonusMaskMap),
GetPortBitMapForCopyBits(savedMaps[index].map),
&starSrc[i], &starSrc[i], &dest);
QOffsetRect(&dest, 0, 31);
}
}
//-------------------------------------------------------------- ReBackUpStar
// Re-backs up the stars - in the event of lighting switch.
void ReBackUpStar (short where, short who)
{
short i, f;
for (i = 0; i < numSavedMaps; i++)
{
if ((savedMaps[i].where == where) && (savedMaps[i].who == who))
{
for (f = 0; f < numStars; f++)
{
if (theStars[f].who == i)
{
BackUpStar(&theStars[f].dest, i);
return;
}
}
}
}
}
//-------------------------------------------------------------- AddStar
// Adds a star to the star array.
void AddStar (short where, short who, short h, short v)
{
Rect src, bounds;
short savedNum;
if (numStars >= kMaxStars)
return;
QSetRect(&src, 0, 0, 32, 31);
if ((thisMac.isDepth == 4) && ((h % 2) == 1))
{
h--;
if (h < 0)
h += 2;
}
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 32, 31 * 6);
savedNum = BackUpToSavedMap(&bounds, where, who);
if (savedNum != -1)
{
BackUpStar(&src, savedNum);
theStars[numStars].dest = src;
theStars[numStars].mode = RandomInt(6);
QSetRect(&theStars[numStars].src, 0, 0, 32, 31);
QOffsetRect(&theStars[numStars].src, 0, theStars[numStars].mode * 31);
theStars[numStars].who = savedNum;
theStars[numStars].link = who;
theStars[numStars].where = where;
numStars++;
}
}
//-------------------------------------------------------------- StopPendulum
// Will set a flag to kill a pendulum.
void StopPendulum (short where, short who)
{
short i;
for (i = 0; i < numPendulums; i++)
{
if ((pendulums[i].link == who) && (pendulums[i].where == where))
pendulums[i].active = false;
}
}
//-------------------------------------------------------------- StopStar
// Will set a flag to kill a star.
void StopStar (short where, short who)
{
short i;
for (i = 0; i < numStars; i++)
{
if ((theStars[i].link == who) && (theStars[i].where == where))
theStars[i].mode = -1;
}
}
//-------------------------------------------------------------- AddAShreddedGlider
// Adds a shredded glider.
void AddAShreddedGlider (Rect *bounds)
{
if (numShredded > kMaxShredded)
return;
shreds[numShredded].bounds.left = bounds->left + 4;
shreds[numShredded].bounds.right = shreds[numShredded].bounds.left + 40;
shreds[numShredded].bounds.top = bounds->top + 14;
shreds[numShredded].bounds.bottom = shreds[numShredded].bounds.top;
shreds[numShredded].frame = 0;
numShredded++;
}
//-------------------------------------------------------------- RemoveShreds
// Remves the shredded glider.
void RemoveShreds (void)
{
short largest, who, i;
largest = 0;
who = -1;
for (i = 0; i < numShredded; i++)
{
if (shreds[i].frame > largest)
{
largest = shreds[i].frame;
who = i;
}
}
if (who != -1)
{
if (who == (numShredded - 1))
{
numShredded--;
shreds[who].frame = 0;
}
else
{
numShredded--;
shreds[who].bounds = shreds[numShredded].bounds;
shreds[who].frame = shreds[numShredded].frame;
shreds[numShredded].frame = 0;
}
}
}
//-------------------------------------------------------------- ZeroFlamesAndTheLike
// Zeroes all counters that indicate the number of flames, pendulums, etc there<72>
// are in a room. Called before a room is drawn. As the room is drawn, the<68>
// above functions are called and the counters incremented as objects of the<68>
// specified types are drawn.
void ZeroFlamesAndTheLike (void)
{
numFlames = 0;
numTikiFlames = 0;
numCoals = 0;
numPendulums = 0;
numGrease = 0;
numStars = 0;
numShredded = 0;
numChimes = 0;
}

0
Headers/DynamicMaps.h → GpApp/DynamicMaps.h Executable file → Normal file
View File

776
GpApp/Dynamics.cpp Normal file
View File

@@ -0,0 +1,776 @@
//============================================================================
//----------------------------------------------------------------------------
// Dynamics.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "RectUtils.h"
#include "Room.h"
#define kShoveVelocity 8
Rect breadSrc[kNumBreadPicts];
extern dynaPtr dinahs;
extern bandPtr bands;
extern short numBands, tvWithMovieNumber;
extern Boolean evenFrame, twoPlayerGame, onePlayerLeft, playerDead;
//============================================================== Functions
//-------------------------------------------------------------- CheckDynamicCollision
// Checks for a collision betwen the glider and one of the dynamic objects.
// For example, did the glider hit a flying piece of toast?
void CheckDynamicCollision (short who, gliderPtr thisGlider, Boolean doOffset)
{
Rect dinahRect;
dinahRect = dinahs[who].dest;
if (doOffset)
QOffsetRect(&dinahRect, -playOriginH, -playOriginV);
if (SectGlider(thisGlider, &dinahRect, true))
{
if ((thisGlider->mode == kGliderNormal) ||
(thisGlider->mode == kGliderFaceLeft) ||
(thisGlider->mode == kGliderFaceRight) ||
(thisGlider->mode == kGliderBurning) ||
(thisGlider->mode == kGliderGoingFoil) ||
(thisGlider->mode == kGliderLosingFoil))
{
if ((foilTotal > 0) || (thisGlider->mode == kGliderLosingFoil))
{
if (IsRectLeftOfRect(&dinahRect, &thisGlider->dest))
thisGlider->hDesiredVel = kShoveVelocity;
else
thisGlider->hDesiredVel = -kShoveVelocity;
if (dinahs[who].vVel < 0)
thisGlider->vDesiredVel = dinahs[who].vVel;
PlayPrioritySound(kFoilHitSound, kFoilHitPriority);
if ((evenFrame) && (foilTotal > 0))
{
foilTotal--;
if (foilTotal <= 0)
StartGliderFoilLosing(thisGlider);
}
}
else
{
StartGliderFadingOut(thisGlider);
PlayPrioritySound(kFadeOutSound, kFadeOutPriority);
}
}
}
}
//-------------------------------------------------------------- DidBandHitDynamic
// Checks to see if a rubber band struck a dynamic.
Boolean DidBandHitDynamic (short who)
{
Rect dinahRect;
short i;
Boolean collided;
dinahRect = dinahs[who].dest;
for (i = 0; i < numBands; i++)
{
if (bands[i].dest.bottom < dinahRect.top)
collided = false;
else if (bands[i].dest.top > dinahRect.bottom)
collided = false;
else if (bands[i].dest.right < dinahRect.left)
collided = false;
else if (bands[i].dest.left > dinahRect.right)
collided = false;
else
collided = true;
if (collided)
break;
}
return (collided);
}
//-------------------------------------------------------------- RenderToast
// The following handful of functions handle drawing specific "dynamic" objecsts.
void RenderToast (short who)
{
Rect src, dest;
short vClip;
if (dinahs[who].moving)
{
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = breadSrc[dinahs[who].frame];
vClip = dinahs[who].dest.bottom - dinahs[who].hVel;
if (vClip > 0)
{
src.bottom -= vClip;
dest.bottom -= vClip;
}
CopyMask((BitMap *)*GetGWorldPixMap(toastSrcMap),
(BitMap *)*GetGWorldPixMap(toastMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
}
//-------------------------------------------------------------- RenderBalloon
void RenderBalloon (short who)
{
Rect src, dest;
if (dinahs[who].moving)
{
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = balloonSrc[dinahs[who].frame];
CopyMask((BitMap *)*GetGWorldPixMap(balloonSrcMap),
(BitMap *)*GetGWorldPixMap(balloonMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
}
//-------------------------------------------------------------- RenderCopter
void RenderCopter (short who)
{
Rect src, dest;
if (dinahs[who].moving)
{
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = copterSrc[dinahs[who].frame];
CopyMask((BitMap *)*GetGWorldPixMap(copterSrcMap),
(BitMap *)*GetGWorldPixMap(copterMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
}
//-------------------------------------------------------------- RenderDart
void RenderDart (short who)
{
Rect src, dest;
if (dinahs[who].moving)
{
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = dartSrc[dinahs[who].frame];
CopyMask((BitMap *)*GetGWorldPixMap(dartSrcMap),
(BitMap *)*GetGWorldPixMap(dartMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
}
//-------------------------------------------------------------- RenderBall
void RenderBall (short who)
{
Rect src, dest;
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = ballSrc[dinahs[who].frame];
CopyMask((BitMap *)*GetGWorldPixMap(ballSrcMap),
(BitMap *)*GetGWorldPixMap(ballMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
//-------------------------------------------------------------- RenderDrip
void RenderDrip (short who)
{
Rect src, dest;
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = dripSrc[dinahs[who].frame];
CopyMask((BitMap *)*GetGWorldPixMap(dripSrcMap),
(BitMap *)*GetGWorldPixMap(dripMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
//-------------------------------------------------------------- RenderFish
void RenderFish (short who)
{
Rect src, dest;
dest = dinahs[who].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
src = fishSrc[dinahs[who].frame];
if (dinahs[who].moving)
{
CopyMask((BitMap *)*GetGWorldPixMap(fishSrcMap),
(BitMap *)*GetGWorldPixMap(fishMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
else
{
CopyBits((BitMap *)*GetGWorldPixMap(fishSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &dest, srcCopy, nil);
AddRectToBackRects(&dest);
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
}
}
//-------------------------------------------------------------- HandleSparkleObject
// The following handful of functions are called each game frame and handle<6C>
// the movement and state of the various types of dynamic objects.
void HandleSparkleObject (short who)
{
Rect tempRect;
if (dinahs[who].active) // is it on?
{
if (dinahs[who].frame <= 0) // is it idle?
{ // it is idle
dinahs[who].timer--;
if (dinahs[who].timer <= 0)
{
dinahs[who].timer = RandomInt(240) + 60;// reset timer
dinahs[who].frame = kNumSparkleModes; // time to sparkle
tempRect = dinahs[who].dest;
AddSparkle(&tempRect);
PlayPrioritySound(kMysticSound, kMysticPriority);
}
}
else // it's sparkling
dinahs[who].frame--;
}
else
{
}
}
//-------------------------------------------------------------- HandleToast
void HandleToast (short who)
{
Rect dest;
if (dinahs[who].moving)
{
if (evenFrame)
{
dinahs[who].frame++;
if (dinahs[who].frame >= kNumBreadPicts)
dinahs[who].frame = 0;
}
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
if (dinahs[who].vVel > 0)
dinahs[who].whole.top -= dinahs[who].vVel;
else
dinahs[who].whole.bottom -= dinahs[who].vVel;
dinahs[who].vVel++; // falls
if (dinahs[who].vVel > dinahs[who].count)
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dinahs[who].moving = false;
dinahs[who].frame = dinahs[who].timer;
PlayPrioritySound(kToastLandSound, kToastLandPriority);
}
}
else
{
if (dinahs[who].active)
dinahs[who].frame--;
if (dinahs[who].frame <= 0)
{
if (dinahs[who].active)
{
dinahs[who].vVel = (short)-dinahs[who].count;
dinahs[who].frame = 0;
dinahs[who].moving = true;
PlayPrioritySound(kToastLaunchSound, kToastLaunchPriority);
}
else
dinahs[who].frame = dinahs[who].timer;
}
}
}
//-------------------------------------------------------------- HandleMacPlus
void HandleMacPlus (short who)
{
if (dinahs[who].timer > 0)
{
dinahs[who].timer--;
if (dinahs[who].active)
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacBeepSound, kMacBeepPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&plusScreen2, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
else if (dinahs[who].timer == 30)
PlayPrioritySound(kMacOnSound, kMacOnPriority);
}
else
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOffSound, kMacOffPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&plusScreen1, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
}
//-------------------------------------------------------------- HandleTV
void HandleTV (short who)
{
if (dinahs[who].timer > 0)
{
dinahs[who].timer--;
if (dinahs[who].active)
{
if (dinahs[who].timer == 0)
{
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) &&
(who == tvWithMovieNumber))
{
}
else
{
AddRectToWorkRects(&dinahs[who].dest);
}
}
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kTVOnSound, kTVOnPriority);
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) &&
(who == tvWithMovieNumber))
{
}
else
{
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&tvScreen2, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
else
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kTVOffSound, kTVOffPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&tvScreen1, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
}
//-------------------------------------------------------------- HandleCoffee
void HandleCoffee (short who)
{
if (dinahs[who].timer > 0)
{
dinahs[who].timer--;
if (dinahs[who].active)
{
if (dinahs[who].timer == 0)
{
AddRectToWorkRects(&dinahs[who].dest);
dinahs[who].timer = 200 + RandomInt(200);
}
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOnSound, kMacOnPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&coffeeLight2, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
else if (dinahs[who].timer == 100)
{
PlayPrioritySound(kCoffeeSound, kCoffeePriority);
dinahs[who].timer = 200 + RandomInt(200);
}
}
else
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOffSound, kMacOffPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&coffeeLight1, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
}
//-------------------------------------------------------------- HandleOutlet
void HandleOutlet (short who)
{
if (dinahs[who].position != 0)
{
dinahs[who].timer--;
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, true);
CheckDynamicCollision(who, &theGlider2, true);
}
}
else
CheckDynamicCollision(who, &theGlider, true);
if (dinahs[who].timer <= 0)
{
dinahs[who].frame = 0;
dinahs[who].position = 0;
dinahs[who].timer = dinahs[who].count;
}
else
{
if ((dinahs[who].timer % 5) == 0)
PlayPrioritySound(kZapSound, kZapPriority);
dinahs[who].frame++;
if (dinahs[who].frame >= kNumOutletPicts)
dinahs[who].frame = 1;
}
if ((dinahs[who].position != 0) || (dinahs[who].hVel > 0))
{
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&outletSrc[dinahs[who].frame],
&dinahs[who].dest,
srcCopy, nil);
}
else
{
// SetPort((GrafPtr)workSrcMap);
PaintRect(&dinahs[who].dest);
}
AddRectToWorkRects(&dinahs[who].dest);
}
else
{
if (dinahs[who].active)
dinahs[who].timer--;
if (dinahs[who].timer <= 0)
{
if (dinahs[who].active)
{
dinahs[who].position = 1;
dinahs[who].timer = kLengthOfZap;
PlayPrioritySound(kZapSound, kZapPriority);
}
else
dinahs[who].timer = dinahs[who].count;
}
}
}
//-------------------------------------------------------------- HandleVCR
void HandleVCR (short who)
{
if (dinahs[who].timer > 0)
{
dinahs[who].timer--;
if (dinahs[who].active)
{
if (dinahs[who].timer == 0)
{
AddRectToWorkRects(&dinahs[who].dest);
dinahs[who].timer = 115;
}
else if (dinahs[who].timer == 5)
PlayPrioritySound(kMacOnSound, kMacOnPriority);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kVCRSound, kVCRPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&vcrTime2, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
else if (dinahs[who].timer == 100)
{
AddRectToWorkRects(&dinahs[who].dest);
dinahs[who].timer = 115;
dinahs[who].frame = 1 - dinahs[who].frame;
}
else if (dinahs[who].timer == 101)
{
if (dinahs[who].frame == 0)
{
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&vcrTime2, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
else
{
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&vcrTime1, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
else
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOffSound, kMacOffPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&vcrTime1, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
}
//-------------------------------------------------------------- HandleStereo
void HandleStereo (short who)
{
if (dinahs[who].timer > 0)
{
dinahs[who].timer--;
if (dinahs[who].active)
{
if (dinahs[who].timer == 0)
{
AddRectToWorkRects(&dinahs[who].dest);
ToggleMusicWhilePlaying();
}
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOnSound, kMacOnPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&stereoLight2, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
else
{
if (dinahs[who].timer == 0)
{
AddRectToWorkRects(&dinahs[who].dest);
ToggleMusicWhilePlaying();
}
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOffSound, kMacOffPriority);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&stereoLight1, &dinahs[who].dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
}
//-------------------------------------------------------------- HandleMicrowave
void HandleMicrowave (short who)
{
Rect dest;
if (dinahs[who].timer > 0)
{
dinahs[who].timer--;
if (dinahs[who].active)
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOnSound, kMacOnPriority);
dest = dinahs[who].dest;
dest.right = dest.left + 16;
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&microOn, &dest,
srcCopy, nil);
QOffsetRect(&dest, 16, 0);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&microOn, &dest,
srcCopy, nil);
QOffsetRect(&dest, 16, 0);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&microOn, &dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
else
{
if (dinahs[who].timer == 0)
AddRectToWorkRects(&dinahs[who].dest);
else if (dinahs[who].timer == 1)
{
PlayPrioritySound(kMacOffSound, kMacOffPriority);
dest = dinahs[who].dest;
dest.right = dest.left + 16;
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&microOff, &dest,
srcCopy, nil);
QOffsetRect(&dest, 16, 0);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&microOff, &dest,
srcCopy, nil);
QOffsetRect(&dest, 16, 0);
CopyBits((BitMap *)*GetGWorldPixMap(applianceSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&microOff, &dest,
srcCopy, nil);
AddRectToBackRects(&dinahs[who].dest);
}
}
}
}

589
GpApp/Dynamics2.cpp Normal file
View File

@@ -0,0 +1,589 @@
//============================================================================
//----------------------------------------------------------------------------
// Dynamics2.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "RectUtils.h"
#define kBalloonStop 8
#define kBalloonStart 310
#define kCopterStart 8
#define kCopterStop 310
#define kDartVelocity 6
#define kDartStop 310
#define kEnemyDropSpeed 8
extern dynaPtr dinahs;
extern short numBands;
extern Boolean evenFrame, twoPlayerGame, onePlayerLeft, playerDead;
//============================================================== Functions
//-------------------------------------------------------------- HandleBalloon
void HandleBalloon (short who)
{
Rect dest;
if (dinahs[who].moving)
{
if (dinahs[who].vVel < 0)
{
if (evenFrame)
{
dinahs[who].frame++;
if (dinahs[who].frame >= 6)
dinahs[who].frame = 0;
}
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
if ((numBands > 0) && (DidBandHitDynamic(who)))
{
dinahs[who].frame = 6;
dinahs[who].vVel = kEnemyDropSpeed;
PlayPrioritySound(kPopSound, kPopPriority);
}
else
{
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.bottom -= dinahs[who].vVel;
}
}
else
{
if (evenFrame)
{
dinahs[who].frame++;
if (dinahs[who].frame >= 8)
dinahs[who].frame = 6;
}
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
}
if ((dinahs[who].dest.top <= kBalloonStop) ||
(dinahs[who].dest.bottom >= kBalloonStart))
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyOutSound, kEnemyOutPriority);
dinahs[who].moving = false;
dinahs[who].vVel = -2;
dinahs[who].timer = dinahs[who].count;
dinahs[who].dest.bottom = kBalloonStart;
dinahs[who].dest.top = dinahs[who].dest.bottom -
RectTall(&balloonSrc[0]);
dinahs[who].whole = dinahs[who].dest;
}
}
else // balloon is idle, waiting to appear
{
if (dinahs[who].active)
{
dinahs[who].timer--;
if (dinahs[who].timer <= 0)
{
dinahs[who].moving = true;
if (dinahs[who].count < kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
else if (dinahs[who].timer == kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
}
}
//-------------------------------------------------------------- HandleCopter
void HandleCopter (short who)
{
Rect dest;
if (dinahs[who].moving) // is 'copter about?
{
if (dinahs[who].hVel != 0) // 'copter was not shot
{
dinahs[who].frame++;
if (dinahs[who].frame >= 8)
dinahs[who].frame = 0;
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
if ((numBands > 0) && (DidBandHitDynamic(who)))
{
dinahs[who].frame = 8;
dinahs[who].hVel = 0;
dinahs[who].vVel = kEnemyDropSpeed;
PlayPrioritySound(kPaperCrunchSound, kPaperCrunchPriority);
}
else
{
HOffsetRect(&dinahs[who].dest, dinahs[who].hVel);
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
if (dinahs[who].hVel < 0)
dinahs[who].whole.right -= dinahs[who].hVel;
else
dinahs[who].whole.left -= dinahs[who].hVel;
}
}
else // 'copter was shot
{
dinahs[who].frame++;
if (dinahs[who].frame >= 10)
dinahs[who].frame = 8;
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
}
if ((dinahs[who].dest.top <= kCopterStart) ||
(dinahs[who].dest.bottom >= kCopterStop))
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyOutSound, kEnemyOutPriority);
dinahs[who].moving = false;
dinahs[who].vVel = 2;
if (dinahs[who].type == kCopterLf)
dinahs[who].hVel = -1;
else
dinahs[who].hVel = 1;
dinahs[who].timer = dinahs[who].count;
dinahs[who].dest.top = kCopterStart;
dinahs[who].dest.bottom = dinahs[who].dest.top +
RectTall(&copterSrc[0]);
dinahs[who].dest.left = dinahs[who].position;
dinahs[who].dest.right = dinahs[who].dest.left + 32;
dinahs[who].whole = dinahs[who].dest;
}
}
else
{
if (dinahs[who].active)
{
dinahs[who].timer--;
if (dinahs[who].timer <= 0)
{
dinahs[who].moving = true;
if (dinahs[who].count < kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
else if (dinahs[who].timer == kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
}
}
//-------------------------------------------------------------- HandleDart
void HandleDart (short who)
{
Rect dest;
if (dinahs[who].moving) // Dart has appeared
{
if (dinahs[who].hVel != 0) // meaning it isn't falling
{
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
if ((numBands > 0) && (DidBandHitDynamic(who)))
{
if (dinahs[who].type == kDartLf)
dinahs[who].frame = 1;
else
dinahs[who].frame = 3;
dinahs[who].hVel = 0;
dinahs[who].vVel = kEnemyDropSpeed;
PlayPrioritySound(kPaperCrunchSound, kPaperCrunchPriority);
}
else
{
HOffsetRect(&dinahs[who].dest, dinahs[who].hVel);
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
if (dinahs[who].hVel < 0)
dinahs[who].whole.right -= dinahs[who].hVel;
else
dinahs[who].whole.left -= dinahs[who].hVel;
}
}
else // dart is falling straight down
{
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
}
if ((dinahs[who].dest.left <= 0) ||
(dinahs[who].dest.right >= kRoomWide) ||
(dinahs[who].dest.bottom >= kDartStop))
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyOutSound, kEnemyOutPriority);
dinahs[who].moving = false;
dinahs[who].vVel = 2;
if (dinahs[who].type == kDartLf)
{
dinahs[who].frame = 0;
dinahs[who].hVel = -kDartVelocity;
dinahs[who].dest.right = kRoomWide;
dinahs[who].dest.left = dinahs[who].dest.right -
RectWide(&dartSrc[0]);
}
else
{
dinahs[who].frame = 2;
dinahs[who].hVel = kDartVelocity;
dinahs[who].dest.left = 0;
dinahs[who].dest.right = dinahs[who].dest.left +
RectWide(&dartSrc[0]);
}
dinahs[who].timer = dinahs[who].count;
dinahs[who].dest.top = dinahs[who].position;
dinahs[who].dest.bottom = dinahs[who].dest.top +
RectTall(&dartSrc[0]);
dinahs[who].whole = dinahs[who].dest;
}
}
else
{
if (dinahs[who].active)
{
dinahs[who].timer--;
if (dinahs[who].timer <= 0)
{
dinahs[who].moving = true;
if (dinahs[who].count < kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
else if (dinahs[who].timer == kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
}
}
//-------------------------------------------------------------- HandleBall
void HandleBall (short who)
{
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
if (dinahs[who].moving) // is ball bouncing?
{
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
if (dinahs[who].dest.bottom >= dinahs[who].position) // bounce!
{
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
dinahs[who].whole.bottom = dinahs[who].position;
dinahs[who].dest.bottom = dinahs[who].position;
dinahs[who].dest.top = dinahs[who].dest.bottom - 32;
if (dinahs[who].active)
dinahs[who].vVel = dinahs[who].count;
else
{
dinahs[who].vVel = -((dinahs[who].vVel * 3) / 4);
if (dinahs[who].vVel == 0)
dinahs[who].moving = false; // stop bounce
}
if (dinahs[who].whole.bottom < dinahs[who].dest.bottom)
dinahs[who].whole.bottom = dinahs[who].dest.bottom;
PlayPrioritySound(kBounceSound, kBouncePriority);
if (dinahs[who].moving)
dinahs[who].frame = 1;
}
else
{
dinahs[who].whole = dinahs[who].dest;
if (dinahs[who].vVel > 0)
dinahs[who].whole.top -= dinahs[who].vVel;
else
dinahs[who].whole.bottom -= dinahs[who].vVel;
if (evenFrame)
dinahs[who].vVel++;
dinahs[who].frame = 0;
}
}
else
{
if (dinahs[who].active)
{
dinahs[who].vVel = dinahs[who].count;
dinahs[who].moving = true;
evenFrame = true;
}
}
}
//-------------------------------------------------------------- HandleDrip
void HandleDrip (short who)
{
Rect dest;
if (dinahs[who].moving)
{
if (evenFrame)
dinahs[who].frame = 9 - dinahs[who].frame;
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
if (dinahs[who].dest.bottom >= dinahs[who].position)
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dinahs[who].dest.top = dinahs[who].hVel;
dinahs[who].dest.bottom = dinahs[who].dest.top + 12;
PlayPrioritySound(kDropSound, kDropPriority);
dinahs[who].vVel = 0;
dinahs[who].timer = dinahs[who].count;
dinahs[who].frame = 3;
dinahs[who].moving = false;
}
else
{
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
if (evenFrame)
dinahs[who].vVel++;
}
}
else
{
if (dinahs[who].active)
{
dinahs[who].timer--;
if (dinahs[who].timer == 6)
dinahs[who].frame = 0;
else if (dinahs[who].timer == 4)
dinahs[who].frame = 1;
else if (dinahs[who].timer == 2)
dinahs[who].frame = 2;
else if (dinahs[who].timer <= 0)
{
VOffsetRect(&dinahs[who].dest, 3);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].moving = true;
dinahs[who].frame = 4;
PlayPrioritySound(kDripSound, kDripPriority);
}
}
}
}
//-------------------------------------------------------------- HandleFish
void HandleFish (short who)
{
Rect dest;
if (dinahs[who].moving) // fish leaping
{
if ((dinahs[who].vVel >= 0) && (dinahs[who].frame < 7))
dinahs[who].frame++;
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
if (dinahs[who].dest.bottom >= dinahs[who].position) // splash down
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dinahs[who].dest.bottom = dinahs[who].position;
dinahs[who].dest.top = dinahs[who].dest.bottom - 16;
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= 2;
PlayPrioritySound(kDropSound, kDropPriority);
dinahs[who].vVel = dinahs[who].count;
dinahs[who].timer = dinahs[who].hVel;
dinahs[who].frame = 0;
dinahs[who].moving = false;
PlayPrioritySound(kFishInSound, kFishInPriority);
}
else
{
dinahs[who].whole = dinahs[who].dest;
if (dinahs[who].vVel > 0)
dinahs[who].whole.top -= dinahs[who].vVel;
else
dinahs[who].whole.bottom -= dinahs[who].vVel;
if (evenFrame)
dinahs[who].vVel++;
}
}
else // fish idle
{
dinahs[who].whole = dinahs[who].dest;
if ((dinahs[who].timer & 0x0003) == 0x0003)
{
dinahs[who].frame++;
if (dinahs[who].frame > 3)
dinahs[who].frame = 0;
if ((dinahs[who].frame == 1) || (dinahs[who].frame == 2))
{
dinahs[who].dest.top++;
dinahs[who].dest.bottom++;
dinahs[who].whole.bottom++;
}
else
{
dinahs[who].dest.top--;
dinahs[who].dest.bottom--;
dinahs[who].whole.top--;
}
}
if (dinahs[who].active)
{
dinahs[who].timer--;
if (dinahs[who].timer <= 0) // fish leaps
{
dinahs[who].whole = dinahs[who].dest;
dinahs[who].moving = true;
dinahs[who].frame = 4;
PlayPrioritySound(kFishOutSound, kFishOutPriority);
}
}
}
}

555
GpApp/Dynamics3.cpp Normal file
View File

@@ -0,0 +1,555 @@
//============================================================================
//----------------------------------------------------------------------------
// Dynamics3.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "RectUtils.h"
#define kBalloonStart 310
#define kCopterStart 8
#define kDartVelocity 6
dynaPtr dinahs;
short numDynamics;
extern Rect breadSrc[];
extern short numLights;
extern Boolean evenFrame;
//============================================================== Functions
//-------------------------------------------------------------- HandleDynamics
// This is the master function that calls all the specific handlers above.
void HandleDynamics (void)
{
short i;
for (i = 0; i < numDynamics; i++)
{
switch (dinahs[i].type)
{
case kSparkle:
HandleSparkleObject(i);
break;
case kToaster:
HandleToast(i);
break;
case kMacPlus:
HandleMacPlus(i);
break;
case kTV:
HandleTV(i);
break;
case kCoffee:
HandleCoffee(i);
break;
case kOutlet:
HandleOutlet(i);
break;
case kVCR:
HandleVCR(i);
break;
case kStereo:
HandleStereo(i);
break;
case kMicrowave:
HandleMicrowave(i);
break;
case kBalloon:
HandleBalloon(i);
break;
case kCopterLf:
case kCopterRt:
HandleCopter(i);
break;
case kDartLf:
case kDartRt:
HandleDart(i);
break;
case kBall:
HandleBall(i);
break;
case kDrip:
HandleDrip(i);
break;
case kFish:
HandleFish(i);
break;
default:
break;
}
}
}
//-------------------------------------------------------------- HandleDynamics
// This is the master function that calls all the various rendering handlers<72>
// above.
void RenderDynamics (void)
{
short i;
for (i = 0; i < numDynamics; i++)
{
switch (dinahs[i].type)
{
case kToaster:
RenderToast(i);
break;
case kBalloon:
RenderBalloon(i);
break;
case kCopterLf:
case kCopterRt:
RenderCopter(i);
break;
case kDartLf:
case kDartRt:
RenderDart(i);
break;
case kBall:
RenderBall(i);
break;
case kDrip:
RenderDrip(i);
break;
case kFish:
RenderFish(i);
break;
default:
break;
}
}
}
//-------------------------------------------------------------- ZeroDinahs
// This clears all dynamics - zeros them all out. Used to initialize them.
void ZeroDinahs (void)
{
short i;
for (i = 0; i < kMaxDynamicObs; i++)
{
dinahs[i].type = kObjectIsEmpty;
QSetRect(&dinahs[i].dest, 0, 0, 0, 0);
QSetRect(&dinahs[i].whole, 0, 0, 0, 0);
dinahs[i].hVel = 0;
dinahs[i].vVel = 0;
dinahs[i].count = 0;
dinahs[i].frame = 0;
dinahs[i].timer = 0;
dinahs[i].position = 0;
dinahs[i].room = 0;
dinahs[i].byte0 = 0;
dinahs[i].active = false;
}
numDynamics = 0;
}
//-------------------------------------------------------------- AddDynamicObject
// When a room is being drawn, various dynamic objects are pointed here.
// This function sets up the structures to handle them.
short AddDynamicObject (short what, Rect *where, objectType *who,
short room, short index, Boolean isOn)
{
short position, velocity;
Boolean lilFrame;
if (numDynamics >= kMaxDynamicObs)
return (-1);
dinahs[numDynamics].type = what;
switch (what)
{
case kSparkle:
dinahs[numDynamics].dest = sparkleSrc[0];
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest, where->left, where->top);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = RandomInt(60) + 15;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kToaster:
dinahs[numDynamics].dest = breadSrc[0];
CenterRectInRect(&dinahs[numDynamics].dest, where);
VOffsetRect(&dinahs[numDynamics].dest,
where->top - dinahs[numDynamics].dest.top);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = where->top + 2; // hVel used as clip
position = who->data.g.height; // reverse engineer init. vel.
velocity = 0;
do
{
velocity++;
position -= velocity;
}
while (position > 0);
dinahs[numDynamics].vVel = -velocity;
dinahs[numDynamics].count = velocity; // count = initial velocity
dinahs[numDynamics].frame = (short)who->data.g.delay * 3;
dinahs[numDynamics].timer = dinahs[numDynamics].frame;
dinahs[numDynamics].position = 0; // launch/idle state
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kMacPlus:
dinahs[numDynamics].dest = plusScreen1;
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH + 10,
where->top + playOriginV + 7);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kTV:
dinahs[numDynamics].dest = tvScreen1;
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH + 17,
where->top + playOriginV + 10);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kCoffee:
dinahs[numDynamics].dest = coffeeLight1;
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH + 32,
where->top + playOriginV + 57);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
if (isOn)
dinahs[numDynamics].timer = 200;
else
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kOutlet:
dinahs[numDynamics].dest = outletSrc[0];
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH,
where->top + playOriginV);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = numLights;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = ((short)who->data.g.delay * 6) / kTicksPerFrame;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = dinahs[numDynamics].count;
dinahs[numDynamics].position = 0; // launch/idle state
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kVCR:
dinahs[numDynamics].dest = vcrTime1;
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH + 64,
where->top + playOriginV + 6);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
if (isOn)
dinahs[numDynamics].timer = 115;
else
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kStereo:
dinahs[numDynamics].dest = stereoLight1;
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH + 56,
where->top + playOriginV + 20);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kMicrowave:
dinahs[numDynamics].dest = microOn;
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left + playOriginH + 14,
where->top + playOriginV + 13);
dinahs[numDynamics].dest.right = dinahs[numDynamics].dest.left + 48;
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = 0;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kBalloon:
dinahs[numDynamics].dest = balloonSrc[0];
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest, where->left, 0);
dinahs[numDynamics].dest.bottom = kBalloonStart;
dinahs[numDynamics].dest.top = dinahs[numDynamics].dest.bottom -
RectTall(&balloonSrc[0]);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
dinahs[numDynamics].vVel = -2;
dinahs[numDynamics].count = ((short)who->data.h.delay * 6) / kTicksPerFrame;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = dinahs[numDynamics].count;
dinahs[numDynamics].position = 0;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn; // initially idle
break;
case kCopterLf:
case kCopterRt:
dinahs[numDynamics].dest = copterSrc[0];
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest, where->left, 0);
dinahs[numDynamics].dest.top = kCopterStart;
dinahs[numDynamics].dest.bottom = dinahs[numDynamics].dest.top +
RectTall(&copterSrc[0]);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
if (what == kCopterLf)
dinahs[numDynamics].hVel = -1;
else
dinahs[numDynamics].hVel = 1;
dinahs[numDynamics].vVel = 2;
dinahs[numDynamics].count = ((short)who->data.h.delay * 6) / kTicksPerFrame;
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = dinahs[numDynamics].count;
dinahs[numDynamics].position = dinahs[numDynamics].dest.left;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn; // initially idle
break;
case kDartLf:
case kDartRt:
dinahs[numDynamics].dest = dartSrc[0];
ZeroRectCorner(&dinahs[numDynamics].dest);
if (what == kDartLf)
{
QOffsetRect(&dinahs[numDynamics].dest,
kRoomWide - RectWide(&dartSrc[0]), where->top);
dinahs[numDynamics].hVel = -kDartVelocity;
dinahs[numDynamics].frame = 0;
}
else
{
QOffsetRect(&dinahs[numDynamics].dest, 0, where->top);
dinahs[numDynamics].hVel = kDartVelocity;
dinahs[numDynamics].frame = 2;
}
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].vVel = 2;
dinahs[numDynamics].count = ((short)who->data.h.delay * 6) / kTicksPerFrame;
dinahs[numDynamics].timer = dinahs[numDynamics].count;
dinahs[numDynamics].position = dinahs[numDynamics].dest.top;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn; // initially idle
break;
case kBall:
dinahs[numDynamics].dest = ballSrc[0];
ZeroRectCorner(&dinahs[numDynamics].dest);
QOffsetRect(&dinahs[numDynamics].dest,
where->left, where->top);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = 0;
position = who->data.h.length; // reverse engineer init. vel.
velocity = 0;
evenFrame = true;
lilFrame = true;
do
{
if (lilFrame)
velocity++;
lilFrame = !lilFrame;
position -= velocity;
}
while (position > 0);
dinahs[numDynamics].vVel = -velocity;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].count = -velocity; // count = initial velocity
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = 0;
dinahs[numDynamics].position = dinahs[numDynamics].dest.bottom;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].active = isOn;
break;
case kDrip:
dinahs[numDynamics].dest = dripSrc[0];
CenterRectInRect(&dinahs[numDynamics].dest, where);
VOffsetRect(&dinahs[numDynamics].dest,
where->top - dinahs[numDynamics].dest.top);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = dinahs[numDynamics].dest.top; // remember
dinahs[numDynamics].vVel = 0;
dinahs[numDynamics].count = ((short)who->data.h.delay * 6) / kTicksPerFrame;
dinahs[numDynamics].frame = 3;
dinahs[numDynamics].timer = dinahs[numDynamics].count;
dinahs[numDynamics].position = dinahs[numDynamics].dest.top +
who->data.h.length;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
case kFish:
dinahs[numDynamics].dest = fishSrc[0];
QOffsetRect(&dinahs[numDynamics].dest,
where->left + 10, where->top + 8);
dinahs[numDynamics].whole = dinahs[numDynamics].dest;
dinahs[numDynamics].hVel = ((short)who->data.h.delay * 6) / kTicksPerFrame;
position = who->data.g.height; // reverse engineer init. vel.
velocity = 0;
evenFrame = true;
lilFrame = true;
do
{
if (lilFrame)
velocity++;
lilFrame = !lilFrame;
position -= velocity;
}
while (position > 0);
dinahs[numDynamics].vVel = -velocity;
dinahs[numDynamics].count = -velocity; // count = initial velocity
dinahs[numDynamics].frame = 0;
dinahs[numDynamics].timer = dinahs[numDynamics].hVel;
dinahs[numDynamics].position = dinahs[numDynamics].dest.bottom;
dinahs[numDynamics].room = room;
dinahs[numDynamics].byte0 = (Byte)index;
dinahs[numDynamics].byte1 = 0;
dinahs[numDynamics].moving = false;
dinahs[numDynamics].active = isOn;
break;
default:
return (-1);
break;
}
numDynamics++;
return (numDynamics - 1);
}

492
GpApp/Environ.cpp Normal file
View File

@@ -0,0 +1,492 @@
//============================================================================
//----------------------------------------------------------------------------
// Environ.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
#define kSwitchDepthAlert 130
#define kSetMemoryAlert 180
#define kLowMemoryAlert 181
#define kWNETrap 0x60
#define kSetDepthTrap 0xA2
#define kUnimpTrap 0x9F
#define kGestaltTrap 0xAD
#define kDisplay9Inch 1
#define kDisplay12Inch 2
#define kDisplay13Inch 3
typedef struct
{
short flags;
long mem1;
long mem2;
} sizeType;
//short GetThisVolumeRefNum (void);
//long GetThisCurrentDirectoryID (void);
//Boolean TrapExists (short);
//Boolean DoWeHaveGestalt (void);
//Boolean DoWeHaveWNE (void);
//Boolean DoWeHaveColor (void);
//Boolean DoWeHaveSystem602 (void);
//Boolean DoWeHaveSystem605 (void);
//Boolean DoWeHaveSystem7 (void);
//Boolean DoWeHaveSoundManager3 (void);
Boolean DoWeHaveQuickTime (void);
Boolean DoWeHaveDragManager (void);
//Boolean CanWeDisplay4Bit (GDHandle);
//Boolean CanWeDisplay1Bit (GDHandle);
short HowManyUsableScreens (Boolean, Boolean, Boolean);
void GetDeviceRect (Rect *);
Boolean AreWeColorOrGrayscale (void);
void SwitchDepthOrAbort (void);
macEnviron thisMac;
extern short isDepthPref;
extern Boolean dontLoadMusic, dontLoadSounds;
//============================================================== Functions
//-------------------------------------------------------------- GetThisVolumeRefNum
// Get a hard reference number for the current drive volume this app is on.
/*
short GetThisVolumeRefNum (void)
{
OSErr theErr;
short vRef;
theErr = GetVol(nil, &vRef);
return (vRef);
}
*/
//-------------------------------------------------------------- GetThisCurrentDirectoryID
// Get a hard ID number for the current directory volume this app is in.
/*
long GetThisCurrentDirectoryID (void)
{
long dirID;
dirID = LMGetCurDirStore();
return (dirID);
}
*/
//-------------------------------------------------------------- TrapExists
// Returns whether or not a ToolBox trap exists for the users ROMs/System.
/*
Boolean TrapExists (short trapNumber)
{
return ((NGetTrapAddress(trapNumber, ToolTrap) !=
NGetTrapAddress(kUnimpTrap, ToolTrap)));
}
*/
//-------------------------------------------------------------- DoWeHaveGestalt
// Specifically tests for the availablity of the Gestalt() trap.
/*
Boolean DoWeHaveGestalt (void)
{
return (TrapExists(kGestaltTrap));
}
*/
//-------------------------------------------------------------- DoWeHaveWNE
// Specifically tests for the availablity of the WaitNextEvent() trap.
/*
Boolean DoWeHaveWNE (void)
{
return (TrapExists(kWNETrap));
}
*/
//-------------------------------------------------------------- DoWeHaveColor
// Determines if ROMs support Color QuickDraw (monitor not neccessarily color).
/*
Boolean DoWeHaveColor (void)
{
SysEnvRec thisWorld;
SysEnvirons(2, &thisWorld);
return (thisWorld.hasColorQD);
}
*/
//-------------------------------------------------------------- DoWeHaveSystem602
// Determines if the System version is at least 6.0.2 or more recent.
/*
Boolean DoWeHaveSystem602 (void)
{
SysEnvRec thisWorld;
Boolean haveIt;
SysEnvirons(2, &thisWorld);
if (thisWorld.systemVersion >= 0x0602)
haveIt = true;
else
haveIt = false;
return (haveIt);
}
*/
//-------------------------------------------------------------- DoWeHaveSystem605
// Determines if the System version is at least 6.0.5 or more recent.
/*
Boolean DoWeHaveSystem605 (void)
{
SysEnvRec thisWorld;
Boolean haveIt;
SysEnvirons(2, &thisWorld);
if (thisWorld.systemVersion >= 0x0605)
haveIt = true;
else
haveIt = false;
return (haveIt);
}
/
//-------------------------------------------------------------- DoWeHaveSystem7
// Determines if the System version is at least 7.0.0 or more recent.
Boolean DoWeHaveSystem7 (void)
{
SysEnvRec thisWorld;
Boolean haveIt;
SysEnvirons(2, &thisWorld);
if (thisWorld.systemVersion >= 0x0700)
haveIt = true;
else
haveIt = false;
return (haveIt);
}
//-------------------------------------------------------------- DoWeHaveSoundManager3
// Determines if the Sound Manager version is at least 3.0.0 or more recent.
/*
Boolean DoWeHaveSoundManager3 (void)
{
// NumVersion version;
Boolean hasIt;
hasIt = true;
version = SndSoundManagerVersion();
hasIt = (version.majorRev >= 3);
return hasIt;
}
*/
//-------------------------------------------------------------- DoWeHaveQuickTime
Boolean DoWeHaveQuickTime (void)
{
return true;
}
//-------------------------------------------------------------- DoWeHaveDragManager
Boolean DoWeHaveDragManager (void)
{
return true;
}
//-------------------------------------------------------------- WhatsOurDepth
// Determines the pixel bit depth for current device (monitor).
short WhatsOurDepth (void)
{
return 8;
}
void SwitchToDepth (short, Boolean)
{
}
//-------------------------------------------------------------- CanWeDisplay4Bit
// Determines if device (monitor) capable of supporting 4 bit (16 colors/grays).
/*
Boolean CanWeDisplay4Bit (GDHandle theDevice)
{
short canDepth;
Boolean canDo;
canDo = false;
canDepth = HasDepth(theDevice, 4, 1, 0);
if (canDepth != 0)
canDo = true;
return (canDo);
}
*/
//-------------------------------------------------------------- CanWeDisplay1Bit
// Determines if device (monitor) capable of supporting 1 bit (black & white).
/*
Boolean CanWeDisplay1Bit (GDHandle theDevice)
{
short canDepth;
Boolean canDo;
canDo = false;
canDepth = HasDepth(theDevice, 1, 1, 0);
if (canDepth != 0)
canDo = true;
return (canDo);
}
*/
//-------------------------------------------------------------- HowManyUsableScreens
// Counts the number of monitors that meet the depth criteria passed in.
short HowManyUsableScreens (Boolean use1Bit, Boolean use4Bit, Boolean use8Bit)
{
return 1;
}
//-------------------------------------------------------------- CheckOurEnvirons
// Calls all the above functions in order to fill out a sort of "spec sheet"<22>
// for the current Mac.
void CheckOurEnvirons (void)
{
thisMac.thisResFile = CurResFile();
thisMac.vRefNum = 0; // TEMP
thisMac.dirID = 0; // TEMP
thisMac.hasGestalt = true; // TEMP
thisMac.hasWNE = true; // TEMP
thisMac.hasColor = true; // TEMP
thisMac.canSwitch = true; // TEMP
thisMac.hasSystem7 = true; // TEMP
thisMac.hasSM3 = true; // TEMP
thisMac.hasQT = DoWeHaveQuickTime();
thisMac.hasDrag = DoWeHaveDragManager();
FindOurDevice();
thisMac.can1Bit = true;
thisMac.can4Bit = true;
thisMac.can8Bit = true;
thisMac.numScreens = HowManyUsableScreens(false, true, true);
GetDeviceRect(&thisMac.screen);
thisMac.wasDepth = WhatsOurDepth();
thisMac.wasColorOrGray = AreWeColorOrGrayscale();
}
//-------------------------------------------------------------- ReflectMonitor2Environs
// Tests second monitor (if available) for specific bit depth capabilities.
/*
void ReflectSecondMonitorEnvirons (Boolean use1Bit, Boolean use4Bit, Boolean use8Bit)
{
GDHandle tempGDevice;
tempGDevice = GetDeviceList();
while (tempGDevice != nil)
{
if (TestDeviceAttribute(tempGDevice, screenDevice))
if ((use1Bit && CanWeDisplay1Bit(tempGDevice)) ||
(use4Bit && CanWeDisplay4Bit(tempGDevice)) ||
(use8Bit && CanWeDisplay8Bit(tempGDevice)))
if (!TestDeviceAttribute(tempGDevice, mainScreen))
{
thisGDevice = tempGDevice;
thisMac.can1Bit = CanWeDisplay1Bit(thisGDevice);
thisMac.can4Bit = CanWeDisplay4Bit(thisGDevice);
thisMac.can8Bit = CanWeDisplay8Bit(thisGDevice);
thisMac.wasDepth = WhatsOurDepth();
thisMac.wasColorOrGray = AreWeColorOrGrayscale();
GetDeviceRect(&thisMac.screen);
break;
}
tempGDevice = GetNextDevice(tempGDevice);
}
}
*/
//-------------------------------------------------------------- HandleDepthSwitching
// Handles setting up a monitor's depth to play on.
void HandleDepthSwitching (void)
{
if (thisMac.hasColor)
{
switch (isDepthPref)
{
case kSwitchIfNeeded:
if ((thisMac.wasDepth != 8) &&
((thisMac.wasDepth != 4) || (thisMac.wasColorOrGray)))
SwitchDepthOrAbort();
break;
case kSwitchTo256Colors:
if (thisMac.wasDepth != 8)
{
if (thisMac.can8Bit)
SwitchToDepth(8, true);
else
SwitchDepthOrAbort();
}
break;
case kSwitchTo16Grays:
if ((thisMac.wasDepth != 4) || (thisMac.wasColorOrGray))
{
if (thisMac.can4Bit)
SwitchToDepth(4, false);
else
SwitchDepthOrAbort();
}
break;
default:
break;
}
}
thisMac.isDepth = WhatsOurDepth();
}
//-------------------------------------------------------------- RestoreColorDepth
// Restores a monitor to its previous depth when we quit (if we changed it).
void RestoreColorDepth (void)
{
if ((thisMac.hasColor) && ((thisMac.wasDepth != thisMac.isDepth) ||
(thisMac.wasColorOrGray != AreWeColorOrGrayscale())))
SwitchToDepth(thisMac.wasDepth, true);
}
//-------------------------------------------------------------- CheckMemorySize
// Tests for a specific amount of memory available. If the required memory<72>
// is not available, attempts to turn off various game features (music, etc.)<29>
// in order to accomodate the constrained memory available.
void CheckMemorySize (void)
{
#define kBaseBytesNeeded 614400L // 600K Base memory
#define kPaddingBytes 204800L // 200K Padding
long bytesNeeded, bytesAvail;
long soundBytes, musicBytes;
dontLoadMusic = false;
dontLoadSounds = false;
bytesNeeded = kBaseBytesNeeded; // base memory
soundBytes = SoundBytesNeeded(); // sound memory
if (soundBytes <= 0L)
RedAlert(kErrNoMemory);
else
bytesNeeded += soundBytes;
musicBytes = MusicBytesNeeded(); // music memory
if (musicBytes <= 0L)
RedAlert(kErrNoMemory);
else
bytesNeeded += musicBytes;
bytesNeeded += 4L * (long)thisMac.screen.bottom; // main screen
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) *
((long)houseRect.bottom + 1 - (long)houseRect.top) *
(long)thisMac.isDepth) / 8L; // work map
bytesNeeded += 4L * (long)houseRect.bottom;
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) *
((long)houseRect.bottom + 1 - (long)houseRect.top) *
(long)thisMac.isDepth) / 8L; // back map
bytesNeeded += 4L * houseRect.bottom;
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) * 21 *
(long)thisMac.isDepth) / 8L; // scoreboard map
bytesNeeded += (6396L * (long)thisMac.isDepth) / 8L; // more scoreboard
bytesNeeded += (32112L * (long)thisMac.isDepth) / 8L; // glider map
bytesNeeded += (32112L * (long)thisMac.isDepth) / 8L; // glider2 map
bytesNeeded += 32064L / 8L; // glider mask
bytesNeeded += (912L * (long)thisMac.isDepth) / 8L; // glider shadow
bytesNeeded += 864L / 8L; // shadow mask
bytesNeeded += (304L * (long)thisMac.isDepth) / 8L; // rubber bands
bytesNeeded += 288L / 8L; // bands mask
bytesNeeded += (19344L * (long)thisMac.isDepth) / 8L; // blower map
bytesNeeded += 19344L / 8L; // blower mask
bytesNeeded += (17856L * (long)thisMac.isDepth) / 8L; // furniture map
bytesNeeded += 17792L / 8L; // furniture mask
bytesNeeded += (33264L * (long)thisMac.isDepth) / 8L; // prizes map
bytesNeeded += 33176L / 8L; // prizes mask
bytesNeeded += (2904L * (long)thisMac.isDepth) / 8L; // points map
bytesNeeded += 2880L / 8L; // points mask
bytesNeeded += (1848L * (long)thisMac.isDepth) / 8L; // transport map
bytesNeeded += 1792L / 8L; // transport mask
bytesNeeded += (3360L * (long)thisMac.isDepth) / 8L; // switches map
bytesNeeded += (9144L * (long)thisMac.isDepth) / 8L; // lights map
bytesNeeded += 9072L / 8L; // lights mask
bytesNeeded += (21600L * (long)thisMac.isDepth) / 8L; // appliances map
bytesNeeded += 21520L / 8L; // appliances mask
bytesNeeded += (5600L * (long)thisMac.isDepth) / 8L; // toast map
bytesNeeded += 5568L / 8L; // toast mask
bytesNeeded += (1440L * (long)thisMac.isDepth) / 8L; // shredded map
bytesNeeded += 1400L / 8L; // shredded mask
bytesNeeded += (5784L * (long)thisMac.isDepth) / 8L; // balloon map
bytesNeeded += 5760L / 8L; // balloon mask
bytesNeeded += (9632L * (long)thisMac.isDepth) / 8L; // copter map
bytesNeeded += 9600L / 8L; // copter mask
bytesNeeded += (4928L * (long)thisMac.isDepth) / 8L; // dart map
bytesNeeded += 4864L / 8L; // dart mask
bytesNeeded += (2080L * (long)thisMac.isDepth) / 8L; // ball map
bytesNeeded += 2048L / 8L; // ball mask
bytesNeeded += (1168L * (long)thisMac.isDepth) / 8L; // drip map
bytesNeeded += 1152L / 8L; // drip mask
bytesNeeded += (1224L * (long)thisMac.isDepth) / 8L; // enemy map
bytesNeeded += 1188L / 8L; // enemy mask
bytesNeeded += (2064L * (long)thisMac.isDepth) / 8L; // fish map
bytesNeeded += 2048L / 8L; // fish mask
bytesNeeded += (8960L * (long)thisMac.isDepth) / 8L; // clutter map
bytesNeeded += 8832L / 8L; // clutter mask
bytesNeeded += (23040L * (long)thisMac.isDepth) / 8L; // support map
bytesNeeded += (4320L * (long)thisMac.isDepth) / 8L; // angel map
bytesNeeded += 4224L / 8L; // angel mask
bytesNeeded += sizeof(roomType);
bytesNeeded += sizeof(hotObject) * kMaxHotSpots;
bytesNeeded += sizeof(sparkleType) * kMaxSparkles;
bytesNeeded += sizeof(flyingPtType) * kMaxFlyingPts;
bytesNeeded += sizeof(flameType) * kMaxCandles;
bytesNeeded += sizeof(flameType) * kMaxTikis;
bytesNeeded += sizeof(flameType) * kMaxCoals;
bytesNeeded += sizeof(pendulumType) * kMaxPendulums;
bytesNeeded += sizeof(savedType) * kMaxSavedMaps;
bytesNeeded += sizeof(bandType) * kMaxRubberBands;
bytesNeeded += sizeof(greaseType) * kMaxGrease;
bytesNeeded += sizeof(starType) * kMaxStars;
bytesNeeded += sizeof(shredType) * kMaxShredded;
bytesNeeded += sizeof(dynaType) * kMaxDynamicObs;
bytesNeeded += sizeof(objDataType) * kMaxMasterObjects;
bytesNeeded += kDemoLength; SpinCursor(1);
bytesAvail = FreeMem(); SpinCursor(1);
}
void GetDeviceRect(Rect *rect)
{
unsigned int width;
unsigned int height;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(width, height);
SetRect(rect, 0, 0, static_cast<short>(width), static_cast<short>(height));
}
Boolean AreWeColorOrGrayscale()
{
// ... As opposed to B&W
return true;
}
void SwitchDepthOrAbort(void)
{
}

37
GpApp/Environ.h Normal file
View File

@@ -0,0 +1,37 @@
//============================================================================
//----------------------------------------------------------------------------
// Environ.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQuickdraw.h"
typedef struct
{
Rect screen, gray;
long dirID;
short wasDepth, isDepth;
short thisResFile;
short numScreens;
short vRefNum;
Boolean can1Bit;
Boolean can4Bit;
Boolean can8Bit;
Boolean wasColorOrGray;
Boolean hasWNE;
Boolean hasSystem7;
Boolean hasColor;
Boolean hasGestalt;
Boolean canSwitch;
Boolean canColor;
Boolean hasSM3;
Boolean hasQT;
Boolean hasDrag;
} macEnviron;
extern macEnviron thisMac;

574
GpApp/Events.cpp Normal file
View File

@@ -0,0 +1,574 @@
//============================================================================
//----------------------------------------------------------------------------
// Events.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLAppleEvents.h"
#include "PLToolUtils.h"
#include "PLQuickdraw.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "ObjectEdit.h"
short BitchAboutColorDepth (void);
void HandleMouseEvent (EventRecord *);
void HandleKeyEvent (EventRecord *);
void HandleUpdateEvent (EventRecord *);
void HandleOSEvent (EventRecord *);
void HandleHighLevelEvent (EventRecord *);
void HandleIdleTask (void);
void IncrementMode (void);
long lastUp, incrementModeTime;
UInt32 doubleTime;
Point lastWhere;
short idleMode;
Boolean doAutoDemo, switchedOut;
extern WindowPtr mapWindow, toolsWindow, linkWindow;
extern WindowPtr menuWindow;
extern short isEditH, isEditV, isMapH, isMapV, isToolsH, isToolsV;
extern short isLinkH, isLinkV, isCoordH, isCoordV;
extern Boolean quitting, isMusicOn, failedMusic;
extern Boolean autoRoomEdit, newRoomNow, isPlayMusicIdle;
//============================================================== Functions
//-------------------------------------------------------------- BitchAboutColorDepth
// Display a dialog that alerts the user that they have switched the bit<69>
// depth of the monitor under our noses. They must return it to previous.
short BitchAboutColorDepth (void)
{
#define kColorSwitchedAlert 1042
short sheSaid;
// CenterAlert(kColorSwitchedAlert);
sheSaid = Alert(kColorSwitchedAlert, nil);
return (sheSaid);
}
//-------------------------------------------------------------- HandleMouseEvent
// Handle a mouse click event.
void HandleMouseEvent (EventRecord *theEvent)
{
WindowPtr whichWindow;
long menuChoice, newSize;
short thePart, hDelta, vDelta;
Boolean isDoubleClick;
thePart = FindWindow(theEvent->where, &whichWindow);
switch (thePart)
{
case inSysWindow:
// SystemClick(theEvent, whichWindow);
break;
case inMenuBar:
menuChoice = MenuSelect(theEvent->where);
DoMenuChoice(menuChoice);
break;
case inDrag:
DragWindow(whichWindow, theEvent->where, &thisMac.screen);
if (whichWindow == mainWindow)
{
SendBehind(mainWindow, (WindowPtr)0L);
GetWindowLeftTop(whichWindow, &isEditH, &isEditV);
}
else if (whichWindow == mapWindow)
GetWindowLeftTop(whichWindow, &isMapH, &isMapV);
else if (whichWindow == toolsWindow)
GetWindowLeftTop(whichWindow, &isToolsH, &isToolsV);
else if (whichWindow == linkWindow)
GetWindowLeftTop(whichWindow, &isLinkH, &isLinkV);
else if (whichWindow == coordWindow)
GetWindowLeftTop(whichWindow, &isCoordH, &isCoordV);
HiliteAllWindows();
break;
case inGoAway:
if (TrackGoAway(whichWindow,theEvent->where))
{
if (whichWindow == mapWindow)
ToggleMapWindow();
else if (whichWindow == toolsWindow)
ToggleToolsWindow();
else if (whichWindow == linkWindow)
CloseLinkWindow();
else if (whichWindow == coordWindow)
ToggleCoordinateWindow();
}
break;
case inGrow:
if (whichWindow == mapWindow)
{
newSize = GrowWindow(mapWindow, theEvent->where, &thisMac.gray);
ResizeMapWindow(LoWord(newSize), HiWord(newSize));
}
break;
case inZoomIn:
case inZoomOut:
if (TrackBox(whichWindow, theEvent->where, thePart))
ZoomWindow(whichWindow, thePart, true);
break;
case inContent:
if (whichWindow == mainWindow)
{
hDelta = theEvent->where.h - lastWhere.h;
if (hDelta < 0)
hDelta = -hDelta;
vDelta = theEvent->where.v - lastWhere.v;
if (vDelta < 0)
vDelta = -vDelta;
if (((theEvent->when - lastUp) < doubleTime) && (hDelta < 5) &&
(vDelta < 5))
isDoubleClick = true;
else
{
isDoubleClick = false;
lastUp = theEvent->when;
lastWhere = theEvent->where;
}
HandleMainClick(theEvent->where, isDoubleClick);
}
else if (whichWindow == mapWindow)
HandleMapClick(theEvent);
else if (whichWindow == toolsWindow)
HandleToolsClick(theEvent->where);
else if (whichWindow == linkWindow)
HandleLinkClick(theEvent->where);
break;
default:
break;
}
}
//-------------------------------------------------------------- HandleKeyEvent
// Handle a key-down event.
void HandleKeyEvent (EventRecord *theEvent)
{
char theChar;
Boolean shiftDown, commandDown, optionDown;
theChar = theEvent->message & charCodeMask;
shiftDown = ((theEvent->modifiers & shiftKey) != 0);
commandDown = ((theEvent->modifiers & cmdKey) != 0);
optionDown = ((theEvent->modifiers & optionKey) != 0);
if ((commandDown) && (!optionDown))
DoMenuChoice(MenuKey(theChar));
else
{
switch (theChar)
{
case kHelpKeyASCII:
break;
case kPageUpKeyASCII:
if (houseUnlocked)
PrevToolMode();
break;
case kPageDownKeyASCII:
if (houseUnlocked)
NextToolMode();
break;
#if BUILD_ARCADE_VERSION
case kLeftArrowKeyASCII:
DoOptionsMenu(iHighScores);
break;
case kRightArrowKeyASCII:
DoOptionsMenu(iHelp);
break;
case kUpArrowKeyASCII:
DoGameMenu(iNewGame);
break;
case kDownArrowKeyASCII:
DoGameMenu(iNewGame);
break;
#else
case kLeftArrowKeyASCII:
if (houseUnlocked)
{
if (objActive == kNoObjectSelected)
SelectNeighborRoom(kRoomToLeft);
else
MoveObject(kBumpLeft, shiftDown);
}
break;
case kRightArrowKeyASCII:
if (houseUnlocked)
{
if (objActive == kNoObjectSelected)
SelectNeighborRoom(kRoomToRight);
else
MoveObject(kBumpRight, shiftDown);
}
break;
case kUpArrowKeyASCII:
if (houseUnlocked)
{
if (objActive == kNoObjectSelected)
SelectNeighborRoom(kRoomAbove);
else
MoveObject(kBumpUp, shiftDown);
}
break;
case kDownArrowKeyASCII:
if (houseUnlocked)
{
if (objActive == kNoObjectSelected)
SelectNeighborRoom(kRoomBelow);
else
MoveObject(kBumpDown, shiftDown);
}
break;
#endif
case kDeleteKeyASCII:
if (houseUnlocked)
{
if (objActive == kNoObjectSelected)
DeleteRoom(true);
else
DeleteObject();
}
break;
case kTabKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
{
if (shiftDown)
SelectPrevObject();
else
SelectNextObject();
}
break;
case kEscapeKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
DeselectObject();
break;
case kAKeyASCII:
case kCapAKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kApplianceMode);
break;
case kBKeyASCII:
case kCapBKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kBlowerMode);
break;
case kCKeyASCII:
case kCapCKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kClutterMode);
break;
case kEKeyASCII:
case kCapEKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kEnemyMode);
break;
case kFKeyASCII:
case kCapFKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kFurnitureMode);
break;
case kLKeyASCII:
case kCapLKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kLightMode);
break;
case kPKeyASCII:
case kCapPKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kBonusMode);
break;
case kSKeyASCII:
case kCapSKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kSwitchMode);
break;
case kTKeyASCII:
case kCapTKeyASCII:
if ((theMode == kEditMode) && (houseUnlocked))
SetSpecificToolMode(kTransportMode);
break;
default:
break;
}
}
}
//-------------------------------------------------------------- HandleUpdateEvent
// Handle an update event.
void HandleUpdateEvent (EventRecord *theEvent)
{
if ((WindowPtr)theEvent->message == mainWindow)
{
SetPort((GrafPtr)mainWindow);
BeginUpdate(mainWindow);
UpdateMainWindow();
EndUpdate(mainWindow);
}
else if ((WindowPtr)theEvent->message == mapWindow)
{
SetPort((GrafPtr)mapWindow);
BeginUpdate(mapWindow);
UpdateMapWindow();
EndUpdate(mapWindow);
}
else if ((WindowPtr)theEvent->message == toolsWindow)
{
SetPort((GrafPtr)toolsWindow);
BeginUpdate(toolsWindow);
UpdateToolsWindow();
EndUpdate(toolsWindow);
}
else if ((WindowPtr)theEvent->message == linkWindow)
{
SetPort((GrafPtr)linkWindow);
BeginUpdate(linkWindow);
UpdateLinkWindow();
EndUpdate(linkWindow);
}
else if ((WindowPtr)theEvent->message == coordWindow)
{
SetPort((GrafPtr)coordWindow);
BeginUpdate(coordWindow);
UpdateCoordWindow();
EndUpdate(coordWindow);
}
else if ((WindowPtr)theEvent->message == menuWindow)
{
SetPort((GrafPtr)menuWindow);
BeginUpdate(menuWindow);
UpdateMenuBarWindow();
EndUpdate(menuWindow);
}
}
//-------------------------------------------------------------- HandleOSEvent
// Handle an OS Event (MultiFinder - user has switched in or out of app).
void HandleOSEvent (EventRecord *theEvent)
{
OSErr theErr;
short buttonHit;
if (theEvent->message & 0x01000000) // suspend or resume event
{
if (theEvent->message & 0x00000001) // resume event
{
if (WhatsOurDepth() != thisMac.isDepth)
{
buttonHit = BitchAboutColorDepth();
if (buttonHit == 1) // player wants to Quit
{
#ifndef COMPILEDEMO
if (QuerySaveChanges())
quitting = true;
#else
quitting = true;
#endif
}
else
{
SwitchToDepth(thisMac.isDepth, thisMac.wasColorOrGray);
}
}
switchedOut = false;
InitCursor();
if ((isPlayMusicIdle) && (theMode != kEditMode))
{
theErr = StartMusic();
if (theErr != noErr)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
incrementModeTime = TickCount() + kIdleSplashTicks;
#ifndef COMPILEDEMO
// if (theMode == kEditMode)
// SeeIfValidScrapAvailable(true);
#endif
}
else // suspend event
{
switchedOut = true;
InitCursor();
if ((isMusicOn) && (theMode != kEditMode))
StopTheMusic();
}
}
}
//-------------------------------------------------------------- HandleHighLevelEvent
// Handle an AppleEvent (Open Document, Quit Application, etc.).
void HandleHighLevelEvent (EventRecord *theEvent)
{
OSErr theErr;
theErr = AEProcessAppleEvent(theEvent);
if ((theErr != noErr) && (theErr != errAEEventNotHandled))
YellowAlert(kYellowAppleEventErr, theErr);
}
//-------------------------------------------------------------- HandleIdleTask
// Handle some processing during event lulls.
void HandleIdleTask (void)
{
if (theMode == kEditMode)
{
SetPort((GrafPtr)mainWindow);
DoMarquee();
if ((autoRoomEdit) && (newRoomNow))
{
if (theMode == kEditMode)
DoRoomInfo();
newRoomNow = false;
}
}
}
//-------------------------------------------------------------- HandleEvent
// "Master" function that tests for events and calls the above functions to<74>
// handle each event type. Not called during and actual game.
void HandleEvent (void)
{
KeyMap eventKeys;
EventRecord theEvent;
long sleep = 2;
Boolean itHappened = true;
GetKeys(eventKeys);
if ((BitTst(&eventKeys, kCommandKeyMap)) &&
(BitTst(&eventKeys, kOptionKeyMap)))
{
HiliteAllObjects();
}
else if ((BitTst(&eventKeys, kOptionKeyMap)) && (theMode == kEditMode) &&
(houseUnlocked))
{
EraseSelectedTool();
SelectTool(kSelectTool);
}
//if (thisMac.hasWNE)
// itHappened = WaitNextEvent(everyEvent, &theEvent, sleep, nil);
//else
{
// SystemTask();
itHappened = GetNextEvent(everyEvent, &theEvent);
}
if (itHappened)
{
switch (theEvent.what)
{
case mouseDown:
HandleMouseEvent(&theEvent);
break;
case keyDown:
case autoKey:
HandleKeyEvent(&theEvent);
break;
case updateEvt:
HandleUpdateEvent(&theEvent);
break;
case osEvt:
HandleOSEvent(&theEvent);
break;
case kHighLevelEvent:
HandleHighLevelEvent(&theEvent);
break;
}
}
else
HandleIdleTask();
if ((theMode == kSplashMode) && doAutoDemo && !switchedOut)
{
if (TickCount() >= incrementModeTime)
DoDemoGame();
}
}
//-------------------------------------------------------------- HiliteAllWindows
// Ugly kludge in order to keep "floating windows" (palettes) on top of<6F>
// the main window.
void HiliteAllWindows (void)
{
if (mainWindow != nil)
HiliteWindow(mainWindow, true);
if (mapWindow != nil)
HiliteWindow(mapWindow, true);
if (toolsWindow != nil)
HiliteWindow(toolsWindow, true);
if (coordWindow != nil)
HiliteWindow(coordWindow, true);
if (linkWindow != nil)
HiliteWindow(linkWindow, true);
}
//-------------------------------------------------------------- IgnoreThisClick
// Another inelegant kludge designed to temporarily prevent an unwanted<65>
// double-click to be registered.
void IgnoreThisClick (void)
{
lastUp -= doubleTime;
lastWhere.h = -100;
lastWhere.v = -100;
}

390
GpApp/Externs.h Normal file
View File

@@ -0,0 +1,390 @@
//============================================================================
//----------------------------------------------------------------------------
// Externs.h
//----------------------------------------------------------------------------
//============================================================================
#pragma once
#include "PLMenus.h"
#define kPreferredDepth 8
#define kNilPointer 0L
#define kPutInFront (WindowPtr)-1L
#define kNormalUpdates TRUE
#define kOneKilobyte 1024
#define kOkayButton 1
#define kCancelButton 2
#define kControlActive 0
#define kControlInactive 255
#define kAsynch TRUE
#define kSynch FALSE
#define kHomeKeyASCII 0x01
#define kEnterKeyASCII 0x03
#define kEndKeyASCII 0x04
#define kHelpKeyASCII 0x05
#define kDeleteKeyASCII 0x08
#define kTabKeyASCII 0x09
#define kPageUpKeyASCII 0x0B
#define kPageDownKeyASCII 0x0C
#define kReturnKeyASCII 0x0D
#define kFunctionKeyASCII 0x10
#define kClearKeyASCII 0x1A
#define kEscapeKeyASCII 0x1B
#define kLeftArrowKeyASCII 0x1C
#define kRightArrowKeyASCII 0x1D
#define kUpArrowKeyASCII 0x1E
#define kDownArrowKeyASCII 0x1F
#define kSpaceBarASCII 0x20
#define kExclamationASCII 0x21
#define kPlusKeyASCII 0x2B
#define kMinusKeyASCII 0x2D
#define k0KeyASCII 0x30
#define k1KeyASCII 0x31
#define k2KeyASCII 0x32
#define k3KeyASCII 0x33
#define k4KeyASCII 0x34
#define k5KeyASCII 0x35
#define k6KeyASCII 0x36
#define k7KeyASCII 0x37
#define k8KeyASCII 0x38
#define k9KeyASCII 0x39
#define kCapAKeyASCII 0x41
#define kCapBKeyASCII 0x42
#define kCapCKeyASCII 0x43
#define kCapDKeyASCII 0x44
#define kCapEKeyASCII 0x45
#define kCapFKeyASCII 0x46
#define kCapGKeyASCII 0x47
#define kCapHKeyASCII 0x48
#define kCapIKeyASCII 0x49
#define kCapJKeyASCII 0x4A
#define kCapKKeyASCII 0x4B
#define kCapLKeyASCII 0x4C
#define kCapMKeyASCII 0x4D
#define kCapNKeyASCII 0x4E
#define kCapOKeyASCII 0x4F
#define kCapPKeyASCII 0x50
#define kCapQKeyASCII 0x51
#define kCapRKeyASCII 0x52
#define kCapSKeyASCII 0x53
#define kCapTKeyASCII 0x54
#define kCapUKeyASCII 0x55
#define kCapVKeyASCII 0x56
#define kCapWKeyASCII 0x57
#define kCapXKeyASCII 0x58
#define kCapYKeyASCII 0x59
#define kCapZKeyASCII 0x5A
#define kAKeyASCII 0x61
#define kBKeyASCII 0x62
#define kCKeyASCII 0x63
#define kDKeyASCII 0x64
#define kEKeyASCII 0x65
#define kFKeyASCII 0x66
#define kGKeyASCII 0x67
#define kHKeyASCII 0x68
#define kIKeyASCII 0x69
#define kJKeyASCII 0x6A
#define kKKeyASCII 0x6B
#define kLKeyASCII 0x6C
#define kMKeyASCII 0x6D
#define kNKeyASCII 0x6E
#define kOKeyASCII 0x6F
#define kPKeyASCII 0x70
#define kQKeyASCII 0x71
#define kRKeyASCII 0x72
#define kSKeyASCII 0x73
#define kTKeyASCII 0x74
#define kUKeyASCII 0x75
#define kVKeyASCII 0x76
#define kWKeyASCII 0x77
#define kXKeyASCII 0x78
#define kYKeyASCII 0x79
#define kZKeyASCII 0x7A
#define kForwardDeleteASCII 0x7F
#define kPlusKeypadMap 66 // key map offset for + on keypad
#define kMinusKeypadMap 73 // key map offset for - on keypad
#define kTimesKeypadMap 68 // key map offset for * on keypad
#define k0KeypadMap 85 // key map offset for 0 on keypad
#define k1KeypadMap 84 // key map offset for 1 on keypad
#define k2KeypadMap 83 // key map offset for 2 on keypad
#define k3KeypadMap 82 // key map offset for 3 on keypad
#define k4KeypadMap 81 // key map offset for 4 on keypad
#define k5KeypadMap 80 // key map offset for 5 on keypad
#define k6KeypadMap 95 // key map offset for 6 on keypad
#define k7KeypadMap 94 // key map offset for 7 on keypad
#define k8KeypadMap 92 // key map offset for 8 on keypad
#define k9KeypadMap 91 // key map offset for 9 on keypad
#define kUpArrowKeyMap 121 // key map offset for up arrow
#define kDownArrowKeyMap 122 // key map offset for down arrow
#define kRightArrowKeyMap 123 // key map offset for right arrow
#define kLeftArrowKeyMap 124 // key map offset for left arrow
#define kAKeyMap 7
#define kBKeyMap 12
#define kCKeyMap 15
#define kDKeyMap 5
#define kEKeyMap 9
#define kFKeyMap 4
#define kGKeyMap 2
#define kHKeyMap 3
#define kMKeyMap 41
#define kNKeyMap 42
#define kOKeyMap 24
#define kPKeyMap 36
#define kQKeyMap 11
#define kRKeyMap 8
#define kSKeyMap 6
#define kTKeyMap 22
#define kVKeyMap 14
#define kWKeyMap 10
#define kXKeyMap 0
#define kZKeyMap 1
#define kPeriodKeyMap 40
#define kCommandKeyMap 48
#define kEscKeyMap 50
#define kDeleteKeyMap 52
#define kSpaceBarMap 54
#define kTabKeyMap 55
#define kControlKeyMap 60
#define kOptionKeyMap 61
#define kCapsLockKeyMap 62
#define kShiftKeyMap 63
#define kTabRawKey 0x30 // key map offset for Tab key
#define kClearRawKey 0x47 // key map offset for Clear key
#define kF5RawKey 0x60 // key map offset for F5
#define kF6RawKey 0x61 // key map offset for F6
#define kF7RawKey 0x62 // key map offset for F7
#define kF3RawKey 0x63 // key map offset for F3
#define kF8RawKey 0x64 // key map offset for F8
#define kF9RawKey 0x65 // key map offset for F9
#define kF11RawKey 0x67 // key map offset for F11
#define kF13RawKey 0x69 // key map offset for F13
#define kF14RawKey 0x6B // key map offset for F14
#define kF10RawKey 0x6D // key map offset for F10
#define kF12RawKey 0x6F // key map offset for F12
#define kF15RawKey 0x71 // key map offset for F15
#define kF4RawKey 0x76 // key map offset for F4
#define kF2RawKey 0x78 // key map offset for F2
#define kF1RawKey 0x7A // key map offset for F1
#define kErrUnnaccounted 1
#define kErrNoMemory 2
#define kErrDialogDidntLoad 3
#define kErrFailedResourceLoad 4
#define kErrFailedGraphicLoad 5
#define kErrFailedOurDirect 6
#define kErrFailedValidation 7
#define kErrNeedSystem7 8
#define kErrFailedGetDevice 9
#define kErrFailedMemoryOperation 10
#define kErrFailedCatSearch 11
#define kErrNeedColorQD 12
#define kErrNeed16Or256Colors 13
#define iAbout 1
#define iNewGame 1
#define iTwoPlayer 2
#define iOpenSavedGame 3
#define iLoadHouse 5
#define iQuit 7
#define iEditor 1
#define iHighScores 3
#define iPrefs 4
#define iHelp 5
#define iNewHouse 1
#define iSave 2
#define iHouse 4
#define iRoom 5
#define iObject 6
#define iCut 8
#define iCopy 9
#define iPaste 10
#define iClear 11
#define iDuplicate 12
#define iBringForward 14
#define iSendBack 15
#define iGoToRoom 17
#define iMapWindow 19
#define iObjectWindow 20
#define iCoordinateWindow 21
//-------------------------------------------------------------- Structs
/*
typedef short SICN[16];
typedef SICN *SICNList;
typedef SICNList *SICNHand;
*/
typedef struct
{
Str32 wasDefaultName;
Str15 wasLeftName, wasRightName;
Str15 wasBattName, wasBandName;
Str15 wasHighName;
Str31 wasHighBanner;
// long encrypted, fakeLong;
long wasLeftMap, wasRightMap;
long wasBattMap, wasBandMap;
short wasVolume;
short prefVersion;
short wasMaxFiles;
short wasEditH, wasEditV;
short wasMapH, wasMapV;
short wasMapWide, wasMapHigh;
short wasToolsH, wasToolsV;
short wasLinkH, wasLinkV;
short wasCoordH, wasCoordV;
short isMapLeft, isMapTop;
short wasNumNeighbors;
short wasDepthPref;
short wasToolGroup;
short smWarnings;
short wasFloor, wasSuite;
Boolean wasZooms, wasMusicOn;
Boolean wasAutoEdit, wasDoColorFade;
Boolean wasMapOpen, wasToolsOpen;
Boolean wasCoordOpen, wasQuickTrans;
Boolean wasIdleMusic, wasGameMusic;
Boolean wasEscPauseKey;
Boolean wasDoAutoDemo, wasScreen2;
Boolean wasDoBackground, wasHouseChecks;
Boolean wasPrettyMap, wasBitchDialogs;
} prefsInfo;
//-------------------------------------------------------------- Prototypes
void DoAbout (void); // --- About.c
void LoadCursors (void); // --- AnimCursor.c
void DisposCursors (void);
void IncrementCursor (void);
void DecrementCursor (void);
void SpinCursor (short);
void BackSpinCursor (short);
void ColorText (StringPtr, long); // --- ColorUtils.c
void ColorRect (Rect *, long);
void ColorOval (Rect *, long);
void ColorRegion (RgnHandle, long);
void ColorLine (short, short, short, short, long);
void HiliteRect (Rect *, short, short);
void ColorFrameRect (Rect *, long);
void ColorFrameWHRect (short, short, short, short, long);
void ColorFrameOval (Rect *, long);
void LtGrayForeColor (void);
void GrayForeColor (void);
void DkGrayForeColor (void);
void RestoreColorsSlam (void);
void MonitorWait (void); // --- DebugUtils.c
void DisplayRect (Rect *);
void FlashRect (Rect *);
void CheckLegitRect(Rect *, Rect *);
void DisplayLong (long);
void DisplayShort (short);
void FlashLong (long);
void FlashShort (short);
void DoBarGraph (short, short, short, short);
short BetaOkay (void);
void DebugNum (long);
void DisplayCTSeed (CGrafPtr);
void FillScreenRed (void);
void DumpToResEditFile (Ptr, long);
void HandleEvent (void); // --- Event.c
void HiliteAllWindows (void);
void IgnoreThisClick (void);
short WhatsOurDepth (void); // --- Environs.c
void SwitchToDepth (short, Boolean);
void CheckOurEnvirons (void);
//void ReflectSecondMonitorEnvirons (Boolean, Boolean, Boolean);
void HandleDepthSwitching (void);
void RestoreColorDepth (void);
void CheckMemorySize (void);
void SetAppMemorySize (long);
Boolean CheckFileError (short, const PLPasStr &); // --- File Error.c
Boolean SavePrefs (prefsInfo *, short); // --- Prefs.c
Boolean LoadPrefs (prefsInfo *, short);
void PasStringCopy (StringPtr, StringPtr); // --- StringUtils.c
short WhichStringFirst (StringPtr, StringPtr);
void PasStringCopyNum (StringPtr, StringPtr, short);
void PasStringConcat (StringPtr, const PLPasStr &);
void GetLineOfText (StringPtr, short, StringPtr);
void WrapText (StringPtr, short);
void GetFirstWordOfString (StringPtr, StringPtr);
void CollapseStringToWidth (StringPtr, short);
void GetChooserName (StringPtr);
StringPtr GetLocalizedString (short, StringPtr);
Point MyGetGlobalMouse (void); // --- Utilities.c
void ToolBoxInit (void);
void FindOurDevice (void);
short RandomInt (short);
long RandomLong (long);
void InitRandomLongQUS (void);
UInt32 RandomLongQUS (void);
//void CenterAlert (short);
void RedAlert (short);
//void CreateOffScreenBitMap (Rect *, GrafPtr *);
//void CreateOffScreenPixMap (Rect *, CGrafPtr *);
//void KillOffScreenPixMap (CGrafPtr);
//void KillOffScreenBitMap (GrafPtr);
void LoadGraphic (short);
void LoadScaledGraphic (short, Rect *);
//void PlotSICN (Rect *, SICNHand, long);
void LargeIconPlot (Rect *, short);
void DrawCIcon (short, short, short);
char KeyMapOffsetFromRawKey (char);
long LongSquareRoot (long);
//void HideMenuBarOld (void);
//void ShowMenuBarOld (void);
Boolean WaitForInputEvent (short);
void WaitCommandQReleased (void);
char GetKeyMapFromMessage (intptr_t);
void GetKeyName (intptr_t, StringPtr);
Boolean OptionKeyDown (void);
long ExtractCTSeed (CGrafPtr);
//void ForceCTSeed (CGrafPtr, long);
void DelayTicks (long);
void UnivGetSoundVolume (short *, Boolean);
void UnivSetSoundVolume (short, Boolean);
Boolean ValidInstallation (Boolean); // --- Validate.c
void GetWindowLeftTop (WindowPtr, short *, short *); // --- WindowUtils.c
void GetWindowRect (WindowPtr, Rect *);
void GetLocalWindowRect (WindowPtr, Rect *);
//void FlagWindowFloating (WindowPtr);
//Boolean IsWindowFloating (WindowPtr);
void OpenMessageWindow (const PLPasStr&);
void SetMessageWindowMessage (StringPtr);
void CloseMessageWindow (void);
void CloseThisWindow (WindowPtr *);
#ifdef powerc
// extern pascal void SetSoundVol(short level); // for old Sound Manager
// extern pascal void GetSoundVol(short *level)
// THREEWORDINLINE(0x4218, 0x10B8, 0x0260);
#endif
#include "GliderDefines.h"
#include "GliderStructs.h"
#include "GliderVars.h"
#include "GliderProtos.h"

101
GpApp/FileError.cpp Normal file
View File

@@ -0,0 +1,101 @@
//============================================================================
//----------------------------------------------------------------------------
// FileError.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLTextUtils.h"
#include "PLPasStr.h"
#include "Externs.h"
#define rFileErrorAlert 140
#define rFileErrorStrings 140
//============================================================== Functions
//-------------------------------------------------------------- CheckFileError
// Given a result code (returned from a previous file operation) this<69>
// function cheks to see if the result code is an error and, if it is<69>
// a common error for which I have a string message, I bring up an<61>
// alert with the error message. If it is an unusual error, I still<6C>
// bring up an alert but with "Miscellaneous file error" and the<68>
// error ID.
Boolean CheckFileError (short resultCode, const PLPasStr &fileName)
{
short dummyInt, stringIndex;
Str255 errMessage, errNumString;
if (resultCode == noErr) // No problems? Then cruise
return(true);
switch (resultCode)
{
case dirFulErr:
stringIndex = 2;
break;
case dskFulErr:
stringIndex = 3;
break;
case ioErr:
stringIndex = 4;
break;
case bdNamErr:
stringIndex = 5;
break;
case fnOpnErr:
stringIndex = 6;
break;
case mFulErr:
stringIndex = 7;
break;
case tmfoErr:
stringIndex = 8;
break;
case wPrErr:
stringIndex = 9;
break;
case fLckdErr:
stringIndex = 10;
break;
case vLckdErr:
stringIndex = 11;
break;
case fBsyErr:
stringIndex = 12;
break;
case dupFNErr:
stringIndex = 13;
break;
case opWrErr:
stringIndex = 14;
break;
case volOffLinErr:
stringIndex = 15;
break;
case permErr:
stringIndex = 16;
break;
case wrPermErr:
stringIndex = 17;
break;
default:
stringIndex = 1;
break;
}
InitCursor();
GetIndString(errMessage, rFileErrorStrings, stringIndex);
NumToString((long)resultCode, errNumString);
ParamText(errMessage, errNumString, fileName, PSTR(""));
// CenterAlert(rFileErrorAlert);
dummyInt = Alert(rFileErrorAlert, 0L);
return(false);
}

508
GpApp/GameOver.cpp Normal file
View File

@@ -0,0 +1,508 @@
//============================================================================
//----------------------------------------------------------------------------
// GameOver.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLToolUtils.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "RectUtils.h"
#include "Utilities.h"
#define kNumCountDownFrames 16
#define kPageFrames 14
#define kPagesPictID 1990
#define kPagesMaskID 1989
#define kLettersPictID 1988
#define kMilkywayPictID 1021
typedef struct
{
Rect dest, was;
short frame, counter;
Boolean stuck;
} pageType, *pagePtr;
void DoGameOverStarAnimation (void);
void SetUpFinalScreen (void);
void InitDiedGameOver (void);
void HandlePages (void);
void DrawPages (void);
pageType pages[8];
Rect pageSrcRect, pageSrc[kPageFrames], lettersSrc[8], angelSrcRect;
RgnHandle roomRgn;
GWorldPtr pageSrcMap, gameOverSrcMap, angelSrcMap;
GWorldPtr pageMaskMap, angelMaskMap;
short countDown, stopPages, pagesStuck;
Boolean gameOver;
extern Rect justRoomsRect;
extern short splashOriginH, splashOriginV, numWork2Main;
extern short numBack2Work;
extern Boolean playing, shadowVisible, demoGoing;
//============================================================== Functions
//-------------------------------------------------------------- DoGameOver
// Handles a game over. This is a game over where the player has<61>
// completed the house.
void DoGameOver (void)
{
playing = false;
SetUpFinalScreen();
SetPort((GrafPtr)mainWindow);
ColorRect(&mainWindowRect, 244);
DoGameOverStarAnimation();
if (!TestHighScore())
RedrawSplashScreen();
}
//-------------------------------------------------------------- SetUpFinalScreen
// This sets up the game over screen (again, this function is for when<65>
// the player completes the house).
void SetUpFinalScreen (void)
{
Rect tempRect;
Str255 tempStr, subStr;
short count, offset, i, textDown;
char wasState;
SetPort((GrafPtr)workSrcMap);
ColorRect(&workSrcRect, 244);
QSetRect(&tempRect, 0, 0, 640, 460);
CenterRectInRect(&tempRect, &workSrcRect);
LoadScaledGraphic(kMilkywayPictID, &tempRect);
textDown = tempRect.top;
if (textDown < 0)
textDown = 0;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
PasStringCopy((*thisHouse)->trailer, tempStr);
HSetState((Handle)thisHouse, wasState);
count = 0;
do
{
GetLineOfText(tempStr, count, subStr);
offset = ((thisMac.screen.right - thisMac.screen.left) -
TextWidth(subStr, 1, subStr[0])) / 2;
TextFont(applFont);
TextFace(bold);
TextSize(12);
ForeColor(blackColor);
MoveTo(offset + 1, textDown + 33 + (count * 20));
DrawString(subStr);
ForeColor(whiteColor);
MoveTo(offset, textDown + 32 + (count * 20));
DrawString(subStr);
ForeColor(blackColor);
count++;
}
while (subStr[0] > 0);
CopyRectWorkToBack(&workSrcRect);
for (i = 0; i < 5; i++) // initialize the falling stars
{
pages[i].dest = starSrc[0];
QOffsetRect(&pages[i].dest,
workSrcRect.right + RandomInt(workSrcRect.right / 5) +
(workSrcRect.right/ 4) * i,
RandomInt(workSrcRect.bottom) - workSrcRect.bottom / 2);
pages[i].was = pages[i].dest;
pages[i].frame = RandomInt(6);
}
}
//-------------------------------------------------------------- DoGameOverStarAnimation
// This handles the falling stars and the flying angel when a player<65>
// completes a house.
void DoGameOverStarAnimation (void)
{
#define kStarFalls 8
EventRecord theEvent;
KeyMap theKeys;
Rect angelDest;
long nextLoop;
short which, i, count, pass;
Boolean noInteruption;
angelDest = angelSrcRect;
QOffsetRect(&angelDest, -96, 0);
noInteruption = true;
nextLoop = TickCount() + 2;
count = 0;
pass = 0;
FlushEvents(everyEvent, 0);
while (noInteruption)
{
if ((angelDest.left % 32) == 0) // add a star
{
PlayPrioritySound(kMysticSound, kMysticPriority);
which = angelDest.left / 32;
which = which % 5;
ZeroRectCorner(&pages[which].dest);
QOffsetRect(&pages[which].dest, angelDest.left, angelDest.bottom);
if (count < (which + 1))
count = which + 1;
}
for (i = 0; i < count; i++)
{
pages[i].frame++;
if (pages[i].frame >= 6)
pages[i].frame = 0;
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap *)*GetGWorldPixMap(bonusMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&starSrc[pages[i].frame],
&starSrc[pages[i].frame],
&pages[i].dest);
pages[i].was = pages[i].dest;
pages[i].was.top -= kStarFalls;
AddRectToWorkRectsWhole(&pages[i].was);
AddRectToBackRects(&pages[i].dest);
if (pages[i].dest.top < workSrcRect.bottom)
QOffsetRect(&pages[i].dest, 0, kStarFalls);
}
if (angelDest.left <= (workSrcRect.right + 2))
{
CopyMask((BitMap *)*GetGWorldPixMap(angelSrcMap),
(BitMap *)*GetGWorldPixMap(angelMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&angelSrcRect, &angelSrcRect, &angelDest);
angelDest.left -= 2;
AddRectToWorkRectsWhole(&angelDest);
angelDest.left += 2;
AddRectToBackRects(&angelDest);
QOffsetRect(&angelDest, 2, 0);
pass = 0;
}
CopyRectsQD();
numWork2Main = 0;
numBack2Work = 0;
do
{
GetKeys(theKeys);
if ((BitTst(&theKeys, kCommandKeyMap)) || (BitTst(&theKeys, kOptionKeyMap)) ||
(BitTst(&theKeys, kShiftKeyMap)) || (BitTst(&theKeys, kControlKeyMap)))
noInteruption = false;
if (GetNextEvent(everyEvent, &theEvent))
if ((theEvent.what == mouseDown) || (theEvent.what == keyDown))
noInteruption = false;
}
while (TickCount() < nextLoop);
nextLoop = TickCount() + 2;
if (pass < 80)
pass++;
else
{
WaitForInputEvent(5);
noInteruption = false;
}
}
}
//-------------------------------------------------------------- FlagGameOver
// Called to indicate (flag) that a game is over. Actual game over<65>
// sequence comes up after a short delay.
void FlagGameOver (void)
{
gameOver = true;
countDown = kNumCountDownFrames;
SetMusicalMode(kPlayWholeScoreMode);
}
//-------------------------------------------------------------- InitDiedGameOver
// This is called when a game is over due to the fact that the player<65>
// lost their last glider (died), not due to getting through the entire<72>
// house. This function initializes the strucures/variables.
void InitDiedGameOver (void)
{
#define kPageSpacing 40
#define kPageRightOffset 128
#define kPageBackUp 128
short i;
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&pageSrcRect, 0, 0, 25, 32 * 8);
theErr = CreateOffScreenGWorld(&gameOverSrcMap, &pageSrcRect, kPreferredDepth);
SetGWorld(gameOverSrcMap, nil);
LoadGraphic(kLettersPictID);
QSetRect(&pageSrcRect, 0, 0, 32, 32 * kPageFrames);
theErr = CreateOffScreenGWorld(&pageSrcMap, &pageSrcRect, kPreferredDepth);
SetGWorld(pageSrcMap, nil);
LoadGraphic(kPagesPictID);
theErr = CreateOffScreenGWorld(&pageMaskMap, &pageSrcRect, 1);
SetGWorld(pageMaskMap, nil);
LoadGraphic(kPagesMaskID);
for (i = 0; i < kPageFrames; i++) // initialize src page rects
{
QSetRect(&pageSrc[i], 0, 0, 32, 32);
QOffsetRect(&pageSrc[i], 0, 32 * i);
}
for (i = 0; i < 8; i++) // initialize dest page rects
{
QSetRect(&pages[i].dest, 0, 0, 32, 32);
CenterRectInRect(&pages[i].dest, &thisMac.screen);
QOffsetRect(&pages[i].dest, -thisMac.screen.left, -thisMac.screen.top);
if (i < 4)
QOffsetRect(&pages[i].dest, -kPageSpacing * (4 - i), 0);
else
QOffsetRect(&pages[i].dest, kPageSpacing * (i - 3), 0);
QOffsetRect(&pages[i].dest, (thisMac.screen.right - thisMac.screen.left) / -2,
(thisMac.screen.right - thisMac.screen.left) / -2);
if (pages[i].dest.left % 2 == 1)
QOffsetRect(&pages[i].dest, 1, 0);
pages[i].was = pages[i].dest;
pages[i].frame = 0;
pages[i].counter = RandomInt(32);
pages[i].stuck = false;
}
for (i = 0; i < 8; i++)
{
QSetRect(&lettersSrc[i], 0, 0, 25, 32);
QOffsetRect(&lettersSrc[i], 0, 32 * i);
}
roomRgn = NewRgn();
RectRgn(roomRgn, &justRoomsRect);
pagesStuck = 0;
stopPages = ((thisMac.screen.bottom - thisMac.screen.top) / 2) - 16;
}
//-------------------------------------------------------------- HandlePages
// This handles the pieces of paper that blow across the screen.
void HandlePages (void)
{
short i;
for (i = 0; i < 8; i++)
{
if ((pages[i].dest.bottom + RandomInt(8)) > stopPages)
{
pages[i].frame = 0;
if (!pages[i].stuck)
{
pages[i].dest.right = pages[i].dest.left + 25;
pages[i].stuck = true;
pagesStuck++;
}
}
else
{
if (pages[i].frame == 0)
{
pages[i].counter--;
if (pages[i].counter <= 0)
pages[i].frame = 1;
}
else if (pages[i].frame == 7)
{
pages[i].counter--;
if (pages[i].counter <= 0)
{
pages[i].frame = 8;
if (RandomInt(2) == 0)
PlayPrioritySound(kPaper3Sound, kPapersPriority);
else
PlayPrioritySound(kPaper4Sound, kPapersPriority);
}
else
QOffsetRect(&pages[i].dest, 10, 10);
}
else
{
pages[i].frame++;
switch (pages[i].frame)
{
case 5:
QOffsetRect(&pages[i].dest, 6, 6);
break;
case 6:
QOffsetRect(&pages[i].dest, 8, 8);
break;
case 7:
QOffsetRect(&pages[i].dest, 8, 8);
pages[i].counter = RandomInt(4) + 4;
break;
case 8:
case 9:
QOffsetRect(&pages[i].dest, 8, 8);
break;
case 10:
QOffsetRect(&pages[i].dest, 6, 6);
break;
case kPageFrames:
QOffsetRect(&pages[i].dest, 8, 0);
pages[i].frame = 0;
pages[i].counter = RandomInt(8) + 8;
if (RandomInt(2) == 0)
PlayPrioritySound(kPaper1Sound, kPapersPriority);
else
PlayPrioritySound(kPaper2Sound, kPapersPriority);
break;
}
}
}
}
}
//-------------------------------------------------------------- DrawPages
// This function does the drawing for the pieces of paper that blow<6F>
// across the screen.
void DrawPages (void)
{
short i;
for (i = 0; i < 8; i++)
{
if (pages[i].stuck)
{
CopyBits((BitMap *)*GetGWorldPixMap(gameOverSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&lettersSrc[i], &pages[i].dest,
srcCopy, roomRgn);
}
else
{
CopyMask((BitMap *)*GetGWorldPixMap(pageSrcMap),
(BitMap *)*GetGWorldPixMap(pageMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&pageSrc[pages[i].frame],
&pageSrc[pages[i].frame],
&pages[i].dest);
}
QUnionSimilarRect(&pages[i].dest, &pages[i].was, &pages[i].was);
AddRectToWorkRects(&pages[i].was);
AddRectToBackRects(&pages[i].dest);
CopyRectsQD();
numWork2Main = 0;
numBack2Work = 0;
pages[i].was = pages[i].dest;
}
}
//-------------------------------------------------------------- DoDiedGameOver
// This is called when a game is over due to the fact that the player<65>
// lost their last glider (died), not due to getting through the entire<72>
// house.
void DoDiedGameOver (void)
{
EventRecord theEvent;
KeyMap theKeys;
long nextLoop;
Boolean userAborted;
userAborted = false;
InitDiedGameOver();
CopyRectMainToWork(&workSrcRect);
CopyRectMainToBack(&workSrcRect);
FlushEvents(everyEvent, 0);
nextLoop = TickCount() + 2;
while (pagesStuck < 8)
{
HandlePages();
DrawPages();
do
{
GetKeys(theKeys);
if ((BitTst(&theKeys, kCommandKeyMap)) || (BitTst(&theKeys, kOptionKeyMap)) ||
(BitTst(&theKeys, kShiftKeyMap)) || (BitTst(&theKeys, kControlKeyMap)))
{
pagesStuck = 8;
userAborted = true;
}
if (GetNextEvent(everyEvent, &theEvent))
if ((theEvent.what == mouseDown) || (theEvent.what == keyDown))
{
pagesStuck = 8;
userAborted = true;
}
}
while (TickCount() < nextLoop);
nextLoop = TickCount() + 2;
}
if (roomRgn != nil)
DisposeRgn(roomRgn);
DisposeGWorld(pageSrcMap);
pageSrcMap = nil;
DisposeGWorld(pageMaskMap);
pageMaskMap = nil;
DisposeGWorld(gameOverSrcMap);
gameOverSrcMap = nil;
playing = false;
if (demoGoing)
{
if (!userAborted)
WaitForInputEvent(1);
}
else
{
if (!userAborted)
WaitForInputEvent(10);
TestHighScore();
}
RedrawSplashScreen();
}

12
GpApp/GameOver.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// GameOver.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr angelSrcMap;
extern GWorldPtr angelMaskMap;

625
GpApp/GliderDefines.h Normal file
View File

@@ -0,0 +1,625 @@
//============================================================================
//----------------------------------------------------------------------------
// GliderDefines.h
//----------------------------------------------------------------------------
//============================================================================
//============================================================== Defines
//#define CREATEDEMODATA
//#define COMPILEDEMO
//#define CAREFULDEBUG
#define COMPILENOCP
#define COMPILEQT
#define BUILD_ARCADE_VERSION 1
#define kYellowUnaccounted 1
#define kYellowFailedResOpen 2
#define kYellowFailedResAdd 3
#define kYellowFailedResCreate 4
#define kYellowNoHouses 5
#define kYellowNewerVersion 6
#define kYellowNoBackground 7
#define kYellowIllegalRoomNum 8
#define kYellowNoBoundsRes 9
#define kYellowScrapError 10
#define kYellowNoMemory 11
#define kYellowFailedWrite 12
#define kYellowNoMusic 13
#define kYellowFailedSound 14
#define kYellowAppleEventErr 15
#define kYellowOpenedOldHouse 16
#define kYellowLostAllHouses 17
#define kYellowFailedSaveGame 18
#define kYellowSavedTimeWrong 19
#define kYellowSavedVersWrong 20
#define kYellowSavedRoomsWrong 21
#define kYellowQTMovieNotLoaded 22
#define kYellowNoRooms 23
#define kYellowCantOrderLinks 24
#define kSwitchIfNeeded 0
#define kSwitchTo256Colors 1
#define kSwitchTo16Grays 2
#define kProdGameScoreMode -4
#define kKickGameScoreMode -3
#define kPlayGameScoreMode -2
#define kPlayWholeScoreMode -1
#define kPlayChorus 4
#define kPlayRefrainSparse1 5
#define kPlayRefrainSparse2 6
#define kHitWallSound 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kFadeInSound 1 // <20><>
#define kFadeOutSound 2 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kBeepsSound 3 // <20><>
#define kBuzzerSound 4 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kDingSound 5 //
#define kEnergizeSound 6 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kFollowSound 7 // <20><> <20><>
#define kMicrowavedSound 8 // <20><> <20><>
#define kSwitchSound 9 // <20><> <20><>
#define kBirdSound 10 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kCuckooSound 11 //
#define kTikSound 12 // <20><> <20><>
#define kTokSound 13 // <20><> <20><>
#define kBlowerOn 14 // <20><> <20><>
#define kBlowerOff 15 // <20><> <20><>
#define kCaughtFireSound 16 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kScoreTikSound 17 //
#define kThrustSound 18 // <20><><EFBFBD> <20><>
#define kFizzleSound 19 // <20><><EFBFBD><EFBFBD> <20><>
#define kFireBandSound 20 // <20><> <20><> <20><>
#define kBandReboundSound 21 // <20><> <20><><EFBFBD><EFBFBD>
#define kGreaseSpillSound 22 // <20><> <20><><EFBFBD>
#define kChordSound 23 //
#define kVCRSound 24 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kFoilHitSound 25 // <20><> <20><>
#define kShredSound 26 // <20><> <20><>
#define kToastLaunchSound 27 // <20><> <20><>
#define kToastLandSound 28 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kMacOnSound 29 //
#define kMacBeepSound 30 //
#define kMacOffSound 31 //
#define kTVOnSound 32 //
#define kTVOffSound 33 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kCoffeeSound 34 // <20><>
#define kMysticSound 35 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kZapSound 36 // <20><>
#define kPopSound 37 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kEnemyInSound 38 //
#define kEnemyOutSound 39 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kPaperCrunchSound 40 // <20><> <20><>
#define kBounceSound 41 // <20><> <20><>
#define kDripSound 42 // <20><> <20><>
#define kDropSound 43 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kFishOutSound 44 //
#define kFishInSound 45 // <20><> <20><>
#define kDontExitSound 46 // <20><> <20><>
#define kSizzleSound 47 // <20><> <20><>
#define kPaper1Sound 48 // <20><> <20><>
#define kPaper2Sound 49 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kPaper3Sound 50 //
#define kPaper4Sound 51 // <20><><EFBFBD> <20><>
#define kTypingSound 52 // <20><><EFBFBD><EFBFBD> <20><>
#define kCarriageSound 53 // <20><> <20><> <20><>
#define kChord2Sound 54 // <20><> <20><><EFBFBD><EFBFBD>
#define kPhoneRingSound 55 // <20><> <20><><EFBFBD>
#define kChime1Sound 56 //
#define kChime2Sound 57 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kWebTwangSound 58 // <20><> <20><>
#define kTransOutSound 59 // <20><> <20><>
#define kTransInSound 60 // <20><> <20><>
#define kBonusSound 61 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kHissSound 62 //
#define kTriggerSound 63
#define kHitWallPriority 100 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kScoreTikPriority 101 // <20><>
#define kBandReboundPriority 102 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kDontExitPriority 103 // <20><>
#define kTikPriority 200 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kTokPriority 201 //
#define kMysticPriority 202 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kChime1Priority 203 // <20><> <20><>
#define kChime2Priority 204 // <20><> <20><>
#define kThrustPriority 300 // <20><> <20><>
#define kFireBandPriority 301 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kChordPriority 302 //
#define kVCRPriority 303 // <20><> <20><>
#define kToastLaunchPriority 304 // <20><> <20><>
#define kToastLandPriority 305 // <20><> <20><>
#define kCoffeePriority 306 // <20><> <20><>
#define kBouncePriority 307 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kDripPriority 308 //
#define kDropPriority 309 // <20><><EFBFBD> <20><>
#define kWebTwangPriority 310 // <20><><EFBFBD><EFBFBD> <20><>
#define kHissPriority 311 // <20><> <20><> <20><>
#define kFoilHitPriority 400 // <20><> <20><><EFBFBD><EFBFBD>
#define kMacOnPriority 401 // <20><> <20><><EFBFBD>
#define kMacOffPriority 402 //
#define kMacBeepPriority 403 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kTVOnPriority 404 // <20><> <20><>
#define kTVOffPriority 405 // <20><> <20><>
#define kZapPriority 406 // <20><> <20><>
#define kPopPriority 407 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kEnemyInPriority 408 //
#define kEnemyOutPriority 409 //
#define kPaperCrunchPriority 410 //
#define kFishOutPriority 411 //
#define kFishInPriority 412 //
#define kSizzlePriority 413
#define kPhoneRingPriority 500
#define kSwitchPriority 700
#define kBlowerOnPriority 701
#define kBlowerOffPriority 702
#define kFizzlePriority 703
#define kBeepsPriority 800
#define kBuzzerPriority 801
#define kDingPriority 802
#define kEnergizePriority 803
#define kBirdPriority 804
#define kCuckooPriority 805
#define kGreaseSpillPriority 806
#define kPapersPriority 807
#define kTypingPriority 808
#define kCarriagePriority 809
#define kChord2Priority 810
#define kMicrowavedPriority 811
#define kBonusPriority 812
#define kFadeInPriority 900
#define kFadeOutPriority 901
#define kCaughtFirePriority 902
#define kShredPriority 903
#define kFollowPriority 904
#define kTransInPriority 905
#define kTransOutPriority 906
#define kTriggerPriority 999
#define kArrowCursor 0
#define kBeamCursor 1
#define kHandCursor 2
#define kAppleMenuID 128
#define kGameMenuID 129
#define kOptionsMenuID 130
#define kHouseMenuID 131
#define kSplashMode 0
#define kEditMode 1
#define kPlayMode 2
#define kIdleSplashMode 0
#define kIdleDemoMode 1
#define kIdleSplashTicks 7200L // 2 minutes
#define kIdleLastMode 1
#define kRoomAbove 1
#define kRoomBelow 2
#define kRoomToRight 3
#define kRoomToLeft 4
#define kBumpUp 1
#define kBumpDown 2
#define kBumpRight 3
#define kBumpLeft 4
#define kAbove 1
#define kToRight 2
#define kBelow 3
#define kToLeft 4
#define kBottomCorner 5
#define kTopCorner 6
#define kCentralRoom 0
#define kNorthRoom 1
#define kNorthEastRoom 2
#define kEastRoom 3
#define kSouthEastRoom 4
#define kSouthRoom 5
#define kSouthWestRoom 6
#define kWestRoom 7
#define kNorthWestRoom 8
#define kSimpleRoom 2000
#define kPaneledRoom 2001
#define kBasement 2002
#define kChildsRoom 2003
#define kAsianRoom 2004
#define kUnfinishedRoom 2005
#define kSwingersRoom 2006
#define kBathroom 2007
#define kLibrary 2008
#define kGarden 2009
#define kSkywalk 2010
#define kDirt 2011
#define kMeadow 2012
#define kField 2013
#define kRoof 2014
#define kSky 2015
#define kStratosphere 2016
#define kStars 2017
#define kMapRoomHeight 20
#define kMapRoomWidth 32
#define kMaxScores 10
#define kMaxRoomObs 24
#define kMaxSparkles 3
#define kNumSparkleModes 5
#define kMaxFlyingPts 3
#define kMaxFlyingPointsLoop 24
#define kMaxCandles 20
#define kMaxTikis 8
#define kMaxCoals 8
#define kMaxPendulums 8
#define kMaxHotSpots 56
#define kMaxSavedMaps 24
#define kMaxRubberBands 2
#define kMaxGrease 16
#define kMaxStars 4
#define kMaxShredded 4
#define kMaxDynamicObs 18
#define kMaxMasterObjects 216 // kMaxRoomObs * 9
#define kMaxViewWidth 1536
#define kMaxViewHeight 1026
#define kSelectTool 0
#define kBlowerMode 1
#define kFurnitureMode 2
#define kBonusMode 3
#define kTransportMode 4
#define kSwitchMode 5
#define kLightMode 6
#define kApplianceMode 7
#define kEnemyMode 8
#define kClutterMode 9
#define kIgnoreIt 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kLiftIt 1 // <20><> <20><>
#define kDropIt 2 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kPushItLeft 3 // <20><> <20><>
#define kPushItRight 4 // <20><> <20><>
#define kDissolveIt 5 //
#define kRewardIt 6 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kMoveItUp 7 // <20><> <20><>
#define kMoveItDown 8 // <20><>
#define kSwitchIt 9 // <20><> <20><>
#define kShredIt 10 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kStrumIt 11 //
#define kTriggerIt 12 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kBurnIt 13 // <20><>
#define kSlideIt 14 // <20><>
#define kTransportIt 15 // <20><>
#define kIgnoreLeftWall 16 // <20><>
#define kIgnoreRightWall 17 //
#define kMailItLeft 18 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kMailItRight 19 // <20><>
#define kDuctItDown 20 // <20><>
#define kDuctItUp 21 // <20><>
#define kMicrowaveIt 22 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kIgnoreGround 23 //
#define kBounceIt 24 //
#define kChimeIt 25 // <20><>
#define kWebIt 26 // <20><>
#define kSoundIt 27
#define kFloorVent 0x01 // Blowers
#define kCeilingVent 0x02
#define kFloorBlower 0x03
#define kCeilingBlower 0x04
#define kSewerGrate 0x05
#define kLeftFan 0x06
#define kRightFan 0x07
#define kTaper 0x08
#define kCandle 0x09
#define kStubby 0x0A
#define kTiki 0x0B
#define kBBQ 0x0C
#define kInvisBlower 0x0D
#define kGrecoVent 0x0E
#define kSewerBlower 0x0F
#define kLiftArea 0x10
#define kTable 0x11 // Furniture
#define kShelf 0x12
#define kCabinet 0x13
#define kFilingCabinet 0x14
#define kWasteBasket 0x15
#define kMilkCrate 0x16
#define kCounter 0x17
#define kDresser 0x18
#define kDeckTable 0x19
#define kStool 0x1A
#define kTrunk 0x1B
#define kInvisObstacle 0x1C
#define kManhole 0x1D
#define kBooks 0x1E
#define kInvisBounce 0x1F
#define kRedClock 0x21 // Prizes
#define kBlueClock 0x22
#define kYellowClock 0x23
#define kCuckoo 0x24
#define kPaper 0x25
#define kBattery 0x26
#define kBands 0x27
#define kGreaseRt 0x28
#define kGreaseLf 0x29
#define kFoil 0x2A
#define kInvisBonus 0x2B
#define kStar 0x2C
#define kSparkle 0x2D
#define kHelium 0x2E
#define kSlider 0x2F
#define kUpStairs 0x31 // Transport
#define kDownStairs 0x32
#define kMailboxLf 0x33
#define kMailboxRt 0x34
#define kFloorTrans 0x35
#define kCeilingTrans 0x36
#define kDoorInLf 0x37
#define kDoorInRt 0x38
#define kDoorExRt 0x39
#define kDoorExLf 0x3A
#define kWindowInLf 0x3B
#define kWindowInRt 0x3C
#define kWindowExRt 0x3D
#define kWindowExLf 0x3E
#define kInvisTrans 0x3F
#define kDeluxeTrans 0x40
#define kLightSwitch 0x41 // Switches
#define kMachineSwitch 0x42
#define kThermostat 0x43
#define kPowerSwitch 0x44
#define kKnifeSwitch 0x45
#define kInvisSwitch 0x46
#define kTrigger 0x47
#define kLgTrigger 0x48
#define kSoundTrigger 0x49
#define kCeilingLight 0x51 // Lights
#define kLightBulb 0x52
#define kTableLamp 0x53
#define kHipLamp 0x54
#define kDecoLamp 0x55
#define kFlourescent 0x56
#define kTrackLight 0x57
#define kInvisLight 0x58
#define kShredder 0x61 // Appliances
#define kToaster 0x62
#define kMacPlus 0x63
#define kGuitar 0x64
#define kTV 0x65
#define kCoffee 0x66
#define kOutlet 0x67
#define kVCR 0x68
#define kStereo 0x69
#define kMicrowave 0x6A
#define kCinderBlock 0x6B
#define kFlowerBox 0x6C
#define kCDs 0x6D
#define kCustomPict 0x6E
#define kBalloon 0x71 // Enemies
#define kCopterLf 0x72
#define kCopterRt 0x73
#define kDartLf 0x74
#define kDartRt 0x75
#define kBall 0x76
#define kDrip 0x77
#define kFish 0x78
#define kCobweb 0x79
#define kOzma 0x81 // Clutter
#define kMirror 0x82
#define kMousehole 0x83
#define kFireplace 0x84
#define kFlower 0x85
#define kWallWindow 0x86
#define kBear 0x87
#define kCalendar 0x88
#define kVase1 0x89
#define kVase2 0x8A
#define kBulletin 0x8B
#define kCloud 0x8C
#define kFaucet 0x8D
#define kRug 0x8E
#define kChimes 0x8F
#define kNumSrcRects 0x90
#define kTableThick 8
#define kShelfThick 6
#define kToggle 0
#define kForceOn 1
#define kForceOff 2
#define kOneShot 3
#define kNumTrackLights 3
#define kNumOutletPicts 4
#define kNumCandleFlames 5
#define kNumTikiFlames 5
#define kNumBBQCoals 4
#define kNumPendulums 3
#define kNumBreadPicts 6
#define kNumBalloonFrames 8
#define kNumCopterFrames 10
#define kNumDartFrames 4
#define kNumBallFrames 2
#define kNumDripFrames 6
#define kNumFishFrames 8
#define kNumFlowers 6
#define kNumMarqueePats 7
#define kObjectNameStrings 1007
#define kSwitchLinkOnly 3
#define kTriggerLinkOnly 4
#define kTransportLinkOnly 5
#define kFloorVentTop 305
#define kCeilingVentTop 8
#define kFloorBlowerTop 304
#define kCeilingBlowerTop 5
#define kSewerGrateTop 303
#define kCeilingTransTop 6
#define kFloorTransTop 302
#define kStairsTop 28
#define kCounterBottom 304
#define kDresserBottom 293
#define kCeilingLightTop 4
#define kHipLampTop 23
#define kDecoLampTop 91
#define kFlourescentTop 12
#define kTrackLightTop 5
#define kDoorInTop 0
#define kDoorInLfLeft 0
#define kDoorInRtLeft 368
#define kDoorExTop 0
#define kDoorExLfLeft 0
#define kDoorExRtLeft 496
#define kWindowInTop 64
#define kWindowInLfLeft 0
#define kWindowInRtLeft 492
#define kWindowExTop 64
#define kWindowExLfLeft 0
#define kWindowExRtLeft 496
#define kNumTiles 8
#define kTileWide 64
#define kTileHigh 322
#define kRoomWide 512 // kNumTiles * kTileWide
#define kFloorSupportTall 44
#define kVertLocalOffset 322 // kTileHigh - 39 (was 283, then 295)
#define kCeilingLimit 8
#define kFloorLimit 312
#define kRoofLimit 122
#define kLeftWallLimit 12
#define kNoLeftWallLimit -24 // 0 - (kGliderWide / 2)
#define kRightWallLimit 500
#define kNoRightWallLimit 536 // kRoomWide + (kGliderWide / 2)
#define kNoCeilingLimit -10
#define kNoFloorLimit 332
#define kScoreboardHigh 0
#define kScoreboardLow 1
#define kScoreboardTall 20
#define kHouseVersion 0x0200
#define kNewHouseVersion 0x0300
#define kBaseBackgroundID 2000
#define kFirstOutdoorBack 2009
#define kNumBackgrounds 18
#define kUserBackground 3000
#define kUserStructureRange 3300
#define kSplash8BitPICT 1000
#define kRoomIsEmpty -1
#define kObjectIsEmpty -1
#define kNoObjectSelected -1
#define kInitialGliderSelected -2
#define kLeftGliderSelected -3
#define kRightGliderSelected -4
#define kWindoidWDEF 2048
#define kWindoidGrowWDEF 2064
#define kTicksPerFrame 2
#define kStarPictID 1995
#define kNumUndergroundFloors 8
#define kRoomVisitScore 100
#define kRedClockPoints 100
#define kBlueClockPoints 300
#define kYellowClockPoints 500
#define kCuckooClockPoints 1000
#define kStarPoints 5000
#define kRedOrangeColor8 23 // actually, 18
#define kMaxNumRoomsH 128
#define kMaxNumRoomsV 64
#define kStartSparkle 4
#define kLengthOfZap 30
#define kGliderWide 48
#define kGliderHigh 20
#define kHalfGliderWide 24
#define kGliderBurningHigh 26
#define kShadowHigh 9
#define kShadowTop 306
#define kFaceRight TRUE
#define kFaceLeft FALSE
#define kPlayer1 TRUE
#define kPlayer2 FALSE
#define kNumGliderSrcRects 31
#define kNumShadowSrcRects 2
#define kFirstAboutFaceFrame 18
#define kLastAboutFaceFrame 20
#define kWasBurning 2
#define kLeftFadeOffset 7
#define kLastFadeSequence 16
#define kGliderFoil2PictID 3963
#define kGlider2PictID 3974
#define kGliderFoilPictID 3976
#define kGliderPictID 3999
#define kGliderStartsDown 32
#define kGliderNormal 0 // <20><> <20><>
#define kGliderFadingIn 1 // <20><><EFBFBD> <20><><EFBFBD>
#define kGliderFadingOut 2 // <20><> <20><> <20><>
#define kGliderGoingUp 3 // <20><> <20><>
#define kGliderComingUp 4 // <20><> <20><>
#define kGliderGoingDown 5 //
#define kGliderComingDown 6 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kGliderFaceLeft 7 // <20><> <20><>
#define kGliderFaceRight 8 // <20><> <20><>
#define kGliderBurning 9 // <20><> <20><>
#define kGliderTransporting 10 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kGliderDuctingDown 11 //
#define kGliderDuctingUp 12 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kGliderDuctingIn 13 // <20><> <20><>
#define kGliderMailInLeft 14 // <20><> <20><>
#define kGliderMailOutLeft 15 // <20><> <20><>
#define kGliderMailInRight 16 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kGliderMailOutRight 17 //
#define kGliderGoingFoil 18 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kGliderLosingFoil 19 // <20><>
#define kGliderShredding 20 // <20><><EFBFBD><EFBFBD>
#define kGliderInLimbo 21 // <20><>
#define kGliderIdle 22 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kGliderTransportingIn 23
#define kPlayerIsDeadForever -69
#define kPlayerMailedOut -12
#define kPlayerDuckedOut -11
#define kPlayerTransportedOut -10
#define kPlayerEscapingDownStairs -9
#define kPlayerEscapingUpStairs -8
#define kPlayerEscapedDownStairs -7
#define kPlayerEscapedUpStairs -6
#define kPlayerEscapedDown -5
#define kPlayerEscapedUp -4
#define kPlayerEscapedLeft -3
#define kPlayerEscapedRight -2
#define kNoOneEscaped -1
#define kLinkedToOther 0
#define kLinkedToLeftMailbox 1
#define kLinkedToRightMailbox 2
#define kLinkedToCeilingDuct 3
#define kLinkedToFloorDuct 4
#define kResumeGameMode 0
#define kNewGameMode 1
#define kNormalTitleMode 0
#define kEscapedTitleMode 1
#define kSavingTitleMode 2
#define kScoreboardPictID 1997
#define kDemoLength 6702

530
GpApp/GliderProtos.h Normal file
View File

@@ -0,0 +1,530 @@
//============================================================================
//----------------------------------------------------------------------------
// GliderProtos.h
//----------------------------------------------------------------------------
//============================================================================
//-------------------------------------------------------------- Prototypes
void SetUpAppleEvents (void); // --- AppleEvents.c
void BringUpBanner (void); // --- Banner.c
SInt16 CountStarsInHouse (void);
void DisplayStarsRemaining (void);
void SetCoordinateHVD (SInt16, SInt16, SInt16); // --- Coordinate.c
void DeltaCoordinateD (SInt16);
void UpdateCoordWindow (void);
void OpenCoordWindow (void);
void CloseCoordWindow (void);
void ToggleCoordinateWindow (void);
void NilSavedMaps (void); // --- DynamicMaps.c
SInt16 BackUpToSavedMap (Rect *, SInt16, SInt16);
SInt16 ReBackUpSavedMap (Rect *, SInt16, SInt16);
void RestoreFromSavedMap (SInt16, SInt16, Boolean);
void AddSparkle (Rect *);
void AddFlyingPoint (Rect *, SInt16, SInt16, SInt16);
void ReBackUpFlames (SInt16, SInt16);
void AddCandleFlame (SInt16, SInt16, SInt16, SInt16);
void ReBackUpTikiFlames (SInt16, SInt16);
void AddTikiFlame (SInt16, SInt16, SInt16, SInt16);
void ReBackUpBBQCoals (SInt16, SInt16);
void AddBBQCoals (SInt16, SInt16, SInt16, SInt16);
void ReBackUpPendulum (SInt16, SInt16);
void AddPendulum (SInt16, SInt16, SInt16, SInt16);
void ReBackUpStar (SInt16, SInt16);
void AddStar (SInt16, SInt16, SInt16, SInt16);
void StopPendulum (SInt16, SInt16);
void StopStar (SInt16, SInt16);
void AddAShreddedGlider (Rect *);
void RemoveShreds (void);
void ZeroFlamesAndTheLike (void);
void CheckDynamicCollision (SInt16, gliderPtr, Boolean); // --- Dynamics.c
Boolean DidBandHitDynamic (SInt16);
void RenderToast (SInt16);
void RenderBalloon (SInt16);
void RenderCopter (SInt16);
void RenderDart (SInt16);
void RenderBall (SInt16);
void RenderDrip (SInt16);
void RenderFish (SInt16);
void HandleSparkleObject (SInt16);
void HandleToast (SInt16);
void HandleMacPlus (SInt16);
void HandleTV (SInt16);
void HandleCoffee (SInt16);
void HandleOutlet (SInt16);
void HandleVCR (SInt16);
void HandleStereo (SInt16);
void HandleMicrowave (SInt16);
void HandleBalloon (SInt16); // --- Dynamics2.c
void HandleCopter (SInt16);
void HandleDart (SInt16);
void HandleBall (SInt16);
void HandleDrip (SInt16);
void HandleFish (SInt16);
void HandleDynamics (void); // --- Dynamics3.c
void RenderDynamics (void);
void ZeroDinahs (void);
SInt16 AddDynamicObject (SInt16, Rect *, objectType *, SInt16, SInt16, Boolean);
void DoGameOver (void); // --- GameOver.c
void FlagGameOver (void);
void DoDiedGameOver (void);
void HandleGrease (void); // --- Grease.c
SInt16 ReBackUpGrease (SInt16, SInt16);
SInt16 AddGrease (SInt16, SInt16, SInt16, SInt16, SInt16, Boolean);
void SpillGrease (SInt16, SInt16);
void RedrawAllGrease (void);
void DoHighScores (void); // --- HighScores.c
void SortHighScores (void);
void ZeroHighScores (void);
void ZeroAllButHighestScore (void);
Boolean TestHighScore (void);
Boolean WriteScoresToDisk (void);
Boolean ReadScoresFromDisk (void);
Boolean CreateNewHouse (void); // --- House.c
Boolean InitializeEmptyHouse (void);
SInt16 RealRoomNumberCount (void);
SInt16 GetFirstRoomNumber (void);
void WhereDoesGliderBegin (Rect *, SInt16);
Boolean HouseHasOriginalPicts (void);
SInt16 CountHouseLinks (void);
void GenerateLinksList (void);
void SortRoomsObjects (SInt16);
void SortHouseObjects (void);
SInt16 CountRoomsVisited (void);
void GenerateRetroLinks (void);
void DoGoToDialog (void);
void ConvertHouseVer1To2 (void);
void ShiftWholeHouse (SInt16);
void DoHouseInfo (void); // --- HouseInfo.c
Boolean OpenHouse (void); // --- HouseIO.c
Boolean OpenSpecificHouse (FSSpec *);
Boolean SaveHouseAs (void);
Boolean ReadHouse (void);
Boolean WriteHouse (Boolean);
Boolean CloseHouse (void);
void OpenHouseResFork (void);
void CloseHouseResFork (void);
Boolean QuerySaveChanges (void);
void YellowAlert (SInt16, SInt16);
Boolean KeepObjectLegal (void); // --- HouseLegal.c
void CheckHouseForProblems (void);
Boolean SectGlider (gliderPtr, Rect *, Boolean); // --- Interactions.c
void HandleSwitches (hotPtr);
void HandleInteraction (void);
void FlagStillOvers (gliderPtr);
void InitializeMenus (void); // --- InterfaceInit.c
void GetExtraCursors (void);
void VariableInit (void);
void GetDemoInput (gliderPtr); // --- Input.c
void GetInput (gliderPtr);
SInt16 MergeFloorSuite (SInt16, SInt16); // --- Link.c
void ExtractFloorSuite (SInt16, SInt16 *, SInt16 *);
void UpdateLinkControl (void);
void UpdateLinkWindow (void);
void OpenLinkWindow (void);
void CloseLinkWindow (void);
void HandleLinkClick (Point);
void RedrawSplashScreen (void); // --- MainWindow.c
void UpdateMainWindow (void);
void UpdateMenuBarWindow (void);
void OpenMainWindow (void);
void CloseMainWindow (void);
void ZoomBetweenWindows (void);
void UpdateEditWindowTitle (void);
void HandleMainClick (Point, Boolean);
//void WashColorIn (void);
void CenterMapOnRoom (SInt16, SInt16); // --- Map.c
Boolean ThisRoomVisibleOnMap (void);
void FindNewActiveRoomRect (void);
void FlagMapRoomsForUpdate (void);
void UpdateMapWindow (void);
void ResizeMapWindow (SInt16, SInt16);
void OpenMapWindow (void);
void CloseMapWindow (void);
void ToggleMapWindow (void);
void HandleMapClick (EventRecord *);
void MoveRoom (Point);
void DoMarquee (void); // --- Marquee.c
void StartMarquee (Rect *);
void StartMarqueeHandled (Rect *, SInt16, SInt16);
void StopMarquee (void);
void PauseMarquee (void);
void ResumeMarquee (void);
void DragOutMarqueeRect (Point, Rect *);
void DragMarqueeRect (Point, Rect *, Boolean, Boolean);
void DragMarqueeHandle (Point, SInt16 *);
void DragMarqueeCorner (Point, SInt16 *, SInt16 *, Boolean);
Boolean MarqueeHasHandles (SInt16 *, SInt16 *);
Boolean PtInMarqueeHandle (Point);
void SetMarqueeGliderRect (SInt16, SInt16);
void InitMarquee (void);
void UpdateClipboardMenus (void); // --- Menu.c
void DoAppleMenu (SInt16);
void DoGameMenu (SInt16);
void DoOptionsMenu (SInt16);
void DoHouseMenu (SInt16);
void DoMenuChoice (long);
void UpdateMenus (Boolean);
void UpdateMapCheckmark (Boolean);
void UpdateToolsCheckmark (Boolean);
void UpdateCoordinateCheckmark (Boolean);
#ifdef COMPILEDEMO
void DoNotInDemo (void);
#endif
void OpenCloseEditWindows (void);
void StartGliderFadingIn (gliderPtr); // --- Modes.c
void StartGliderTransportingIn (gliderPtr);
void StartGliderFadingOut (gliderPtr);
void StartGliderGoingUpStairs (gliderPtr);
void StartGliderGoingDownStairs (gliderPtr);
void StartGliderMailingIn (gliderPtr, Rect *, hotPtr);
void StartGliderMailingOut (gliderPtr);
void StartGliderDuctingDown (gliderPtr, Rect *, hotPtr);
void StartGliderDuctingUp (gliderPtr, Rect *, hotPtr);
void StartGliderDuctingIn (gliderPtr);
void StartGliderTransporting (gliderPtr, hotPtr);
void FlagGliderNormal (gliderPtr);
void FlagGliderShredding (gliderPtr, Rect *);
void FlagGliderBurning (gliderPtr);
void FlagGliderFaceLeft (gliderPtr);
void FlagGliderFaceRight (gliderPtr);
void FlagGliderInLimbo (gliderPtr, Boolean);
void UndoGliderLimbo (gliderPtr);
void ToggleGliderFacing (gliderPtr);
void InsureGliderFacingRight (gliderPtr);
void InsureGliderFacingLeft (gliderPtr);
void ReadyGliderForTripUpStairs (gliderPtr);
void ReadyGliderForTripDownStairs (gliderPtr);
void StartGliderFoilGoing (gliderPtr);
void StartGliderFoilLosing (gliderPtr);
void TagGliderIdle (gliderPtr);
OSErr StartMusic (void); // --- Music.c
void StopTheMusic (void);
void ToggleMusicWhilePlaying (void);
void SetMusicalMode (SInt16);
void InitMusic (void);
void KillMusic (void);
long MusicBytesNeeded (void);
void TellHerNoMusic (void);
Boolean AddNewObject (Point, SInt16, Boolean); // --- ObjectAdd.c
SInt16 FindObjectSlotInRoom (SInt16);
Boolean DoesRoomNumHaveObject (SInt16, SInt16);
void ShoutNoMoreObjects (void);
void DrawSimpleBlowers (SInt16, Rect *); // --- ObjectDraw.c
void DrawTiki (Rect *, SInt16);
void DrawInvisibleBlower (Rect *);
void DrawLiftArea (Rect *);
void DrawTable (Rect *, SInt16);
void DrawShelf (Rect *);
void DrawCabinet (Rect *);
void DrawSimpleFurniture (SInt16, Rect *);
void DrawCounter (Rect *);
void DrawDresser (Rect *);
void DrawDeckTable (Rect *, SInt16);
void DrawStool (Rect *, SInt16);
void DrawInvisObstacle (Rect *);
void DrawInvisBounce (Rect *);
void DrawRedClock (Rect *);
void DrawBlueClock (Rect *);
void DrawYellowClock (Rect *);
void DrawCuckoo (Rect *);
void DrawSimplePrizes (SInt16, Rect *);
void DrawGreaseRt (Rect *, SInt16, Boolean);
void DrawGreaseLf (Rect *, SInt16, Boolean);
void DrawFoil (Rect *);
void DrawInvisBonus (Rect *);
void DrawSlider (Rect *);
void DrawMailboxLeft (Rect *, SInt16); // --- ObjectDraw2.c
void DrawMailboxRight (Rect *, SInt16);
void DrawSimpleTransport (SInt16, Rect *);
void DrawInvisTransport (Rect *);
void DrawLightSwitch (Rect *, Boolean);
void DrawMachineSwitch (Rect *, Boolean);
void DrawThermostat (Rect *, Boolean);
void DrawPowerSwitch (Rect *, Boolean);
void DrawKnifeSwitch (Rect *, Boolean);
void DrawInvisibleSwitch (Rect *);
void DrawTrigger (Rect *);
void DrawSoundTrigger (Rect *);
void DrawSimpleLight (SInt16, Rect *);
void DrawFlourescent (Rect *);
void DrawSimpleAppliance (SInt16, Rect *);
void DrawMacPlus (Rect *, Boolean, Boolean);
void DrawTrackLight (Rect *);
void DrawInvisLight (Rect *);
void DrawTV (Rect *, Boolean, Boolean);
void DrawCoffee (Rect *, Boolean, Boolean);
void DrawOutlet (Rect *);
void DrawVCR (Rect *, Boolean, Boolean);
void DrawStereo (Rect *, Boolean, Boolean);
void DrawMicrowave (Rect *, Boolean, Boolean);
void DrawBalloon (Rect *);
void DrawCopter (Rect *);
void DrawDart (Rect *, SInt16);
void DrawBall (SInt16, Rect *);
void DrawFish (SInt16, Rect *);
void DrawDrip (Rect *);
void DrawMirror (Rect *);
void DrawSimpleClutter (SInt16, Rect *);
void DrawFlower (Rect *, SInt16);
void DrawWallWindow (Rect *);
void DrawCalendar (Rect *);
void DrawBulletin (Rect *);
void DrawPictObject (SInt16, Rect *);
void DrawPictWithMaskObject (SInt16, Rect *);
void DrawPictSansWhiteObject (SInt16, Rect *);
void DrawCustPictSansWhite (SInt16, Rect *);
void DrawARoomsObjects (SInt16, Boolean); // --- ObjectDrawAll.c
void DoSelectionClick (Point, Boolean); // --- ObjectEdit.c
void DoNewObjectClick (Point);
void DeleteObject (void);
void DuplicateObject (void);
void MoveObject (SInt16, Boolean);
void DeselectObject (void);
Boolean ObjectHasHandle (SInt16 *, SInt16 *);
void HandleBlowerGlider (void);
void SelectNextObject (void);
void SelectPrevObject (void);
void GetThisRoomsObjRects (void);
void DrawThisRoomsObjects (void);
void HiliteAllObjects (void);
void GoToObjectInRoom (SInt16, SInt16, SInt16);
void GoToObjectInRoomNum (SInt16, SInt16);
void DoObjectInfo (void); // --- ObjectInfo.c
void GetObjectRect (objectPtr, Rect *); // --- ObjectRects.c
SInt16 CreateActiveRects (SInt16);
SInt16 VerticalRoomOffset (SInt16);
void OffsetRectRoomRelative (Rect *, SInt16);
SInt16 GetUpStairsRightEdge (void);
SInt16 GetDownStairsLeftEdge (void);
SInt16 GetRoomLinked (objectType *); // --- Objects.c
Boolean ObjectIsLinkTransport (objectType *);
Boolean ObjectIsLinkSwitch (objectType *);
void ListAllLocalObjects (void);
Boolean SetObjectState (SInt16, SInt16, SInt16, SInt16);
Boolean GetObjectState (SInt16, SInt16);
void BringSendFrontBack (Boolean);
Boolean IsThisValid (SInt16, SInt16);
void AddTempManholeRect (Rect *);
void NewGame (SInt16); // --- Play.c
void DoDemoGame (void);
void HideGlider (gliderPtr);
void StrikeChime (void);
void RestoreEntireGameScreen (void);
void HandleGlider (gliderPtr); // --- Player.c
void FinishGliderUpStairs (gliderPtr);
void FinishGliderDownStairs (gliderPtr);
void FinishGliderDuctingIn (gliderPtr);
void DeckGliderInFoil (gliderPtr);
void RemoveFoilFromGlider (gliderPtr);
void OffsetGlider (gliderPtr, SInt16);
void OffAMortal (gliderPtr);
void AddRectToWorkRects (Rect *); // --- Render.c
void AddRectToBackRects (Rect *);
void AddRectToWorkRectsWhole (Rect *);
void RenderGlider (gliderPtr, Boolean);
void CopyRectsQD (void);
void DirectWork2Main8 (Rect *);
void DirectBack2Work8 (Rect *);
void DirectGeneric2Work8 (long, long, Rect *, Rect *);
void DirectWork2Main4 (Rect *);
void DirectBack2Work4 (Rect *);
void DirectGeneric2Work4 (long, long, Rect *, Rect *);
void CopyRectsAssm (void);
void DirectFillBack8 (Rect *, Byte);
void DirectFillWork8 (Rect *, Byte);
void DirectFillBack4 (Rect *, Byte);
void DirectFillWork4 (Rect *, Byte);
void RenderFrame (void);
void InitGarbageRects (void);
void CopyRectBackToWork (Rect *);
void CopyRectWorkToBack (Rect *);
void CopyRectWorkToMain (Rect *);
void CopyRectMainToWork (Rect *);
void CopyRectMainToBack (Rect *);
void AddToMirrorRegion (Rect *);
void ZeroMirrorRegion (void);
void SetInitialTiles (SInt16, Boolean); // --- Room.c
Boolean CreateNewRoom (SInt16, SInt16);
void DoRoomInfo (void);
void ReadyBackground (SInt16, SInt16 *);
void ReflectCurrentRoom (Boolean);
void CopyRoomToThisRoom (SInt16);
void CopyThisRoomToRoom (void);
void ForceThisRoom (SInt16);
Boolean RoomExists (SInt16, SInt16, SInt16 *);
Boolean RoomNumExists (SInt16);
void DeleteRoom (Boolean);
SInt16 DoesNeighborRoomExist (SInt16);
void SelectNeighborRoom (SInt16);
SInt16 GetNeighborRoomNumber (SInt16);
Boolean GetRoomFloorSuite (SInt16, SInt16 *, SInt16 *);
SInt16 GetRoomNumber (SInt16, SInt16);
Boolean IsRoomAStructure (SInt16);
void DetermineRoomOpenings (void);
SInt16 GetOriginalBounding (SInt16);
SInt16 GetNumberOfLights (SInt16);
Boolean IsShadowVisible (void);
Boolean DoesRoomHaveFloor (void);
Boolean DoesRoomHaveCeiling (void);
void ReadyLevel (void); // --- RoomGraphics.c
void DrawLocale (void);
void RedrawRoomLighting (void);
Boolean PictIDExists (SInt16); // --- RoomInfo.c
void HandleBands (void); // --- RubberBands.c
Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean);
void KillAllBands (void);
void SaveGame2 (void); // --- SavedGames.c
Boolean OpenSavedGame (void);
void SaveGame (Boolean);
void RefreshScoreboard (SInt16); // --- Scoreboard.c
void HandleDynamicScoreboard (void);
void QuickGlidersRefresh (void);
void QuickScoreRefresh (void);
void QuickBatteryRefresh (Boolean);
void QuickBandsRefresh (Boolean);
void QuickFoilRefresh (Boolean);
void HandleScore (void);
void AdjustScoreboardHeight (void);
void BlackenScoreboard (void);
//void PutRoomScrap (void); // --- Scrap.c
//void PutObjectScrap (void);
void GetRoomScrap (void);
void GetObjectScrap (void);
//void SeeIfValidScrapAvailable (Boolean);
Boolean HasDragManager (void);
//Boolean DragRoom (EventRecord *, Rect *, SInt16);
void DoLoadHouse (void); // --- SelectHouse.c
void BuildHouseList (void);
void AddExtraHouse (FSSpec *);
void DoSettingsMain (void); // --- Settings.c
void PlayPrioritySound (SInt16, SInt16); // --- Sound.c
void FlushAnyTriggerPlaying (void);
void PlaySound0 (SInt16, SInt16);
void PlaySound1 (SInt16, SInt16);
void PlaySound2 (SInt16, SInt16);
OSErr LoadTriggerSound (SInt16);
void DumpTriggerSound (void);
void InitSound (void);
void KillSound (void);
long SoundBytesNeeded (void);
void TellHerNoSounds (void);
void BitchAboutSM3 (void);
void InitScoreboardMap (void); // --- StructuresInit.c
void InitGliderMap (void);
void InitBlowers (void);
void InitFurniture (void);
void InitPrizes (void);
void InitTransports (void);
void InitSwitches (void);
void InitLights (void);
void InitAppliances (void);
void InitEnemies (void);
void CreateOffscreens (void); // --- StructuresInit2.c
void CreatePointers (void);
void InitSrcRects (void);
void UpdateToolsWindow (void); // --- Tools.c
void EraseSelectedTool (void);
void SelectTool (SInt16);
void OpenToolsWindow (void);
void CloseToolsWindow (void);
void ToggleToolsWindow (void);
void HandleToolsClick (Point);
void NextToolMode (void);
void PrevToolMode (void);
void SetSpecificToolMode (SInt16);
SInt16 WhatAreWeLinkedTo (SInt16, Byte); // --- Transit.c
void ReadyGliderFromTransit (gliderPtr, SInt16);
void MoveRoomToRoom (gliderPtr, SInt16);
void TransportRoomToRoom (gliderPtr);
void MoveDuctToDuct (gliderPtr);
void MoveMailToMail (gliderPtr);
void ForceKillGlider (void);
void FollowTheLeader (void);
void PourScreenOn (Rect *); // --- Transitions.c
void WipeScreenOn (SInt16, Rect *);
void DumpScreenOn (Rect *);
//void DissBits (Rect *);
//void DissBitsChunky (Rect *);
//void FillColorNoise (Rect *);
//void FillSnow (Rect *);
void ToggleToaster (SInt16); // --- Trip.c
void ToggleMacPlus (SInt16);
void ToggleTV (SInt16);
void ToggleCoffee (SInt16);
void ToggleOutlet (SInt16);
void ToggleVCR (SInt16);
void ToggleStereos (SInt16);
void ToggleMicrowave (SInt16);
void ToggleBalloon (SInt16);
void ToggleCopter (SInt16);
void ToggleDart (SInt16);
void ToggleBall (SInt16);
void ToggleDrip (SInt16);
void ToggleFish (SInt16);
void TriggerSwitch (SInt16);
void TriggerToast (SInt16);
void TriggerOutlet (SInt16);
void TriggerDrip (SInt16);
void TriggerFish (SInt16);
void TriggerBalloon (SInt16);
void TriggerCopter (SInt16);
void TriggerDart (SInt16);
void UpdateOutletsLighting (SInt16, SInt16);
void ArmTrigger (hotPtr); // --- Triggers.c
void HandleTriggers (void);
void ZeroTriggers (void);

347
GpApp/GliderStructs.h Normal file
View File

@@ -0,0 +1,347 @@
//============================================================================
//----------------------------------------------------------------------------
// GliderStructs.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
typedef struct
{
Point topLeft; // 4
short distance; // 2
Boolean initial; // 1
Boolean state; // 1 F. lf. dn. rt. up
Byte vector; // 1 | x | x | x | x | 8 | 4 | 2 | 1 |
Byte tall; // 1
} blowerType; // total = 10
typedef struct
{
Rect bounds; // 8
short pict; // 2
} furnitureType; // total = 10
typedef struct
{
Point topLeft; // 4
short length; // 2 grease spill
short points; // 2 invis bonus
Boolean state; // 1
Boolean initial; // 1
} bonusType; // total = 10
typedef struct
{
Point topLeft; // 4
short tall; // 2 invis transport
short where; // 2
Byte who; // 1
Byte wide; // 1
} transportType; // total = 10
typedef struct
{
Point topLeft; // 4
short delay; // 2
short where; // 2
Byte who; // 1
Byte type; // 1
} switchType; // total = 10
typedef struct
{
Point topLeft; // 4
short length; // 2
Byte byte0; // 1
Byte byte1; // 1
Boolean initial; // 1
Boolean state; // 1
} lightType; // total = 10
typedef struct
{
Point topLeft; // 4
short height; // 2 toaster, pict ID
Byte byte0; // 1
Byte delay; // 1
Boolean initial; // 1
Boolean state; // 1
} applianceType; // total = 10
typedef struct
{
Point topLeft; // 4
short length; // 2
Byte delay; // 1
Byte byte0; // 1
Boolean initial; // 1
Boolean state; // 1
} enemyType; // total = 10
typedef struct
{
Rect bounds; // 8
short pict; // 2
} clutterType; // total = 10
typedef struct
{
short what; // 2
union
{
blowerType a;
furnitureType b;
bonusType c;
transportType d;
switchType e;
lightType f;
applianceType g;
enemyType h;
clutterType i;
} data; // 10
} objectType, *objectPtr; // total = 12
typedef struct
{
Str31 banner; // 32 = 32
Str15 names[kMaxScores]; // 16 * 10 = 160
Int32 scores[kMaxScores]; // 4 * 10 = 40
UInt32 timeStamps[kMaxScores]; // 4 * 10 = 40
short levels[kMaxScores]; // 2 * 10 = 20
} scoresType; // total = 292
typedef struct
{
short version; // 2
short wasStarsLeft; // 2
UInt32 timeStamp; // 4
Point where; // 4
Int32 score; // 4
Int32 unusedLong; // 4
Int32 unusedLong2; // 4
short energy; // 2
short bands; // 2
short roomNumber; // 2
short gliderState; // 2
short numGliders; // 2
short foil; // 2
short unusedShort; // 2
Boolean facing; // 1
Boolean showFoil; // 1
} gameType; // total = 40
typedef struct
{
short unusedShort; // 2
Byte unusedByte; // 1
Boolean visited; // 1
objectType objects[kMaxRoomObs]; // 24 * 12
} savedRoom, *saveRoomPtr; // total = 292
typedef struct
{
FSSpec house; // 70
short version; // 2
short wasStarsLeft; // 2
long timeStamp; // 4
Point where; // 4
long score; // 4
long unusedLong; // 4
long unusedLong2; // 4
short energy; // 2
short bands; // 2
short roomNumber; // 2
short gliderState; // 2
short numGliders; // 2
short foil; // 2
short nRooms; // 2
Boolean facing; // 1
Boolean showFoil; // 1
savedRoom savedData[1]; // 4
} game2Type, *gamePtr; // total = 114
typedef struct
{
Str27 name; // 28
short bounds; // 2
Byte leftStart; // 1
Byte rightStart; // 1
Byte unusedByte; // 1
Boolean visited; // 1
short background; // 2
short tiles[kNumTiles]; // 2 * 8
short floor, suite; // 2 + 2
short openings; // 2
short numObjects; // 2
objectType objects[kMaxRoomObs]; // 24 * 12
} roomType, *roomPtr; // total = 348
typedef struct
{
short version; // 2
short unusedShort; // 2
long timeStamp; // 4
long flags; // 4 (bit 0 = wardBit)
Point initial; // 4
Str255 banner; // 256
Str255 trailer; // 256
scoresType highScores; // 292
gameType savedGame; // 40
Boolean hasGame; // 1
Boolean unusedBoolean; // 1
short firstRoom; // 2
short nRooms; // 2
roomType rooms[1]; // 348 * nRooms
} houseType, *housePtr, **houseHand; // total = 866 +
typedef struct
{
Rect src, mask, dest, whole;
Rect destShadow, wholeShadow;
Rect clip, enteredRect;
Int32 leftKey, rightKey;
Int32 battKey, bandKey;
short hVel, vVel;
short wasHVel, wasVVel;
short vDesiredVel, hDesiredVel;
short mode, frame, wasMode;
Boolean facing, tipped;
Boolean sliding, ignoreLeft, ignoreRight;
Boolean fireHeld, which;
Boolean heldLeft, heldRight;
Boolean dontDraw, ignoreGround;
} gliderType, *gliderPtr;
typedef struct
{
Rect bounds;
short action;
short who;
Boolean isOn, stillOver;
Boolean doScrutinize;
} hotObject, *hotPtr;
typedef struct
{
Rect dest;
GWorldPtr map;
short where;
short who;
} savedType, *savedPtr;
typedef struct
{
Rect bounds;
short mode;
} sparkleType, *sparklePtr;
typedef struct
{
Rect dest, whole;
short start;
short stop;
short mode;
short loops;
short hVel, vVel;
} flyingPtType, *flyingPtPtr;
typedef struct
{
Rect dest, src;
short mode;
short who;
} flameType, *flamePtr;
typedef struct
{
Rect dest, src;
short mode, where;
short who, link;
Boolean toOrFro, active;
} pendulumType, *pendulumPtr;
typedef struct
{
Boolean left;
Boolean top;
Boolean right;
Boolean bottom;
} boundsType, *boundsPtr, **boundsHand;
typedef struct
{
Rect dest;
short mode, count;
short hVel, vVel;
} bandType, *bandPtr;
typedef struct
{
short srcRoom, srcObj;
short destRoom, destObj;
} linksType, *linksPtr;
typedef struct
{
Rect dest;
short mapNum, mode;
short who, where;
short start, stop;
short frame, hotNum;
Boolean isRight;
} greaseType, *greasePtr;
typedef struct
{
Rect dest, src;
short mode, who;
short link, where;
} starType, *starPtr;
typedef struct
{
Rect bounds;
short frame;
} shredType, *shredPtr;
typedef struct
{
Rect dest;
Rect whole;
short hVel, vVel;
short type, count;
short frame, timer;
short position, room;
Byte byte0, byte1;
Boolean moving, active;
} dynaType, *dynaPtr;
typedef struct
{
short roomNum; // room # object in (real number)
short objectNum; // obj. # in house (real number)
short roomLink; // room # object linked to (if any)
short objectLink; // obj. # object linked to (if any)
short localLink; // index in master list if exists
short hotNum; // index into active rects (if any)
short dynaNum; // index into dinahs (if any)
objectType theObject; // actual object data
} objDataType, *objDataPtr;
typedef struct
{
Int32 frame;
char key;
char padding;
} demoType, *demoPtr;
typedef struct
{
short room;
short object;
} retroLink, *retroLinkPtr;

59
GpApp/GliderVars.h Normal file
View File

@@ -0,0 +1,59 @@
//============================================================================
//----------------------------------------------------------------------------
// GliderVars.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLMovies.h"
extern Rect blowerSrcRect;
extern Rect flame[], tikiFlame[];
extern Rect coals[];
extern Rect furnitureSrcRect;
extern Rect tableSrc, shelfSrc, hingeSrc, handleSrc, knobSrc;
extern Rect leftFootSrc, rightFootSrc, deckSrc;
extern Rect bonusSrcRect;
extern Rect pointsSrcRect;
extern Rect starSrc[], sparkleSrc[];
extern Rect digits[], pendulumSrc[], greaseSrcRt[], greaseSrcLf[];
extern Rect transSrcRect;
extern Rect switchSrcRect;
extern Rect lightSwitchSrc[], machineSwitchSrc[], thermostatSrc[];
extern Rect powerSrc[], knifeSwitchSrc[];
extern Rect lightSrcRect;
extern Rect flourescentSrc1, flourescentSrc2;
extern Rect trackLightSrc[];
extern Rect applianceSrcRect, toastSrcRect, shredSrcRect; // Appliances
extern Rect plusScreen1, plusScreen2, tvScreen1, tvScreen2;
extern Rect coffeeLight1, coffeeLight2, vcrTime1, vcrTime2;
extern Rect stereoLight1, stereoLight2, microOn, microOff;
extern Rect outletSrc[];
extern Rect balloonSrcRect, copterSrcRect, dartSrcRect; // Enemies
extern Rect ballSrcRect, dripSrcRect, enemySrcRect;
extern Rect fishSrcRect;
extern Rect balloonSrc[], copterSrc[], dartSrc[];
extern Rect ballSrc[], dripSrc[], fishSrc[];
extern Rect clutterSrcRect;
extern Rect flowerSrc[];
extern Rect *srcRects;
extern Movie theMovie;
extern Rect movieRect;
extern Boolean hasMovie, tvInRoom;
extern gliderType theGlider, theGlider2;
extern objDataPtr masterObjects;
extern Rect workSrcRect;
extern Rect backSrcRect;
extern Rect mainWindowRect, houseRect;
extern houseHand thisHouse;
extern roomPtr thisRoom;
extern WindowPtr mainWindow, coordWindow;
extern long theScore;
extern short playOriginH, playOriginV;
extern short thisRoomNumber, theMode, batteryTotal, bandsTotal;
extern short foilTotal, mortals, numMasterObjects, previousRoom;
extern Boolean fileDirty, gameDirty, showFoil, doZooms, isPlayMusicGame;

12
GpApp/GpApp.props Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>GP_APP_DLL;GP_APP_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

204
GpApp/GpApp.vcxproj Normal file
View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{6233C3F2-5781-488E-B190-4FA8836F5A77}</ProjectGuid>
<RootNamespace>GpApp</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\PortabilityLayer.props" />
<Import Project="GpApp.props" />
<Import Project="..\Common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\PortabilityLayer.props" />
<Import Project="GpApp.props" />
<Import Project="..\Common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\PortabilityLayer.props" />
<Import Project="GpApp.props" />
<Import Project="..\Common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\PortabilityLayer.props" />
<Import Project="GpApp.props" />
<Import Project="..\Common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="About.cpp" />
<ClCompile Include="AnimCursor.cpp" />
<ClCompile Include="AppleEvents.cpp" />
<ClCompile Include="Banner.cpp" />
<ClCompile Include="ColorUtils.cpp" />
<ClCompile Include="Coordinates.cpp" />
<ClCompile Include="DialogUtils.cpp" />
<ClCompile Include="DynamicMaps.cpp" />
<ClCompile Include="Dynamics.cpp" />
<ClCompile Include="Dynamics2.cpp" />
<ClCompile Include="Dynamics3.cpp" />
<ClCompile Include="Environ.cpp" />
<ClCompile Include="Events.cpp" />
<ClCompile Include="FileError.cpp" />
<ClCompile Include="GameOver.cpp" />
<ClCompile Include="GpAppInterface.cpp" />
<ClCompile Include="Grease.cpp" />
<ClCompile Include="HighScores.cpp" />
<ClCompile Include="House.cpp" />
<ClCompile Include="HouseInfo.cpp" />
<ClCompile Include="HouseIO.cpp" />
<ClCompile Include="HouseLegal.cpp" />
<ClCompile Include="Input.cpp" />
<ClCompile Include="Interactions.cpp" />
<ClCompile Include="InterfaceInit.cpp" />
<ClCompile Include="Link.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="MainWindow.cpp" />
<ClCompile Include="Map.cpp" />
<ClCompile Include="Marquee.cpp" />
<ClCompile Include="Menu.cpp" />
<ClCompile Include="Modes.cpp" />
<ClCompile Include="Music.cpp" />
<ClCompile Include="ObjectAdd.cpp" />
<ClCompile Include="ObjectDraw.cpp" />
<ClCompile Include="ObjectDraw2.cpp" />
<ClCompile Include="ObjectDrawAll.cpp" />
<ClCompile Include="ObjectEdit.cpp" />
<ClCompile Include="ObjectInfo.cpp" />
<ClCompile Include="ObjectRects.cpp" />
<ClCompile Include="Objects.cpp" />
<ClCompile Include="Play.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="Prefs.cpp" />
<ClCompile Include="RectUtils.cpp" />
<ClCompile Include="Render.cpp" />
<ClCompile Include="Room.cpp" />
<ClCompile Include="RoomGraphics.cpp" />
<ClCompile Include="RoomInfo.cpp" />
<ClCompile Include="RubberBands.cpp" />
<ClCompile Include="SavedGames.cpp" />
<ClCompile Include="Scoreboard.cpp" />
<ClCompile Include="SelectHouse.cpp" />
<ClCompile Include="Settings.cpp" />
<ClCompile Include="Sound.cpp" />
<ClCompile Include="StringUtils.cpp" />
<ClCompile Include="StructuresInit.cpp" />
<ClCompile Include="StructuresInit2.cpp" />
<ClCompile Include="Tools.cpp" />
<ClCompile Include="Transit.cpp" />
<ClCompile Include="Transitions.cpp" />
<ClCompile Include="Triggers.cpp" />
<ClCompile Include="Trip.cpp" />
<ClCompile Include="Utilities.cpp" />
<ClCompile Include="WindowUtils.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PortabilityLayer\PortabilityLayer.vcxproj">
<Project>{6ec62b0f-9353-40a4-a510-3788f1368b33}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

214
GpApp/GpApp.vcxproj.filters Normal file
View File

@@ -0,0 +1,214 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AnimCursor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Events.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Environ.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Prefs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StringUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Utilities.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AppleEvents.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="House.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HouseIO.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="InterfaceInit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MainWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Marquee.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Music.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SelectHouse.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StructuresInit2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HighScores.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Settings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RoomGraphics.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Map.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Tools.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Coordinates.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Link.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HouseLegal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Input.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Room.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Play.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WindowUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Menu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectEdit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RoomInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileError.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Objects.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Banner.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RectUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectAdd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ColorUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DialogUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StructuresInit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GameOver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DynamicMaps.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Grease.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Dynamics.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RubberBands.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Dynamics3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Interactions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Modes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Scoreboard.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Transit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SavedGames.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectDrawAll.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Trip.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Triggers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectRects.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Transitions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="About.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HouseInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectDraw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ObjectDraw2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Dynamics2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GpAppInterface.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

57
GpApp/GpAppInterface.cpp Normal file
View File

@@ -0,0 +1,57 @@
#include "GpAppInterface.h"
#include "DisplayDeviceManager.h"
#include "HostFileSystem.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
int gpAppMain();
class GpAppInterfaceImpl final : public GpAppInterface
{
public:
int ApplicationMain() override;
void PL_IncrementTickCounter(uint32_t count) override;
void PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) override;
void PL_HostDisplayDriver_SetInstance(PortabilityLayer::HostDisplayDriver *instance) override;
void PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance) override;
void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) override;
};
int GpAppInterfaceImpl::ApplicationMain()
{
return gpAppMain();
}
void GpAppInterfaceImpl::PL_IncrementTickCounter(uint32_t count)
{
PortabilityLayer::DisplayDeviceManager::GetInstance()->IncrementTickCount(count);
}
void GpAppInterfaceImpl::PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance)
{
PortabilityLayer::HostFileSystem::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostDisplayDriver_SetInstance(PortabilityLayer::HostDisplayDriver *instance)
{
PortabilityLayer::HostDisplayDriver::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance)
{
PortabilityLayer::HostSystemServices::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context)
{
PortabilityLayer::InstallHostSuspendHook(hook, context);
}
static GpAppInterfaceImpl gs_application;
extern "C" GpAppInterface *GpAppInterface_Get()
{
return &gs_application;
}

302
GpApp/Grease.cpp Normal file
View File

@@ -0,0 +1,302 @@
//============================================================================
//----------------------------------------------------------------------------
// Grease.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "RectUtils.h"
#include "Room.h"
#define kGreaseIdle 0
#define kGreaseFalling 1
#define kGreaseSpreading 2
#define kGreaseSpiltIdle 3
void BackupGrease (Rect *, short, Boolean);
greasePtr grease;
short numGrease;
extern hotPtr hotSpots;
extern savedType savedMaps[];
extern Point shieldPt;
extern Rect greaseSrcRt[], greaseSrcLf[], shieldRect;
//============================================================== Functions
//-------------------------------------------------------------- HandleGrease
// Goes through all grease objects currently on screen and handles<65>
// them. If they're upright, nothing happens, but if they're in<69>
// the course of falling or spilling, this function will handle<6C>
// advancing the spill, etc.
void HandleGrease (void)
{
Rect src;
short i;
if (numGrease == 0)
return;
for (i = 0; i < numGrease; i++)
{
if (grease[i].mode == kGreaseFalling)
{
grease[i].frame++;
if (grease[i].frame >= 3) // grease completely tipped
{
grease[i].frame = 3;
grease[i].mode = kGreaseSpreading;
hotSpots[grease[i].hotNum].action = kSlideIt;
hotSpots[grease[i].hotNum].isOn = true;
if (grease[i].isRight)
QSetRect(&src, 0, -2, 2, 0);
else
QSetRect(&src, -2, -2, 0, 0);
QOffsetRect(&src, -playOriginH, -playOriginV);
QOffsetRect(&src, grease[i].start, grease[i].dest.bottom);
hotSpots[grease[i].hotNum].bounds = src;
}
QSetRect(&src, 0, 0, 32, 27);
QOffsetRect(&src, 0, grease[i].frame * 27);
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[grease[i].mapNum].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &grease[i].dest,
srcCopy, nil);
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[grease[i].mapNum].map),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &grease[i].dest,
srcCopy, nil);
AddRectToWorkRects(&grease[i].dest);
if (grease[i].isRight)
QOffsetRect(&grease[i].dest, 2, 0);
else
QOffsetRect(&grease[i].dest, -2, 0);
}
else if (grease[i].mode == kGreaseSpreading)
{
if (grease[i].isRight)
{
QSetRect(&src, 0, -2, 2, 0);
QOffsetRect(&src, grease[i].start, grease[i].dest.bottom);
grease[i].start += 2;
hotSpots[grease[i].hotNum].bounds.right += 2;
}
else
{
QSetRect(&src, -2, -2, 0, 0);
QOffsetRect(&src, grease[i].start, grease[i].dest.bottom);
grease[i].start -= 2;
hotSpots[grease[i].hotNum].bounds.left -= 2;
}
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
PaintRect(&src);
SetGWorld(workSrcMap, nil);
PaintRect(&src);
AddRectToWorkRects(&src);
SetGWorld(wasCPort, wasWorld);
}
if (grease[i].isRight)
{
if (grease[i].start >= grease[i].stop)
grease[i].mode = kGreaseSpiltIdle;
}
else
{
if (grease[i].start <= grease[i].stop)
grease[i].mode = kGreaseSpiltIdle;
}
}
}
}
//-------------------------------------------------------------- BackupGrease
// This makes copies of the region of the screen the grease is about<75>
// to be drawn to. It is called in the "set up" when a player has<61>
// just entered a new room. The "grease jar falling over" animation<6F>
// is set up here.
void BackupGrease (Rect *src, short index, Boolean isRight)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 32, 27);
for (i = 0; i < 4; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
(BitMap *)*GetGWorldPixMap(savedMaps[index].map),
src, &dest, srcCopy, nil);
if (isRight)
{
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap *)*GetGWorldPixMap(bonusMaskMap),
(BitMap *)*GetGWorldPixMap(savedMaps[index].map),
&greaseSrcRt[i], &greaseSrcRt[i], &dest);
QOffsetRect(src, 2, 0);
}
else
{
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap *)*GetGWorldPixMap(bonusMaskMap),
(BitMap *)*GetGWorldPixMap(savedMaps[index].map),
&greaseSrcLf[i], &greaseSrcLf[i], &dest);
QOffsetRect(src, -2, 0);
}
QOffsetRect(&dest, 0, 27);
}
}
//-------------------------------------------------------------- ReBackUpGrease
// Just like th eabove function but it is called while the player is<69>
// active in a room and has changed the lighting situation (like turned<65>
// off or on the lights). It assumes certain data strucutures are<72>
// already declared from an earlier call to the above funciton.
short ReBackUpGrease (short where, short who)
{
Rect src;
short i;
for (i = 0; i < numGrease; i++)
{
if ((grease[i].where == where) && (grease[i].who == who))
{
if ((grease[i].mode == kGreaseIdle) || (grease[i].mode == kGreaseFalling))
{
src = grease[i].dest;
BackupGrease(&src, grease[i].mapNum, grease[i].isRight);
}
return (i);
}
}
return (-1);
}
//-------------------------------------------------------------- AddGrease
// Called when a new room is being set up during a game. This adds<64>
// another jar of grease to the queue of jars to be handled.
short AddGrease (short where, short who, short h, short v,
short distance, Boolean isRight)
{
Rect src, bounds;
short savedNum;
if (numGrease >= kMaxGrease)
return (-1);
QSetRect(&src, 0, 0, 32, 27);
QOffsetRect(&src, h, v);
QSetRect(&bounds, 0, 0, 32, 27 * 4);
savedNum = BackUpToSavedMap(&bounds, where, who);
if (savedNum != -1)
{
BackupGrease (&src, savedNum, isRight);
if (isRight)
QOffsetRect(&src, -8, 0);
else
QOffsetRect(&src, 8, 0);
grease[numGrease].who = who;
grease[numGrease].where = where;
grease[numGrease].dest = src;
grease[numGrease].mapNum = savedNum;
grease[numGrease].mode = kGreaseIdle;
grease[numGrease].frame = -1;
if (isRight)
{
grease[numGrease].isRight = true;
grease[numGrease].start = src.right + 4;
grease[numGrease].stop = src.right + distance;
}
else
{
grease[numGrease].isRight = false;
grease[numGrease].start = src.left - 4;
grease[numGrease].stop = src.left - distance;
}
numGrease++;
return (numGrease - 1);
}
else
return (-1);
}
//-------------------------------------------------------------- SpillGrease
// A player has knocked a jar of grease over - this function flags that.
void SpillGrease (short who, short index)
{
if (grease[who].mode == kGreaseIdle)
{
grease[who].mode = kGreaseFalling;
grease[who].hotNum = index;
PlayPrioritySound(kGreaseSpillSound, kGreaseSpillPriority);
}
}
//-------------------------------------------------------------- RedrawAllGrease
// Called to redraw all the black lines of spilt grease.
void RedrawAllGrease (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
Rect src;
short i;
if (numGrease == 0)
return;
for (i = 0; i < numGrease; i++)
{
src = hotSpots[grease[i].hotNum].bounds;
if ((grease[i].where == thisRoomNumber) &&
((src.bottom - src.top) == 2) &&
(grease[i].mode != kGreaseIdle))
{
QOffsetRect(&src, playOriginH, playOriginV);
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
PaintRect(&src);
SetGWorld(workSrcMap, nil);
PaintRect(&src);
AddRectToWorkRects(&src);
SetGWorld(wasCPort, wasWorld);
}
}
}

856
GpApp/HighScores.cpp Normal file
View File

@@ -0,0 +1,856 @@
//============================================================================
//----------------------------------------------------------------------------
// HighScores.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLFolders.h"
#include "PLNumberFormatting.h"
#include "PLScript.h"
#include "PLSound.h"
#include "PLStringCompare.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "Utilities.h"
#define kHighScoresPictID 1994
#define kHighScoresMaskID 1998
#define kHighNameDialogID 1020
#define kHighBannerDialogID 1021
#define kHighNameItem 2
#define kNameNCharsItem 5
#define kHighBannerItem 2
#define kBannerScoreNCharsItem 5
void DrawHighScores (void);
void UpdateNameDialog (DialogPtr);
Boolean NameFilter (DialogPtr, EventRecord *, short *);
void GetHighScoreName (short);
void UpdateBannerDialog (DialogPtr);
Boolean BannerFilter (DialogPtr, EventRecord *, short *);
void GetHighScoreBanner (void);
Boolean CreateScoresFolder (long *);
Boolean FindHighScoresFolder (short *, long *);
Boolean OpenHighScoresFile (FSSpec *, short *);
Str31 highBanner;
Str15 highName;
short lastHighScore;
Boolean keyStroke;
extern short splashOriginH, splashOriginV;
extern Boolean quickerTransitions, resumedSavedGame;
//============================================================== Functions
//-------------------------------------------------------------- DoHighScores
// Handles fading in and cleaning up the high scores screen.
void DoHighScores (void)
{
Rect tempRect;
SpinCursor(3);
SetPort((GrafPtr)workSrcMap);
PaintRect(&workSrcRect);
QSetRect(&tempRect, 0, 0, 640, 480);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(kStarPictID, &tempRect);
// if (quickerTransitions)
// DissBitsChunky(&workSrcRect);
// else
// DissBits(&workSrcRect);
SpinCursor(3);
SetPort((GrafPtr)workSrcMap);
DrawHighScores();
SpinCursor(3);
// if (quickerTransitions)
// DissBitsChunky(&workSrcRect);
// else
// DissBits(&workSrcRect);
InitCursor();
DelayTicks(60);
WaitForInputEvent(30);
RedrawSplashScreen();
}
//-------------------------------------------------------------- DrawHighScores
// Draws the actual scores on the screen.
#define kScoreSpacing 18
#define kScoreWide 352
#define kKimsLifted 4
void DrawHighScores (void)
{
GWorldPtr tempMap, tempMask;
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
houseType *thisHousePtr;
Rect tempRect, tempRect2;
Str255 tempStr;
short scoreLeft, bannerWidth, i, dropIt;
char wasState;
scoreLeft = ((thisMac.screen.right - thisMac.screen.left) - kScoreWide) / 2;
dropIt = 129 + splashOriginV;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&tempRect, 0, 0, 332, 30);
theErr = CreateOffScreenGWorld(&tempMap, &tempRect, kPreferredDepth);
SetGWorld(tempMap, nil);
LoadGraphic(kHighScoresPictID);
theErr = CreateOffScreenGWorld(&tempMask, &tempRect, 1);
SetGWorld(tempMask, nil);
LoadGraphic(kHighScoresMaskID);
tempRect2 = tempRect;
QOffsetRect(&tempRect2, scoreLeft + (kScoreWide - 332) / 2, dropIt - 60);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
(BitMap *)*GetGWorldPixMap(tempMask),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&tempRect, &tempRect, &tempRect2);
DisposeGWorld(tempMap);
DisposeGWorld(tempMask);
SetGWorld(wasCPort, wasWorld);
TextFont(applFont);
TextFace(bold);
TextSize(14);
PasStringCopy(PSTR("<EFBFBD> "), tempStr);
PasStringConcat(tempStr, thisHouseName);
PasStringConcat(tempStr, PSTR(" <20>"));
MoveTo(scoreLeft + ((kScoreWide - StringWidth(tempStr)) / 2) - 1, dropIt - 66);
ForeColor(blackColor);
DrawString(tempStr);
MoveTo(scoreLeft + ((kScoreWide - StringWidth(tempStr)) / 2), dropIt - 65);
ForeColor(cyanColor);
DrawString(tempStr);
ForeColor(blackColor);
TextFont(applFont);
TextFace(bold);
TextSize(12);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
// message for score #1
PasStringCopy(thisHousePtr->highScores.banner, tempStr);
bannerWidth = StringWidth(tempStr);
ForeColor(blackColor);
MoveTo(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted);
DrawString(tempStr);
ForeColor(yellowColor);
MoveTo(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted - 1);
DrawString(tempStr);
QSetRect(&tempRect, 0, 0, bannerWidth + 8, kScoreSpacing);
QOffsetRect(&tempRect, scoreLeft - 3 + (kScoreWide - bannerWidth) / 2,
dropIt + 5 - kScoreSpacing - kKimsLifted);
ForeColor(blackColor);
FrameRect(&tempRect);
QOffsetRect(&tempRect, -1, -1);
ForeColor(yellowColor);
FrameRect(&tempRect);
for (i = 0; i < kMaxScores; i++)
{
if (thisHousePtr->highScores.scores[i] > 0L)
{
SpinCursor(1);
NumToString((long)i + 1L, tempStr); // draw placing number
ForeColor(blackColor);
if (i == 0)
MoveTo(scoreLeft + 1, dropIt - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 1, dropIt + (i * kScoreSpacing));
DrawString(tempStr);
if (i == lastHighScore)
ForeColor(whiteColor);
else
ForeColor(cyanColor);
if (i == 0)
MoveTo(scoreLeft + 0, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 0, dropIt - 1 + (i * kScoreSpacing));
DrawString(tempStr);
// draw high score name
PasStringCopy(thisHousePtr->highScores.names[i], tempStr);
ForeColor(blackColor);
if (i == 0)
MoveTo(scoreLeft + 31, dropIt - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 31, dropIt + (i * kScoreSpacing));
DrawString(tempStr);
if (i == lastHighScore)
ForeColor(whiteColor);
else
ForeColor(yellowColor);
if (i == 0)
MoveTo(scoreLeft + 30, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 30, dropIt - 1 + (i * kScoreSpacing));
DrawString(tempStr);
// draw level number
NumToString(thisHousePtr->highScores.levels[i], tempStr);
ForeColor(blackColor);
if (i == 0)
MoveTo(scoreLeft + 161, dropIt - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 161, dropIt + (i * kScoreSpacing));
DrawString(tempStr);
if (i == lastHighScore)
ForeColor(whiteColor);
else
ForeColor(yellowColor);
if (i == 0)
MoveTo(scoreLeft + 160, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 160, dropIt - 1 + (i * kScoreSpacing));
DrawString(tempStr);
// draw word "rooms"
if (thisHousePtr->highScores.levels[i] == 1)
GetLocalizedString(6, tempStr);
else
GetLocalizedString(7, tempStr);
ForeColor(blackColor);
if (i == 0)
MoveTo(scoreLeft + 193, dropIt - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 193, dropIt + (i * kScoreSpacing));
DrawString(tempStr);
ForeColor(cyanColor);
if (i == 0)
MoveTo(scoreLeft + 192, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 192, dropIt - 1 + (i * kScoreSpacing));
DrawString(tempStr);
// draw high score points
NumToString(thisHousePtr->highScores.scores[i], tempStr);
ForeColor(blackColor);
if (i == 0)
MoveTo(scoreLeft + 291, dropIt - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 291, dropIt + (i * kScoreSpacing));
DrawString(tempStr);
if (i == lastHighScore)
ForeColor(whiteColor);
else
ForeColor(yellowColor);
if (i == 0)
MoveTo(scoreLeft + 290, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
MoveTo(scoreLeft + 290, dropIt - 1 + (i * kScoreSpacing));
DrawString(tempStr);
}
}
ForeColor(blueColor);
TextFont(applFont);
TextFace(bold);
TextSize(9);
MoveTo(scoreLeft + 80, dropIt - 1 + (10 * kScoreSpacing));
GetLocalizedString(8, tempStr);
DrawString(tempStr);
ForeColor(blackColor);
HSetState((Handle)thisHouse, wasState);
}
//-------------------------------------------------------------- SortHighScores
// This does a simple sort of the high scores.
void SortHighScores (void)
{
scoresType tempScores;
houseType *thisHousePtr;
long greatest;
short i, h, which;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
for (h = 0; h < kMaxScores; h++)
{
greatest = -1L;
which = -1;
for (i = 0; i < kMaxScores; i++)
{
if (thisHousePtr->highScores.scores[i] > greatest)
{
greatest = thisHousePtr->highScores.scores[i];
which = i;
}
}
if (which != -1)
{
PasStringCopy(thisHousePtr->highScores.names[which], tempScores.names[h]);
tempScores.scores[h] = thisHousePtr->highScores.scores[which];
tempScores.timeStamps[h] = thisHousePtr->highScores.timeStamps[which];
tempScores.levels[h] = thisHousePtr->highScores.levels[which];
thisHousePtr->highScores.scores[which] = -1L;
}
}
PasStringCopy(thisHousePtr->highScores.banner, tempScores.banner);
thisHousePtr->highScores = tempScores;
HSetState((Handle)thisHouse, wasState);
}
//-------------------------------------------------------------- ZeroHighScores
// This funciton goes through and resets or "zeros" all high scores.
void ZeroHighScores (void)
{
houseType *thisHousePtr;
short i;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
PasStringCopy(thisHouseName, thisHousePtr->highScores.banner);
for (i = 0; i < kMaxScores; i++)
{
PasStringCopy(PSTR("--------------"), thisHousePtr->highScores.names[i]);
thisHousePtr->highScores.scores[i] = 0L;
thisHousePtr->highScores.timeStamps[i] = 0L;
thisHousePtr->highScores.levels[i] = 0;
}
HSetState((Handle)thisHouse, wasState);
}
//-------------------------------------------------------------- ZeroAllButHighestScore
// Like the above, but this function preserves the highest score.
void ZeroAllButHighestScore (void)
{
houseType *thisHousePtr;
short i;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
for (i = 1; i < kMaxScores; i++)
{
PasStringCopy(PSTR("--------------"), thisHousePtr->highScores.names[i]);
thisHousePtr->highScores.scores[i] = 0L;
thisHousePtr->highScores.timeStamps[i] = 0L;
thisHousePtr->highScores.levels[i] = 0;
}
HSetState((Handle)thisHouse, wasState);
}
//-------------------------------------------------------------- TestHighScore
// This function is called after a game ends in order to test the<68>
// current high score against the high score list. It returns true<75>
// if the player is on the high score list now.
Boolean TestHighScore (void)
{
houseType *thisHousePtr;
short placing, i;
char wasState;
if (resumedSavedGame)
return (false);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
lastHighScore = -1;
placing = -1;
for (i = 0; i < kMaxScores; i++)
{
if (theScore > thisHousePtr->highScores.scores[i])
{
placing = i;
lastHighScore = i;
break;
}
}
if (placing != -1)
{
FlushEvents(everyEvent, 0);
GetHighScoreName(placing + 1);
PasStringCopy(highName, thisHousePtr->highScores.names[kMaxScores - 1]);
if (placing == 0)
{
GetHighScoreBanner();
PasStringCopy(highBanner, thisHousePtr->highScores.banner);
}
thisHousePtr->highScores.scores[kMaxScores - 1] = theScore;
GetDateTime(&thisHousePtr->highScores.timeStamps[kMaxScores - 1]);
thisHousePtr->highScores.levels[kMaxScores - 1] = CountRoomsVisited();
SortHighScores();
gameDirty = true;
}
HSetState((Handle)thisHouse, wasState);
if (placing != -1)
{
DoHighScores();
return (true);
}
else
return (false);
}
//-------------------------------------------------------------- UpdateNameDialog
// Redraws the "Enter High Score Name" dialog.
void UpdateNameDialog (DialogPtr theDialog)
{
short nChars;
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
nChars = GetDialogStringLen(theDialog, kHighNameItem);
SetDialogNumToStr(theDialog, kNameNCharsItem, (long)nChars);
}
//-------------------------------------------------------------- NameFilter
// Dialog filter for the "Enter High Score Name" dialog.
Boolean NameFilter (DialogPtr dial, EventRecord *event, short *item)
{
short nChars;
if (keyStroke)
{
nChars = GetDialogStringLen(dial, kHighNameItem);
SetDialogNumToStr(dial, kNameNCharsItem, (long)nChars);
keyStroke = false;
}
switch (event->what)
{
case keyDown:
keyStroke = true;
switch ((event->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
PlayPrioritySound(kCarriageSound, kCarriagePriority);
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
case kTabKeyASCII:
SelectDialogItemText(dial, kHighNameItem, 0, 1024);
return(false);
break;
default:
PlayPrioritySound(kTypingSound, kTypingPriority);
return(false);
}
break;
case updateEvt:
BeginUpdate(GetDialogWindow(dial));
UpdateNameDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
return(false);
break;
}
}
//-------------------------------------------------------------- GetHighScoreName
// Brings up a dialog to get player's name (due to a high score).
void GetHighScoreName (short place)
{
DialogPtr theDial;
Str255 scoreStr, placeStr, tempStr;
short item;
Boolean leaving;
ModalFilterUPP nameFilterUPP;
nameFilterUPP = NewModalFilterUPP(NameFilter);
InitCursor();
NumToString(theScore, scoreStr);
NumToString((long)place, placeStr);
ParamText(scoreStr, placeStr, thisHouseName, PSTR(""));
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
BringUpDialog(&theDial, kHighNameDialogID);
FlushEvents(everyEvent, 0);
SetDialogString(theDial, kHighNameItem, highName);
SelectDialogItemText(theDial, kHighNameItem, 0, 1024);
leaving = false;
while (!leaving)
{
ModalDialog(nameFilterUPP, &item);
if (item == kOkayButton)
{
GetDialogString(theDial, kHighNameItem, tempStr);
PasStringCopyNum(tempStr, highName, 15);
leaving = true;
}
}
DisposeDialog(theDial);
DisposeModalFilterUPP(nameFilterUPP);
}
//-------------------------------------------------------------- UpdateBannerDialog
// Redraws the "Enter Message" dialog.
void UpdateBannerDialog (DialogPtr theDialog)
{
short nChars;
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
nChars = GetDialogStringLen(theDialog, kHighBannerItem);
SetDialogNumToStr(theDialog, kBannerScoreNCharsItem, (long)nChars);
}
//-------------------------------------------------------------- BannerFilter
// Dialog filter for the "Enter Message" dialog.
Boolean BannerFilter (DialogPtr dial, EventRecord *event, short *item)
{
short nChars;
if (keyStroke)
{
nChars = GetDialogStringLen(dial, kHighBannerItem);
SetDialogNumToStr(dial, kBannerScoreNCharsItem, (long)nChars);
keyStroke = false;
}
switch (event->what)
{
case keyDown:
keyStroke = true;
switch ((event->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
PlayPrioritySound(kCarriageSound, kCarriagePriority);
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
case kTabKeyASCII:
SelectDialogItemText(dial, kHighBannerItem, 0, 1024);
return(false);
break;
default:
PlayPrioritySound(kTypingSound, kTypingPriority);
return(false);
}
break;
case updateEvt:
BeginUpdate(GetDialogWindow(dial));
UpdateBannerDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
return(false);
break;
}
}
//-------------------------------------------------------------- GetHighScoreBanner
// A player who gets the #1 slot gets to enter a short message (that<61>
// appears across the top of the high scores list). This dialog<6F>
// gets that message.
void GetHighScoreBanner (void)
{
DialogPtr theDial;
Str255 tempStr;
short item;
Boolean leaving;
ModalFilterUPP bannerFilterUPP;
bannerFilterUPP = NewModalFilterUPP(BannerFilter);
PlayPrioritySound(kEnergizeSound, kEnergizePriority);
BringUpDialog(&theDial, kHighBannerDialogID);
SetDialogString(theDial, kHighBannerItem, highBanner);
SelectDialogItemText(theDial, kHighBannerItem, 0, 1024);
leaving = false;
while (!leaving)
{
ModalDialog(bannerFilterUPP, &item);
if (item == kOkayButton)
{
GetDialogString(theDial, kHighBannerItem, tempStr);
PasStringCopyNum(tempStr, highBanner, 31);
leaving = true;
}
}
DisposeDialog(theDial);
DisposeModalFilterUPP(bannerFilterUPP);
}
//-------------------------------------------------------------- CreateScoresFolder
Boolean CreateScoresFolder (long *scoresDirID)
{
FSSpec scoresSpec;
long prefsDirID;
OSErr theErr;
short volRefNum;
theErr = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
&volRefNum, &prefsDirID);
if (!CheckFileError(theErr, PSTR("Prefs Folder")))
return (false);
theErr = FSMakeFSSpec(volRefNum, prefsDirID, PSTR("G-PRO Scores <20>"), &scoresSpec);
theErr = FSpDirCreate(&scoresSpec, smSystemScript, scoresDirID);
if (!CheckFileError(theErr, PSTR("High Scores Folder")))
return (false);
return (true);
}
//-------------------------------------------------------------- FindHighScoresFolder
Boolean FindHighScoresFolder (short *volRefNum, long *scoresDirID)
{
CInfoPBRec theBlock;
Str255 nameString;
long prefsDirID;
OSErr theErr;
short count;
Boolean foundIt;
theErr = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
volRefNum, &prefsDirID);
if (!CheckFileError(theErr, PSTR("Prefs Folder")))
return (false);
PasStringCopy(PSTR("G-PRO Scores <20>"), nameString);
count = 1;
foundIt = false;
theBlock.dirInfo.ioCompletion = nil;
theBlock.dirInfo.ioVRefNum = *volRefNum;
theBlock.dirInfo.ioNamePtr = nameString;
while ((theErr == noErr) && (!foundIt))
{
theBlock.dirInfo.ioFDirIndex = count;
theBlock.dirInfo.ioDrDirID = prefsDirID;
theErr = PBGetCatInfo(&theBlock, false);
if (theErr == noErr)
{
if ((theBlock.dirInfo.ioFlAttrib & 0x10) == 0x10)
{
if (EqualString(theBlock.dirInfo.ioNamePtr, PSTR("G-PRO Scores <20>"),
true, true))
{
foundIt = true;
*scoresDirID = theBlock.dirInfo.ioDrDirID;
}
}
count++;
}
}
if (theErr == fnfErr)
{
if (CreateScoresFolder(scoresDirID))
return (true);
else
return (false);
}
else
return (true);
}
//-------------------------------------------------------------- OpenHighScoresFile
Boolean OpenHighScoresFile (FSSpec *scoreSpec, short *scoresRefNum)
{
OSErr theErr;
theErr = FSpOpenDF(scoreSpec, fsCurPerm, scoresRefNum);
if (theErr == fnfErr)
{
theErr = FSpCreate(scoreSpec, 'ozm5', 'gliS', smSystemScript);
if (!CheckFileError(theErr, PSTR("New High Scores File")))
return (false);
theErr = FSpOpenDF(scoreSpec, fsCurPerm, scoresRefNum);
if (!CheckFileError(theErr, PSTR("High Score")))
return (false);
}
else if (!CheckFileError(theErr, PSTR("High Score")))
return (false);
return (true);
}
//-------------------------------------------------------------- WriteScoresToDisk
Boolean WriteScoresToDisk (void)
{
scoresType *theScores;
FSSpec scoreSpec;
long dirID, byteCount;
OSErr theErr;
short volRefNum, scoresRefNum;
char wasState;
if (!FindHighScoresFolder(&volRefNum, &dirID))
{
SysBeep(1);
return (false);
}
theErr = FSMakeFSSpec(volRefNum, dirID, thisHouseName, &scoreSpec);
if (!OpenHighScoresFile(&scoreSpec, &scoresRefNum))
{
SysBeep(1);
return (false);
}
theErr = SetFPos(scoresRefNum, fsFromStart, 0L);
if (!CheckFileError(theErr, PSTR("High Scores File")))
{
theErr = FSClose(scoresRefNum);
return(false);
}
byteCount = sizeof(scoresType);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
theScores = &((*thisHouse)->highScores);
theErr = FSWrite(scoresRefNum, &byteCount, (Ptr)theScores);
if (!CheckFileError(theErr, PSTR("High Scores File")))
{
HSetState((Handle)thisHouse, wasState);
theErr = FSClose(scoresRefNum);
return(false);
}
HSetState((Handle)thisHouse, wasState);
theErr = SetEOF(scoresRefNum, byteCount);
if (!CheckFileError(theErr, PSTR("High Scores File")))
{
theErr = FSClose(scoresRefNum);
return(false);
}
theErr = FSClose(scoresRefNum);
if (!CheckFileError(theErr, PSTR("High Scores File")))
return(false);
return (true);
}
//-------------------------------------------------------------- ReadScoresFromDisk
Boolean ReadScoresFromDisk (void)
{
scoresType *theScores;
FSSpec scoreSpec;
long dirID, byteCount;
OSErr theErr;
short volRefNum, scoresRefNum;
char wasState;
if (!FindHighScoresFolder(&volRefNum, &dirID))
{
SysBeep(1);
return (false);
}
theErr = FSMakeFSSpec(volRefNum, dirID, thisHouseName, &scoreSpec);
if (!OpenHighScoresFile(&scoreSpec, &scoresRefNum))
{
SysBeep(1);
return (false);
}
theErr = GetEOF(scoresRefNum, &byteCount);
if (!CheckFileError(theErr, PSTR("High Scores File")))
{
theErr = FSClose(scoresRefNum);
return (false);
}
theErr = SetFPos(scoresRefNum, fsFromStart, 0L);
if (!CheckFileError(theErr, PSTR("High Scores File")))
{
theErr = FSClose(scoresRefNum);
return (false);
}
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
theScores = &((*thisHouse)->highScores);
theErr = FSRead(scoresRefNum, &byteCount, theScores);
if (!CheckFileError(theErr, PSTR("High Scores File")))
{
HSetState((Handle)thisHouse, wasState);
theErr = FSClose(scoresRefNum);
return (false);
}
HSetState((Handle)thisHouse, wasState);
theErr = FSClose(scoresRefNum);
if (!CheckFileError(theErr, PSTR("High Scores File")))
return(false);
return (true);
}

860
GpApp/House.cpp Normal file
View File

@@ -0,0 +1,860 @@
//============================================================================
//----------------------------------------------------------------------------
// House.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLAppleEvents.h"
#include "PLNavigation.h"
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "PLResources.h"
#include "PLSound.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "House.h"
#include "RectUtils.h"
#define kGoToDialogID 1043
void UpdateGoToDialog (DialogPtr);
Boolean GoToFilter (DialogPtr, EventRecord *, short *);
houseHand thisHouse;
linksPtr linksList;
Str32 thisHouseName;
short srcLocations[kMaxRoomObs];
short destLocations[kMaxRoomObs];
short wasFloor, wasSuite;
retroLink retroLinkList[kMaxRoomObs];
Boolean houseUnlocked;
extern gameType smallGame;
extern short numberRooms, mapLeftRoom, mapTopRoom, numStarsRemaining;
extern Boolean houseOpen, noRoomAtAll;
extern Boolean twoPlayerGame, wardBitSet, phoneBitSet;
//============================================================== Functions
//-------------------------------------------------------------- CreateNewHouse
// Called to create a new house file.
#ifndef COMPILEDEMO
Boolean CreateNewHouse (void)
{
AEKeyword theKeyword;
DescType actualType;
Size actualSize;
NavReplyRecord theReply;
NavDialogOptions dialogOptions;
FSSpec tempSpec;
FSSpec theSpec;
OSErr theErr;
theErr = NavGetDefaultDialogOptions(&dialogOptions);
theErr = NavPutFile(nil, &theReply, &dialogOptions, nil, 'gliH', 'ozm5', nil);
if (theErr == userCanceledErr)
return false;
if (!theReply.validRecord)
return (false);
theErr = AEGetNthPtr(&(theReply.selection), 1, typeFSS, &theKeyword,
&actualType, &theSpec, sizeof(FSSpec), &actualSize);
if (theReply.replacing)
{
theErr = FSMakeFSSpec(theSpec.vRefNum, theSpec.parID,
theSpec.name, &tempSpec);
if (!CheckFileError(theErr, theSpec.name))
return (false);
theErr = FSpDelete(&tempSpec);
if (!CheckFileError(theErr, theSpec.name))
return (false);
}
if (houseOpen)
{
if (!CloseHouse())
return (false);
}
theErr = FSpCreate(&theSpec, 'ozm5', 'gliH', theReply.keyScript);
if (!CheckFileError(theErr, PSTR("New House")))
return (false);
HCreateResFile(theSpec.vRefNum, theSpec.parID, theSpec.name);
if (ResError() != noErr)
YellowAlert(kYellowFailedResCreate, ResError());
PasStringCopy(theSpec.name, thisHouseName);
AddExtraHouse(&theSpec);
BuildHouseList();
InitCursor();
if (!OpenHouse())
return (false);
return (true);
}
#endif
//-------------------------------------------------------------- InitializeEmptyHouse
// Initializes all the structures for an empty (new) house.
#ifndef COMPILEDEMO
Boolean InitializeEmptyHouse (void)
{
houseType *thisHousePtr;
Str255 tempStr;
if (thisHouse != nil)
DisposeHandle((Handle)thisHouse);
thisHouse = (houseHand)NewHandle(sizeof(houseType));
if (thisHouse == nil)
{
YellowAlert(kYellowUnaccounted, 1);
return (false);
}
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
thisHousePtr->version = kHouseVersion;
thisHousePtr->firstRoom = -1;
thisHousePtr->timeStamp = 0L;
thisHousePtr->flags = 0L;
thisHousePtr->initial.h = 32;
thisHousePtr->initial.v = 32;
ZeroHighScores();
GetLocalizedString(11, tempStr);
PasStringCopy(tempStr, thisHousePtr->banner);
GetLocalizedString(12, tempStr);
PasStringCopy(tempStr, thisHousePtr->trailer);
thisHousePtr->hasGame = false;
thisHousePtr->nRooms = 0;
wardBitSet = false;
phoneBitSet = false;
HUnlock((Handle)thisHouse);
numberRooms = 0;
mapLeftRoom = 60;
mapTopRoom = 50;
thisRoomNumber = kRoomIsEmpty;
previousRoom = -1;
houseUnlocked = true;
OpenMapWindow();
UpdateMapWindow();
noRoomAtAll = true;
fileDirty = true;
UpdateMenus(false);
ReflectCurrentRoom(true);
return (true);
}
#endif
//-------------------------------------------------------------- RealRoomNumberCount
// Returns the real number of rooms in a house (some rooms may still<6C>
// be place-holders - they were deleted earlier and are flagged as<61>
// deleted but still occupy space in the file).
short RealRoomNumberCount (void)
{
short realRoomCount, i;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
realRoomCount = (*thisHouse)->nRooms;
if (realRoomCount != 0)
{
for (i = 0; i < (*thisHouse)->nRooms; i++)
{
if ((*thisHouse)->rooms[i].suite == kRoomIsEmpty)
realRoomCount--;
}
}
HSetState((Handle)thisHouse, wasState);
return (realRoomCount);
}
//-------------------------------------------------------------- GetFirstRoomNumber
// Returns the room number (indicee into house file) of the room where<72>
// the player is to begin.
short GetFirstRoomNumber (void)
{
short firstRoom;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
if ((*thisHouse)->nRooms <= 0)
{
firstRoom = -1;
noRoomAtAll = true;
}
else
{
firstRoom = (*thisHouse)->firstRoom;
if ((firstRoom >= (*thisHouse)->nRooms) || (firstRoom < 0))
firstRoom = 0;
}
HSetState((Handle)thisHouse, wasState);
return (firstRoom);
}
//-------------------------------------------------------------- WhereDoesGliderBegin
// Returns a rectangle indicating where in the first room the player's<>
// glider is to appear.
void WhereDoesGliderBegin (Rect *theRect, short mode)
{
Point initialPt;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
if (mode == kResumeGameMode)
initialPt = smallGame.where;
else if (mode == kNewGameMode)
initialPt = (*thisHouse)->initial;
HSetState((Handle)thisHouse, wasState);
QSetRect(theRect, 0, 0, kGliderWide, kGliderHigh);
QOffsetRect(theRect, initialPt.h, initialPt.v);
}
//-------------------------------------------------------------- HouseHasOriginalPicts
// Returns true is the current house has custom artwork imbedded.
Boolean HouseHasOriginalPicts (void)
{
short nPicts;
nPicts = Count1Resources('PICT');
return (nPicts > 0);
}
//-------------------------------------------------------------- CountHouseLinks
// Counts up the number of linked objects in a house.
short CountHouseLinks (void)
{
houseType *thisHousePtr;
short numRooms, numLinks;
short r, i, what;
char wasState;
numLinks = 0;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
for (r = 0; r < numRooms; r++)
{
for (i = 0; i < kMaxRoomObs; i++)
{
what = thisHousePtr->rooms[r].objects[i].what;
switch (what)
{
case kLightSwitch:
case kMachineSwitch:
case kThermostat:
case kPowerSwitch:
case kKnifeSwitch:
case kInvisSwitch:
case kTrigger:
case kLgTrigger:
if (thisHousePtr->rooms[r].objects[i].data.e.where != -1)
numLinks++;
break;
case kMailboxLf:
case kMailboxRt:
case kFloorTrans:
case kCeilingTrans:
case kInvisTrans:
case kDeluxeTrans:
if (thisHousePtr->rooms[r].objects[i].data.d.where != -1)
numLinks++;
break;
}
}
}
HSetState((Handle)thisHouse, wasState);
return (numLinks);
}
//-------------------------------------------------------------- GenerateLinksList
// Generates a list of all objects that have links and what rooms<6D>
// and objects they are linked to. It is called in order to preserve<76>
// the links if the objects or rooms in a house are to be shuffled<65>
// around.
#ifndef COMPILEDEMO
void GenerateLinksList (void)
{
houseType *thisHousePtr;
objectType thisObject;
short numLinks, numRooms, r, i, what;
short floor, suite, roomLinked, objectLinked;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
numLinks = 0;
for (r = 0; r < numRooms; r++)
{
for (i = 0; i < kMaxRoomObs; i++)
{
what = thisHousePtr->rooms[r].objects[i].what;
switch (what)
{
case kLightSwitch:
case kMachineSwitch:
case kThermostat:
case kPowerSwitch:
case kKnifeSwitch:
case kInvisSwitch:
case kTrigger:
case kLgTrigger:
thisObject = thisHousePtr->rooms[r].objects[i];
if (thisObject.data.e.where != -1)
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
roomLinked = GetRoomNumber(floor, suite);
objectLinked = (short)thisObject.data.e.who;
linksList[numLinks].srcRoom = r;
linksList[numLinks].srcObj = i;
linksList[numLinks].destRoom = roomLinked;
linksList[numLinks].destObj = objectLinked;
numLinks++;
}
break;
case kMailboxLf:
case kMailboxRt:
case kFloorTrans:
case kCeilingTrans:
case kInvisTrans:
case kDeluxeTrans:
thisObject = thisHousePtr->rooms[r].objects[i];
if (thisObject.data.d.where != -1)
{
ExtractFloorSuite(thisObject.data.d.where, &floor, &suite);
roomLinked = GetRoomNumber(floor, suite);
objectLinked = (short)thisObject.data.d.who;
linksList[numLinks].srcRoom = r;
linksList[numLinks].srcObj = i;
linksList[numLinks].destRoom = roomLinked;
linksList[numLinks].destObj = objectLinked;
numLinks++;
}
break;
}
}
}
HSetState((Handle)thisHouse, wasState);
}
#endif
//-------------------------------------------------------------- SortRoomObjects
// I'm a little fuzzy on what this does.
#ifndef COMPILEDEMO
void SortRoomsObjects (short which)
{
short probe, probe2, room, obj;
Boolean busy, looking;
busy = true;
probe = 0;
do
{
if ((*thisHouse)->rooms[which].objects[probe].what == kObjectIsEmpty)
{
looking = true;
probe2 = probe + 1; // begin by looking at the next object
do
{
if ((*thisHouse)->rooms[which].objects[probe2].what != kObjectIsEmpty)
{
(*thisHouse)->rooms[which].objects[probe] =
(*thisHouse)->rooms[which].objects[probe2];
(*thisHouse)->rooms[which].objects[probe2].what = kObjectIsEmpty;
if (srcLocations[probe2] != -1)
linksList[srcLocations[probe2]].srcObj = probe;
if (destLocations[probe2] != -1)
{
linksList[destLocations[probe2]].destObj = probe;
room = linksList[destLocations[probe2]].srcRoom;
obj = linksList[destLocations[probe2]].srcObj;
(*thisHouse)->rooms[room].objects[obj].data.e.who = static_cast<Byte>(probe);
}
fileDirty = true;
looking = false;
}
probe2++;
if ((probe2 >= kMaxRoomObs) && (looking))
{
looking = false;
busy = false;
}
}
while (looking);
}
probe++;
if (probe >= (kMaxRoomObs - 1))
busy = false;
}
while (busy);
}
#endif
//-------------------------------------------------------------- SortHouseObjects
// I'm a little fuzzy on what this does exactly either.
#ifndef COMPILEDEMO
void SortHouseObjects (void)
{
houseType *thisHousePtr;
short numLinks, numRooms, r, i, l;
char wasState;
SpinCursor(3);
CopyThisRoomToRoom();
numLinks = CountHouseLinks();
if (numLinks == 0)
return;
linksList = nil;
linksList = (linksPtr)NewPtr(sizeof(linksType) * numLinks);
if (linksList == nil)
RedAlert(kErrNoMemory);
GenerateLinksList();
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
for (r = 0; r < numRooms; r++)
{
for (i = 0; i < kMaxRoomObs; i++) // initialize arrays
{
srcLocations[i] = -1;
destLocations[i] = -1;
}
for (i = 0; i < kMaxRoomObs; i++) // walk object list
{
for (l = 0; l < numLinks; l++) // walk link list
{
if ((linksList[l].srcRoom == r) && (linksList[l].srcObj == i))
srcLocations[i] = l;
if ((linksList[l].destRoom == r) && (linksList[l].destObj == i))
destLocations[i] = l;
}
}
SortRoomsObjects(r);
if ((r & 0x0007) == 0x0007)
IncrementCursor();
}
SpinCursor(3);
HSetState((Handle)thisHouse, wasState);
if (linksList != nil)
DisposePtr((Ptr)linksList);
ForceThisRoom(thisRoomNumber);
}
#endif
//-------------------------------------------------------------- CountRoomsVisited
// Goes through and counts the number of rooms a player has been to in<69>
// the current game.
short CountRoomsVisited (void)
{
houseType *thisHousePtr;
short numRooms, r, count;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
count = 0;
for (r = 0; r < numRooms; r++)
{
if (thisHousePtr->rooms[r].visited)
count++;
}
HSetState((Handle)thisHouse, wasState);
return (count);
}
//-------------------------------------------------------------- GenerateRetroLinks
// Walk entire house looking for objects which are linked to objects<74>
// in the current room.
void GenerateRetroLinks (void)
{
houseType *thisHousePtr;
objectType thisObject;
short i, r, numRooms, floor, suite;
short what, roomLinked, objectLinked;
char wasState;
for (i = 0; i < kMaxRoomObs; i++) // Initialize array.
retroLinkList[i].room = -1;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
for (r = 0; r < numRooms; r++)
{
for (i = 0; i < kMaxRoomObs; i++)
{
what = thisHousePtr->rooms[r].objects[i].what;
switch (what)
{
case kLightSwitch:
case kMachineSwitch:
case kThermostat:
case kPowerSwitch:
case kKnifeSwitch:
case kInvisSwitch:
case kTrigger:
case kLgTrigger:
thisObject = thisHousePtr->rooms[r].objects[i];
if (thisObject.data.e.where != -1)
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
roomLinked = GetRoomNumber(floor, suite);
if (roomLinked == thisRoomNumber)
{
objectLinked = (short)thisObject.data.e.who;
if (retroLinkList[objectLinked].room == -1)
{
retroLinkList[objectLinked].room = r;
retroLinkList[objectLinked].object = i;
}
}
}
break;
case kMailboxLf:
case kMailboxRt:
case kFloorTrans:
case kCeilingTrans:
case kInvisTrans:
case kDeluxeTrans:
thisObject = thisHousePtr->rooms[r].objects[i];
if (thisObject.data.d.where != -1)
{
ExtractFloorSuite(thisObject.data.d.where, &floor, &suite);
roomLinked = GetRoomNumber(floor, suite);
if (roomLinked == thisRoomNumber)
{
objectLinked = (short)thisObject.data.d.who;
if (retroLinkList[objectLinked].room == -1)
{
retroLinkList[objectLinked].room = r;
retroLinkList[objectLinked].object = i;
}
}
}
break;
}
}
}
HSetState((Handle)thisHouse, wasState);
}
//-------------------------------------------------------------- UpdateGoToDialog
// Redraws the "Go To Room..." dialog.
void UpdateGoToDialog (DialogPtr theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
FrameDialogItemC(theDialog, 10, kRedOrangeColor8);
}
//-------------------------------------------------------------- GoToFilter
// Dialog filter for the "Go To Room..." dialog.
Boolean GoToFilter (DialogPtr dial, EventRecord *event, short *item)
{
switch (event->what)
{
case keyDown:
switch ((event->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
default:
return(false);
}
break;
case updateEvt:
SetPort((GrafPtr)dial);
BeginUpdate(GetDialogWindow(dial));
UpdateGoToDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
return(false);
break;
}
}
//-------------------------------------------------------------- DoGoToDialog
// "Go To Room..." dialog.
void DoGoToDialog (void)
{
#define kGoToFirstButt 2
#define kGoToPrevButt 3
#define kGoToFSButt 4
#define kFloorEditText 5
#define kSuiteEditText 6
DialogPtr theDialog;
long tempLong;
short item, roomToGoTo;
Boolean leaving, canceled;
ModalFilterUPP goToFilterUPP;
goToFilterUPP = NewModalFilterUPP(GoToFilter);
BringUpDialog(&theDialog, kGoToDialogID);
if (GetFirstRoomNumber() == thisRoomNumber)
MyDisableControl(theDialog, kGoToFirstButt);
if ((!RoomNumExists(previousRoom)) || (previousRoom == thisRoomNumber))
MyDisableControl(theDialog, kGoToPrevButt);
SetDialogNumToStr(theDialog, kFloorEditText, (long)wasFloor);
SetDialogNumToStr(theDialog, kSuiteEditText, (long)wasSuite);
SelectDialogItemText(theDialog, kFloorEditText, 0, 1024);
leaving = false;
canceled = false;
while (!leaving)
{
ModalDialog(goToFilterUPP, &item);
if (item == kOkayButton)
{
roomToGoTo = -1;
canceled = true;
leaving = true;
}
else if (item == kGoToFirstButt)
{
roomToGoTo = GetFirstRoomNumber();
leaving = true;
}
else if (item == kGoToPrevButt)
{
roomToGoTo = previousRoom;
leaving = true;
}
else if (item == kGoToFSButt)
{
GetDialogNumFromStr(theDialog, kFloorEditText, &tempLong);
wasFloor = (short)tempLong;
GetDialogNumFromStr(theDialog, kSuiteEditText, &tempLong);
wasSuite = (short)tempLong;
roomToGoTo = GetRoomNumber(wasFloor, wasSuite);
leaving = true;
}
}
DisposeDialog(theDialog);
DisposeModalFilterUPP(goToFilterUPP);
if (!canceled)
{
if (RoomNumExists(roomToGoTo))
{
DeselectObject();
CopyRoomToThisRoom(roomToGoTo);
ReflectCurrentRoom(false);
}
else
SysBeep(1);
}
}
//-------------------------------------------------------------- ConvertHouseVer1To2
// This function goes through an old version 1 house and converts it<69>
// to version 2.
void ConvertHouseVer1To2 (void)
{
Str255 roomStr, message;
short wasRoom, floor, suite;
short i, h, numRooms;
char wasState;
CopyThisRoomToRoom();
wasRoom = thisRoomNumber;
GetLocalizedString(13, message);
OpenMessageWindow(message);
SpinCursor(3);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++)
{
if ((*thisHouse)->rooms[i].suite != kRoomIsEmpty)
{
NumToString((long)i, roomStr);
GetLocalizedString(14, message);
PasStringConcat(message, roomStr);
SetMessageWindowMessage(message);
SpinCursor(1);
ForceThisRoom(i);
for (h = 0; h < kMaxRoomObs; h++)
{
switch (thisRoom->objects[h].what)
{
case kMailboxLf:
case kMailboxRt:
case kFloorTrans:
case kCeilingTrans:
case kInvisTrans:
case kDeluxeTrans:
if (thisRoom->objects[h].data.d.where != -1)
{
ExtractFloorSuite(thisRoom->objects[h].data.d.where, &floor, &suite);
floor += kNumUndergroundFloors;
thisRoom->objects[h].data.d.where = MergeFloorSuite(floor, suite);
}
break;
case kLightSwitch:
case kMachineSwitch:
case kThermostat:
case kPowerSwitch:
case kKnifeSwitch:
case kInvisSwitch:
case kTrigger:
case kLgTrigger:
if (thisRoom->objects[h].data.e.where != -1)
{
ExtractFloorSuite(thisRoom->objects[h].data.e.where, &floor, &suite);
floor += kNumUndergroundFloors;
thisRoom->objects[h].data.e.where = MergeFloorSuite(floor, suite);
}
break;
}
}
CopyThisRoomToRoom();
}
}
(*thisHouse)->version = kHouseVersion;
HSetState((Handle)thisHouse, wasState);
InitCursor();
CloseMessageWindow();
ForceThisRoom(wasRoom);
}
//-------------------------------------------------------------- ShiftWholeHouse
void ShiftWholeHouse (short howFar)
{
short wasRoom;
short i, h, numRooms;
char wasState;
OpenMessageWindow(PSTR("Shifting Whole House<73>"));
SpinCursor(3);
CopyThisRoomToRoom();
wasRoom = thisRoomNumber;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++)
{
if ((*thisHouse)->rooms[i].suite != kRoomIsEmpty)
{
SpinCursor(1);
ForceThisRoom(i);
for (h = 0; h < kMaxRoomObs; h++)
{
}
CopyThisRoomToRoom();
}
}
HSetState((Handle)thisHouse, wasState);
ForceThisRoom(wasRoom);
InitCursor();
CloseMessageWindow();
}

12
GpApp/House.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// House.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLMacTypes.h"
extern Str32 thisHouseName;
extern Boolean houseUnlocked;

707
GpApp/HouseIO.cpp Normal file
View File

@@ -0,0 +1,707 @@
//============================================================================
//----------------------------------------------------------------------------
// HouseIO.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLAliases.h"
#include "PLMovies.h"
#include "PLResources.h"
#include "PLStringCompare.h"
#include "PLTextUtils.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "ObjectEdit.h"
#define kSaveChangesAlert 1002
#define kSaveChanges 1
#define kDiscardChanges 2
void LoopMovie (void);
void OpenHouseMovie (void);
void CloseHouseMovie (void);
Boolean IsFileReadOnly (FSSpec *);
Movie theMovie;
Rect movieRect;
short houseRefNum, houseResFork, wasHouseVersion;
Boolean houseOpen, fileDirty, gameDirty;
Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly;
Boolean hasMovie, tvInRoom;
extern FSSpecPtr theHousesSpecs;
extern short thisHouseIndex, tvWithMovieNumber;
extern short numberRooms, housesFound;
extern Boolean noRoomAtAll, quitting, wardBitSet;
extern Boolean phoneBitSet, bannerStarCountOn;
//============================================================== Functions
//-------------------------------------------------------------- LoopMovie
void LoopMovie (void)
{
Handle theLoop;
UserData theUserData;
short theCount;
theLoop = NewHandle(sizeof(long));
(** (long **) theLoop) = 0;
theUserData = GetMovieUserData(theMovie);
theCount = CountUserDataType(theUserData, 'LOOP');
while (theCount--)
{
RemoveUserData(theUserData, 'LOOP', 1);
}
AddUserData(theUserData, theLoop, 'LOOP');
}
//-------------------------------------------------------------- OpenHouseMovie
void OpenHouseMovie (void)
{
#ifdef COMPILEQT
TimeBase theTime;
FSSpec theSpec;
FInfo finderInfo;
Handle spaceSaver;
OSErr theErr;
short movieRefNum;
Boolean dataRefWasChanged;
if (thisMac.hasQT)
{
theSpec = theHousesSpecs[thisHouseIndex];
PasStringConcat(theSpec.name, PSTR(".mov"));
theErr = FSpGetFInfo(&theSpec, &finderInfo);
if (theErr != noErr)
return;
theErr = OpenMovieFile(&theSpec, &movieRefNum, fsCurPerm);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
return;
}
theErr = NewMovieFromFile(&theMovie, movieRefNum, nil, theSpec.name,
newMovieActive, &dataRefWasChanged);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
theErr = CloseMovieFile(movieRefNum);
return;
}
theErr = CloseMovieFile(movieRefNum);
spaceSaver = NewHandle(307200L);
if (spaceSaver == nil)
{
YellowAlert(kYellowQTMovieNotLoaded, 749);
CloseHouseMovie();
return;
}
GoToBeginningOfMovie(theMovie);
theErr = LoadMovieIntoRam(theMovie,
GetMovieTime(theMovie, 0L), GetMovieDuration(theMovie), 0);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
DisposeHandle(spaceSaver);
CloseHouseMovie();
return;
}
DisposeHandle(spaceSaver);
theErr = PrerollMovie(theMovie, 0, 0x000F0000);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
CloseHouseMovie();
return;
}
theTime = GetMovieTimeBase(theMovie);
SetTimeBaseFlags(theTime, loopTimeBase);
SetMovieMasterTimeBase(theMovie, theTime, nil);
LoopMovie();
GetMovieBox(theMovie, &movieRect);
hasMovie = true;
}
#endif
}
//-------------------------------------------------------------- CloseHouseMovie
void CloseHouseMovie (void)
{
#ifdef COMPILEQT
OSErr theErr;
if ((thisMac.hasQT) && (hasMovie))
{
theErr = LoadMovieIntoRam(theMovie,
GetMovieTime(theMovie, 0L), GetMovieDuration(theMovie), flushFromRam);
DisposeMovie(theMovie);
}
#endif
hasMovie = false;
}
//-------------------------------------------------------------- OpenHouse
// Opens a house (whatever current selection is). Returns true if all went well.
Boolean OpenHouse (void)
{
OSErr theErr;
Boolean targetIsFolder, wasAliased;
if (houseOpen)
{
if (!CloseHouse())
return(false);
}
if ((housesFound < 1) || (thisHouseIndex == -1))
return(false);
theErr = ResolveAliasFile(&theHousesSpecs[thisHouseIndex], true,
&targetIsFolder, &wasAliased);
if (!CheckFileError(theErr, thisHouseName))
return (false);
#ifdef COMPILEDEMO
if (!EqualString(theHousesSpecs[thisHouseIndex].name, "\pDemo House", false, true))
return (false);
#endif
houseIsReadOnly = IsFileReadOnly(&theHousesSpecs[thisHouseIndex]);
theErr = FSpOpenDF(&theHousesSpecs[thisHouseIndex], fsCurPerm, &houseRefNum);
if (!CheckFileError(theErr, thisHouseName))
return (false);
houseOpen = true;
OpenHouseResFork();
hasMovie = false;
tvInRoom = false;
tvWithMovieNumber = -1;
OpenHouseMovie();
return (true);
}
//-------------------------------------------------------------- OpenSpecificHouse
// Opens the specific house passed in.
#ifndef COMPILEDEMO
Boolean OpenSpecificHouse (FSSpec *specs)
{
short i;
Boolean itOpened;
if ((housesFound < 1) || (thisHouseIndex == -1))
return (false);
itOpened = true;
for (i = 0; i < housesFound; i++)
{
if ((theHousesSpecs[i].vRefNum == specs->vRefNum) &&
(theHousesSpecs[i].parID == specs->parID) &&
(EqualString(theHousesSpecs[i].name, specs->name, false, true)))
{
thisHouseIndex = i;
PasStringCopy(theHousesSpecs[thisHouseIndex].name, thisHouseName);
if (OpenHouse())
itOpened = ReadHouse();
else
itOpened = false;
break;
}
}
return (itOpened);
}
#endif
//-------------------------------------------------------------- SaveHouseAs
#ifndef COMPILEDEMO
Boolean SaveHouseAs (void)
{
// TEMP - fix this later -- use NavServices (see House.c)
/*
StandardFileReply theReply;
FSSpec oldHouse;
OSErr theErr;
Boolean noProblems;
Str255 tempStr;
noProblems = true;
GetLocalizedString(15, tempStr);
StandardPutFile(tempStr, thisHouseName, &theReply);
if (theReply.sfGood)
{
oldHouse = theHousesSpecs[thisHouseIndex];
CloseHouseResFork(); // close this house file
theErr = FSClose(houseRefNum);
if (theErr != noErr)
{
CheckFileError(theErr, "\pPreferences");
return(false);
}
// create new house file
theErr = FSpCreate(&theReply.sfFile, 'ozm5', 'gliH', theReply.sfScript);
if (!CheckFileError(theErr, theReply.sfFile.name))
return (false);
HCreateResFile(theReply.sfFile.vRefNum, theReply.sfFile.parID,
theReply.sfFile.name);
if (ResError() != noErr)
YellowAlert(kYellowFailedResCreate, ResError());
PasStringCopy(theReply.sfFile.name, thisHouseName);
// open new house data fork
theErr = FSpOpenDF(&theReply.sfFile, fsRdWrPerm, &houseRefNum);
if (!CheckFileError(theErr, thisHouseName))
return (false);
houseOpen = true;
noProblems = WriteHouse(false); // write out house data
if (!noProblems)
return(false);
BuildHouseList();
if (OpenSpecificHouse(&theReply.sfFile)) // open new house again
{
}
else
{
if (OpenSpecificHouse(&oldHouse))
{
YellowAlert(kYellowOpenedOldHouse, 0);
}
else
{
YellowAlert(kYellowLostAllHouses, 0);
noProblems = false;
}
}
}
return (noProblems);
*/
return false;
}
#endif
//-------------------------------------------------------------- ReadHouse
// With a house open, this function reads in the actual bits of data<74>
// into memory.
Boolean ReadHouse (void)
{
long byteCount;
OSErr theErr;
short whichRoom;
if (!houseOpen)
{
YellowAlert(kYellowUnaccounted, 2);
return (false);
}
if (gameDirty || fileDirty)
{
if (houseIsReadOnly)
{
if (!WriteScoresToDisk())
{
YellowAlert(kYellowFailedWrite, 0);
return(false);
}
}
else if (!WriteHouse(false))
return(false);
}
theErr = GetEOF(houseRefNum, &byteCount);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
return(false);
}
#ifdef COMPILEDEMO
if (byteCount != 16526L)
return (false);
#endif
if (thisHouse != nil)
DisposeHandle((Handle)thisHouse);
thisHouse = (houseHand)NewHandle(byteCount);
if (thisHouse == nil)
{
YellowAlert(kYellowNoMemory, 10);
return(false);
}
MoveHHi((Handle)thisHouse);
theErr = SetFPos(houseRefNum, fsFromStart, 0L);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
return(false);
}
HLock((Handle)thisHouse);
theErr = FSRead(houseRefNum, &byteCount, *thisHouse);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
HUnlock((Handle)thisHouse);
return(false);
}
numberRooms = (*thisHouse)->nRooms;
#ifdef COMPILEDEMO
if (numberRooms != 45)
return (false);
#endif
if ((numberRooms < 1) || (byteCount == 0L))
{
numberRooms = 0;
noRoomAtAll = true;
YellowAlert(kYellowNoRooms, 0);
HUnlock((Handle)thisHouse);
return(false);
}
wasHouseVersion = (*thisHouse)->version;
if (wasHouseVersion >= kNewHouseVersion)
{
YellowAlert(kYellowNewerVersion, 0);
HUnlock((Handle)thisHouse);
return(false);
}
houseUnlocked = (((*thisHouse)->timeStamp & 0x00000001) == 0);
#ifdef COMPILEDEMO
if (houseUnlocked)
return (false);
#endif
changeLockStateOfHouse = false;
saveHouseLocked = false;
whichRoom = (*thisHouse)->firstRoom;
#ifdef COMPILEDEMO
if (whichRoom != 0)
return (false);
#endif
wardBitSet = (((*thisHouse)->flags & 0x00000001) == 0x00000001);
phoneBitSet = (((*thisHouse)->flags & 0x00000002) == 0x00000002);
bannerStarCountOn = (((*thisHouse)->flags & 0x00000004) == 0x00000000);
HUnlock((Handle)thisHouse);
noRoomAtAll = (RealRoomNumberCount() == 0);
thisRoomNumber = -1;
previousRoom = -1;
if (!noRoomAtAll)
CopyRoomToThisRoom(whichRoom);
if (houseIsReadOnly)
{
houseUnlocked = false;
if (ReadScoresFromDisk())
{
}
}
objActive = kNoObjectSelected;
ReflectCurrentRoom(true);
gameDirty = false;
fileDirty = false;
UpdateMenus(false);
return (true);
}
//-------------------------------------------------------------- WriteHouse
// This function writes out the house data to disk.
Boolean WriteHouse (Boolean checkIt)
{
UInt32 timeStamp;
long byteCount;
OSErr theErr;
if (!houseOpen)
{
YellowAlert(kYellowUnaccounted, 4);
return (false);
}
theErr = SetFPos(houseRefNum, fsFromStart, 0L);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
return(false);
}
CopyThisRoomToRoom();
if (checkIt)
CheckHouseForProblems();
HLock((Handle)thisHouse);
byteCount = GetHandleSize((Handle)thisHouse);
if (fileDirty)
{
GetDateTime(&timeStamp);
timeStamp &= 0x7FFFFFFF;
if (changeLockStateOfHouse)
houseUnlocked = !saveHouseLocked;
if (houseUnlocked) // house unlocked
timeStamp &= 0x7FFFFFFE;
else
timeStamp |= 0x00000001;
(*thisHouse)->timeStamp = (long)timeStamp;
(*thisHouse)->version = wasHouseVersion;
}
theErr = FSWrite(houseRefNum, &byteCount, *thisHouse);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
HUnlock((Handle)thisHouse);
return(false);
}
theErr = SetEOF(houseRefNum, byteCount);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
HUnlock((Handle)thisHouse);
return(false);
}
HUnlock((Handle)thisHouse);
if (changeLockStateOfHouse)
{
changeLockStateOfHouse = false;
ReflectCurrentRoom(true);
}
gameDirty = false;
fileDirty = false;
UpdateMenus(false);
return (true);
}
//-------------------------------------------------------------- CloseHouse
// This function closes the current house that is open.
Boolean CloseHouse (void)
{
OSErr theErr;
if (!houseOpen)
return (true);
if (gameDirty)
{
if (houseIsReadOnly)
{
if (!WriteScoresToDisk())
YellowAlert(kYellowFailedWrite, 0);
}
else if (!WriteHouse(theMode == kEditMode))
YellowAlert(kYellowFailedWrite, 0);
}
else if (fileDirty)
{
#ifndef COMPILEDEMO
if (!QuerySaveChanges()) // false signifies user canceled
return(false);
#endif
}
CloseHouseResFork();
CloseHouseMovie();
theErr = FSClose(houseRefNum);
if (theErr != noErr)
{
CheckFileError(theErr, thisHouseName);
return(false);
}
houseOpen = false;
return (true);
}
//-------------------------------------------------------------- OpenHouseResFork
// Opens the resource fork of the current house that is open.
void OpenHouseResFork (void)
{
if (houseResFork == -1)
{
houseResFork = FSpOpenResFile(&theHousesSpecs[thisHouseIndex], fsCurPerm);
if (houseResFork == -1)
YellowAlert(kYellowFailedResOpen, ResError());
else
UseResFile(houseResFork);
}
}
//-------------------------------------------------------------- CloseHouseResFork
// Closes the resource fork of the current house that is open.
void CloseHouseResFork (void)
{
if (houseResFork != -1)
{
CloseResFile(houseResFork);
houseResFork = -1;
}
}
//-------------------------------------------------------------- QuerySaveChanges
// If changes were made, this function will present the user with a<>
// dialog asking them if they would like to save the changes.
#ifndef COMPILEDEMO
Boolean QuerySaveChanges (void)
{
short hitWhat;
Boolean whoCares;
if (!fileDirty)
return(true);
InitCursor();
// CenterAlert(kSaveChangesAlert);
ParamText(thisHouseName, PSTR(""), PSTR(""), PSTR(""));
hitWhat = Alert(kSaveChangesAlert, nil);
if (hitWhat == kSaveChanges)
{
if (wasHouseVersion < kHouseVersion)
ConvertHouseVer1To2();
wasHouseVersion = kHouseVersion;
if (WriteHouse(true))
return (true);
else
return (false);
}
else if (hitWhat == kDiscardChanges)
{
fileDirty = false;
if (!quitting)
{
whoCares = CloseHouse();
if (OpenHouse())
whoCares = ReadHouse();
}
UpdateMenus(false);
return (true);
}
else
return (false);
}
#endif
//-------------------------------------------------------------- YellowAlert
// This is a dialog used to present an error code and explanation<6F>
// to the user when a non-lethal error has occurred. Ideally, of<6F>
// course, this never is called.
void YellowAlert (short whichAlert, short identifier)
{
#define kYellowAlert 1006
Str255 errStr, errNumStr;
short whoCares;
InitCursor();
GetIndString(errStr, kYellowAlert, whichAlert);
NumToString((long)identifier, errNumStr);
// CenterAlert(kYellowAlert);
ParamText(errStr, errNumStr, PSTR(""), PSTR(""));
whoCares = Alert(kYellowAlert, nil);
}
//-------------------------------------------------------------- IsFileReadOnly
Boolean IsFileReadOnly (FSSpec *theSpec)
{
return false;
/*
Str255 tempStr;
ParamBlockRec theBlock;
HParamBlockRec hBlock;
VolumeParam *volPtr;
OSErr theErr;
volPtr = (VolumeParam *)&theBlock;
volPtr->ioCompletion = nil;
volPtr->ioVolIndex = 0;
volPtr->ioNamePtr = tempStr;
volPtr->ioVRefNum = theSpec->vRefNum;
theErr = PBGetVInfo(&theBlock, false);
if (CheckFileError(theErr, "\pRead/Write"))
{
if (((volPtr->ioVAtrb & 0x0080) == 0x0080) ||
((volPtr->ioVAtrb & 0x8000) == 0x8000))
return (true); // soft/hard locked bits
else
{
hBlock.fileParam.ioCompletion = nil;
hBlock.fileParam.ioVRefNum = theSpec->vRefNum;
hBlock.fileParam.ioFVersNum = 0;
hBlock.fileParam.ioFDirIndex = 0;
hBlock.fileParam.ioNamePtr = theSpec->name;
hBlock.fileParam.ioDirID = theSpec->parID;
theErr = PBHGetFInfo(&hBlock, false);
if (CheckFileError(theErr, "\pRead/Write"))
{
if ((hBlock.fileParam.ioFlAttrib & 0x0001) == 0x0001)
return (true);
else
return (false);
}
else
return (false);
}
}
else
return (false);
*/
}

344
GpApp/HouseInfo.cpp Normal file
View File

@@ -0,0 +1,344 @@
//============================================================================
//----------------------------------------------------------------------------
// HouseInfo.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "DialogUtils.h"
#define kHouseInfoDialogID 1001
#define kBannerTextItem 4
#define kLockHouseButton 6
#define kClearScoresButton 9
#define kTrailerTextItem 11
#define kNoPhoneCheck 14
#define kBannerNCharsItem 15
#define kTrailerNCharsItem 16
#define kHouseSizeItem 18
#define kLockHouseAlert 1029
#define kZeroScoresAlert 1032
long CountTotalHousePoints (void);
void UpdateHouseInfoDialog (DialogPtr);
Boolean HouseFilter (DialogPtr, EventRecord *, short *);
Boolean WarnLockingHouse (void);
void HowToZeroScores (void);
Str255 banner, trailer;
Rect houseEditText1, houseEditText2;
short houseCursorIs;
Boolean keyHit, tempPhoneBit;
extern Cursor beamCursor;
extern Boolean noRoomAtAll, changeLockStateOfHouse, saveHouseLocked;
extern Boolean phoneBitSet;
#ifndef COMPILEDEMO
//============================================================== Functions
//-------------------------------------------------------------- CountTotalHousePoints
// The following functions all handle the "House Info" dialog in the editor.
long CountTotalHousePoints (void)
{
long pointTotal;
short numRooms, h, i;
char wasState;
pointTotal = (long)RealRoomNumberCount() * (long)kRoomVisitScore;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++)
{
if ((*thisHouse)->rooms[i].suite != kRoomIsEmpty)
{
for (h = 0; h < kMaxRoomObs; h++)
{
switch ((*thisHouse)->rooms[i].objects[h].what)
{
case kRedClock:
pointTotal += kRedClockPoints;
break;
case kBlueClock:
pointTotal += kBlueClockPoints;
break;
case kYellowClock:
pointTotal += kYellowClockPoints;
break;
case kCuckoo:
pointTotal += kCuckooClockPoints;
break;
case kStar:
pointTotal += kStarPoints;
break;
case kInvisBonus:
pointTotal += (*thisHouse)->rooms[i].objects[h].data.c.points;
break;
default:
break;
}
}
}
}
HSetState((Handle)thisHouse, wasState);
return (pointTotal);
}
//-------------------------------------------------------------- UpdateHouseInfoDialog
void UpdateHouseInfoDialog (DialogPtr theDialog)
{
short nChars;
DrawDialog(theDialog);
nChars = GetDialogStringLen(theDialog, kBannerTextItem);
SetDialogNumToStr(theDialog, kBannerNCharsItem, (long)nChars);
nChars = GetDialogStringLen(theDialog, kTrailerTextItem);
SetDialogNumToStr(theDialog, kTrailerNCharsItem, (long)nChars);
SetDialogNumToStr(theDialog, kHouseSizeItem, CountTotalHousePoints());
FrameDialogItemC(theDialog, 10, kRedOrangeColor8);
SetDialogItemValue(theDialog, kNoPhoneCheck, (short)tempPhoneBit);
}
//-------------------------------------------------------------- HouseFilter
Boolean HouseFilter (DialogPtr dial, EventRecord *event, short *item)
{
Point mouseIs;
short nChars;
if (keyHit)
{
nChars = GetDialogStringLen(dial, kBannerTextItem);
SetDialogNumToStr(dial, kBannerNCharsItem, (long)nChars);
nChars = GetDialogStringLen(dial, kTrailerTextItem);
SetDialogNumToStr(dial, kTrailerNCharsItem, (long)nChars);
keyHit = false;
}
switch (event->what)
{
case keyDown:
switch ((event->message) & charCodeMask)
{
case kEnterKeyASCII:
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
case kEscapeKeyASCII:
FlashDialogButton(dial, kCancelButton);
*item = kCancelButton;
return(true);
break;
default:
keyHit = true;
return(false);
}
break;
case mouseDown:
return(false);
break;
case mouseUp:
return(false);
break;
case updateEvt:
SetPort((GrafPtr)dial);
BeginUpdate(GetDialogWindow(dial));
UpdateHouseInfoDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
mouseIs = event->where;
GlobalToLocal(&mouseIs);
if ((PtInRect(mouseIs, &houseEditText1)) ||
(PtInRect(mouseIs, &houseEditText2)))
{
if (houseCursorIs != kBeamCursor)
{
SetCursor(&beamCursor);
houseCursorIs = kBeamCursor;
}
}
else
{
if (houseCursorIs != kArrowCursor)
{
InitCursor();
houseCursorIs = kArrowCursor;
}
}
return(false);
break;
}
}
//-------------------------------------------------------------- DoHouseInfo
void DoHouseInfo (void)
{
DialogPtr houseInfoDialog;
Str255 versStr, loVers, nRoomsStr;
long h, v;
short item, numRooms, version;
char wasState;
Boolean leaving;
ModalFilterUPP houseFilterUPP;
houseFilterUPP = NewModalFilterUPP(HouseFilter);
tempPhoneBit = phoneBitSet;
wasState = HGetState((Handle)thisHouse);
numRooms = RealRoomNumberCount();
HLock((Handle)thisHouse);
PasStringCopy((*thisHouse)->banner, banner);
PasStringCopy((*thisHouse)->trailer, trailer);
version = (*thisHouse)->version;
if (!noRoomAtAll)
{
h = (long)(*thisHouse)->rooms[(*thisHouse)->firstRoom].suite;
v = (long)(*thisHouse)->rooms[(*thisHouse)->firstRoom].floor;
}
HSetState((Handle)thisHouse, wasState);
NumToString((long)version >> 8, versStr); // Convert version to two strings<67>
NumToString((long)version % 0x0100, loVers); // the 1's and 1/10th's part.
NumToString((long)numRooms, nRoomsStr); // Number of rooms -> string.
ParamText(versStr, loVers, nRoomsStr, PSTR(""));
// CenterDialog(kHouseInfoDialogID);
houseInfoDialog = GetNewDialog(kHouseInfoDialogID, nil, kPutInFront);
if (houseInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort((GrafPtr)houseInfoDialog);
ShowWindow(GetDialogWindow(houseInfoDialog));
SetDialogString(houseInfoDialog, kBannerTextItem, banner);
SetDialogString(houseInfoDialog, kTrailerTextItem, trailer);
SelectDialogItemText(houseInfoDialog, kBannerTextItem, 0, 1024);
GetDialogItemRect(houseInfoDialog, kBannerTextItem, &houseEditText1);
GetDialogItemRect(houseInfoDialog, kTrailerTextItem, &houseEditText2);
houseCursorIs = kArrowCursor;
leaving = false;
while (!leaving)
{
ModalDialog(houseFilterUPP, &item);
if (item == kOkayButton)
{
GetDialogString(houseInfoDialog, kBannerTextItem, banner);
GetDialogString(houseInfoDialog, kTrailerTextItem, trailer);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
PasStringCopyNum(banner, (*thisHouse)->banner, 255);
PasStringCopyNum(trailer, (*thisHouse)->trailer, 255);
if (tempPhoneBit != phoneBitSet)
{
phoneBitSet = tempPhoneBit;
if (phoneBitSet)
(*thisHouse)->flags = (*thisHouse)->flags | 0x00000002;
else
(*thisHouse)->flags = (*thisHouse)->flags & 0xFFFFDFFD;
}
HSetState((Handle)thisHouse, wasState);
fileDirty = true;
UpdateMenus(false);
leaving = true;
}
else if (item == kCancelButton)
leaving = true;
else if (item == kLockHouseButton)
{
if (WarnLockingHouse())
{
changeLockStateOfHouse = true;
saveHouseLocked = true;
fileDirty = true;
UpdateMenus(false);
}
}
else if (item == kClearScoresButton)
HowToZeroScores();
else if (item == kNoPhoneCheck)
{
tempPhoneBit = !tempPhoneBit;
SetDialogItemValue(houseInfoDialog, kNoPhoneCheck, (short)tempPhoneBit);
}
}
InitCursor();
DisposeDialog(houseInfoDialog);
DisposeModalFilterUPP(houseFilterUPP);
}
//-------------------------------------------------------------- WarnLockingHouse
Boolean WarnLockingHouse (void)
{
short hitWhat;
// CenterAlert(kLockHouseAlert);
hitWhat = Alert(kLockHouseAlert, nil);
return (hitWhat == 1);
}
//-------------------------------------------------------------- HowToZeroScores
void HowToZeroScores (void)
{
short hitWhat;
// CenterAlert(kZeroScoresAlert);
hitWhat = Alert(kZeroScoresAlert, nil);
switch (hitWhat)
{
case 2: // zero all
ZeroHighScores();
fileDirty = true;
UpdateMenus(false);
break;
case 3: // zero all but highest
ZeroAllButHighestScore();
fileDirty = true;
UpdateMenus(false);
break;
}
}
#endif

1219
GpApp/HouseLegal.cpp Normal file

File diff suppressed because it is too large Load Diff

399
GpApp/Input.cpp Normal file
View File

@@ -0,0 +1,399 @@
//============================================================================
//----------------------------------------------------------------------------
// Input.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLToolUtils.h"
#include "PLDialogs.h"
#include "Externs.h"
#include "MainWindow.h"
#include "RectUtils.h"
#define kNormalThrust 5
#define kHyperThrust 8
#define kHeliumLift 4
#define kEscPausePictID 1015
#define kTabPausePictID 1016
#define kSavingGameDial 1042
void LogDemoKey (char);
void DoCommandKey (void);
void DoPause (void);
void DoBatteryEngaged (gliderPtr);
void DoHeliumEngaged (gliderPtr);
Boolean QuerySaveGame (void);
demoPtr demoData;
KeyMap theKeys;
DialogPtr saveDial;
short demoIndex, batteryFrame;
Boolean isEscPauseKey, paused, batteryWasEngaged;
extern long gameFrame;
extern short otherPlayerEscaped;
extern Boolean quitting, playing, onePlayerLeft, twoPlayerGame, demoGoing;
//============================================================== Functions
//-------------------------------------------------------------- LogDemoKey
void LogDemoKey (char keyIs)
{
demoData[demoIndex].frame = gameFrame;
demoData[demoIndex].key = keyIs;
demoIndex++;
}
//-------------------------------------------------------------- DoCommandKey
void DoCommandKey (void)
{
if (BitTst(&theKeys, kQKeyMap))
{
playing = false;
paused = false;
if ((!twoPlayerGame) && (!demoGoing))
{
if (QuerySaveGame())
SaveGame2(); // New save game.
}
}
else if ((BitTst(&theKeys, kSKeyMap)) && (!twoPlayerGame))
{
RefreshScoreboard(kSavingTitleMode);
SaveGame2(); // New save game.
HideCursor();
CopyRectWorkToMain(&workSrcRect);
RefreshScoreboard(kNormalTitleMode);
}
}
//-------------------------------------------------------------- DoPause
void DoPause (void)
{
Rect bounds;
SetPort((GrafPtr)mainWindow);
QSetRect(&bounds, 0, 0, 214, 54);
CenterRectInRect(&bounds, &houseRect);
if (isEscPauseKey)
LoadScaledGraphic(kEscPausePictID, &bounds);
else
LoadScaledGraphic(kTabPausePictID, &bounds);
do
{
GetKeys(theKeys);
}
while ((isEscPauseKey && BitTst(&theKeys, kEscKeyMap)) ||
(!isEscPauseKey && BitTst(&theKeys, kTabKeyMap)));
paused = true;
while (paused)
{
GetKeys(theKeys);
if ((isEscPauseKey && BitTst(&theKeys, kEscKeyMap)) ||
(!isEscPauseKey && BitTst(&theKeys, kTabKeyMap)))
paused = false;
else if (BitTst(&theKeys, kCommandKeyMap))
DoCommandKey();
}
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&bounds, &bounds, srcCopy, nil);
do
{
GetKeys(theKeys);
}
while ((isEscPauseKey && BitTst(&theKeys, kEscKeyMap)) ||
(!isEscPauseKey && BitTst(&theKeys, kTabKeyMap)));
}
//-------------------------------------------------------------- DoBatteryEngaged
void DoBatteryEngaged (gliderPtr thisGlider)
{
if (thisGlider->facing == kFaceLeft)
{
if (thisGlider->tipped)
thisGlider->hVel += kHyperThrust;
else
thisGlider->hVel -= kHyperThrust;
}
else
{
if (thisGlider->tipped)
thisGlider->hVel -= kHyperThrust;
else
thisGlider->hVel += kHyperThrust;
}
batteryTotal--;
if (batteryTotal == 0)
{
QuickBatteryRefresh(false);
PlayPrioritySound(kFizzleSound, kFizzlePriority);
}
else
{
if (!batteryWasEngaged)
batteryFrame = 0;
if (batteryFrame == 0)
PlayPrioritySound(kThrustSound, kThrustPriority);
batteryFrame++;
if (batteryFrame >= 4)
batteryFrame = 0;
batteryWasEngaged = true;
}
}
//-------------------------------------------------------------- DoHeliumEngaged
void DoHeliumEngaged (gliderPtr thisGlider)
{
thisGlider->vDesiredVel = -kHeliumLift;
batteryTotal++;
if (batteryTotal == 0)
{
QuickBatteryRefresh(false);
PlayPrioritySound(kFizzleSound, kFizzlePriority);
batteryWasEngaged = false;
}
else
{
if (!batteryWasEngaged)
batteryFrame = 0;
if (batteryFrame == 0)
PlayPrioritySound(kHissSound, kHissPriority);
batteryFrame++;
if (batteryFrame >= 4)
batteryFrame = 0;
batteryWasEngaged = true;
}
}
//-------------------------------------------------------------- GetDemoInput
void GetDemoInput (gliderPtr thisGlider)
{
if (thisGlider->which == kPlayer1)
{
GetKeys(theKeys);
#if BUILD_ARCADE_VERSION
if ((BitTst(&theKeys, thisGlider->leftKey)) ||
(BitTst(&theKeys, thisGlider->rightKey)) ||
(BitTst(&theKeys, thisGlider->battKey)) ||
(BitTst(&theKeys, thisGlider->bandKey)))
{
playing = false;
paused = false;
}
#else
if (BitTst(&theKeys, kCommandKeyMap))
DoCommandKey();
#endif
}
if (thisGlider->mode == kGliderBurning)
{
if (thisGlider->facing == kFaceLeft)
thisGlider->hDesiredVel -= kNormalThrust;
else
thisGlider->hDesiredVel += kNormalThrust;
}
else
{
thisGlider->heldLeft = false;
thisGlider->heldRight = false;
thisGlider->tipped = false;
if (gameFrame == (long)demoData[demoIndex].frame)
{
switch (demoData[demoIndex].key)
{
case 0: // left key
thisGlider->hDesiredVel += kNormalThrust;
thisGlider->tipped = (thisGlider->facing == kFaceLeft);
thisGlider->heldRight = true;
thisGlider->fireHeld = false;
break;
case 1: // right key
thisGlider->hDesiredVel -= kNormalThrust;
thisGlider->tipped = (thisGlider->facing == kFaceRight);
thisGlider->heldLeft = true;
thisGlider->fireHeld = false;
break;
case 2: // battery key
if (batteryTotal > 0)
DoBatteryEngaged(thisGlider);
else
DoHeliumEngaged(thisGlider);
thisGlider->fireHeld = false;
break;
case 3: // rubber band key
if (!thisGlider->fireHeld)
{
if (AddBand(thisGlider, thisGlider->dest.left + 24,
thisGlider->dest.top + 10, thisGlider->facing))
{
bandsTotal--;
if (bandsTotal <= 0)
QuickBandsRefresh(false);
thisGlider->fireHeld = true;
}
}
break;
}
demoIndex++;
}
else
thisGlider->fireHeld = false;
if ((isEscPauseKey && BitTst(&theKeys, kEscKeyMap)) ||
(!isEscPauseKey && BitTst(&theKeys, kTabKeyMap)))
{
DoPause();
}
}
}
//-------------------------------------------------------------- GetInput
void GetInput (gliderPtr thisGlider)
{
if (thisGlider->which == kPlayer1)
{
GetKeys(theKeys);
if (BitTst(&theKeys, kCommandKeyMap))
DoCommandKey();
}
if (thisGlider->mode == kGliderBurning)
{
if (thisGlider->facing == kFaceLeft)
thisGlider->hDesiredVel -= kNormalThrust;
else
thisGlider->hDesiredVel += kNormalThrust;
}
else
{
thisGlider->heldLeft = false;
thisGlider->heldRight = false;
if (BitTst(&theKeys, thisGlider->rightKey)) // right key
{
#ifdef CREATEDEMODATA
LogDemoKey(0);
#endif
if (BitTst(&theKeys, thisGlider->leftKey))
{
ToggleGliderFacing(thisGlider);
thisGlider->heldLeft = true;
}
else
{
thisGlider->hDesiredVel += kNormalThrust;
thisGlider->tipped = (thisGlider->facing == kFaceLeft);
thisGlider->heldRight = true;
}
}
else if (BitTst(&theKeys, thisGlider->leftKey)) // left key
{
#ifdef CREATEDEMODATA
LogDemoKey(1);
#endif
thisGlider->hDesiredVel -= kNormalThrust;
thisGlider->tipped = (thisGlider->facing == kFaceRight);
thisGlider->heldLeft = true;
}
else
thisGlider->tipped = false;
if ((BitTst(&theKeys, thisGlider->battKey)) && (batteryTotal != 0) &&
(thisGlider->mode == kGliderNormal))
{
#ifdef CREATEDEMODATA
LogDemoKey(2);
#endif
if (batteryTotal > 0)
DoBatteryEngaged(thisGlider);
else
DoHeliumEngaged(thisGlider);
}
else
batteryWasEngaged = false;
if ((BitTst(&theKeys, thisGlider->bandKey)) && (bandsTotal > 0) &&
(thisGlider->mode == kGliderNormal))
{
#ifdef CREATEDEMODATA
LogDemoKey(3);
#endif
if (!thisGlider->fireHeld)
{
if (AddBand(thisGlider, thisGlider->dest.left + 24,
thisGlider->dest.top + 10, thisGlider->facing))
{
bandsTotal--;
if (bandsTotal <= 0)
QuickBandsRefresh(false);
thisGlider->fireHeld = true;
}
}
}
else
thisGlider->fireHeld = false;
if ((otherPlayerEscaped != kNoOneEscaped) &&
(BitTst(&theKeys, kDeleteKeyMap)) &&
(thisGlider->which) && (!onePlayerLeft))
{
ForceKillGlider();
}
if ((isEscPauseKey && BitTst(&theKeys, kEscKeyMap)) ||
(!isEscPauseKey && BitTst(&theKeys, kTabKeyMap)))
{
DoPause();
}
}
}
//-------------------------------------------------------------- QuerySaveGame
Boolean QuerySaveGame (void)
{
#define kSaveGameAlert 1041
#define kYesSaveGameButton 1
short hitWhat;
InitCursor();
FlushEvents(everyEvent, 0);
// CenterAlert(kSaveGameAlert);
hitWhat = Alert(kSaveGameAlert, nil);
if (hitWhat == kYesSaveGameButton)
return (true);
else
return (false);
}

1777
GpApp/Interactions.cpp Normal file

File diff suppressed because it is too large Load Diff

220
GpApp/InterfaceInit.cpp Normal file
View File

@@ -0,0 +1,220 @@
//============================================================================
//----------------------------------------------------------------------------
// InterfaceInit.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "Map.h"
#include "RectUtils.h"
#include "Tools.h"
#define kHandCursorID 128
#define kVertCursorID 129
#define kHoriCursorID 130
#define kDiagCursorID 131
extern RgnHandle mirrorRgn;
extern WindowPtr mapWindow, toolsWindow, linkWindow;
extern WindowPtr menuWindow;
extern Rect shieldRect, boardSrcRect, localRoomsDest[];
extern CursHandle handCursorH, beamCursorH, vertCursorH, horiCursorH;
extern CursHandle diagCursorH;
extern Cursor handCursor, beamCursor, vertCursor, horiCursor;
extern Cursor diagCursor;
extern MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu;
extern Point shieldPt;
extern long incrementModeTime;
extern UInt32 doubleTime;
extern short fadeInSequence[], idleMode;
extern short toolSelected, lastBackground, wasFlower, numExtraHouses;
extern short houseResFork, lastHighScore, maxFiles, willMaxFiles;
extern Boolean quitting, playing, fadeGraysOut;
extern Boolean houseOpen, newRoomNow, evenFrame, menusUp, demoGoing;
extern Boolean twoPlayerGame, paused, hasMirror, splashDrawn;
//============================================================== Functions
//-------------------------------------------------------------- InitializeMenus
// The menus are loaded from disk and the menu bar set up and drawn.
void InitializeMenus (void)
{
appleMenu = GetMenu(kAppleMenuID);
if (appleMenu == nil)
RedAlert(kErrFailedResourceLoad);
AppendResMenu(appleMenu, 'DRVR');
InsertMenu(appleMenu, 0);
gameMenu = GetMenu(kGameMenuID);
if (gameMenu == nil)
RedAlert(kErrFailedResourceLoad);
InsertMenu(gameMenu, 0);
optionsMenu = GetMenu(kOptionsMenuID);
if (optionsMenu == nil)
RedAlert(kErrFailedResourceLoad);
InsertMenu(optionsMenu, 0);
menusUp = true;
DrawMenuBar();
houseMenu = GetMenu(kHouseMenuID);
if (houseMenu == nil)
RedAlert(kErrFailedResourceLoad);
UpdateMenus(false);
}
//-------------------------------------------------------------- GetExtraCursors
// Extra cursors (custom cursors) like the "hand" and various room<6F>
// editing cursors are loaded up.
void GetExtraCursors (void)
{
handCursorH = GetCursor(kHandCursorID);
if (handCursorH == nil)
RedAlert(kErrFailedResourceLoad);
HLock((Handle)handCursorH);
handCursor = **handCursorH;
beamCursorH = GetCursor(iBeamCursor);
if (beamCursorH == nil)
RedAlert(kErrFailedResourceLoad);
HLock((Handle)beamCursorH);
beamCursor = **beamCursorH;
vertCursorH = GetCursor(kVertCursorID);
if (vertCursorH == nil)
RedAlert(kErrFailedResourceLoad);
HLock((Handle)vertCursorH);
vertCursor = **vertCursorH;
horiCursorH = GetCursor(kHoriCursorID);
if (horiCursorH == nil)
RedAlert(kErrFailedResourceLoad);
HLock((Handle)horiCursorH);
horiCursor = **horiCursorH;
diagCursorH = GetCursor(kDiagCursorID);
if (diagCursorH == nil)
RedAlert(kErrFailedResourceLoad);
HLock((Handle)diagCursorH);
diagCursor = **diagCursorH;
}
//-------------------------------------------------------------- VariableInit
// All the simple interface variables are intialized here - Booleans,<2C>
// shorts, a few Rects, etc.
void VariableInit (void)
{
short i;
shieldPt.h = 0;
shieldPt.v = 0;
shieldRect = thisMac.screen;
menusUp = false;
quitting = false;
houseOpen = false;
newRoomNow = false;
playing = false;
evenFrame = false;
if (thisMac.isDepth == 8)
fadeGraysOut = true;
else
fadeGraysOut = false;
twoPlayerGame = false;
paused = false;
hasMirror = false;
demoGoing = false;
// scrapIsARoom = true;
splashDrawn = false;
#ifndef COMPILEDEMO
// SeeIfValidScrapAvailable(false);
#endif
theGlider.which = kPlayer1;
theGlider2.leftKey = kControlKeyMap;
theGlider2.rightKey = kCommandKeyMap;
theGlider2.battKey = kOptionKeyMap;
theGlider2.bandKey = kShiftKeyMap;
theGlider2.which = kPlayer2;
theMode = kSplashMode;
thisRoomNumber = 0;
previousRoom = -1;
toolSelected = kSelectTool;
houseResFork = -1;
lastBackground = kBaseBackgroundID;
wasFlower = RandomInt(kNumFlowers);
lastHighScore = -1;
idleMode = kIdleSplashMode;
incrementModeTime = TickCount() + kIdleSplashTicks;
willMaxFiles = maxFiles;
numExtraHouses = 0;
fadeInSequence[0] = 4; // 4
fadeInSequence[1] = 5;
fadeInSequence[2] = 6;
fadeInSequence[3] = 7;
fadeInSequence[4] = 5; // 5
fadeInSequence[5] = 6;
fadeInSequence[6] = 7;
fadeInSequence[7] = 8;
fadeInSequence[8] = 6; // 6
fadeInSequence[9] = 7;
fadeInSequence[10] = 8;
fadeInSequence[11] = 9;
fadeInSequence[12] = 7; // 7
fadeInSequence[13] = 8;
fadeInSequence[14] = 9;
fadeInSequence[15] = 10;
doubleTime = GetDblTime();
mirrorRgn = nil;
mainWindow = nil;
mapWindow = nil;
toolsWindow = nil;
linkWindow = nil;
coordWindow = nil;
toolSrcMap = nil;
nailSrcMap = nil;
menuWindow = nil;
houseRect = thisMac.screen;
houseRect.bottom -= kScoreboardTall;
if (houseRect.right > kMaxViewWidth)
houseRect.right = kMaxViewWidth;
if (houseRect.bottom > kMaxViewHeight)
houseRect.bottom = kMaxViewHeight;
playOriginH = (RectWide(&thisMac.screen) - kRoomWide) / 2;
playOriginV = (RectTall(&thisMac.screen) - kTileHigh) / 2;
for (i = 0; i < 9; i++)
{
QSetRect(&localRoomsDest[i], 0, 0, kRoomWide, kTileHigh);
QOffsetRect(&localRoomsDest[i], playOriginH, playOriginV);
}
QOffsetRect(&localRoomsDest[kNorthRoom], 0, -kVertLocalOffset);
QOffsetRect(&localRoomsDest[kNorthEastRoom], kRoomWide, -kVertLocalOffset);
QOffsetRect(&localRoomsDest[kEastRoom], kRoomWide, 0);
QOffsetRect(&localRoomsDest[kSouthEastRoom], kRoomWide, kVertLocalOffset);
QOffsetRect(&localRoomsDest[kSouthRoom], 0, kVertLocalOffset);
QOffsetRect(&localRoomsDest[kSouthWestRoom], -kRoomWide, kVertLocalOffset);
QOffsetRect(&localRoomsDest[kWestRoom], -kRoomWide, 0);
QOffsetRect(&localRoomsDest[kNorthWestRoom], -kRoomWide, -kVertLocalOffset);
}

397
GpApp/Link.cpp Normal file
View File

@@ -0,0 +1,397 @@
//============================================================================
//----------------------------------------------------------------------------
// Link.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLControlDefinitions.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "ObjectEdit.h"
#include "RectUtils.h"
#define kLinkControlID 130
#define kUnlinkControlID 131
void DoLink (void);
void DoUnlink (void);
Rect linkWindowRect;
ControlHandle linkControl, unlinkControl;
WindowPtr linkWindow;
short isLinkH, isLinkV, linkRoom, linkType;
Byte linkObject;
Boolean isLinkOpen, linkerIsSwitch;
//============================================================== Functions
//-------------------------------------------------------------- MergeFloorSuite
short MergeFloorSuite (short floor, short suite)
{
return ((suite * 100) + floor);
}
//-------------------------------------------------------------- ExtractFloorSuite
void ExtractFloorSuite (short combo, short *floor, short *suite)
{
if ((*thisHouse)->version < 0x0200) // old floor/suite combo
{
*floor = (combo / 100) - kNumUndergroundFloors;
*suite = combo % 100;
}
else
{
*suite = combo / 100;
*floor = (combo % 100) - kNumUndergroundFloors;
}
}
//-------------------------------------------------------------- UpdateLinkControl
void UpdateLinkControl (void)
{
#ifndef COMPILEDEMO
if (linkWindow == nil)
return;
switch (linkType)
{
case kSwitchLinkOnly:
if (objActive == kNoObjectSelected)
HiliteControl(linkControl, kControlInactive);
else
switch (thisRoom->objects[objActive].what)
{
case kFloorVent:
case kCeilingVent:
case kFloorBlower:
case kCeilingBlower:
case kSewerGrate:
case kLeftFan:
case kRightFan:
case kInvisBlower:
case kGrecoVent:
case kSewerBlower:
case kLiftArea:
case kRedClock:
case kBlueClock:
case kYellowClock:
case kCuckoo:
case kPaper:
case kBattery:
case kBands:
case kFoil:
case kInvisBonus:
case kHelium:
case kDeluxeTrans:
case kCeilingLight:
case kLightBulb:
case kTableLamp:
case kHipLamp:
case kDecoLamp:
case kFlourescent:
case kTrackLight:
case kInvisLight:
case kShredder:
case kToaster:
case kMacPlus:
case kTV:
case kCoffee:
case kOutlet:
case kVCR:
case kStereo:
case kMicrowave:
case kBalloon:
case kCopterLf:
case kCopterRt:
case kDartLf:
case kDartRt:
case kBall:
case kDrip:
case kFish:
HiliteControl(linkControl, kControlActive);
break;
default:
HiliteControl(linkControl, kControlInactive);
break;
}
break;
case kTriggerLinkOnly:
if (objActive == kNoObjectSelected)
HiliteControl(linkControl, kControlInactive);
else
switch (thisRoom->objects[objActive].what)
{
case kGreaseRt:
case kGreaseLf:
case kToaster:
case kGuitar:
case kCoffee:
case kOutlet:
case kBalloon:
case kCopterLf:
case kCopterRt:
case kDartLf:
case kDartRt:
case kDrip:
case kFish:
HiliteControl(linkControl, kControlActive);
break;
case kLightSwitch:
case kMachineSwitch:
case kThermostat:
case kPowerSwitch:
case kKnifeSwitch:
case kInvisSwitch:
if (linkRoom == thisRoomNumber)
HiliteControl(linkControl, kControlActive);
break;
default:
HiliteControl(linkControl, kControlInactive);
break;
}
break;
case kTransportLinkOnly:
if (objActive == kNoObjectSelected)
HiliteControl(linkControl, kControlInactive);
else
switch (thisRoom->objects[objActive].what)
{
case kMailboxLf:
case kMailboxRt:
case kCeilingTrans:
case kInvisTrans:
case kDeluxeTrans:
case kInvisLight:
case kOzma:
case kMirror:
case kFireplace:
case kWallWindow:
case kCalendar:
case kBulletin:
case kCloud:
HiliteControl(linkControl, kControlActive);
break;
default:
HiliteControl(linkControl, kControlInactive);
break;
}
break;
}
#endif
}
//-------------------------------------------------------------- UpdateLinkWindow
void UpdateLinkWindow (void)
{
#ifndef COMPILEDEMO
if (linkWindow == nil)
return;
SetPortWindowPort(linkWindow);
DrawControls(linkWindow);
UpdateLinkControl();
#endif
}
//-------------------------------------------------------------- OpenLinkWindow
void OpenLinkWindow (void)
{
#ifndef COMPILEDEMO
Rect src, dest;
Point globalMouse;
if (linkWindow == nil)
{
QSetRect(&linkWindowRect, 0, 0, 129, 30);
if (thisMac.hasColor)
linkWindow = NewCWindow(nil, &linkWindowRect,
PSTR("Link"), false, kWindoidWDEF, kPutInFront, true, 0L);
else
linkWindow = NewWindow(nil, &linkWindowRect,
PSTR("Link"), false, kWindoidWDEF, kPutInFront, true, 0L);
MoveWindow(linkWindow, isLinkH, isLinkV, true);
globalMouse = MyGetGlobalMouse();
QSetRect(&src, 0, 0, 1, 1);
QOffsetRect(&src, globalMouse.h, globalMouse.v);
GetWindowRect(linkWindow, &dest);
BringToFront(linkWindow);
ShowHide(linkWindow, true);
// FlagWindowFloating(linkWindow); TEMP - use flaoting windows
HiliteAllWindows();
linkControl = GetNewControl(kLinkControlID, linkWindow);
if (linkControl == nil)
RedAlert(kErrFailedResourceLoad);
unlinkControl = GetNewControl(kUnlinkControlID, linkWindow);
if (unlinkControl == nil)
RedAlert(kErrFailedResourceLoad);
linkRoom = -1;
linkObject = 255;
isLinkOpen = true;
}
#endif
}
//-------------------------------------------------------------- CloseLinkWindow
void CloseLinkWindow (void)
{
#ifndef COMPILEDEMO
if (linkWindow != nil)
DisposeWindow(linkWindow);
linkWindow = nil;
isLinkOpen = false;
#endif
}
//-------------------------------------------------------------- DoLink
#ifndef COMPILEDEMO
void DoLink (void)
{
short floor, suite;
char wasState;
if (GetRoomFloorSuite(thisRoomNumber, &floor, &suite))
{
floor += kNumUndergroundFloors;
if (thisRoomNumber == linkRoom)
{
if (linkerIsSwitch)
{
thisRoom->objects[linkObject].data.e.where =
MergeFloorSuite(floor, suite);
thisRoom->objects[linkObject].data.e.who =
objActive;
}
else
{
thisRoom->objects[linkObject].data.d.where =
MergeFloorSuite(floor, suite);
thisRoom->objects[linkObject].data.d.who =
objActive;
}
}
else
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
if (linkerIsSwitch)
{
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.e.where =
MergeFloorSuite(floor, suite);
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.e.who =
objActive;
}
else // linker is transport
{
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.where =
MergeFloorSuite(floor, suite);
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.who =
objActive;
}
HSetState((Handle)thisHouse, wasState);
}
fileDirty = true;
UpdateMenus(false);
CloseLinkWindow();
}
}
#endif
//-------------------------------------------------------------- DoUnlink
#ifndef COMPILEDEMO
void DoUnlink (void)
{
char wasState;
if (thisRoomNumber == linkRoom)
{
if (linkerIsSwitch)
{
thisRoom->objects[linkObject].data.e.where = -1;
thisRoom->objects[linkObject].data.e.who = 255;
}
else
{
thisRoom->objects[linkObject].data.d.where = -1;
thisRoom->objects[linkObject].data.d.who = 255;
}
}
else
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
if (linkerIsSwitch)
{
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.e.where = -1;
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.e.who = 255;
}
else
{
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.where = -1;
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.who = 255;
}
HSetState((Handle)thisHouse, wasState);
}
fileDirty = true;
UpdateMenus(false);
CloseLinkWindow();
}
#endif
//-------------------------------------------------------------- HandleLinkClick
void HandleLinkClick (Point wherePt)
{
#ifndef COMPILEDEMO
ControlHandle theControl;
short part;
if (linkWindow == nil)
return;
SetPortWindowPort(linkWindow);
GlobalToLocal(&wherePt);
part = FindControl(wherePt, linkWindow, &theControl);
if ((theControl != nil) && (part != 0))
{
part = TrackControl(theControl, wherePt, nil);
if (part != 0)
{
if (theControl == linkControl)
DoLink();
else if (theControl == unlinkControl)
DoUnlink();
if (thisRoomNumber == linkRoom)
CopyThisRoomToRoom();
GenerateRetroLinks();
}
}
#endif
}

389
GpApp/Main.cpp Normal file
View File

@@ -0,0 +1,389 @@
//============================================================================
//----------------------------------------------------------------------------
// Glider PRO 1.0.4
// by john calhoun
//----------------------------------------------------------------------------
//============================================================================
#include "PLApplication.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#define kPrefsVersion 0x0034
void ReadInPrefs (void);
void WriteOutPrefs (void);
int main(int argc, const char **argv);
short isVolume, wasVolume;
short isDepthPref, dataResFile, numSMWarnings;
Boolean quitting, doZooms, quickerTransitions, isUseSecondScreen;
extern Str31 highBanner;
extern Str15 leftName, rightName, batteryName, bandName;
extern Str15 highName;
//extern long encryptedNumber;
extern short maxFiles, numNeighbors, houseRefNum, willMaxFiles;
extern short isEditH, isEditV, isMapH, isMapV;
extern short isToolsH, isToolsV, isCoordH, isCoordV;
extern short isLinkH, isLinkV, toolMode, mapLeftRoom, mapTopRoom;
extern short mapRoomsWide, mapRoomsHigh, wasFloor, wasSuite;
extern Boolean isMusicOn, isSoundOn, isPlayMusicIdle, isHouseChecks;
extern Boolean houseOpen, isDoColorFade, isEscPauseKey;
extern Boolean autoRoomEdit, doAutoDemo, doBackground;
extern Boolean isMapOpen, isToolsOpen, isCoordOpen;
extern Boolean doPrettyMap, doBitchDialogs;
//extern Boolean didValidation;
//============================================================== Functions
//-------------------------------------------------------------- ReadInPrefs
// Called only once when game launches - reads in the preferences saved<65>
// from the last time Glider PRO was launched. If no prefs are found,<2C>
// it assigns default settings.
void ReadInPrefs (void)
{
prefsInfo thePrefs;
if (LoadPrefs(&thePrefs, kPrefsVersion))
{
#ifdef COMPILEDEMO
PasStringCopy("\pDemo House", thisHouseName);
#else
PasStringCopy(thePrefs.wasDefaultName, thisHouseName);
#endif
PasStringCopy(thePrefs.wasLeftName, leftName);
PasStringCopy(thePrefs.wasRightName, rightName);
PasStringCopy(thePrefs.wasBattName, batteryName);
PasStringCopy(thePrefs.wasBandName, bandName);
PasStringCopy(thePrefs.wasHighName, highName);
PasStringCopy(thePrefs.wasHighBanner, highBanner);
theGlider.leftKey = thePrefs.wasLeftMap;
theGlider.rightKey = thePrefs.wasRightMap;
theGlider.battKey = thePrefs.wasBattMap;
theGlider.bandKey = thePrefs.wasBandMap;
#ifndef COMPILEDEMO
#ifndef COMPILENOCP
encryptedNumber = thePrefs.encrypted;
#endif // COMPILENOCP
#endif // COMPILEDEMO
isVolume = thePrefs.wasVolume;
isDepthPref = thePrefs.wasDepthPref;
isMusicOn = thePrefs.wasMusicOn;
doZooms = thePrefs.wasZooms;
quickerTransitions = thePrefs.wasQuickTrans;
isDoColorFade = thePrefs.wasDoColorFade;
isPlayMusicIdle = thePrefs.wasIdleMusic;
isPlayMusicGame = thePrefs.wasGameMusic;
isHouseChecks = thePrefs.wasHouseChecks;
maxFiles = thePrefs.wasMaxFiles;
if ((maxFiles < 12) || (maxFiles > 500))
maxFiles = 12;
isEditH = thePrefs.wasEditH;
isEditV = thePrefs.wasEditV;
isMapH = thePrefs.wasMapH;
isMapV = thePrefs.wasMapV;
mapRoomsWide = thePrefs.wasMapWide;
mapRoomsHigh = thePrefs.wasMapHigh;
isToolsH = thePrefs.wasToolsH;
isToolsV = thePrefs.wasToolsV;
isLinkH = thePrefs.wasLinkH;
isLinkV = thePrefs.wasLinkV;
isCoordH = thePrefs.wasCoordH;
isCoordV = thePrefs.wasCoordV;
mapLeftRoom = thePrefs.isMapLeft;
mapTopRoom = thePrefs.isMapTop;
wasFloor = thePrefs.wasFloor;
wasSuite = thePrefs.wasSuite;
numSMWarnings = thePrefs.smWarnings;
autoRoomEdit = thePrefs.wasAutoEdit;
isMapOpen = thePrefs.wasMapOpen;
isToolsOpen = thePrefs.wasToolsOpen;
isCoordOpen = thePrefs.wasCoordOpen;
numNeighbors = thePrefs.wasNumNeighbors;
toolMode = thePrefs.wasToolGroup;
doAutoDemo = thePrefs.wasDoAutoDemo;
isEscPauseKey = thePrefs.wasEscPauseKey;
isUseSecondScreen = thePrefs.wasScreen2;
if (thisMac.numScreens < 2)
isUseSecondScreen = false;
doBackground = thePrefs.wasDoBackground;
doPrettyMap = thePrefs.wasPrettyMap;
doBitchDialogs = thePrefs.wasBitchDialogs;
}
else
{
#ifdef COMPILEDEMO
PasStringCopy("\pDemo House", thisHouseName);
#else
PasStringCopy(PSTR("Slumberland"), thisHouseName);
#endif
PasStringCopy(PSTR("lf arrow"), leftName);
PasStringCopy(PSTR("rt arrow"), rightName);
PasStringCopy(PSTR("dn arrow"), batteryName);
PasStringCopy(PSTR("up arrow"), bandName);
PasStringCopy(PSTR("Your Name"), highName);
PasStringCopy(PSTR("Your Message Here"), highBanner);
theGlider.leftKey = kLeftArrowKeyMap;
theGlider.rightKey = kRightArrowKeyMap;
theGlider.battKey = kDownArrowKeyMap;
theGlider.bandKey = kUpArrowKeyMap;
UnivGetSoundVolume(&isVolume, thisMac.hasSM3);
if (isVolume < 1)
isVolume = 1;
else if (isVolume > 3)
isVolume = 3;
isDepthPref = kSwitchIfNeeded;
isSoundOn = true;
isMusicOn = true;
isPlayMusicIdle = true;
isPlayMusicGame = true;
isHouseChecks = true;
doZooms = true;
quickerTransitions = false;
numNeighbors = 9;
isDoColorFade = true;
maxFiles = 48;
willMaxFiles = 48;
isEditH = 3;
isEditV = 41;
isMapH = 3;
// isMapV = qd.screenBits.bounds.bottom - 100;
isMapV = 100;
mapRoomsWide = 15;
mapRoomsHigh = 4;
// isToolsH = qd.screenBits.bounds.right - 120;
isToolsH = 100;
isToolsV = 35;
isLinkH = 50;
isLinkV = 80;
// isCoordH = qd.screenBits.bounds.right - 55;
isCoordH = 50;
isCoordV = 204;
mapLeftRoom = 60;
mapTopRoom = 50;
wasFloor = 0;
wasSuite = 0;
numSMWarnings = 0;
autoRoomEdit = true;
isMapOpen = true;
isToolsOpen = true;
isCoordOpen = false;
toolMode = kBlowerMode;
doAutoDemo = true;
isEscPauseKey = false;
isUseSecondScreen = false;
doBackground = false;
doPrettyMap = false;
doBitchDialogs = true;
}
if ((numNeighbors > 1) && (thisMac.screen.right <= 512))
numNeighbors = 1;
UnivGetSoundVolume(&wasVolume, thisMac.hasSM3);
UnivSetSoundVolume(isVolume, thisMac.hasSM3);
if (isVolume == 0)
isSoundOn = false;
else
isSoundOn = true;
}
//-------------------------------------------------------------- WriteOutPrefs
// Called just before Glider PRO quits. This function writes out<75>
// the user preferences to disk.
void WriteOutPrefs (void)
{
prefsInfo thePrefs;
UnivGetSoundVolume(&isVolume, thisMac.hasSM3);
#ifdef COMPILEDEMO
PasStringCopy("\pDemo House", thePrefs.wasDefaultName);
#else
PasStringCopy(thisHouseName, thePrefs.wasDefaultName);
#endif
PasStringCopy(leftName, thePrefs.wasLeftName);
PasStringCopy(rightName, thePrefs.wasRightName);
PasStringCopy(batteryName, thePrefs.wasBattName);
PasStringCopy(bandName, thePrefs.wasBandName);
PasStringCopy(highName, thePrefs.wasHighName);
PasStringCopy(highBanner, thePrefs.wasHighBanner);
thePrefs.wasLeftMap = theGlider.leftKey;
thePrefs.wasRightMap = theGlider.rightKey;
thePrefs.wasBattMap = theGlider.battKey;
thePrefs.wasBandMap = theGlider.bandKey;
#ifndef COMPILEDEMO
#ifndef COMPILENOCP
thePrefs.encrypted = encryptedNumber;
thePrefs.fakeLong = Random();
#endif // COMPILENOCP
#endif // COMPILEDEMO
thePrefs.wasVolume = isVolume;
thePrefs.wasDepthPref = isDepthPref;
thePrefs.wasMusicOn = isMusicOn;
thePrefs.wasZooms = doZooms;
thePrefs.wasQuickTrans = quickerTransitions;
thePrefs.wasDoColorFade = isDoColorFade;
thePrefs.wasIdleMusic = isPlayMusicIdle;
thePrefs.wasGameMusic = isPlayMusicGame;
thePrefs.wasHouseChecks = isHouseChecks;
thePrefs.wasMaxFiles = willMaxFiles;
thePrefs.wasEditH = isEditH;
thePrefs.wasEditV = isEditV;
thePrefs.wasMapH = isMapH;
thePrefs.wasMapV = isMapV;
thePrefs.wasMapWide = mapRoomsWide;
thePrefs.wasMapHigh = mapRoomsHigh;
thePrefs.wasToolsH = isToolsH;
thePrefs.wasToolsV = isToolsV;
thePrefs.isMapLeft = mapLeftRoom;
thePrefs.isMapTop = mapTopRoom;
thePrefs.wasFloor = wasFloor;
thePrefs.wasSuite = wasSuite;
thePrefs.wasLinkH = isLinkH;
thePrefs.wasLinkV = isLinkV;
thePrefs.wasCoordH = isCoordH;
thePrefs.wasCoordV = isCoordV;
thePrefs.smWarnings = numSMWarnings;
thePrefs.wasAutoEdit = autoRoomEdit;
thePrefs.wasMapOpen = isMapOpen;
thePrefs.wasToolsOpen = isToolsOpen;
thePrefs.wasCoordOpen = isCoordOpen;
thePrefs.wasNumNeighbors = numNeighbors;
thePrefs.wasToolGroup = toolMode;
thePrefs.wasDoAutoDemo = doAutoDemo;
thePrefs.wasEscPauseKey = isEscPauseKey;
thePrefs.wasScreen2 = isUseSecondScreen;
thePrefs.wasDoBackground = doBackground;
thePrefs.wasPrettyMap = doPrettyMap;
thePrefs.wasBitchDialogs = doBitchDialogs;
if (!SavePrefs(&thePrefs, kPrefsVersion))
SysBeep(1);
UnivSetSoundVolume(wasVolume, thisMac.hasSM3);
}
//-------------------------------------------------------------- main
// Here is main(). The first function called when Glider PRO comes up.
int gpAppMain()
{
// long wasSeed;
long theErr;
OSErr fileErr;
Boolean whoCares, copyGood;
PL_Init();
ToolBoxInit();
CheckOurEnvirons();
if (!thisMac.hasColor)
RedAlert(kErrNeedColorQD);
if (!thisMac.hasSystem7)
RedAlert(kErrNeedSystem7);
if (thisMac.numScreens == 0)
RedAlert(kErrNeed16Or256Colors);
// dataResFile = OpenResFile("\pMermaid");
SetUpAppleEvents();
LoadCursors();
ReadInPrefs();
#if defined COMPILEDEMO
copyGood = true;
#elif defined COMPILENOCP
// didValidation = false;
copyGood = true;
#else
didValidation = false;
copyGood = ValidInstallation(true);
if (!copyGood)
encryptedNumber = 0L;
else if (didValidation)
WriteOutPrefs(); SpinCursor(3);
#endif
// if ((thisMac.numScreens > 1) && (isUseSecondScreen))
// ReflectSecondMonitorEnvirons(false, true, true);
HandleDepthSwitching();
VariableInit(); SpinCursor(2);
CheckMemorySize();
GetExtraCursors(); SpinCursor(2);
InitMarquee();
CreatePointers(); SpinCursor(2);
InitSrcRects();
CreateOffscreens(); SpinCursor(2);
OpenMainWindow();
if (thisMac.hasQT)
{
theErr = EnterMovies();
if (theErr != noErr)
thisMac.hasQT = false;
}
InitSound(); SpinCursor(2);
InitMusic(); SpinCursor(2);
BuildHouseList();
if (OpenHouse())
whoCares = ReadHouse();
PlayPrioritySound(kBirdSound, kBirdPriority);
DelayTicks(6);
InitializeMenus(); InitCursor();
#if BUILD_ARCADE_VERSION
// HideMenuBarOld();
#endif
// if ((isDoColorFade) && (thisMac.isDepth == 8))
// {
// wasSeed = ExtractCTSeed((CGrafPtr)mainWindow);
// WashColorIn();
// ForceCTSeed((CGrafPtr)mainWindow, wasSeed);
// }
// if ((!thisMac.hasSM3) && (numSMWarnings < 3))
// {
// numSMWarnings++;
// BitchAboutSM3();
// }
while (!quitting) // this is the main loop
HandleEvent();
/*
#if BUILD_ARCADE_VERSION
ShowMenuBarOld();
#endif
*/
KillMusic();
KillSound();
if (houseOpen)
{
if (!CloseHouse())
{
CloseHouseResFork();
fileErr = FSClose(houseRefNum);
houseOpen = false;
}
}
WriteOutPrefs();
RestoreColorDepth();
PL_DEAD(FlushEvents(everyEvent, 0));
// theErr = LoadScrap();
return 0;
}

602
GpApp/MainWindow.cpp Normal file
View File

@@ -0,0 +1,602 @@
//============================================================================
//----------------------------------------------------------------------------
// MainWindow.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLToolUtils.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "RectUtils.h"
#define kMainWindowID 128
#define kEditWindowID 129
#define kMenuWindowID 130
void DrawOnSplash (void);
void SetPaletteToGrays (void);
void HardDrawMainWindow (void);
void RestoreColorsSlam (void);
CTabHandle theCTab;
PixMapHandle thePMap;
ColorSpec * wasColors;
ColorSpec * newColors;
CursHandle handCursorH, beamCursorH, vertCursorH, horiCursorH;
CursHandle diagCursorH;
Cursor handCursor, beamCursor, vertCursor, horiCursor;
Cursor diagCursor;
Rect workSrcRect;
GWorldPtr workSrcMap;
Rect mainWindowRect;
WindowPtr mainWindow, menuWindow;
short isEditH, isEditV;
short playOriginH, playOriginV;
short splashOriginH, splashOriginV;
short theMode;
Boolean fadeGraysOut, isDoColorFade, splashDrawn;
extern GDHandle thisGDevice;
extern short toolSelected;
extern Boolean noRoomAtAll, isUseSecondScreen;
extern Boolean quickerTransitions, houseIsReadOnly;
//============================================================== Functions
//-------------------------------------------------------------- DrawOnSplash
// Draws additional text on top of splash screen.
void DrawOnSplash (void)
{
Str255 houseLoadedStr;
PasStringCopy(PSTR("House: "), houseLoadedStr);
PasStringConcat(houseLoadedStr, thisHouseName);
if ((thisMac.hasQT) && (hasMovie))
PasStringConcat(houseLoadedStr, PSTR(" (QT)"));
TextSize(9);
TextFace(1);
TextFont(applFont);
MoveTo(splashOriginH + 436, splashOriginV + 314);
if (thisMac.isDepth == 4)
{
ForeColor(whiteColor);
DrawString(houseLoadedStr);
ForeColor(blackColor);
}
else
{
if (houseIsReadOnly)
ColorText(houseLoadedStr, 5L);
else
ColorText(houseLoadedStr, 28L);
}
#if defined(powerc) || defined(__powerc)
TextSize(12);
TextFace(0);
TextFont(systemFont);
ForeColor(blackColor);
MoveTo(splashOriginH + 5, splashOriginV + 457);
DrawString("\pPowerPC Native!");
ForeColor(whiteColor);
MoveTo(splashOriginH + 4, splashOriginV + 456);
DrawString("\pPowerPC Native!");
ForeColor(blackColor);
#endif
}
//-------------------------------------------------------------- RedrawSplashScreen
void RedrawSplashScreen (void)
{
Rect tempRect;
SetPort((GrafPtr)workSrcMap);
PaintRect(&workSrcRect);
QSetRect(&tempRect, 0, 0, 640, 460);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(kSplash8BitPICT, &tempRect);
DrawOnSplash();
SetPortWindowPort(mainWindow);
// if (quickerTransitions)
// DissBitsChunky(&workSrcRect);
// else
// DissBits(&workSrcRect);
CopyRectMainToWork(&workSrcRect);
}
//-------------------------------------------------------------- UpdateMainWindow
// Redraws the main window (depends on mode were in - splash, editing, playing).
void UpdateMainWindow (void)
{
Rect tempRect;
RgnHandle dummyRgn;
dummyRgn = NewRgn();
SetPortWindowPort(mainWindow);
if (theMode == kEditMode)
{
PauseMarquee();
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&mainWindowRect, &mainWindowRect, srcCopy,
GetPortVisibleRegion(GetWindowPort(mainWindow), dummyRgn));
ResumeMarquee();
}
else if ((theMode == kSplashMode) || (theMode == kPlayMode))
{
SetPort((GrafPtr)workSrcMap);
PaintRect(&workSrcRect);
QSetRect(&tempRect, 0, 0, 640, 460);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(kSplash8BitPICT, &tempRect);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&workSrcRect, &mainWindowRect, srcCopy,
GetPortVisibleRegion(GetWindowPort(mainWindow), dummyRgn));
SetPortWindowPort(mainWindow);
DrawOnSplash();
}
DisposeRgn(dummyRgn);
splashDrawn = true;
}
//-------------------------------------------------------------- UpdateMenuBarWindow
// Ugly kludge to cover over the menu bar when playing game on 2nd monitor.
void UpdateMenuBarWindow (void)
{
Rect bounds;
if (menuWindow == nil)
return;
GetLocalWindowRect(menuWindow, &bounds);
PaintRect(&bounds);
}
//-------------------------------------------------------------- OpenMainWindow
// Opens up the main window (how it does this depends on mode were in).
void OpenMainWindow (void)
{
// long wasSeed;
short whichRoom;
if (mainWindow != nil)
{
YellowAlert(kYellowUnaccounted, 6);
return;
}
if (theMode == kEditMode)
{
if (menuWindow != nil)
DisposeWindow(menuWindow);
menuWindow = nil;
QSetRect(&mainWindowRect, 0, 0, 512, 322);
mainWindow = GetNewCWindow(kEditWindowID, nil, kPutInFront);
SizeWindow(mainWindow, mainWindowRect.right,
mainWindowRect.bottom, false);
if (OptionKeyDown())
{
isEditH = 3;
isEditV = 41;
}
MoveWindow(mainWindow, isEditH, isEditV, true);
ShowWindow(mainWindow);
SetPortWindowPort(mainWindow);
ClipRect(&mainWindowRect);
ForeColor(blackColor);
BackColor(whiteColor);
whichRoom = GetFirstRoomNumber();
CopyRoomToThisRoom(whichRoom);
ReflectCurrentRoom(false);
}
else
{
if (menuWindow == nil)
{
menuWindow = GetNewCWindow(kMenuWindowID, nil, kPutInFront);
SizeWindow(menuWindow, RectWide(&thisMac.screen), 20, false);
MoveWindow(menuWindow, thisMac.screen.left,
thisMac.screen.top, true);
ShowWindow(menuWindow);
}
mainWindowRect = thisMac.screen;
ZeroRectCorner(&mainWindowRect);
mainWindowRect.bottom -= 20; // thisMac.menuHigh
mainWindow = GetNewCWindow(kMainWindowID, nil, kPutInFront);
SizeWindow(mainWindow, mainWindowRect.right - mainWindowRect.left,
mainWindowRect.bottom - mainWindowRect.top, false);
MoveWindow(mainWindow, thisMac.screen.left,
thisMac.screen.top + 20, true); // thisMac.menuHigh
ShowWindow(mainWindow);
SetPortWindowPort(mainWindow);
ClipRect(&mainWindowRect);
// CopyRgn(mainWindow->clipRgn, mainWindow->visRgn);
ForeColor(blackColor);
BackColor(whiteColor);
PaintRect(&mainWindowRect);
splashOriginH = ((thisMac.screen.right - thisMac.screen.left) - 640) / 2;
if (splashOriginH < 0)
splashOriginH = 0;
splashOriginV = ((thisMac.screen.bottom - thisMac.screen.top) - 480) / 2;
if (splashOriginV < 0)
splashOriginV = 0;
SetPort((GrafPtr)workSrcMap);
PaintRect(&workSrcRect);
LoadGraphic(kSplash8BitPICT);
// if ((fadeGraysOut) && (isDoColorFade))
// {
// wasSeed = ExtractCTSeed((CGrafPtr)mainWindow);
// SetPortWindowPort(mainWindow);
// SetPaletteToGrays();
// HardDrawMainWindow();
// fadeGraysOut = false;
// ForceCTSeed((CGrafPtr)mainWindow, wasSeed);
// }
SetPortWindowPort(mainWindow);
}
}
//-------------------------------------------------------------- CloseMainWindow
// Closes the main window.
void CloseMainWindow (void)
{
if (mainWindow != nil)
DisposeWindow(mainWindow);
mainWindow = nil;
}
//-------------------------------------------------------------- ZoomBetweenWindows
// Zooms from one window size to another. Just for effect.
/*
#ifndef COMPILEDEMO
void ZoomBetweenWindows (void)
{
Rect aRect;
short h, v;
if (theMode == kEditMode)
{
QSetRect(&aRect, 0, 0, 512, 342);
QOffsetRect(&aRect, isEditH, isEditV);
ZoomRectToRect(&(thisMac.screen), &aRect);
}
else
{
aRect = mainWindow->portRect;
GetWindowLeftTop(mainWindow, &h, &v);
QOffsetRect(&aRect, h, v);
ZoomRectToRect(&aRect, &(thisMac.screen));
}
}
#endif
*/
//-------------------------------------------------------------- UpdateEditWindowTitle
// Handles changing the title across the top of the main window. Only<6C>
// relevant when editing a house (room title displayed in window title).
#ifndef COMPILEDEMO
void UpdateEditWindowTitle (void)
{
Str255 newTitle, tempStr;
if (mainWindow == nil)
return;
PasStringCopy(thisHouseName, newTitle);
PasStringConcat(newTitle, PSTR(" - "));
if (noRoomAtAll)
PasStringConcat(newTitle, PSTR("No rooms"));
else if (houseUnlocked)
{
PasStringConcat(newTitle, thisRoom->name);
PasStringConcat(newTitle, PSTR(" ("));
NumToString((long)thisRoom->floor, tempStr);
PasStringConcat(newTitle, tempStr);
PasStringConcat(newTitle, PSTR(", "));
NumToString((long)thisRoom->suite, tempStr);
PasStringConcat(newTitle, tempStr);
PasStringConcat(newTitle, PSTR(")"));
}
else
PasStringConcat(newTitle, PSTR("House Locked"));
SetWTitle(mainWindow, newTitle);
}
#endif
//-------------------------------------------------------------- HandleMainClick
// Handle a mouse click in the main window (relevant only when editing).
void HandleMainClick (Point wherePt, Boolean isDoubleClick)
{
KeyMap theseKeys;
if ((theMode != kEditMode) || (mainWindow == nil) ||
(!houseUnlocked))
return;
SetPortWindowPort(mainWindow);
GlobalToLocal(&wherePt);
if (toolSelected == kSelectTool)
DoSelectionClick(wherePt, isDoubleClick);
else
DoNewObjectClick(wherePt);
GetKeys(theseKeys);
if (!BitTst(&theseKeys, kShiftKeyMap))
{
EraseSelectedTool();
SelectTool(kSelectTool);
}
}
//-------------------------------------------------------------- ShowMenuBarOld
// Displays the menu bar (after having been hidden).
/*
void ShowMenuBarOld (void)
{
Rect theRect;
GrafPtr wasPort, tempPort;
RgnHandle worldRgn, menuBarRgn;
if (LMGetMBarHeight() == 0)
{
GetPort(&wasPort);
tempPort = (GrafPtr)NewPtrClear(sizeof(GrafPort));
OpenPort(tempPort);
SetPort((GrafPtr)tempPort);
LMSetMBarHeight(thisMac.menuHigh);
theRect = (**GetGrayRgn()).rgnBBox;
UnionRect(&theRect, &qd.screenBits.bounds, &theRect);
worldRgn = NewRgn();
OpenRgn();
FrameRoundRect(&theRect, 16, 16);
CloseRgn(worldRgn);
theRect = qd.screenBits.bounds;
theRect.bottom = theRect.top + thisMac.menuHigh;
menuBarRgn = NewRgn();
RectRgn(menuBarRgn, &theRect);
SectRgn(worldRgn, menuBarRgn, menuBarRgn); // /------------------\
DisposeRgn(worldRgn); // |__________________|
UnionRgn(tempPort->visRgn, menuBarRgn, tempPort->visRgn);
DiffRgn(tempPort->visRgn, menuBarRgn, tempPort->visRgn);
DisposeRgn(menuBarRgn);
ClosePort(tempPort);
SetPort((GrafPtr)wasPort);
DrawMenuBar();
}
}
*/
//-------------------------------------------------------------- HideMenuBarOld
// Hides the menu bar - completely erasing it from the screen.
/*
void HideMenuBarOld (void)
{
Rect theRect;
RgnHandle worldRgn, menuBarRgn;
GrafPtr wasPort, tempPort;
if (LMGetMBarHeight() != 0)
{
GetPort(&wasPort);
tempPort = (GrafPtr)NewPtrClear(sizeof(GrafPort));
OpenPort(tempPort);
SetPort((GrafPtr)tempPort);
LMSetMBarHeight(0);
theRect = (**GetGrayRgn()).rgnBBox;
UnionRect(&theRect, &qd.screenBits.bounds, &theRect);
worldRgn = NewRgn();
OpenRgn();
FrameRoundRect(&theRect, 16, 16);
CloseRgn(worldRgn);
theRect = qd.screenBits.bounds;
theRect.bottom = theRect.top + thisMac.menuHigh;
menuBarRgn = NewRgn();
RectRgn(menuBarRgn, &theRect);
SectRgn(worldRgn, menuBarRgn, menuBarRgn); // /------------------\
DisposeRgn(worldRgn); // |__________________|
UnionRgn(tempPort->visRgn, menuBarRgn, tempPort->visRgn);
DisposeRgn(menuBarRgn);
PaintRect(&theRect);
ClosePort(tempPort);
SetPort((GrafPtr)wasPort);
}
}
*/
//-------------------------------------------------------------- SetPaletteToGrays
// Sets up a gray palette corresponding in luminance to the standard color<6F>
// palette. This is to facilitate the gray->color fade when the game comes up.
/*
void SetPaletteToGrays (void)
{
GDHandle theDevice;
long longGray;
short i;
char wasState;
wasState = HGetState((Handle)thisGDevice);
HLock((Handle)thisGDevice);
thePMap = (*thisGDevice)->gdPMap;
HSetState((Handle)thisGDevice, wasState);
theCTab = (*thePMap)->pmTable;
wasColors = nil;
wasColors = (ColorSpec*)NewPtr(sizeof(ColorSpec) * 256);
if (wasColors == nil)
RedAlert(kErrNoMemory);
newColors = nil;
newColors = (ColorSpec*)NewPtr(sizeof(ColorSpec) * 256);
if (newColors == nil)
RedAlert(kErrNoMemory);
for (i = 0; i < 256; i++)
{
wasColors[i] = (*theCTab)->ctTable[i];
newColors[i] = (*theCTab)->ctTable[i];
if (i != 5)
{
longGray = ((long)newColors[i].rgb.red * 3L) / 10L +
((long)newColors[i].rgb.green * 6L) / 10L +
((long)newColors[i].rgb.blue * 1L) / 10L;
newColors[i].rgb.red = (unsigned short)longGray;
newColors[i].rgb.green = (unsigned short)longGray;
newColors[i].rgb.blue = (unsigned short)longGray;
}
}
theDevice = GetGDevice();
SetGDevice(thisGDevice);
SetEntries(0, 255, newColors);
SetGDevice(theDevice);
}
*/
//-------------------------------------------------------------- HardDrawMainWindow
// Ignores the ToolBox - this function draws direct to screen in order to<74>
// circumvent the Toolbox's attempt to color-match to the current palette.
/*
void HardDrawMainWindow (void)
{
PixMapHandle pixMapH;
Point offsetPt;
long srcRowBytes, destRowBytes;
long src;
long dest;
short i, w;
SInt8 mode;
char wasState;
wasState = HGetState((Handle)thisGDevice);
HLock((Handle)thisGDevice);
pixMapH = (**thisGDevice).gdPMap;
HSetState((Handle)thisGDevice, wasState);
srcRowBytes = (long)((*(workSrcMap->portPixMap))->rowBytes & 0x7FFF);
destRowBytes = (**pixMapH).rowBytes & 0x7FFF;
src = (long)((*(workSrcMap->portPixMap))->baseAddr);
dest = (long)((**pixMapH).baseAddr) + splashOriginH +
((splashOriginV + thisMac.menuHigh) * destRowBytes);
offsetPt.h = 0;
offsetPt.v = 0;
ShieldCursor(&mainWindowRect, offsetPt);
mode = true32b;
SwapMMUMode(&mode);
for (i = 0; i < 460; i++)
{
for (w = 0; w < 160; w++)
{
*(long *)dest = *(long *)src;
dest += 4L;
src += 4L;
}
src -= 640;
dest -= 640;
src += srcRowBytes;
dest += destRowBytes;
}
SwapMMUMode(&mode);
ShowCursor();
}
*/
//-------------------------------------------------------------- WashColorIn
// Slowly walks the palette from its gray luminance state to the full color<6F>
// palette. In this way, color appears to slowly wash in.
/*
void WashColorIn (void)
{
#define kGray2ColorSteps 180
GDHandle theDevice;
long longDelta;
short i, c;
theDevice = GetGDevice();
SetGDevice(thisGDevice);
for (i = 0; i < kGray2ColorSteps; i++)
{
for (c = 0; c < 256; c++)
{
if (c != 5)
{
longDelta = (((long)wasColors[c].rgb.red -
(long)newColors[c].rgb.red) /
(long)(kGray2ColorSteps - i)) + (long)newColors[c].rgb.red;
newColors[c].rgb.red = (unsigned short)longDelta;
longDelta = (((long)wasColors[c].rgb.green -
(long)newColors[c].rgb.green) /
(long)(kGray2ColorSteps - i)) +
(long)newColors[c].rgb.green;
newColors[c].rgb.green = (unsigned short)longDelta;
longDelta = (((long)wasColors[c].rgb.blue -
(long)newColors[c].rgb.blue) /
(long)(kGray2ColorSteps - i)) +
(long)newColors[c].rgb.blue;
newColors[c].rgb.blue = (unsigned short)longDelta;
}
}
SetEntries(0, 255, newColors);
if (Button())
break;
}
SetEntries(0, 255, wasColors);
SetGDevice(theDevice);
RestoreColorsSlam();
if (wasColors != nil)
DisposePtr((Ptr)wasColors);
if (newColors != nil)
DisposePtr((Ptr)newColors);
}
*/

11
GpApp/MainWindow.h Normal file
View File

@@ -0,0 +1,11 @@
//============================================================================
//----------------------------------------------------------------------------
// MainWindow.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr workSrcMap;

797
GpApp/Map.cpp Normal file
View File

@@ -0,0 +1,797 @@
//============================================================================
//----------------------------------------------------------------------------
// Map.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLControlDefinitions.h"
#include "PLResources.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "RectUtils.h"
#include "Utilities.h"
#define kMapRoomsHigh 9 // was 7
#define kMapRoomsWide 9 // was 7
#define kMapScrollBarWidth 16
#define kHScrollRef 5L
#define kVScrollRef 27L
#define kMapGroundValue 56
#define kNewRoomAlert 1004
#define kYesDoNewRoom 1
#define kThumbnailPictID 1010
void LoadGraphicPlus (short, Rect *);
void RedrawMapContents (void);
void LiveHScrollAction (ControlHandle, short);
void LiveVScrollAction (ControlHandle, short);
Boolean QueryNewRoom (void);
void CreateNailOffscreen (void);
void KillNailOffscreen (void);
Rect nailSrcRect, activeRoomRect, wasActiveRoomRect;
Rect mapHScrollRect, mapVScrollRect, mapCenterRect;
Rect mapWindowRect;
GWorldPtr nailSrcMap;
WindowPtr mapWindow;
ControlHandle mapHScroll, mapVScroll;
short isMapH, isMapV, mapRoomsHigh, mapRoomsWide;
short mapLeftRoom, mapTopRoom;
Boolean isMapOpen, doPrettyMap;
extern Boolean doBitchDialogs;
//============================================================== Functions
//-------------------------------------------------------------- ThisRoomVisibleOnMap
#ifndef COMPILEDEMO
Boolean ThisRoomVisibleOnMap (void)
{
short h, v;
h = thisRoom->suite;
v = kMapGroundValue - thisRoom->floor;
if ((h < mapLeftRoom) || (v < mapTopRoom) ||
(h >= (mapLeftRoom + mapRoomsWide)) ||
(v >= (mapTopRoom + mapRoomsHigh)))
return (false);
else
return (true);
}
#endif
//-------------------------------------------------------------- CenterMapOnRoom
#ifndef COMPILEDEMO
void CenterMapOnRoom (short h, short v)
{
if (mapWindow == nil)
return;
mapLeftRoom = h - (mapRoomsWide / 2);
mapTopRoom = (kMapGroundValue - v) - (mapRoomsHigh / 2);
if (mapLeftRoom < 0)
mapLeftRoom = 0;
else if (mapLeftRoom > (kMaxNumRoomsH - mapRoomsWide))
mapLeftRoom = kMaxNumRoomsH - mapRoomsWide;
if (mapTopRoom < 0)
mapTopRoom = 0;
else if (mapTopRoom > (kMaxNumRoomsV - mapRoomsHigh))
mapTopRoom = kMaxNumRoomsV - mapRoomsHigh;
if (mapWindow != nil)
{
SetControlValue(mapHScroll, mapLeftRoom);
SetControlValue(mapVScroll, mapTopRoom);
}
}
#endif
//-------------------------------------------------------------- FlagMapRoomsForUpdate
#ifndef COMPILEDEMO
void FlagMapRoomsForUpdate (void)
{
if (mapWindow == nil)
return;
// SetPortWindowPort(mapWindow);
InvalWindowRect(mapWindow, &wasActiveRoomRect);
InvalWindowRect(mapWindow, &activeRoomRect);
}
#endif
//-------------------------------------------------------------- FindNewActiveRoomRect
#ifndef COMPILEDEMO
void FindNewActiveRoomRect (void)
{
Rect aRoom;
short h, i;
short floor, suite, whoCares;
char wasState;
Boolean activeRoomVisible;
if (mapWindow == nil)
return;
activeRoomVisible = false;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
for (i = 0; i < mapRoomsHigh; i++)
{
for (h = 0; h < mapRoomsWide; h++)
{
QSetRect(&aRoom, 0, 0, kMapRoomWidth, kMapRoomHeight);
QOffsetRect(&aRoom, kMapRoomWidth * h, kMapRoomHeight * i);
suite = h + mapLeftRoom;
floor = kMapGroundValue - (i + mapTopRoom);
if ((RoomExists(suite, floor, &whoCares)) && (houseUnlocked))
{
if (whoCares == thisRoomNumber)
{
wasActiveRoomRect = activeRoomRect;
activeRoomRect = aRoom;
activeRoomVisible = true;
}
}
}
}
HSetState((Handle)thisHouse, wasState);
if (activeRoomVisible)
{
activeRoomRect.right++;
activeRoomRect.bottom++;
InsetRect(&activeRoomRect, -1, -1);
}
}
#endif
//-------------------------------------------------------------- LoadGraphicPlus
void LoadGraphicPlus (short resID, Rect *theRect)
{
PicHandle thePicture;
thePicture = GetPicture(resID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', resID);
if (thePicture == nil)
{
return;
}
}
DrawPicture(thePicture, theRect);
ReleaseResource((Handle)thePicture);
}
//-------------------------------------------------------------- RedrawMapContents
#ifndef COMPILEDEMO
void RedrawMapContents (void)
{
Rect newClip, aRoom, src;
RgnHandle wasClip;
short h, i, groundLevel;
short floor, suite, whoCares, type;
char wasState;
Boolean activeRoomVisible;
if (mapWindow == nil)
return;
activeRoomVisible = false;
groundLevel = kMapGroundValue - mapTopRoom;
newClip.left = mapWindowRect.left;
newClip.top = mapWindowRect.top;
newClip.right = mapWindowRect.right + 2 - kMapScrollBarWidth;
newClip.bottom = mapWindowRect.bottom + 2 - kMapScrollBarWidth;
SetPort((GrafPtr)mapWindow);
wasClip = NewRgn();
if (wasClip != nil)
{
GetClip(wasClip);
ClipRect(&newClip);
}
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
for (i = 0; i < mapRoomsHigh; i++)
{
for (h = 0; h < mapRoomsWide; h++)
{
QSetRect(&aRoom, 0, 0, kMapRoomWidth, kMapRoomHeight);
QOffsetRect(&aRoom, kMapRoomWidth * h, kMapRoomHeight * i);
suite = h + mapLeftRoom;
floor = kMapGroundValue - (i + mapTopRoom);
if ((RoomExists(suite, floor, &whoCares)) && (houseUnlocked))
{
PenNormal();
type = (*thisHouse)->rooms[whoCares].background - kBaseBackgroundID;
if (type > kNumBackgrounds)
{
if (!doPrettyMap)
type = kNumBackgrounds; // Draw "?" thumbnail.
}
ForeColor(blackColor);
if (type > kNumBackgrounds) // Do a "pretty" thumbnail.
{
LoadGraphicPlus(type + kBaseBackgroundID, &aRoom);
}
else
{
QSetRect(&src, 0, 0, kMapRoomWidth, kMapRoomHeight);
QOffsetRect(&src, 0, type * kMapRoomHeight);
CopyBits((BitMap *)*GetGWorldPixMap(nailSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mapWindow)),
&src, &aRoom, srcCopy, nil);
}
if (whoCares == thisRoomNumber)
{
activeRoomRect = aRoom;
activeRoomVisible = true;
}
}
else
{
Pattern dummyPat;
PenPat(GetQDGlobalsGray(&dummyPat));
if (i >= groundLevel)
ForeColor(greenColor);
else
ForeColor(blueColor);
PaintRect(&aRoom);
}
}
}
HSetState((Handle)thisHouse, wasState);
ForeColor(blackColor);
PenNormal();
for (i = 1; i < mapRoomsWide; i++)
{
MoveTo(i * kMapRoomWidth, 0);
Line(0, mapRoomsHigh * kMapRoomHeight);
}
for (i = 1; i < mapRoomsHigh; i++)
{
MoveTo(0, i * kMapRoomHeight);
Line(mapRoomsWide * kMapRoomWidth, 0);
}
if (activeRoomVisible)
{
ForeColor(redColor);
activeRoomRect.right++;
activeRoomRect.bottom++;
FrameRect(&activeRoomRect);
InsetRect(&activeRoomRect, 1, 1);
FrameRect(&activeRoomRect);
ForeColor(blackColor);
InsetRect(&activeRoomRect, -1, -1);
}
if (wasClip != nil)
{
SetClip(wasClip);
DisposeRgn(wasClip);
}
}
#endif
//-------------------------------------------------------------- UpdateMapWindow
void UpdateMapWindow (void)
{
#ifndef COMPILEDEMO
if (mapWindow == nil)
return;
SetControlValue(mapHScroll, mapLeftRoom);
SetControlValue(mapVScroll, mapTopRoom);
SetPortWindowPort(mapWindow);
DrawControls(mapWindow);
DrawGrowIcon(mapWindow);
RedrawMapContents();
#endif
}
//-------------------------------------------------------------- ResizeMapWindow
void ResizeMapWindow (short newH, short newV)
{
#ifndef COMPILEDEMO
if ((newH == 0) && (newV == 0))
return;
SetPortWindowPort(mapWindow);
mapRoomsWide = newH / kMapRoomWidth;
if (mapRoomsWide < 3)
mapRoomsWide = 3;
mapRoomsHigh = newV / kMapRoomHeight;
if (mapRoomsHigh < 3)
mapRoomsHigh = 3;
QSetRect(&mapWindowRect, 0, 0,
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 2,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 2);
EraseRect(&mapWindowRect);
SizeWindow(mapWindow, mapWindowRect.right, mapWindowRect.bottom, true);
SetControlMaximum(mapHScroll, kMaxNumRoomsH - mapRoomsWide);
MoveControl(mapHScroll, 0, mapWindowRect.bottom - kMapScrollBarWidth + 2);
SizeControl(mapHScroll, mapWindowRect.right - kMapScrollBarWidth + 3,
kMapScrollBarWidth);
mapLeftRoom = GetControlValue(mapHScroll);
SetControlMaximum(mapVScroll, kMaxNumRoomsV - mapRoomsHigh);
MoveControl(mapVScroll, mapWindowRect.right - kMapScrollBarWidth + 2, 0);
SizeControl(mapVScroll, kMapScrollBarWidth,
mapWindowRect.bottom - kMapScrollBarWidth + 3);
mapTopRoom = GetControlValue(mapVScroll);
InvalWindowRect(mapWindow, &mapWindowRect);
#endif
}
//-------------------------------------------------------------- OpenMapWindow
void OpenMapWindow (void)
{
#ifndef COMPILEDEMO
Rect src, dest;
Point globalMouse;
if (mapWindow == nil)
{
CreateNailOffscreen();
QSetRect(&mapWindowRect, 0, 0,
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 2,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 2);
mapWindow = NewCWindow(nil, &mapWindowRect,
PSTR("Map"), false, kWindoidGrowWDEF, kPutInFront, true, 0L);
if (mapWindow == nil)
RedAlert(kErrNoMemory);
// if (OptionKeyDown())
// {
// isMapH = 3;
// isMapV = qd.screenBits.bounds.bottom - 100;
// }
MoveWindow(mapWindow, isMapH, isMapV, true);
globalMouse = MyGetGlobalMouse();
QSetRect(&wasActiveRoomRect, 0, 0, 1, 1);
QSetRect(&activeRoomRect, 0, 0, 1, 1);
QSetRect(&src, 0, 0, 1, 1);
QOffsetRect(&src, globalMouse.h, globalMouse.v);
GetWindowRect(mapWindow, &dest);
BringToFront(mapWindow);
ShowHide(mapWindow, true);
// FlagWindowFloating(mapWindow); TEMP - use flaoting windows
HiliteAllWindows();
SetPort((GrafPtr)mapWindow);
SetOrigin(1, 1);
QSetRect(&mapHScrollRect, -1, mapRoomsHigh * kMapRoomHeight,
mapRoomsWide * kMapRoomWidth + 1,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth);
QSetRect(&mapVScrollRect, mapRoomsWide * kMapRoomWidth, -1,
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth,
mapRoomsHigh * kMapRoomHeight + 1);
mapHScroll = NewControl(mapWindow, &mapHScrollRect, PSTR(""), true, mapLeftRoom,
0, kMaxNumRoomsH - mapRoomsWide, scrollBarProc, kHScrollRef);
if (mapHScroll == nil)
RedAlert(kErrNoMemory);
mapVScroll = NewControl(mapWindow, &mapVScrollRect, PSTR(""), true, mapTopRoom,
0, kMaxNumRoomsV - mapRoomsHigh, scrollBarProc, kVScrollRef);
if (mapVScroll == nil)
RedAlert(kErrNoMemory);
QSetRect(&mapCenterRect, -16, -16, 0, 0);
QOffsetRect(&mapCenterRect, mapWindowRect.right + 2,
mapWindowRect.bottom + 2);
CenterMapOnRoom(thisRoom->suite, thisRoom->floor);
}
UpdateMapCheckmark(true);
#endif
}
//-------------------------------------------------------------- CloseMapWindow
void CloseMapWindow (void)
{
#ifndef COMPILEDEMO
CloseThisWindow(&mapWindow);
UpdateMapCheckmark(false);
#endif
}
//-------------------------------------------------------------- ToggleMapWindow
void ToggleMapWindow (void)
{
#ifndef COMPILEDEMO
if (mapWindow == nil)
{
OpenMapWindow();
isMapOpen = true;
}
else
{
CloseMapWindow();
isMapOpen = false;
}
#endif
}
//-------------------------------------------------------------- LiveHScrollAction
#ifndef COMPILEDEMO
void LiveHScrollAction (ControlHandle theControl, short thePart)
{
short wasValue, newValue;
switch (thePart)
{
case kControlUpButtonPart:
wasValue = GetControlValue(theControl);
SetControlValue(theControl, wasValue - 1);
if (GetControlValue(theControl) != wasValue)
{
mapLeftRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlDownButtonPart:
wasValue = GetControlValue(theControl);
SetControlValue(theControl, wasValue + 1);
if (GetControlValue(theControl) != wasValue)
{
mapLeftRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlPageUpPart:
wasValue = GetControlValue(theControl);
newValue = wasValue - (mapRoomsWide / 2);
SetControlValue(theControl, newValue);
if (GetControlValue(theControl) != wasValue)
{
mapLeftRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlPageDownPart:
wasValue = GetControlValue(theControl);
newValue = wasValue + (mapRoomsWide / 2);
SetControlValue(theControl, newValue);
if (GetControlValue(theControl) != wasValue)
{
mapLeftRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlIndicatorPart:
break;
}
}
#endif
//-------------------------------------------------------------- LiveVScrollAction
#ifndef COMPILEDEMO
void LiveVScrollAction (ControlHandle theControl, short thePart)
{
short wasValue, newValue;
switch (thePart)
{
case kControlUpButtonPart:
wasValue = GetControlValue(theControl);
SetControlValue(theControl, wasValue - 1);
if (GetControlValue(theControl) != wasValue)
{
mapTopRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlDownButtonPart:
wasValue = GetControlValue(theControl);
SetControlValue(theControl, wasValue + 1);
if (GetControlValue(theControl) != wasValue)
{
mapTopRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlPageUpPart:
wasValue = GetControlValue(theControl);
newValue = wasValue - (mapRoomsHigh / 2);
SetControlValue(theControl, newValue);
if (GetControlValue(theControl) != wasValue)
{
mapTopRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlPageDownPart:
wasValue = GetControlValue(theControl);
newValue = wasValue + (mapRoomsHigh / 2);
SetControlValue(theControl, newValue);
if (GetControlValue(theControl) != wasValue)
{
mapTopRoom = GetControlValue(theControl);
RedrawMapContents();
}
break;
case kControlIndicatorPart:
break;
}
}
#endif
//-------------------------------------------------------------- HandleMapClick
void HandleMapClick (EventRecord *theEvent)
{
#ifndef COMPILEDEMO
Rect aRoom;
ControlHandle whichControl;
Point wherePt, globalWhere;
long controlRef;
short whichPart, localH, localV;
short roomH, roomV, itsNumber;
ControlActionUPP scrollHActionUPP, scrollVActionUPP;
wherePt = theEvent->where;
scrollHActionUPP = NewControlActionUPP(LiveHScrollAction);
scrollVActionUPP = NewControlActionUPP(LiveVScrollAction);
if (mapWindow == nil)
return;
SetPortWindowPort(mapWindow);
globalWhere = wherePt;
GlobalToLocal(&wherePt);
wherePt.h -= 1;
wherePt.v -= 1;
whichPart = FindControl(wherePt, mapWindow, &whichControl);
if (whichPart == 0) // User clicked in map content area.
{
localH = wherePt.h / kMapRoomWidth;
localV = wherePt.v / kMapRoomHeight;
if ((localH >= mapRoomsWide) || (localV >= mapRoomsHigh))
return;
roomH = localH + mapLeftRoom;
roomV = kMapGroundValue - (localV + mapTopRoom);
if (RoomExists(roomH, roomV, &itsNumber))
{
CopyRoomToThisRoom(itsNumber);
DeselectObject();
ReflectCurrentRoom(false);
if (thisMac.hasDrag)
{
SetPortWindowPort(mainWindow);
QSetRect(&aRoom, 0, 0, kMapRoomWidth, kMapRoomHeight);
CenterRectOnPoint(&aRoom, globalWhere);
// if (DragRoom(theEvent, &aRoom, itsNumber))
// { // TEMP disabled.
// }
}
}
else
{
if (doBitchDialogs)
{
if (QueryNewRoom())
{
if (!CreateNewRoom(roomH, roomV))
{
YellowAlert(kYellowUnaccounted, 11);
return;
}
else
{
DeselectObject();
ReflectCurrentRoom(false);
}
}
else
return;
}
else
{
if (!CreateNewRoom(roomH, roomV))
{
YellowAlert(kYellowUnaccounted, 11);
return;
}
else
{
DeselectObject();
ReflectCurrentRoom(false);
}
}
}
}
else
{
controlRef = GetControlReference(whichControl);
if (controlRef == kHScrollRef)
{
switch (whichPart)
{
case kControlUpButtonPart:
case kControlDownButtonPart:
case kControlPageUpPart:
case kControlPageDownPart:
if (TrackControl(whichControl, wherePt, scrollHActionUPP))
{
}
break;
case kControlIndicatorPart:
if (TrackControl(whichControl, wherePt, nil))
{
mapLeftRoom = GetControlValue(whichControl);
RedrawMapContents();
}
break;
}
}
else if (controlRef == kVScrollRef)
{
switch (whichPart)
{
case kControlUpButtonPart:
case kControlDownButtonPart:
case kControlPageUpPart:
case kControlPageDownPart:
if (TrackControl(whichControl, wherePt, scrollVActionUPP))
{
}
break;
case kControlIndicatorPart:
if (TrackControl(whichControl, wherePt, nil))
{
mapTopRoom = GetControlValue(whichControl);
RedrawMapContents();
}
break;
}
}
}
DisposeControlActionUPP(scrollHActionUPP);
DisposeControlActionUPP(scrollVActionUPP);
#endif
}
//-------------------------------------------------------------- QueryNewRoom
#ifndef COMPILEDEMO
Boolean QueryNewRoom (void)
{
short hitWhat;
// CenterAlert(kNewRoomAlert);
hitWhat = Alert(kNewRoomAlert, nil);
if (hitWhat == kYesDoNewRoom)
return (true);
else
return (false);
}
#endif
//-------------------------------------------------------------- CreateNailOffscreen
#ifndef COMPILEDEMO
void CreateNailOffscreen (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
if (nailSrcMap == nil)
{
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&nailSrcRect, 0, 0, kMapRoomWidth, kMapRoomHeight * (kNumBackgrounds + 1));
theErr = CreateOffScreenGWorld(&nailSrcMap, &nailSrcRect, kPreferredDepth);
SetGWorld(nailSrcMap, nil);
LoadGraphic(kThumbnailPictID);
SetGWorld(wasCPort, wasWorld);
}
}
#endif
//-------------------------------------------------------------- KillNailOffscreen
#ifndef COMPILEDEMO
void KillNailOffscreen (void)
{
if (nailSrcMap != nil)
{
// KillOffScreenPixMap(nailSrcMap);
DisposeGWorld(nailSrcMap);
nailSrcMap = nil;
}
}
#endif
//-------------------------------------------------------------- MoveRoom
void MoveRoom (Point wherePt)
{
short localH, localV;
short roomH, roomV, itsNumber;
localH = wherePt.h / kMapRoomWidth;
localV = wherePt.v / kMapRoomHeight;
if ((localH >= mapRoomsWide) || (localV >= mapRoomsHigh))
return;
roomH = localH + mapLeftRoom;
roomV = kMapGroundValue - (localV + mapTopRoom);
if (RoomExists(roomH, roomV, &itsNumber))
{
}
else
{
thisRoom->floor = roomV;
thisRoom->suite = roomH;
fileDirty = true;
UpdateMenus(false);
RedrawMapContents();
}
}

12
GpApp/Map.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// Map.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr nailSrcMap;
extern WindowPtr mapWindow;

511
GpApp/Marquee.cpp Normal file
View File

@@ -0,0 +1,511 @@
//============================================================================
//----------------------------------------------------------------------------
// Marquee.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Marquee.h"
#include "Objects.h"
#include "ObjectEdit.h"
#include "RectUtils.h"
#define kMarqueePatListID 128
#define kHandleSideLong 9
void DrawGliderMarquee (void);
void DrawMarquee (void);
marquee theMarquee;
Rect marqueeGliderRect;
Boolean gliderMarqueeUp;
extern Cursor handCursor, vertCursor, horiCursor, diagCursor;
extern Rect leftStartGliderSrc;
//============================================================== Functions
//-------------------------------------------------------------- DoMarquee
void DoMarquee (void)
{
if ((!theMarquee.active) || (theMarquee.paused))
return;
SetPortWindowPort(mainWindow);
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
DrawMarquee();
theMarquee.index++;
if (theMarquee.index >= kNumMarqueePats)
theMarquee.index = 0;
PenPat(&theMarquee.pats[theMarquee.index]);
DrawMarquee();
PenNormal();
}
//-------------------------------------------------------------- StartMarquee
void StartMarquee (Rect *theRect)
{
if (theMarquee.active)
StopMarquee();
if (objActive == kNoObjectSelected)
return;
SetPortWindowPort(mainWindow);
theMarquee.bounds = *theRect;
theMarquee.active = true;
theMarquee.paused = false;
theMarquee.handled = false;
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
DrawMarquee();
PenNormal();
SetCoordinateHVD(theMarquee.bounds.left, theMarquee.bounds.top, -1);
}
//-------------------------------------------------------------- StartMarqueeHandled
void StartMarqueeHandled (Rect *theRect, short direction, short dist)
{
if (theMarquee.active)
StopMarquee();
if (objActive == kNoObjectSelected)
return;
SetPortWindowPort(mainWindow);
theMarquee.bounds = *theRect;
theMarquee.active = true;
theMarquee.paused = false;
theMarquee.handled = true;
QSetRect(&theMarquee.handle, 0, 0, kHandleSideLong, kHandleSideLong);
QOffsetRect(&theMarquee.handle, kHandleSideLong / -2, kHandleSideLong / -2);
switch (direction)
{
case kAbove:
QOffsetRect(&theMarquee.handle, theMarquee.bounds.left,
theMarquee.bounds.top);
QOffsetRect(&theMarquee.handle, HalfRectWide(&theMarquee.bounds), -dist);
break;
case kToRight:
QOffsetRect(&theMarquee.handle, theMarquee.bounds.right,
theMarquee.bounds.top);
QOffsetRect(&theMarquee.handle, dist, HalfRectTall(&theMarquee.bounds));
break;
case kBelow:
QOffsetRect(&theMarquee.handle, theMarquee.bounds.left,
theMarquee.bounds.bottom);
QOffsetRect(&theMarquee.handle, HalfRectWide(&theMarquee.bounds), dist);
break;
case kToLeft:
QOffsetRect(&theMarquee.handle, theMarquee.bounds.left,
theMarquee.bounds.top);
QOffsetRect(&theMarquee.handle, -dist, HalfRectTall(&theMarquee.bounds));
break;
case kBottomCorner:
QOffsetRect(&theMarquee.handle, theMarquee.bounds.right,
theMarquee.bounds.bottom);
break;
case kTopCorner:
QOffsetRect(&theMarquee.handle, theMarquee.bounds.right,
theMarquee.bounds.top);
break;
}
theMarquee.direction = direction;
theMarquee.dist = dist;
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
DrawMarquee();
PenNormal();
SetCoordinateHVD(theMarquee.bounds.left, theMarquee.bounds.top, dist);
}
//-------------------------------------------------------------- StopMarquee
void StopMarquee (void)
{
if (gliderMarqueeUp)
{
DrawGliderMarquee();
gliderMarqueeUp = false;
}
if (!theMarquee.active)
return;
SetPortWindowPort(mainWindow);
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
DrawMarquee();
PenNormal();
theMarquee.active = false;
SetCoordinateHVD(-1, -1, -1);
}
//-------------------------------------------------------------- PauseMarquee
void PauseMarquee (void)
{
if (!theMarquee.active)
return;
theMarquee.paused = true;
StopMarquee();
}
//-------------------------------------------------------------- ResumeMarquee
void ResumeMarquee (void)
{
if (!theMarquee.paused)
return;
if (theMarquee.handled)
{
StartMarqueeHandled(&theMarquee.bounds, theMarquee.direction, theMarquee.dist);
HandleBlowerGlider();
}
else
StartMarquee(&theMarquee.bounds);
}
//-------------------------------------------------------------- DragOutMarqueeRect
void DragOutMarqueeRect (Point start, Rect *theRect)
{
Point wasPt, newPt;
SetPortWindowPort(mainWindow);
InitCursor();
QSetRect(theRect, start.h, start.v, start.h, start.v);
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
FrameRect(theRect);
wasPt = start;
while (WaitMouseUp())
{
GetMouse(&newPt);
if (DeltaPoint(wasPt, newPt))
{
FrameRect(theRect);
QSetRect(theRect, start.h, start.v, newPt.h, newPt.v);
NormalizeRect(theRect);
FrameRect(theRect);
wasPt = newPt;
}
}
FrameRect(theRect);
PenNormal();
}
//-------------------------------------------------------------- DragMarqueeRect
void DragMarqueeRect (Point start, Rect *theRect, Boolean lockH, Boolean lockV)
{
Point wasPt, newPt;
short deltaH, deltaV;
SetCursor(&handCursor);
StopMarquee();
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
theMarquee.bounds = *theRect;
FrameRect(&theMarquee.bounds);
wasPt = start;
while (WaitMouseUp())
{
GetMouse(&newPt);
if (DeltaPoint(wasPt, newPt))
{
if (lockV)
deltaH = 0;
else
deltaH = newPt.h - wasPt.h;
if (lockH)
deltaV = 0;
else
deltaV = newPt.v - wasPt.v;
FrameRect(&theMarquee.bounds);
QOffsetRect(&theMarquee.bounds, deltaH, deltaV);
FrameRect(&theMarquee.bounds);
wasPt = newPt;
SetCoordinateHVD(theMarquee.bounds.left, theMarquee.bounds.top, -2);
}
}
FrameRect(&theMarquee.bounds);
*theRect = theMarquee.bounds;
PenNormal();
InitCursor();
}
//-------------------------------------------------------------- DragMarqueeHandle
void DragMarqueeHandle (Point start, short *dragged)
{
Point wasPt, newPt;
short deltaH, deltaV;
if ((theMarquee.direction == kAbove) || (theMarquee.direction == kBelow))
SetCursor(&vertCursor);
else
SetCursor(&horiCursor);
StopMarquee();
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
FrameRect(&theMarquee.bounds);
PaintRect(&theMarquee.handle);
wasPt = start;
while (WaitMouseUp())
{
GetMouse(&newPt);
if (DeltaPoint(wasPt, newPt))
{
switch (theMarquee.direction)
{
case kAbove:
deltaH = 0;
deltaV = newPt.v - wasPt.v;
*dragged -= deltaV;
if (*dragged <= 0)
{
deltaV += *dragged;
*dragged = 0;
}
DeltaCoordinateD(*dragged);
break;
case kToRight:
deltaH = newPt.h - wasPt.h;
deltaV = 0;
*dragged += deltaH;
if (*dragged <= 0)
{
deltaH -= *dragged;
*dragged = 0;
}
DeltaCoordinateD(*dragged);
break;
case kBelow:
deltaH = 0;
deltaV = newPt.v - wasPt.v;
*dragged += deltaV;
if (*dragged <= 0)
{
deltaV -= *dragged;
*dragged = 0;
}
DeltaCoordinateD(*dragged);
break;
case kToLeft:
deltaH = newPt.h - wasPt.h;
deltaV = 0;
*dragged -= deltaH;
if (*dragged <= 0)
{
deltaH += *dragged;
*dragged = 0;
}
DeltaCoordinateD(*dragged);
break;
}
PaintRect(&theMarquee.handle);
QOffsetRect(&theMarquee.handle, deltaH, deltaV);
PaintRect(&theMarquee.handle);
wasPt = newPt;
}
}
FrameRect(&theMarquee.bounds);
PaintRect(&theMarquee.handle);
PenNormal();
InitCursor();
}
//-------------------------------------------------------------- DragMarqueeCorner
void DragMarqueeCorner (Point start, short *hDragged, short *vDragged, Boolean isTop)
{
Point wasPt, newPt;
short deltaH, deltaV;
SetCursor(&diagCursor);
StopMarquee();
PenMode(patXor);
PenPat(&theMarquee.pats[theMarquee.index]);
FrameRect(&theMarquee.bounds);
PaintRect(&theMarquee.handle);
wasPt = start;
while (WaitMouseUp())
{
GetMouse(&newPt);
if (DeltaPoint(wasPt, newPt))
{
deltaH = newPt.h - wasPt.h;
if (isTop)
deltaV = wasPt.v - newPt.v;
else
deltaV = newPt.v - wasPt.v;
*hDragged += deltaH;
if (*hDragged <= 0)
{
deltaH -= *hDragged;
*hDragged = 0;
}
*vDragged += deltaV;
if (*vDragged <= 0)
{
deltaV -= *vDragged;
*vDragged = 0;
}
FrameRect(&theMarquee.bounds);
PaintRect(&theMarquee.handle);
if (isTop)
{
QOffsetRect(&theMarquee.handle, deltaH, -deltaV);
theMarquee.bounds.right += deltaH;
theMarquee.bounds.top -= deltaV;
}
else
{
QOffsetRect(&theMarquee.handle, deltaH, deltaV);
theMarquee.bounds.right += deltaH;
theMarquee.bounds.bottom += deltaV;
}
FrameRect(&theMarquee.bounds);
PaintRect(&theMarquee.handle);
wasPt = newPt;
}
}
FrameRect(&theMarquee.bounds);
PaintRect(&theMarquee.handle);
PenNormal();
InitCursor();
}
//-------------------------------------------------------------- MarqueeHasHandles
Boolean MarqueeHasHandles (short *direction, short *dist)
{
if (theMarquee.handled)
{
*direction = theMarquee.direction;
*dist = theMarquee.dist;
return (true);
}
else
{
*direction = 0;
*dist = 0;
return (false);
}
}
//-------------------------------------------------------------- PtInMarqueeHandle
Boolean PtInMarqueeHandle (Point where)
{
return (PtInRect(where, &theMarquee.handle));
}
//-------------------------------------------------------------- DrawGliderMarquee
void DrawGliderMarquee (void)
{
CopyBits((BitMap *)*GetGWorldPixMap(blowerMaskMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&leftStartGliderSrc,
&marqueeGliderRect,
srcXor, nil);
}
//-------------------------------------------------------------- SetMarqueeGliderCenter
void SetMarqueeGliderRect (short h, short v)
{
marqueeGliderRect = leftStartGliderSrc;
ZeroRectCorner(&marqueeGliderRect);
QOffsetRect(&marqueeGliderRect, h - kHalfGliderWide, v - kGliderHigh);
DrawGliderMarquee();
gliderMarqueeUp = true;
}
//-------------------------------------------------------------- DrawMarquee
void DrawMarquee (void)
{
FrameRect(&theMarquee.bounds);
if (theMarquee.handled)
{
PaintRect(&theMarquee.handle);
switch (theMarquee.direction)
{
case kAbove:
MoveTo(theMarquee.handle.left + (kHandleSideLong / 2),
theMarquee.handle.bottom);
LineTo(theMarquee.handle.left + (kHandleSideLong / 2),
theMarquee.bounds.top - 1);
break;
case kToRight:
MoveTo(theMarquee.handle.left,
theMarquee.handle.top + (kHandleSideLong / 2));
LineTo(theMarquee.bounds.right,
theMarquee.handle.top + (kHandleSideLong / 2));
break;
case kBelow:
MoveTo(theMarquee.handle.left + (kHandleSideLong / 2),
theMarquee.handle.top - 1);
LineTo(theMarquee.handle.left + (kHandleSideLong / 2),
theMarquee.bounds.bottom);
break;
case kToLeft:
MoveTo(theMarquee.handle.right,
theMarquee.handle.top + (kHandleSideLong / 2));
LineTo(theMarquee.bounds.left,
theMarquee.handle.top + (kHandleSideLong / 2));
break;
}
}
if (gliderMarqueeUp)
DrawGliderMarquee();
}
//-------------------------------------------------------------- InitMarquee
void InitMarquee (void)
{
short i;
for (i = 0; i < kNumMarqueePats; i++)
GetIndPattern(&theMarquee.pats[i], kMarqueePatListID, i + 1);
theMarquee.index = 0;
theMarquee.active = false;
theMarquee.paused = false;
theMarquee.handled = false;
gliderMarqueeUp = false;
}

24
GpApp/Marquee.h Normal file
View File

@@ -0,0 +1,24 @@
//============================================================================
//----------------------------------------------------------------------------
// Marquee.h
//----------------------------------------------------------------------------
//============================================================================
#pragma once
#include "PLQuickdraw.h"
typedef struct
{
Pattern pats[kNumMarqueePats];
Rect bounds, handle;
short index, direction, dist;
Boolean active, paused, handled;
} marquee;
extern marquee theMarquee;

814
GpApp/Menu.cpp Normal file
View File

@@ -0,0 +1,814 @@
//============================================================================
//----------------------------------------------------------------------------
// Menu.c
//----------------------------------------------------------------------------
//============================================================================
//#include <Balloons.h>
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "PLToolUtils.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "House.h"
#include "ObjectEdit.h"
#define kSheWantsNewGame 1
#define kSheWantsResumeGame 2
void UpdateMenusEditMode (void);
void UpdateMenusNonEditMode (void);
void UpdateMenusHouseOpen (void);
void UpdateMenusHouseClosed (void);
void UpdateResumeDialog (DialogPtr);
Boolean ResumeFilter (DialogPtr, EventRecord *, short *);
short QueryResumeGame (void);
void HeyYourPissingAHighScore (void);
MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu;
Boolean menusUp, resumedSavedGame;
extern long incrementModeTime;
extern short demoHouseIndex, wasHouseVersion;
extern short splashOriginH, splashOriginV, numberRooms;
extern Boolean quitting, noRoomAtAll, twoPlayerGame;
extern Boolean isMapOpen, isToolsOpen, isPlayMusicIdle;
extern Boolean isCoordOpen, failedMusic, splashDrawn;
extern Boolean houseOpen;
//============================================================== Functions
//-------------------------------------------------------------- UpdateMenusEditMode
// Sets the menus to reflect that user is in edit mode.
void UpdateMenusEditMode (void)
{
DisableMenuItem(gameMenu, iNewGame);
DisableMenuItem(gameMenu, iTwoPlayer);
DisableMenuItem(gameMenu, iOpenSavedGame);
DisableMenuItem(optionsMenu, iHighScores);
DisableMenuItem(optionsMenu, iHelp);
CheckMenuItem(optionsMenu, iEditor, true);
}
//-------------------------------------------------------------- UpdateMenusNonEditMode
// Sets the menus to reflect that user is NOT in edit mode.
void UpdateMenusNonEditMode (void)
{
if ((noRoomAtAll) || (!houseOpen) || (numberRooms <= 0))
{
DisableMenuItem(gameMenu, iNewGame);
DisableMenuItem(gameMenu, iTwoPlayer);
DisableMenuItem(gameMenu, iOpenSavedGame);
if (houseOpen)
{
EnableMenuItem(gameMenu, iLoadHouse);
EnableMenuItem(optionsMenu, iHighScores);
}
else
{
DisableMenuItem(gameMenu, iLoadHouse);
DisableMenuItem(optionsMenu, iHighScores);
}
}
else
{
EnableMenuItem(gameMenu, iNewGame);
EnableMenuItem(gameMenu, iTwoPlayer);
EnableMenuItem(gameMenu, iOpenSavedGame);
EnableMenuItem(gameMenu, iLoadHouse);
EnableMenuItem(optionsMenu, iHighScores);
}
if (demoHouseIndex == -1)
DisableMenuItem(optionsMenu, iHelp);
else
EnableMenuItem(optionsMenu, iHelp);
CheckMenuItem(optionsMenu, iEditor, false);
}
//-------------------------------------------------------------- UpdateMenusHouseOpen
// Sets the menus to reflect that a house is currently open.
void UpdateMenusHouseOpen (void)
{
EnableMenuItem(gameMenu, iLoadHouse);
if ((fileDirty) && (houseUnlocked))
EnableMenuItem(houseMenu, iSave);
else
DisableMenuItem(houseMenu, iSave);
if (houseUnlocked)
{
// EnableMenuItem(houseMenu, iSaveAs);
EnableMenuItem(houseMenu, iHouse);
}
else
{
// DisableMenuItem(houseMenu, iSaveAs);
DisableMenuItem(houseMenu, iHouse);
}
if ((noRoomAtAll) || (!houseUnlocked))
DisableMenuItem(houseMenu, iRoom);
else
EnableMenuItem(houseMenu, iRoom);
if ((objActive == kNoObjectSelected) || (!houseUnlocked))
{
DisableMenuItem(houseMenu, iObject);
DisableMenuItem(houseMenu, iBringForward);
DisableMenuItem(houseMenu, iSendBack);
}
else
{
EnableMenuItem(houseMenu, iObject);
if ((objActive == kInitialGliderSelected) ||
(objActive == kLeftGliderSelected) ||
(objActive == kRightGliderSelected))
{
DisableMenuItem(houseMenu, iBringForward);
DisableMenuItem(houseMenu, iSendBack);
}
else
{
EnableMenuItem(houseMenu, iBringForward);
EnableMenuItem(houseMenu, iSendBack);
}
}
}
//-------------------------------------------------------------- UpdateMenusHouseClosed
// Sets the menus to reflect that a house is NOT currently open.
void UpdateMenusHouseClosed (void)
{
DisableMenuItem(gameMenu, iLoadHouse);
DisableMenuItem(houseMenu, iSave);
// DisableMenuItem(houseMenu, iSaveAs);
DisableMenuItem(houseMenu, iHouse);
DisableMenuItem(houseMenu, iRoom);
DisableMenuItem(houseMenu, iObject);
DisableMenuItem(houseMenu, iCut);
DisableMenuItem(houseMenu, iCopy);
DisableMenuItem(houseMenu, iPaste);
DisableMenuItem(houseMenu, iClear);
DisableMenuItem(houseMenu, iDuplicate);
}
//-------------------------------------------------------------- UpdateClipboardMenus
// Set the Cut/Copy/Paste menus to reflect if we have data in the<68>
// Mac's "clipboard" or not.
void UpdateClipboardMenus (void)
{
Str255 title;
if (!houseOpen)
return;
if (houseUnlocked)
{
if (objActive > kNoObjectSelected)
{
GetLocalizedString(36, title);
SetMenuItemText(houseMenu, iCut, title);
GetLocalizedString(37, title);
SetMenuItemText(houseMenu, iCopy, title);
GetLocalizedString(38, title);
SetMenuItemText(houseMenu, iClear, title);
EnableMenuItem(houseMenu, iDuplicate);
}
else
{
GetLocalizedString(39, title);
SetMenuItemText(houseMenu, iCut, title);
GetLocalizedString(40, title);
SetMenuItemText(houseMenu, iCopy, title);
GetLocalizedString(41, title);
SetMenuItemText(houseMenu, iClear, title);
DisableMenuItem(houseMenu, iDuplicate);
}
EnableMenuItem(houseMenu, iCut);
EnableMenuItem(houseMenu, iCopy);
// if (hasScrap)
// {
// EnableMenuItem(houseMenu, iPaste);
// if (scrapIsARoom)
// {
// GetLocalizedString(42, title);
// SetMenuItemText(houseMenu, iPaste, title);
// }
// else
// {
// GetLocalizedString(43, title);
// SetMenuItemText(houseMenu, iPaste, title);
// }
// }
// else
{
DisableMenuItem(houseMenu, iPaste);
GetLocalizedString(44, title);
SetMenuItemText(houseMenu, iPaste, title);
}
EnableMenuItem(houseMenu, iClear);
EnableMenuItem(houseMenu, iGoToRoom);
EnableMenuItem(houseMenu, iMapWindow);
EnableMenuItem(houseMenu, iObjectWindow);
EnableMenuItem(houseMenu, iCoordinateWindow);
}
else
{
DisableMenuItem(houseMenu, iCut);
DisableMenuItem(houseMenu, iCopy);
DisableMenuItem(houseMenu, iPaste);
DisableMenuItem(houseMenu, iClear);
DisableMenuItem(houseMenu, iDuplicate);
DisableMenuItem(houseMenu, iGoToRoom);
DisableMenuItem(houseMenu, iMapWindow);
DisableMenuItem(houseMenu, iObjectWindow);
DisableMenuItem(houseMenu, iCoordinateWindow);
}
}
//-------------------------------------------------------------- UpdateMenus
// Called whenever a significant change to the environment has taken<65>
// place and some of the menu states may have changes (for example,<2C>
// a menui was grayed out before becuase it wasn't an option - now<6F>
// perhaps the situation has changed and we want the menu to be "usable").
void UpdateMenus (Boolean newMode)
{
if (!menusUp)
return;
if (newMode)
{
if (theMode == kEditMode)
InsertMenu(houseMenu, 0);
else
DeleteMenu(kHouseMenuID);
}
if (theMode == kEditMode)
{
UpdateMenusEditMode();
if (houseOpen)
{
UpdateMenusHouseOpen();
UpdateClipboardMenus();
}
else
UpdateMenusHouseClosed();
UpdateLinkControl();
}
else
UpdateMenusNonEditMode();
DrawMenuBar();
}
//-------------------------------------------------------------- DoAppleMenu
// Handle the Apple menu (About box and desk accessories).
void DoAppleMenu (short theItem)
{
// Str255 daName;
// GrafPtr wasPort;
// short daNumber;
switch (theItem)
{
case iAbout:
DoAbout();
break;
default:
// GetMenuItemText(appleMenu, theItem, daName);
// GetPort(&wasPort);
// daNumber = OpenDeskAccesory(daName);
// SetPort((GrafPtr)wasPort);
break;
}
}
//-------------------------------------------------------------- DoGameMenu
// Handle the user selecting an item from the Game menu.
void DoGameMenu (short theItem)
{
switch (theItem)
{
case iNewGame:
twoPlayerGame = false;
resumedSavedGame = false;
NewGame(kNewGameMode);
break;
case iTwoPlayer:
twoPlayerGame = true;
resumedSavedGame = false;
NewGame(kNewGameMode);
break;
case iOpenSavedGame:
resumedSavedGame = true;
HeyYourPissingAHighScore();
if (OpenSavedGame())
{
twoPlayerGame = false;
NewGame(kResumeGameMode);
}
break;
case iLoadHouse:
#ifdef COMPILEDEMO
DoNotInDemo();
#else
if (splashDrawn)
{
DoLoadHouse();
OpenCloseEditWindows();
UpdateMenus(false);
incrementModeTime = TickCount() + kIdleSplashTicks;
if ((theMode == kSplashMode) || (theMode == kPlayMode))
{
Rect updateRect;
SetRect(&updateRect, splashOriginH + 474, splashOriginV + 304, splashOriginH + 474 + 166, splashOriginV + 304 + 12);
InvalWindowRect(mainWindow, &updateRect);
}
}
#endif
break;
case iQuit:
#ifndef COMPILEDEMO
quitting = true;
if (!QuerySaveChanges())
quitting = false;
#else
quitting = true;
#endif
break;
default:
break;
}
}
//-------------------------------------------------------------- DoOptionsMenu
// Handle the user selecting an item from the Options menu.
void DoOptionsMenu (short theItem)
{
#ifndef COMPILEDEMO
OSErr theErr;
#endif
switch (theItem)
{
case iEditor:
#ifdef COMPILEDEMO
DoNotInDemo();
#else
if (theMode == kEditMode) // switching to splash mode
{
if (fileDirty)
SortHouseObjects();
if (!QuerySaveChanges())
break;
theMode = kSplashMode;
CloseMapWindow();
CloseToolsWindow();
CloseCoordWindow();
CloseLinkWindow();
DeselectObject();
StopMarquee();
if (isPlayMusicIdle)
{
theErr = StartMusic();
if (theErr != noErr)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
CloseMainWindow();
OpenMainWindow();
incrementModeTime = TickCount() + kIdleSplashTicks;
}
else if (theMode == kSplashMode) // switching to edit mode
{
theMode = kEditMode;
StopTheMusic();
CloseMainWindow();
OpenMainWindow();
OpenCloseEditWindows();
}
InitCursor();
UpdateMenus(true);
#endif
break;
case iHighScores:
DoHighScores();
incrementModeTime = TickCount() + kIdleSplashTicks;
break;
case iPrefs:
DoSettingsMain();
incrementModeTime = TickCount() + kIdleSplashTicks;
break;
case iHelp:
DoDemoGame();
break;
}
}
//-------------------------------------------------------------- DoHouseMenu
// Handle the user selecting an item from the House menu (only in Edit mode).
void DoHouseMenu (short theItem)
{
#ifndef COMPILEDEMO
short direction, dist;
Boolean whoCares;
switch (theItem)
{
case iNewHouse:
if (CreateNewHouse())
{
whoCares = InitializeEmptyHouse();
OpenCloseEditWindows();
}
break;
case iSave:
DeselectObject();
if (fileDirty)
SortHouseObjects();
if ((fileDirty) && (houseUnlocked))
{
// SaveGame(false);
if (wasHouseVersion < kHouseVersion)
ConvertHouseVer1To2();
wasHouseVersion = kHouseVersion;
whoCares = WriteHouse(true);
ForceThisRoom(thisRoomNumber);
ReadyBackground(thisRoom->background, thisRoom->tiles);
GetThisRoomsObjRects();
DrawThisRoomsObjects();
}
break;
// case iSaveAs:
// whoCares = SaveHouseAs();
// break;
case iHouse:
if (houseUnlocked)
DoHouseInfo();
break;
case iRoom:
if (houseUnlocked)
DoRoomInfo();
break;
case iObject:
if (houseUnlocked)
{
DoObjectInfo();
if (ObjectHasHandle(&direction, &dist))
{
StartMarqueeHandled(&roomObjectRects[objActive], direction, dist);
HandleBlowerGlider();
}
else
StartMarquee(&roomObjectRects[objActive]);
}
break;
case iCut:
if (houseUnlocked)
{
if (objActive > kNoObjectSelected)
{
// PutObjectScrap();
DeleteObject();
}
else
{
// PutRoomScrap();
DeleteRoom(false);
}
UpdateClipboardMenus();
}
break;
case iCopy:
if (houseUnlocked)
{
// if (objActive > kNoObjectSelected)
// PutObjectScrap();
// else
// PutRoomScrap();
UpdateClipboardMenus();
}
break;
case iPaste:
if (houseUnlocked)
{
/* if (scrapIsARoom)
GetRoomScrap();
else
GetObjectScrap();
UpdateClipboardMenus();
*/
}
break;
case iClear:
if (houseUnlocked)
{
if (objActive > kNoObjectSelected)
DeleteObject();
else
DeleteRoom(false);
UpdateClipboardMenus();
}
break;
case iDuplicate:
if (houseUnlocked)
DuplicateObject();
break;
case iBringForward:
if (houseUnlocked)
BringSendFrontBack(true);
break;
case iSendBack:
if (houseUnlocked)
BringSendFrontBack(false);
break;
case iGoToRoom:
if (houseUnlocked)
DoGoToDialog();
break;
case iMapWindow:
if (houseUnlocked)
ToggleMapWindow();
break;
case iObjectWindow:
if (houseUnlocked)
ToggleToolsWindow();
break;
case iCoordinateWindow:
if (houseUnlocked)
ToggleCoordinateWindow();
break;
}
#endif
}
//-------------------------------------------------------------- DoMenuChoice
// Users has selected a menu item - determin which menu was selected<65>
// and call the appropriate function above.
void DoMenuChoice (long menuChoice)
{
short theMenu, theItem;
if (menuChoice == 0)
return;
theMenu = HiWord(menuChoice);
theItem = LoWord(menuChoice);
switch (theMenu)
{
case kAppleMenuID:
DoAppleMenu(theItem);
break;
case kGameMenuID:
DoGameMenu(theItem);
break;
case kOptionsMenuID:
DoOptionsMenu(theItem);
break;
case kHouseMenuID:
DoHouseMenu(theItem);
break;
}
HiliteMenu(0);
}
//-------------------------------------------------------------- UpdateMapCheckmark
// Checks or unchecks the Map Window item (to indicate if open or not).
void UpdateMapCheckmark (Boolean checkIt)
{
if (!menusUp)
return;
CheckMenuItem(houseMenu, iMapWindow, checkIt);
}
//-------------------------------------------------------------- UpdateToolsCheckmark
// Checks or unchecks the Tools Window item (to indicate if open or not).
void UpdateToolsCheckmark (Boolean checkIt)
{
if (!menusUp)
return;
CheckMenuItem(houseMenu, iObjectWindow, checkIt);
}
//-------------------------------------------------------------- UpdateCoordinateCheckmark
// Checks or unchecks the Coordinates Window item (to indicate if open or not).
void UpdateCoordinateCheckmark (Boolean checkIt)
{
if (!menusUp)
return;
CheckMenuItem(houseMenu, iCoordinateWindow, checkIt);
}
//-------------------------------------------------------------- UpdateResumeDialog
// Update function for Resume dialog (below).
void UpdateResumeDialog (DialogPtr theDialog)
{
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
}
//-------------------------------------------------------------- ResumeFilter
// Dialog filter for the Resume dialog (below).
Boolean ResumeFilter (DialogPtr dial, EventRecord *event, short *item)
{
switch (event->what)
{
case keyDown:
switch ((event->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
default:
return(false);
}
break;
case updateEvt:
if ((WindowPtr)event->message == GetDialogWindow(dial))
{
SetPort((GrafPtr)dial);
BeginUpdate(GetDialogWindow(dial));
UpdateResumeDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
}
return(false);
break;
default:
return(false);
break;
}
}
//-------------------------------------------------------------- QueryResumeGame
// Dialog that asks user whether they want to resume a saved game or<6F>
// begin a new one. It displays a little info on the state of their<69>
// saved game (number of glider left, points, etc.).
short QueryResumeGame (void)
{
#define kResumeGameDial 1025
DialogPtr theDial;
houseType *thisHousePtr;
Str255 scoreStr, glidStr;
long hadPoints;
short hitWhat, hadGliders;
char wasState;
Boolean leaving;
ModalFilterUPP resumeFilterUPP;
resumeFilterUPP = NewModalFilterUPP(ResumeFilter);
wasState = HGetState((Handle)thisHouse); // get score & num. gliders
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
hadPoints = thisHousePtr->savedGame.score;
hadGliders = thisHousePtr->savedGame.numGliders;
HSetState((Handle)thisHouse, wasState);
NumToString(hadPoints, scoreStr); // param text strings
NumToString((long)hadGliders, glidStr);
if (hadGliders == 1)
ParamText(glidStr, PSTR(""), scoreStr, PSTR(""));
else
ParamText(glidStr, PSTR("s"), scoreStr, PSTR(""));
// CenterDialog(kResumeGameDial);
theDial = GetNewDialog(kResumeGameDial, nil, kPutInFront);
if (theDial == nil)
RedAlert(kErrDialogDidntLoad);
SetPort((GrafPtr)theDial);
ShowWindow(GetDialogWindow(theDial));
DrawDefaultButton(theDial);
leaving = false;
while (!leaving)
{
ModalDialog(resumeFilterUPP, &hitWhat);
if ((hitWhat == kSheWantsNewGame) || (hitWhat == kSheWantsResumeGame))
{
leaving = true;
}
}
DisposeDialog(theDial);
DisposeModalFilterUPP(resumeFilterUPP);
return (hitWhat);
}
//-------------------------------------------------------------- DoNotInDemo
// Only compiled for "demo version" of Glider PRO. It brings up a<>
// dialog that says, essentially, "x" feature is not implemented in<69>
// the demo version.
#ifdef COMPILEDEMO
void DoNotInDemo (void)
{
#define kNotInDemoAlert 1037
short whoCares;
// CenterAlert(kNotInDemoAlert);
whoCares = Alert(kNotInDemoAlert, nil);
}
#endif
//-------------------------------------------------------------- HeyYourPissingAHighScore
void HeyYourPissingAHighScore (void)
{
#define kNoHighScoreAlert 1046
short whoCares;
// CenterAlert(kNoHighScoreAlert);
whoCares = Alert(kNoHighScoreAlert, nil);
}
//-------------------------------------------------------------- OpenCloseEditWindows
// Function goes through and either closes or opens all the various<75>
// editing windows (in response to switching in or out of editor).
void OpenCloseEditWindows (void)
{
if (theMode == kEditMode)
{
if (houseUnlocked)
{
if (isMapOpen)
OpenMapWindow();
if (isToolsOpen)
OpenToolsWindow();
if (isCoordOpen)
OpenCoordWindow();
}
else
{
CloseMapWindow();
CloseToolsWindow();
CloseCoordWindow();
}
}
}

640
GpApp/Modes.cpp Normal file
View File

@@ -0,0 +1,640 @@
//============================================================================
//----------------------------------------------------------------------------
// Modes.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "RectUtils.h"
short saidFollow;
extern Rect gliderSrc[];
extern Rect transRect;
extern short fadeInSequence[], linkedToWhat;
extern short rightClip, leftClip, transRoom;
extern Boolean hasMirror, shadowVisible, firstPlayer, twoPlayerGame;
extern Boolean onePlayerLeft, playerDead;
//============================================================== Functions
//-------------------------------------------------------------- StartGliderFadingIn
void StartGliderFadingIn (gliderPtr thisGlider)
{
if (foilTotal <= 0)
showFoil = false;
thisGlider->mode = kGliderFadingIn;
thisGlider->whole = thisGlider->dest;
thisGlider->frame = 0;
thisGlider->dontDraw = false;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
thisGlider->mask =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
}
else
{
thisGlider->src = gliderSrc[fadeInSequence[thisGlider->frame]];
thisGlider->mask = gliderSrc[fadeInSequence[thisGlider->frame]];
}
}
//-------------------------------------------------------------- StartGliderTransportingIn
void StartGliderTransportingIn (gliderPtr thisGlider)
{
if (foilTotal <= 0)
showFoil = false;
thisGlider->mode = kGliderTransportingIn;
thisGlider->whole = thisGlider->dest;
thisGlider->frame = 0;
thisGlider->dontDraw = false;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
thisGlider->mask =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
}
else
{
thisGlider->src = gliderSrc[fadeInSequence[thisGlider->frame]];
thisGlider->mask = gliderSrc[fadeInSequence[thisGlider->frame]];
}
}
//-------------------------------------------------------------- StartGliderFadingOut
void StartGliderFadingOut (gliderPtr thisGlider)
{
Rect tempBounds;
if (thisGlider->mode == kGliderFadingOut)
return;
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
if (RectTall(&thisGlider->dest) > kGliderHigh)
{
tempBounds = thisGlider->dest;
QOffsetRect(&tempBounds, playOriginH, playOriginV);
AddRectToWorkRects(&tempBounds);
if (hasMirror)
{
tempBounds = thisGlider->dest;
QOffsetRect(&tempBounds, playOriginH - 20, playOriginV - 16);
AddRectToWorkRects(&tempBounds);
}
thisGlider->dest.right = thisGlider->dest.left + kGliderWide;
thisGlider->dest.top = thisGlider->dest.bottom - kGliderHigh;
}
thisGlider->mode = kGliderFadingOut;
thisGlider->whole = thisGlider->dest;
thisGlider->frame = kLastFadeSequence - 1;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
thisGlider->mask =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
}
else
{
thisGlider->src = gliderSrc[fadeInSequence[thisGlider->frame]];
thisGlider->mask = gliderSrc[fadeInSequence[thisGlider->frame]];
}
}
//-------------------------------------------------------------- StartGliderGoingUpStairs
void StartGliderGoingUpStairs (gliderPtr thisGlider)
{
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
if (thisGlider->mode == kGliderBurning)
thisGlider->frame = kWasBurning;
else
thisGlider->frame = 0;
thisGlider->mode = kGliderGoingUp;
}
//-------------------------------------------------------------- StartGliderGoingDownStairs
void StartGliderGoingDownStairs (gliderPtr thisGlider)
{
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
if (thisGlider->mode == kGliderBurning)
thisGlider->frame = kWasBurning;
else
thisGlider->frame = 0;
thisGlider->mode = kGliderGoingDown;
rightClip = GetUpStairsRightEdge();
}
//-------------------------------------------------------------- StartGliderMailingIn
void StartGliderMailingIn (gliderPtr thisGlider, Rect *bounds, hotPtr who)
{
short topSought, whoLinked;
Byte objLinked;
char wasState;
PlayPrioritySound(kTransOutSound, kTransOutPriority);
whoLinked = who->who;
transRoom = masterObjects[whoLinked].roomLink;
objLinked = masterObjects[whoLinked].objectLink;
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
HSetState((Handle)thisHouse, wasState);
thisGlider->frame = 0;
thisGlider->clip = *bounds;
topSought = bounds->bottom - RectTall(&thisGlider->dest);
thisGlider->clip.top = topSought;
}
//-------------------------------------------------------------- StartGliderMailingOut
void StartGliderMailingOut (gliderPtr thisGlider)
{
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
if (linkedToWhat == kLinkedToLeftMailbox)
{
thisGlider->facing = kFaceLeft;
thisGlider->mode = kGliderMailOutLeft;
thisGlider->src = gliderSrc[2];
thisGlider->mask = gliderSrc[2];
}
else
{
thisGlider->facing = kFaceRight;
thisGlider->mode = kGliderMailOutRight;
thisGlider->src = gliderSrc[0];
thisGlider->mask = gliderSrc[0];
}
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->tipped = false;
thisGlider->dontDraw = false;
}
//-------------------------------------------------------------- StartGliderDuctingDown
void StartGliderDuctingDown (gliderPtr thisGlider, Rect *bounds, hotPtr who)
{
short leftSought, whoLinked;
Byte objLinked;
char wasState;
PlayPrioritySound(kTransOutSound, kTransOutPriority);
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
whoLinked = who->who;
transRoom = masterObjects[whoLinked].roomLink;
objLinked = masterObjects[whoLinked].objectLink;
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
HSetState((Handle)thisHouse, wasState);
thisGlider->frame = 0;
thisGlider->clip = *bounds;
leftSought = bounds->left + ((RectWide(bounds) - kGliderWide) / 2);
thisGlider->clip.left = leftSought;
thisGlider->mode = kGliderDuctingDown;
}
//-------------------------------------------------------------- StartGliderDuctingUp
void StartGliderDuctingUp (gliderPtr thisGlider, Rect *bounds, hotPtr who)
{
short leftSought, whoLinked;
Byte objLinked;
char wasState;
PlayPrioritySound(kTransOutSound, kTransOutPriority);
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
whoLinked = who->who;
transRoom = masterObjects[whoLinked].roomLink;
objLinked = masterObjects[whoLinked].objectLink;
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
HSetState((Handle)thisHouse, wasState);
thisGlider->frame = 0;
thisGlider->clip = *bounds;
leftSought = bounds->left + ((RectWide(bounds) - kGliderWide) / 2);
thisGlider->clip.left = leftSought;
thisGlider->mode = kGliderDuctingUp;
}
//-------------------------------------------------------------- StartGliderDuctingIn
void StartGliderDuctingIn (gliderPtr thisGlider)
{
thisGlider->mode = kGliderDuctingIn;
thisGlider->whole = thisGlider->dest;
thisGlider->dontDraw = false;
}
//-------------------------------------------------------------- StartGliderTransporting
void StartGliderTransporting (gliderPtr thisGlider, hotPtr who)
{
short whoLinked;
Byte objLinked;
char wasState;
PlayPrioritySound(kTransOutSound, kTransOutPriority);
if (thisGlider->mode == kGliderGoingFoil)
DeckGliderInFoil(thisGlider);
else if (thisGlider->mode == kGliderLosingFoil)
RemoveFoilFromGlider(thisGlider);
whoLinked = who->who;
transRoom = masterObjects[whoLinked].roomLink;
objLinked = masterObjects[whoLinked].objectLink;
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
HSetState((Handle)thisHouse, wasState);
thisGlider->dest.right = thisGlider->dest.left + kGliderWide;
thisGlider->dest.bottom = thisGlider->dest.top + kGliderHigh;
thisGlider->destShadow.right = thisGlider->destShadow.left + kGliderWide;
thisGlider->destShadow.bottom = thisGlider->destShadow.top + kShadowHigh;
thisGlider->mode = kGliderTransporting;
thisGlider->whole = thisGlider->dest;
thisGlider->frame = kLastFadeSequence - 1;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
thisGlider->mask =
gliderSrc[fadeInSequence[thisGlider->frame] + kLeftFadeOffset];
}
else
{
thisGlider->src = gliderSrc[fadeInSequence[thisGlider->frame]];
thisGlider->mask = gliderSrc[fadeInSequence[thisGlider->frame]];
}
}
//-------------------------------------------------------------- FlagGliderNormal
void FlagGliderNormal (gliderPtr thisGlider)
{
thisGlider->dest.right = thisGlider->dest.left + kGliderWide;
thisGlider->dest.bottom = thisGlider->dest.top + kGliderHigh;
thisGlider->destShadow.right = thisGlider->destShadow.left + kGliderWide;
thisGlider->destShadow.bottom = thisGlider->destShadow.top + kShadowHigh;
thisGlider->mode = kGliderNormal;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src = gliderSrc[2];
thisGlider->mask = gliderSrc[2];
}
else
{
thisGlider->src = gliderSrc[0];
thisGlider->mask = gliderSrc[0];
}
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->tipped = false;
thisGlider->ignoreLeft = false;
thisGlider->ignoreRight = false;
thisGlider->ignoreGround = false;
thisGlider->dontDraw = false;
thisGlider->frame = 0;
shadowVisible = IsShadowVisible();
}
//-------------------------------------------------------------- FlagGliderShredding
void FlagGliderShredding (gliderPtr thisGlider, Rect *bounds)
{
PlayPrioritySound(kCaughtFireSound, kCaughtFirePriority);
thisGlider->dest.left = bounds->left + 36;
thisGlider->dest.right = thisGlider->dest.left + kGliderWide;
thisGlider->dest.bottom = thisGlider->dest.top + kGliderHigh;
if (thisGlider->dest.left > thisGlider->whole.left)
{
thisGlider->whole.right = thisGlider->dest.right;
thisGlider->wholeShadow.right = thisGlider->dest.right;
}
else
{
thisGlider->whole.left = thisGlider->dest.left;
thisGlider->wholeShadow.left = thisGlider->dest.left;
}
thisGlider->destShadow.left = thisGlider->dest.left;
thisGlider->destShadow.right = thisGlider->destShadow.left + kGliderWide;
thisGlider->destShadow.bottom = thisGlider->destShadow.top + kShadowHigh;
thisGlider->mode = kGliderShredding;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src = gliderSrc[2];
thisGlider->mask = gliderSrc[2];
}
else
{
thisGlider->src = gliderSrc[0];
thisGlider->mask = gliderSrc[0];
}
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->frame = bounds->bottom - 3;
thisGlider->tipped = false;
}
//-------------------------------------------------------------- FlagGliderBurning
void FlagGliderBurning (gliderPtr thisGlider)
{
#define kFramesToBurn 60
PlayPrioritySound(kCaughtFireSound, kCaughtFirePriority);
thisGlider->dest.right = thisGlider->dest.left + kGliderWide;
thisGlider->dest.top = thisGlider->dest.bottom - kGliderBurningHigh;
thisGlider->destShadow.right = thisGlider->destShadow.left + kGliderWide;
thisGlider->destShadow.bottom = thisGlider->destShadow.top + kShadowHigh;
thisGlider->mode = kGliderBurning;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src = gliderSrc[25];
thisGlider->mask = gliderSrc[25];
}
else
{
thisGlider->src = gliderSrc[21];
thisGlider->mask = gliderSrc[21];
}
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->frame = 0;
thisGlider->wasMode = kFramesToBurn; // used to count down burning
thisGlider->tipped = false;
}
//-------------------------------------------------------------- FlagGliderFaceLeft
void FlagGliderFaceLeft (gliderPtr thisGlider)
{
thisGlider->mode = kGliderFaceLeft;
thisGlider->frame = kLastAboutFaceFrame;
thisGlider->src = gliderSrc[kLastAboutFaceFrame];
thisGlider->mask = gliderSrc[kLastAboutFaceFrame];
}
//-------------------------------------------------------------- FlagGliderFaceRight
void FlagGliderFaceRight (gliderPtr thisGlider)
{
thisGlider->mode = kGliderFaceRight;
thisGlider->frame = kFirstAboutFaceFrame;
thisGlider->src = gliderSrc[kFirstAboutFaceFrame];
thisGlider->mask = gliderSrc[kFirstAboutFaceFrame];
}
//-------------------------------------------------------------- FlagGliderInLimbo
void FlagGliderInLimbo (gliderPtr thisGlider, Boolean sayIt)
{
thisGlider->wasMode = thisGlider->mode;
thisGlider->mode = kGliderInLimbo;
if ((sayIt) && (saidFollow < 3))
{
PlayPrioritySound(kFollowSound, kFollowPriority);
saidFollow++;
}
firstPlayer = thisGlider->which;
}
//-------------------------------------------------------------- UndoGliderLimbo
void UndoGliderLimbo (gliderPtr thisGlider)
{
if ((twoPlayerGame) && (onePlayerLeft) && (thisGlider->which == playerDead))
return;
if (thisGlider->mode == kGliderInLimbo)
thisGlider->mode = thisGlider->wasMode;
thisGlider->dontDraw = false;
}
//-------------------------------------------------------------- ToggleGliderFacing
void ToggleGliderFacing (gliderPtr thisGlider)
{
if (thisGlider->mode != kGliderNormal)
return;
if (thisGlider->facing == kFaceLeft)
FlagGliderFaceRight(thisGlider);
else
FlagGliderFaceLeft(thisGlider);
}
//-------------------------------------------------------------- InsureGliderFacingRight
void InsureGliderFacingRight (gliderPtr thisGlider)
{
if ((twoPlayerGame) && (onePlayerLeft) && (thisGlider->which == playerDead))
return;
if ((thisGlider->facing == kFaceLeft) && (thisGlider->mode != kGliderBurning))
FlagGliderFaceRight(thisGlider);
}
//-------------------------------------------------------------- InsureGliderFacingLeft
void InsureGliderFacingLeft (gliderPtr thisGlider)
{
if ((twoPlayerGame) && (onePlayerLeft) && (thisGlider->which == playerDead))
return;
if ((thisGlider->facing == kFaceRight) && (thisGlider->mode != kGliderBurning))
FlagGliderFaceLeft(thisGlider);
}
//-------------------------------------------------------------- ReadyGliderForTripUpStairs
void ReadyGliderForTripUpStairs (gliderPtr thisGlider)
{
#define kVGliderAppearsComingUp 100
if ((twoPlayerGame) && (thisGlider->which == playerDead) && (onePlayerLeft))
return;
thisGlider->facing = kFaceLeft;
thisGlider->mode = kGliderComingUp;
thisGlider->src = gliderSrc[2];
thisGlider->mask = gliderSrc[2];
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->tipped = false;
rightClip = GetUpStairsRightEdge();
thisGlider->dest = thisGlider->src;
ZeroRectCorner(&thisGlider->dest);
QOffsetRect(&thisGlider->dest, rightClip, kVGliderAppearsComingUp);
thisGlider->whole = thisGlider->dest;
thisGlider->destShadow.left = thisGlider->dest.left;
thisGlider->destShadow.right = thisGlider->dest.right;
thisGlider->wholeShadow = thisGlider->destShadow;
FinishGliderUpStairs(thisGlider);
}
//-------------------------------------------------------------- ReadyGliderForTripDownStairs
void ReadyGliderForTripDownStairs (gliderPtr thisGlider)
{
#define kVGliderAppearsComingDown 100
if ((twoPlayerGame) && (thisGlider->which == playerDead) && (onePlayerLeft))
return;
thisGlider->facing = kFaceRight;
thisGlider->mode = kGliderComingDown;
thisGlider->src = gliderSrc[0];
thisGlider->mask = gliderSrc[0];
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->tipped = false;
leftClip = GetDownStairsLeftEdge();
thisGlider->dest = thisGlider->src;
ZeroRectCorner(&thisGlider->dest);
QOffsetRect(&thisGlider->dest, leftClip - kGliderWide, kVGliderAppearsComingDown);
thisGlider->whole = thisGlider->dest;
thisGlider->destShadow.left = thisGlider->dest.left;
thisGlider->destShadow.right = thisGlider->dest.right;
thisGlider->wholeShadow = thisGlider->destShadow;
FinishGliderDownStairs(thisGlider);
}
//-------------------------------------------------------------- StartGliderFoilGoing
void StartGliderFoilGoing (gliderPtr thisGlider)
{
if ((thisGlider->mode == kGliderGoingFoil) || (thisGlider->mode == kGliderInLimbo))
return;
QuickFoilRefresh(false);
thisGlider->mode = kGliderGoingFoil;
thisGlider->whole = thisGlider->dest;
thisGlider->frame = 0;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src = gliderSrc[(10 - thisGlider->frame) + kLeftFadeOffset];
thisGlider->mask = gliderSrc[(10 - thisGlider->frame) + kLeftFadeOffset];
}
else
{
thisGlider->src = gliderSrc[10 - thisGlider->frame];
thisGlider->mask = gliderSrc[10 - thisGlider->frame];
}
}
//-------------------------------------------------------------- StartGliderFoilLosing
void StartGliderFoilLosing (gliderPtr thisGlider)
{
if ((thisGlider->mode == kGliderLosingFoil) ||
(thisGlider->mode == kGliderInLimbo))
return;
QuickFoilRefresh(false);
PlayPrioritySound(kFizzleSound, kFizzlePriority);
thisGlider->mode = kGliderLosingFoil;
thisGlider->whole = thisGlider->dest;
thisGlider->frame = 0;
if (thisGlider->facing == kFaceLeft)
{
thisGlider->src = gliderSrc[(10 - thisGlider->frame) + kLeftFadeOffset];
thisGlider->mask = gliderSrc[(10 - thisGlider->frame) + kLeftFadeOffset];
}
else
{
thisGlider->src = gliderSrc[10 - thisGlider->frame];
thisGlider->mask = gliderSrc[10 - thisGlider->frame];
}
}
//-------------------------------------------------------------- TagGliderIdle
void TagGliderIdle (gliderPtr thisGlider)
{
if ((twoPlayerGame) && (onePlayerLeft) && (thisGlider->which == playerDead))
return;
thisGlider->wasMode = thisGlider->mode;
thisGlider->mode = kGliderIdle;
thisGlider->hVel = 30; // used for 30 frame delay
}

416
GpApp/Music.cpp Normal file
View File

@@ -0,0 +1,416 @@
//============================================================================
//----------------------------------------------------------------------------
// Music.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLSound.h"
#include "Environ.h"
#include "Externs.h"
#define kBaseBufferMusicID 2000
#define kMaxMusic 7
#define kLastMusicPiece 16
#define kLastGamePiece 6
void MusicCallBack (SndChannelPtr, SndCommand *);
OSErr LoadMusicSounds (void);
OSErr DumpMusicSounds (void);
OSErr OpenMusicChannel (void);
OSErr CloseMusicChannel (void);
SndCallBackUPP musicCallBackUPP;
SndChannelPtr musicChannel;
Ptr theMusicData[kMaxMusic];
short musicSoundID, musicCursor;
short musicScore[kLastMusicPiece];
short gameScore[kLastGamePiece];
short musicMode;
Boolean isMusicOn, isPlayMusicIdle, isPlayMusicGame;
Boolean failedMusic, dontLoadMusic;
extern Boolean isSoundOn;
//============================================================== Functions
//-------------------------------------------------------------- StartMusic
OSErr StartMusic (void)
{
SndCommand theCommand;
OSErr theErr;
short soundVolume;
theErr = noErr;
if (dontLoadMusic)
return(theErr);
UnivGetSoundVolume(&soundVolume, thisMac.hasSM3);
if ((soundVolume != 0) && (!failedMusic))
{
theCommand.cmd = bufferCmd;
theCommand.param1 = 0;
theCommand.param2 = (intptr_t)(theMusicData[musicSoundID]);
theErr = SndDoCommand(musicChannel, &theCommand, false);
if (theErr != noErr)
return (theErr);
// GP: No idea what "1964" means
theCommand.cmd = nullCmd;
theCommand.param1 = 1964;
theCommand.param2 = 0;
theErr = SndDoCommand(musicChannel, &theCommand, false);
if (theErr != noErr)
return (theErr);
musicCursor++;
if (musicCursor >= kLastMusicPiece)
musicCursor = 0;
musicSoundID = musicScore[musicCursor];
theCommand.cmd = bufferCmd;
theCommand.param1 = 0;
theCommand.param2 = (intptr_t)(theMusicData[musicSoundID]);
theErr = SndDoCommand(musicChannel, &theCommand, false);
if (theErr != noErr)
return (theErr);
theCommand.cmd = callBackCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoCommand(musicChannel, &theCommand, false);
isMusicOn = true;
}
return (theErr);
}
//-------------------------------------------------------------- StopTheMusic
void StopTheMusic (void)
{
SndCommand theCommand;
OSErr theErr;
if (dontLoadMusic)
return;
theErr = noErr;
if ((isMusicOn) && (!failedMusic))
{
theCommand.cmd = flushCmd;
theCommand.param1 = 0;
theCommand.param2 = 0L;
theErr = SndDoImmediate(musicChannel, &theCommand);
theCommand.cmd = quietCmd;
theCommand.param1 = 0;
theCommand.param2 = 0L;
theErr = SndDoImmediate(musicChannel, &theCommand);
isMusicOn = false;
}
}
//-------------------------------------------------------------- ToggleMusicWhilePlaying
void ToggleMusicWhilePlaying (void)
{
OSErr theErr;
if (dontLoadMusic)
return;
if (isPlayMusicGame)
{
if (!isMusicOn)
theErr = StartMusic();
}
else
{
if (isMusicOn)
StopTheMusic();
}
}
//-------------------------------------------------------------- SetMusicalPiece
void SetMusicalMode (short newMode)
{
if (dontLoadMusic)
return;
switch (newMode)
{
case kKickGameScoreMode:
musicCursor = 2;
break;
case kProdGameScoreMode:
musicCursor = -1;
break;
default:
musicMode = newMode;
musicCursor = 0;
break;
}
}
//-------------------------------------------------------------- MusicCallBack
void MusicCallBack (SndChannelPtr theChannel, SndCommand *theCommand)
{
OSErr theErr;
// gameA5 = theCommand.param2;
// thisA5 = SetA5(gameA5);
switch (musicMode)
{
case kPlayGameScoreMode:
musicCursor++;
if (musicCursor >= kLastGamePiece)
musicCursor = 1;
musicSoundID = gameScore[musicCursor];
if (musicSoundID < 0)
{
musicCursor += musicSoundID;
musicSoundID = gameScore[musicCursor];
}
break;
case kPlayWholeScoreMode:
musicCursor++;
if (musicCursor >= kLastMusicPiece - 1)
musicCursor = 0;
musicSoundID = musicScore[musicCursor];
break;
default:
musicSoundID = musicMode;
break;
}
theCommand->cmd = bufferCmd;
theCommand->param1 = 0;
theCommand->param2 = (intptr_t)(theMusicData[musicSoundID]);
theErr = SndDoCommand(musicChannel, theCommand, false);
theCommand->cmd = callBackCmd;
theCommand->param1 = 0;
theCommand->param2 = 0;
theErr = SndDoCommand(musicChannel, theCommand, false);
}
//-------------------------------------------------------------- LoadMusicSounds
OSErr LoadMusicSounds (void)
{
Handle theSound;
long soundDataSize;
OSErr theErr;
short i;
theErr = noErr;
for (i = 0; i < kMaxMusic; i++)
theMusicData[i] = nil;
for (i = 0; i < kMaxMusic; i++)
{
theSound = GetResource('snd ', i + kBaseBufferMusicID);
if (theSound == nil)
return (MemError());
HLock(theSound);
soundDataSize = GetHandleSize(theSound) - 20L;
HUnlock(theSound);
theMusicData[i] = NewPtr(soundDataSize);
if (theMusicData[i] == nil)
return (MemError());
HLock(theSound);
BlockMove((Ptr)(static_cast<Byte*>(*theSound) + 20L), theMusicData[i], soundDataSize);
ReleaseResource(theSound);
}
return (theErr);
}
//-------------------------------------------------------------- DumpMusicSounds
OSErr DumpMusicSounds (void)
{
OSErr theErr;
short i;
theErr = noErr;
for (i = 0; i < kMaxMusic; i++)
{
if (theMusicData[i] != nil)
DisposePtr(theMusicData[i]);
theMusicData[i] = nil;
}
return (theErr);
}
//-------------------------------------------------------------- OpenMusicChannel
OSErr OpenMusicChannel (void)
{
OSErr theErr;
musicCallBackUPP = NewSndCallBackProc(MusicCallBack);
theErr = noErr;
if (musicChannel != nil)
return (theErr);
musicChannel = nil;
theErr = SndNewChannel(&musicChannel,
sampledSynth, initNoInterp + initMono,
(SndCallBackUPP)musicCallBackUPP);
return (theErr);
}
//-------------------------------------------------------------- CloseMusicChannel
OSErr CloseMusicChannel (void)
{
OSErr theErr;
theErr = noErr;
if (musicChannel != nil)
theErr = SndDisposeChannel(musicChannel, true);
musicChannel = nil;
DisposeSndCallBackUPP(musicCallBackUPP);
return (theErr);
}
//-------------------------------------------------------------- InitMusic
void InitMusic (void)
{
OSErr theErr;
if (dontLoadMusic)
return;
musicChannel = nil;
failedMusic = false;
isMusicOn = false;
theErr = LoadMusicSounds();
if (theErr != noErr)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
return;
}
theErr = OpenMusicChannel();
musicScore[0] = 0;
musicScore[1] = 1;
musicScore[2] = 2;
musicScore[3] = 3;
musicScore[4] = 4;
musicScore[5] = 4;
musicScore[6] = 0;
musicScore[7] = 1;
musicScore[8] = 2;
musicScore[9] = 3;
musicScore[10] = kPlayChorus;
musicScore[11] = kPlayChorus;
musicScore[12] = kPlayRefrainSparse1;
musicScore[13] = kPlayRefrainSparse2;
musicScore[14] = kPlayChorus;
musicScore[15] = kPlayChorus;
gameScore[0] = kPlayRefrainSparse2;
gameScore[1] = kPlayRefrainSparse1;
gameScore[2] = -1;
gameScore[3] = kPlayRefrainSparse2;
gameScore[4] = kPlayChorus;
gameScore[5] = kPlayChorus;
musicCursor = 0;
musicSoundID = musicScore[musicCursor];
musicMode = kPlayWholeScoreMode;
if (isPlayMusicIdle)
{
theErr = StartMusic();
if (theErr != noErr)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
}
//-------------------------------------------------------------- KillMusic
void KillMusic (void)
{
OSErr theErr;
if (dontLoadMusic)
return;
theErr = DumpMusicSounds();
theErr = CloseMusicChannel();
}
//-------------------------------------------------------------- MusicBytesNeeded
long MusicBytesNeeded (void)
{
Handle theSound;
long totalBytes;
short i;
totalBytes = 0L;
SetResLoad(false);
for (i = 0; i < kMaxMusic; i++)
{
theSound = GetResource('snd ', i + kBaseBufferMusicID);
if (theSound == nil)
{
SetResLoad(true);
return ((long)ResError());
}
totalBytes += GetMaxResourceSize(theSound);
// ReleaseResource(theSound);
}
SetResLoad(true);
return totalBytes;
}
//-------------------------------------------------------------- TellHerNoMusic
void TellHerNoMusic (void)
{
#define kNoMemForMusicAlert 1038
short hitWhat;
// CenterAlert(kNoMemForMusicAlert);
hitWhat = Alert(kNoMemForMusicAlert, nil);
}

1084
GpApp/ObjectAdd.cpp Normal file

File diff suppressed because it is too large Load Diff

1406
GpApp/ObjectDraw.cpp Normal file

File diff suppressed because it is too large Load Diff

1438
GpApp/ObjectDraw2.cpp Normal file

File diff suppressed because it is too large Load Diff

966
GpApp/ObjectDrawAll.cpp Normal file
View File

@@ -0,0 +1,966 @@
//============================================================================
//----------------------------------------------------------------------------
// ObjectDrawAll.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "RectUtils.h"
extern Rect localRoomsDest[], movieRect;
extern short localNumbers[];
extern short numLights, tvWithMovieNumber;
extern Boolean tvOn;
//============================================================== Functions
//-------------------------------------------------------------- DrawARoomsObjects
void DrawARoomsObjects (short neighbor, Boolean redraw)
{
objectType thisObject;
Rect whoCares, itsRect, rectA, rectB, testRect;
RgnHandle theRgn;
short i, legit, dynamicNum, n;
short floor, suite, room, obj;
char wasState;
Boolean isLit;
if (localNumbers[neighbor] == kRoomIsEmpty)
return;
testRect = houseRect;
ZeroRectCorner(&testRect);
isLit = (numLights > 0);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
for (i = 0; i < kMaxRoomObs; i++)
{
dynamicNum = -1;
legit = -1;
if (IsThisValid(localNumbers[neighbor], i))
{
thisObject = (*thisHouse)->rooms[localNumbers[neighbor]].objects[i];
switch (thisObject.what)
{
case kObjectIsEmpty:
break;
case kFloorVent:
case kCeilingVent:
case kFloorBlower:
case kCeilingBlower:
case kSewerGrate:
case kLeftFan:
case kRightFan:
case kGrecoVent:
case kSewerBlower:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawSimpleBlowers(thisObject.what, &itsRect);
break;
case kTaper:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (isLit)
DrawSimpleBlowers(thisObject.what, &itsRect);
if (neighbor == kCentralRoom)
{
if (redraw)
ReBackUpFlames(localNumbers[neighbor], i);
else
AddCandleFlame(localNumbers[neighbor], i,
itsRect.left + 10, itsRect.top + 7);
}
else
{
QSetRect(&rectA, 0, 0, 16, 15);
QOffsetRect(&rectA, itsRect.left + 10 - 8, itsRect.top + 7 - 15);
rectB = localRoomsDest[kCentralRoom];
rectB.top -= kFloorSupportTall;
rectB.bottom += kFloorSupportTall;
if (!SectRect(&rectA, &rectB, &whoCares))
{
if (redraw)
ReBackUpFlames(localNumbers[neighbor], i);
else
AddCandleFlame(localNumbers[neighbor], i,
itsRect.left + 10, itsRect.top + 7);
}
}
}
break;
case kCandle:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (isLit)
DrawSimpleBlowers(thisObject.what, &itsRect);
if (neighbor == kCentralRoom)
{
if (redraw)
ReBackUpFlames(localNumbers[neighbor], i);
else
AddCandleFlame(localNumbers[neighbor], i,
itsRect.left + 14, itsRect.top + 7);
}
else
{
QSetRect(&rectA, 0, 0, 16, 15);
QOffsetRect(&rectA, itsRect.left + 14 - 8, itsRect.top + 7 - 15);
rectB = localRoomsDest[kCentralRoom];
rectB.top -= kFloorSupportTall;
rectB.bottom += kFloorSupportTall;
if (!SectRect(&rectA, &rectB, &whoCares))
{
if (redraw)
ReBackUpFlames(localNumbers[neighbor], i);
else
AddCandleFlame(localNumbers[neighbor], i,
itsRect.left + 14, itsRect.top + 7);
}
}
}
break;
case kStubby:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (isLit)
DrawSimpleBlowers(thisObject.what, &itsRect);
if (neighbor == kCentralRoom)
{
if (redraw)
ReBackUpFlames(localNumbers[neighbor], i);
else
AddCandleFlame(localNumbers[neighbor], i,
itsRect.left + 9, itsRect.top + 7);
}
else
{
QSetRect(&rectA, 0, 0, 16, 15);
QOffsetRect(&rectA, itsRect.left + 9 - 8, itsRect.top + 7 - 15);
rectB = localRoomsDest[kCentralRoom];
rectB.top -= kFloorSupportTall;
rectB.bottom += kFloorSupportTall;
if (!SectRect(&rectA, &rectB, &whoCares))
{
if (redraw)
ReBackUpFlames(localNumbers[neighbor], i);
else
AddCandleFlame(localNumbers[neighbor], i,
itsRect.left + 9, itsRect.top + 7);
}
}
}
break;
case kTiki:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (isLit)
DrawTiki(&itsRect, playOriginV + VerticalRoomOffset(neighbor));
if (redraw)
ReBackUpTikiFlames(localNumbers[neighbor], i);
else
AddTikiFlame(localNumbers[neighbor], i,
itsRect.left + 10, itsRect.top - 9);
break;
case kBBQ:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (isLit)
DrawPictSansWhiteObject(thisObject.what, &itsRect);
if (redraw)
ReBackUpBBQCoals(localNumbers[neighbor], i);
else
AddBBQCoals(localNumbers[neighbor], i,
itsRect.left + 16, itsRect.top + 9);
}
break;
case kInvisBlower:
case kLiftArea:
break;
case kTable:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (isLit)
DrawTable(&itsRect, playOriginV);
break;
case kShelf:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (isLit)
DrawShelf(&itsRect);
break;
case kCabinet:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawCabinet(&itsRect);
break;
case kFilingCabinet:
case kOzma:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawPictObject(thisObject.what, &itsRect);
break;
case kWasteBasket:
case kMilkCrate:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawSimpleFurniture(thisObject.what, &itsRect);
break;
case kCounter:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawCounter(&itsRect);
break;
case kDresser:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (isLit)
DrawDresser(&itsRect);
break;
case kDeckTable:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (isLit)
DrawDeckTable(&itsRect, playOriginV);
break;
case kStool:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (isLit)
DrawStool(&itsRect, playOriginV + VerticalRoomOffset(neighbor));
break;
case kInvisObstacle:
break;
case kManhole:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
AddTempManholeRect(&itsRect);
if (isLit)
DrawPictSansWhiteObject(thisObject.what, &itsRect);
}
break;
case kInvisBounce:
break;
case kRedClock:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
DrawRedClock(&itsRect);
}
break;
case kBlueClock:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
DrawBlueClock(&itsRect);
}
break;
case kYellowClock:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
DrawYellowClock(&itsRect);
}
break;
case kCuckoo:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
{
DrawCuckoo(&itsRect);
if (redraw)
ReBackUpPendulum(localNumbers[neighbor], i);
else
AddPendulum(localNumbers[neighbor], i,
itsRect.left + 4, itsRect.top + 46);
}
}
break;
case kPaper:
case kBattery:
case kBands:
case kHelium:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
DrawSimplePrizes(thisObject.what, &itsRect);
}
break;
case kGreaseRt:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (thisObject.data.c.state) // standing
{
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
dynamicNum = ReBackUpGrease(localNumbers[neighbor], i);
else
dynamicNum = AddGrease(localNumbers[neighbor], i,
itsRect.left, itsRect.top,
thisObject.data.c.length, true);
if (dynamicNum != -1)
DrawGreaseRt(&itsRect, thisObject.data.c.length, true);
}
}
else // fallen
DrawGreaseRt(&itsRect, thisObject.data.c.length, false);
break;
case kGreaseLf:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (thisObject.data.c.state)
{
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
dynamicNum = ReBackUpGrease(localNumbers[neighbor], i);
else
dynamicNum = AddGrease(localNumbers[neighbor], i,
itsRect.left, itsRect.top,
thisObject.data.c.length, false);
if (dynamicNum != -1)
DrawGreaseLf(&itsRect, thisObject.data.c.length, true);
}
}
else
DrawGreaseLf(&itsRect, thisObject.data.c.length, false);
break;
case kFoil:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
DrawFoil(&itsRect);
}
break;
case kInvisBonus:
case kSlider:
break;
case kStar:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (redraw)
legit = ReBackUpSavedMap(&itsRect, localNumbers[neighbor], i);
else
legit = BackUpToSavedMap(&itsRect, localNumbers[neighbor], i);
if (legit != -1)
{
if (redraw)
ReBackUpStar(localNumbers[neighbor], i);
else
AddStar(localNumbers[neighbor], i, itsRect.left,
itsRect.top);
DrawSimplePrizes(thisObject.what, &itsRect);
}
}
break;
case kSparkle:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if ((!redraw) && (neighbor == kCentralRoom))
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kSparkle, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.c.state);
}
}
break;
case kUpStairs:
case kDoorInLf:
case kDoorInRt:
case kWindowInLf:
case kWindowInRt:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
DrawPictSansWhiteObject(thisObject.what, &itsRect);
break;
case kDownStairs:
case kDoorExRt:
case kDoorExLf:
case kWindowExRt:
case kWindowExLf:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
DrawPictObject(thisObject.what, &itsRect);
break;
case kMailboxLf:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
DrawMailboxLeft(&itsRect, playOriginV + VerticalRoomOffset(neighbor));
break;
case kMailboxRt:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
DrawMailboxRight(&itsRect, playOriginV + VerticalRoomOffset(neighbor));
break;
case kFloorTrans:
case kCeilingTrans:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
DrawSimpleTransport(thisObject.what, &itsRect);
break;
case kInvisTrans:
case kDeluxeTrans:
break;
case kLightSwitch:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
room = GetRoomNumber(floor, suite);
obj = (short)thisObject.data.e.who;
DrawLightSwitch(&itsRect, GetObjectState(room, obj));
}
dynamicNum = masterObjects[i].hotNum;
break;
case kMachineSwitch:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
room = GetRoomNumber(floor, suite);
obj = (short)thisObject.data.e.who;
DrawMachineSwitch(&itsRect, GetObjectState(room, obj));
}
dynamicNum = masterObjects[i].hotNum;
break;
case kThermostat:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
room = GetRoomNumber(floor, suite);
obj = (short)thisObject.data.e.who;
DrawThermostat(&itsRect, GetObjectState(room, obj));
}
dynamicNum = masterObjects[i].hotNum;
break;
case kPowerSwitch:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
room = GetRoomNumber(floor, suite);
obj = (short)thisObject.data.e.who;
DrawPowerSwitch(&itsRect, GetObjectState(room, obj));
}
dynamicNum = masterObjects[i].hotNum;
break;
case kKnifeSwitch:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
ExtractFloorSuite(thisObject.data.e.where, &floor, &suite);
room = GetRoomNumber(floor, suite);
obj = (short)thisObject.data.e.who;
DrawKnifeSwitch(&itsRect, GetObjectState(room, obj));
}
dynamicNum = masterObjects[i].hotNum;
break;
case kInvisSwitch:
dynamicNum = masterObjects[i].hotNum;
break;
case kTrigger:
case kLgTrigger:
case kSoundTrigger:
break;
case kCeilingLight:
case kLightBulb:
case kTableLamp:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawSimpleLight(thisObject.what, &itsRect);
break;
case kTrunk:
case kBooks:
case kHipLamp:
case kDecoLamp:
case kGuitar:
case kCinderBlock:
case kFlowerBox:
case kFireplace:
case kBear:
case kVase1:
case kVase2:
case kRug:
case kChimes:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawPictSansWhiteObject(thisObject.what, &itsRect);
break;
case kCustomPict:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawCustPictSansWhite(thisObject.data.g.height, &itsRect);
break;
case kFlourescent:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawFlourescent(&itsRect);
break;
case kTrackLight:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawTrackLight(&itsRect);
break;
case kInvisLight:
break;
case kShredder:
case kCDs:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawSimpleAppliance(thisObject.what, &itsRect);
break;
case kToaster:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawSimpleAppliance(thisObject.what, &itsRect);
if ((!redraw) && (neighbor == kCentralRoom))
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kToaster, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kMacPlus:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawMacPlus(&itsRect, thisObject.data.g.state, isLit);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kMacPlus, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kTV:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (neighbor == kCentralRoom) &&
(!tvInRoom))
{
whoCares = tvScreen1;
ZeroRectCorner(&whoCares);
OffsetRect(&whoCares, itsRect.left + 17, itsRect.top + 10);
GetMovieBox(theMovie, &movieRect);
CenterRectInRect(&movieRect, &whoCares);
SetMovieBox(theMovie, &movieRect);
theRgn = NewRgn();
RectRgn(theRgn, &whoCares);
SetMovieDisplayClipRgn(theMovie, theRgn);
DisposeRgn(theRgn);
tvOn = thisObject.data.g.state;
}
#endif
DrawTV(&itsRect, thisObject.data.g.state, isLit);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kTV, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (neighbor == kCentralRoom) &&
(!tvInRoom))
{
tvWithMovieNumber = dynamicNum;
tvInRoom = true;
}
#endif
}
}
break;
case kCoffee:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawCoffee(&itsRect, thisObject.data.g.state, isLit);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kCoffee, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kOutlet:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
if (isLit)
DrawOutlet(&itsRect);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kOutlet, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kVCR:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawVCR(&itsRect, thisObject.data.g.state, isLit);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kVCR, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kStereo:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawStereo(&itsRect, isPlayMusicGame, isLit);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kStereo, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kMicrowave:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawMicrowave(&itsRect, thisObject.data.g.state, isLit);
if (!redraw)
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kMicrowave, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.g.state);
}
}
break;
case kBalloon:
if ((neighbor == kCentralRoom) && (!redraw))
{
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
QOffsetRect(&itsRect, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kBalloon, &itsRect, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
break;
case kCopterLf:
if ((neighbor == kCentralRoom) && (!redraw))
{
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
QOffsetRect(&itsRect, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kCopterLf, &itsRect, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
break;
case kCopterRt:
if ((neighbor == kCentralRoom) && (!redraw))
{
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
QOffsetRect(&itsRect, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kCopterRt, &itsRect, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
break;
case kDartLf:
if ((neighbor == kCentralRoom) && (!redraw))
{
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
QOffsetRect(&itsRect, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kDartLf, &itsRect, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
break;
case kDartRt:
if ((neighbor == kCentralRoom) && (!redraw))
{
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
QOffsetRect(&itsRect, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kDartRt, &itsRect, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
break;
case kBall:
if ((neighbor == kCentralRoom) && (!redraw))
{
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
QOffsetRect(&itsRect, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kBall, &itsRect, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
break;
case kDrip:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawDrip(&itsRect);
if ((!redraw) && (neighbor == kCentralRoom))
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kDrip, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
}
break;
case kFish:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
{
DrawFish(thisObject.what, &itsRect);
if ((!redraw) && (neighbor == kCentralRoom))
{
rectA = itsRect;
QOffsetRect(&rectA, -playOriginH, -playOriginV);
dynamicNum = AddDynamicObject(kFish, &rectA, &thisObject,
localNumbers[neighbor], i, thisObject.data.h.state);
}
}
break;
case kCobweb:
case kCloud:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawPictWithMaskObject(thisObject.what, &itsRect);
break;
case kMirror:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawMirror(&itsRect);
if ((neighbor == kCentralRoom) && (!redraw))
{
InsetRect(&itsRect, 4, 4);
AddToMirrorRegion(&itsRect);
}
break;
case kMousehole:
case kFaucet:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawSimpleClutter(thisObject.what, &itsRect);
break;
case kFlower:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawFlower(&itsRect, thisObject.data.i.pict);
break;
case kWallWindow:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if (SectRect(&itsRect, &testRect, &whoCares))
DrawWallWindow(&itsRect);
break;
case kCalendar:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawCalendar(&itsRect);
break;
case kBulletin:
GetObjectRect(&thisObject, &itsRect);
OffsetRectRoomRelative(&itsRect, neighbor);
if ((SectRect(&itsRect, &testRect, &whoCares)) && isLit)
DrawBulletin(&itsRect);
break;
}
}
if (!redraw) // set up links
{
for (n = 0; n < numMasterObjects; n++)
{
if ((masterObjects[n].objectNum == i) &&
(masterObjects[n].roomNum == localNumbers[neighbor]))
masterObjects[n].dynaNum = dynamicNum;
}
}
}
HSetState((Handle)thisHouse, wasState);
}

2811
GpApp/ObjectEdit.cpp Normal file

File diff suppressed because it is too large Load Diff

15
GpApp/ObjectEdit.h Normal file
View File

@@ -0,0 +1,15 @@
//============================================================================
//----------------------------------------------------------------------------
// ObjectEdit.h
//----------------------------------------------------------------------------
//============================================================================
#pragma once
#include "PLQuickdraw.h"
extern Rect roomObjectRects[];
extern short objActive;

2568
GpApp/ObjectInfo.cpp Normal file

File diff suppressed because it is too large Load Diff

1188
GpApp/ObjectRects.cpp Normal file

File diff suppressed because it is too large Load Diff

1001
GpApp/Objects.cpp Normal file

File diff suppressed because it is too large Load Diff

42
GpApp/Objects.h Normal file
View File

@@ -0,0 +1,42 @@
//============================================================================
//----------------------------------------------------------------------------
// Objects.h
//----------------------------------------------------------------------------
//============================================================================
extern GWorldPtr blowerSrcMap;
extern GWorldPtr blowerMaskMap;
extern GWorldPtr furnitureSrcMap;
extern GWorldPtr furnitureMaskMap;
extern GWorldPtr bonusSrcMap;
extern GWorldPtr bonusMaskMap;
extern GWorldPtr pointsSrcMap;
extern GWorldPtr pointsMaskMap;
extern GWorldPtr transSrcMap;
extern GWorldPtr transMaskMap;
extern GWorldPtr switchSrcMap;
extern GWorldPtr lightSrcMap;
extern GWorldPtr lightMaskMap;
extern GWorldPtr applianceSrcMap;
extern GWorldPtr applianceMaskMap;
extern GWorldPtr toastSrcMap;
extern GWorldPtr toastMaskMap;
extern GWorldPtr shredSrcMap;
extern GWorldPtr shredMaskMap;
extern GWorldPtr balloonSrcMap;
extern GWorldPtr balloonMaskMap;
extern GWorldPtr copterSrcMap;
extern GWorldPtr copterMaskMap;
extern GWorldPtr dartSrcMap;
extern GWorldPtr dartMaskMap;
extern GWorldPtr ballSrcMap;
extern GWorldPtr ballMaskMap;
extern GWorldPtr dripSrcMap;
extern GWorldPtr dripMaskMap;
extern GWorldPtr enemySrcMap;
extern GWorldPtr enemyMaskMap;
extern GWorldPtr fishSrcMap;
extern GWorldPtr fishMaskMap;
extern GWorldPtr clutterSrcMap;
extern GWorldPtr clutterMaskMap;

821
GpApp/Play.cpp Normal file
View File

@@ -0,0 +1,821 @@
//============================================================================
//----------------------------------------------------------------------------
// Play.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "Scoreboard.h"
#define kHouseBannerAlert 1009
#define kInitialGliders 2
#define kRingDelay 90
#define kRingSpread 25000 // 25000
#define kRingBaseDelay 5000 // 5000
#define kChimeDelay 180
typedef struct
{
short nextRing;
short rings;
short delay;
} phoneType, *phonePtr;
void InitGlider (gliderPtr, short);
void SetHouseToFirstRoom (void);
void SetHouseToSavedRoom (void);
void HandlePlayEvent (void);
void PlayGame (void);
void HandleRoomVisitation (void);
void SetObjectsToDefaults (void);
void InitTelephone (void);
void HandleTelephone (void);
Boolean DoesStarCodeExist (short);
short GetNumStarsRemaining (short, short);
phoneType thePhone, theChimes;
Rect glidSrcRect, justRoomsRect;
GWorldPtr glidSrcMap, glid2SrcMap;
GWorldPtr glidMaskMap;
long gameFrame;
short batteryTotal, bandsTotal, foilTotal, mortals;
Boolean playing, evenFrame, twoPlayerGame, showFoil, demoGoing;
Boolean doBackground, playerSuicide, phoneBitSet, tvOn;
extern WindowPtr menuWindow;
extern FSSpecPtr theHousesSpecs;
extern demoPtr demoData;
extern gameType smallGame;
extern Rect gliderSrc[kNumGliderSrcRects];
extern Rect boardDestRect, boardSrcRect;
extern long incrementModeTime;
extern short numBands, otherPlayerEscaped, demoIndex, demoHouseIndex;
extern short splashOriginH, splashOriginV, countDown, thisHouseIndex;
extern short numStarsRemaining, numChimes, saidFollow;
extern Boolean quitting, isMusicOn, gameOver, hasMirror, onePlayerLeft;
extern Boolean isPlayMusicIdle, failedMusic, quickerTransitions;
extern Boolean switchedOut;
//============================================================== Functions
//-------------------------------------------------------------- NewGame
void NewGame (short mode)
{
Rect tempRect;
Size freeBytes, growBytes;
OSErr theErr;
Boolean wasPlayMusicPref;
AdjustScoreboardHeight();
gameOver = false;
theMode = kPlayMode;
if (isPlayMusicGame)
{
if (!isMusicOn)
{
theErr = StartMusic();
if (theErr != noErr)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
SetMusicalMode(kPlayGameScoreMode);
}
else
{
if (isMusicOn)
StopTheMusic();
}
if (mode != kResumeGameMode)
SetObjectsToDefaults();
HideCursor();
if (mode == kResumeGameMode)
SetHouseToSavedRoom();
else if (mode == kNewGameMode)
SetHouseToFirstRoom();
DetermineRoomOpenings();
NilSavedMaps();
gameFrame = 0L;
numBands = 0;
demoIndex = 0;
saidFollow = 0;
otherPlayerEscaped = kNoOneEscaped;
onePlayerLeft = false;
playerSuicide = false;
if (twoPlayerGame) // initialize glider(s)
{
InitGlider(&theGlider, kNewGameMode);
InitGlider(&theGlider2, kNewGameMode);
SetPort((GrafPtr)glidSrcMap);
LoadGraphic(kGliderPictID);
SetPort((GrafPtr)glid2SrcMap);
LoadGraphic(kGlider2PictID);
}
else
{
InitGlider(&theGlider, mode);
SetPort((GrafPtr)glidSrcMap);
LoadGraphic(kGliderPictID);
SetPort((GrafPtr)glid2SrcMap);
LoadGraphic(kGliderFoilPictID);
}
#if !BUILD_ARCADE_VERSION
// HideMenuBarOld(); // TEMP
#endif
SetPort((GrafPtr)mainWindow); // paint strip on screen black
tempRect = thisMac.screen;
tempRect.top = tempRect.bottom - 20; // thisMac.menuHigh
PaintRect(&tempRect);
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie))
{
SetMovieGWorld(theMovie, (CGrafPtr)mainWindow, nil);
}
#endif
SetPort((GrafPtr)workSrcMap);
PaintRect(&workSrcRect);
// if (quickerTransitions)
// DissBitsChunky(&workSrcRect);
// else
// DissBits(&workSrcRect);
// DebugStr("\pIf screen isn't black, exit to shell."); // TEMP TEMP TEMP
DrawLocale();
RefreshScoreboard(kNormalTitleMode);
// if (quickerTransitions)
// DissBitsChunky(&justRoomsRect);
// else
// DissBits(&justRoomsRect);
if (mode == kNewGameMode)
{
BringUpBanner();
DumpScreenOn(&justRoomsRect);
}
else if (mode == kResumeGameMode)
{
DisplayStarsRemaining();
DumpScreenOn(&justRoomsRect);
}
else
{
DumpScreenOn(&justRoomsRect);
}
InitGarbageRects();
StartGliderFadingIn(&theGlider);
if (twoPlayerGame)
{
StartGliderFadingIn(&theGlider2);
TagGliderIdle(&theGlider2);
theGlider2.dontDraw = true;
}
InitTelephone();
wasPlayMusicPref = isPlayMusicGame;
freeBytes = MaxMem(&growBytes);
#ifdef CREATEDEMODATA
SysBeep(1);
#endif
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom))
{
SetMovieActive(theMovie, true);
if (tvOn)
{
StartMovie(theMovie);
MoviesTask(theMovie, 0);
}
}
#endif
playing = true; // everything before this line is game set-up
PlayGame(); // everything following is after a game has ended
#ifdef CREATEDEMODATA
DumpToResEditFile((Ptr)demoData, sizeof(demoType) * (long)demoIndex);
#endif
isPlayMusicGame = wasPlayMusicPref;
ZeroMirrorRegion();
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom))
{
tvInRoom = false;
StopMovie(theMovie);
SetMovieActive(theMovie, false);
}
#endif
twoPlayerGame = false;
theMode = kSplashMode;
InitCursor();
if (isPlayMusicIdle)
{
if (!isMusicOn)
{
theErr = StartMusic();
if (theErr != noErr)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
SetMusicalMode(kPlayWholeScoreMode);
}
else
{
if (isMusicOn)
StopTheMusic();
}
NilSavedMaps();
SetPortWindowPort(mainWindow);
BlackenScoreboard();
UpdateMenus(false);
if (!gameOver)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
InvalWindowRect(mainWindow, &mainWindowRect);
SetGWorld(workSrcMap, nil);
PaintRect(&workSrcRect);
QSetRect(&tempRect, 0, 0, 640, 460);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(kSplash8BitPICT, &tempRect);
SetGWorld(wasCPort, wasWorld);
}
WaitCommandQReleased();
demoGoing = false;
incrementModeTime = TickCount() + kIdleSplashTicks;
}
//-------------------------------------------------------------- DoDemoGame
void DoDemoGame (void)
{
short wasHouseIndex;
Boolean whoCares;
wasHouseIndex = thisHouseIndex;
whoCares = CloseHouse();
thisHouseIndex = demoHouseIndex;
PasStringCopy(theHousesSpecs[thisHouseIndex].name, thisHouseName);
if (OpenHouse())
{
whoCares = ReadHouse();
demoGoing = true;
NewGame(kNewGameMode);
}
whoCares = CloseHouse();
thisHouseIndex = wasHouseIndex;
PasStringCopy(theHousesSpecs[thisHouseIndex].name, thisHouseName);
if (OpenHouse())
whoCares = ReadHouse();
incrementModeTime = TickCount() + kIdleSplashTicks;
}
//-------------------------------------------------------------- InitGlider
void InitGlider (gliderPtr thisGlider, short mode)
{
WhereDoesGliderBegin(&thisGlider->dest, mode);
if (mode == kResumeGameMode)
numStarsRemaining = smallGame.wasStarsLeft;
else if (mode == kNewGameMode)
numStarsRemaining = CountStarsInHouse();
if (mode == kResumeGameMode)
{
theScore = smallGame.score;
mortals = smallGame.numGliders;
batteryTotal = smallGame.energy;
bandsTotal = smallGame.bands;
foilTotal = smallGame.foil;
thisGlider->mode = smallGame.gliderState;
thisGlider->facing = smallGame.facing;
showFoil = smallGame.showFoil;
switch (thisGlider->mode)
{
case kGliderBurning:
FlagGliderBurning(thisGlider);
break;
default:
FlagGliderNormal(thisGlider);
break;
}
}
else
{
theScore = 0L;
mortals = kInitialGliders;
if (twoPlayerGame)
mortals += kInitialGliders;
batteryTotal = 0;
bandsTotal = 0;
foilTotal = 0;
thisGlider->mode = kGliderNormal;
thisGlider->facing = kFaceRight;
thisGlider->src = gliderSrc[0];
thisGlider->mask = gliderSrc[0];
showFoil = false;
}
QSetRect(&thisGlider->destShadow, 0, 0, kGliderWide, kShadowHigh);
QOffsetRect(&thisGlider->destShadow, thisGlider->dest.left, kShadowTop);
thisGlider->wholeShadow = thisGlider->destShadow;
thisGlider->hVel = 0;
thisGlider->vVel = 0;
thisGlider->hDesiredVel = 0;
thisGlider->vDesiredVel = 0;
thisGlider->tipped = false;
thisGlider->sliding = false;
thisGlider->dontDraw = false;
}
//-------------------------------------------------------------- SetHouseToFirstRoom
void SetHouseToFirstRoom (void)
{
short firstRoom;
firstRoom = GetFirstRoomNumber();
ForceThisRoom(firstRoom);
}
//-------------------------------------------------------------- SetHouseToSavedRoom
void SetHouseToSavedRoom (void)
{
ForceThisRoom(smallGame.roomNumber);
}
//-------------------------------------------------------------- HandlePlayEvent
void HandlePlayEvent (void)
{
EventRecord theEvent;
GrafPtr wasPort;
long sleep = 2;
if (WaitNextEvent(everyEvent, &theEvent, sleep, nil))
{
if ((theEvent.what == updateEvt) &&
((WindowPtr)theEvent.message == mainWindow))
{
GetPort(&wasPort);
SetPortWindowPort(mainWindow);
BeginUpdate(mainWindow);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&justRoomsRect, &justRoomsRect, srcCopy, nil);
RefreshScoreboard(kNormalTitleMode);
EndUpdate(mainWindow);
SetPort(wasPort);
}
else if ((theEvent.what == osEvt) && (theEvent.message & 0x01000000))
{
if (theEvent.message & 0x00000001) // resume event
{
switchedOut = false;
ToggleMusicWhilePlaying();
HideCursor();
// HideMenuBarOld(); // TEMP
}
else // suspend event
{
InitCursor();
switchedOut = true;
ToggleMusicWhilePlaying();
// ShowMenuBarOld(); // TEMP replace with Carbon calls
}
}
}
}
//-------------------------------------------------------------- PlayGame
void PlayGame (void)
{
while ((playing) && (!quitting))
{
gameFrame++;
evenFrame = !evenFrame;
if (doBackground)
{
do
{
HandlePlayEvent();
} while (switchedOut);
}
HandleTelephone();
if (twoPlayerGame)
{
HandleDynamics();
if (!gameOver)
{
GetInput(&theGlider);
GetInput(&theGlider2);
HandleInteraction();
}
HandleTriggers();
HandleBands();
if (!gameOver)
{
HandleGlider(&theGlider);
HandleGlider(&theGlider2);
}
if (playing)
{
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) && (tvOn))
MoviesTask(theMovie, 0);
#endif
RenderFrame();
HandleDynamicScoreboard();
}
}
else
{
HandleDynamics();
if (!gameOver)
{
if (demoGoing)
GetDemoInput(&theGlider);
else
GetInput(&theGlider);
HandleInteraction();
}
HandleTriggers();
HandleBands();
if (!gameOver)
HandleGlider(&theGlider);
if (playing)
{
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) && (tvOn))
MoviesTask(theMovie, 0);
#endif
RenderFrame();
HandleDynamicScoreboard();
}
}
if (gameOver)
{
countDown--;
if (countDown <= 0)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
HideGlider(&theGlider);
RefreshScoreboard(kNormalTitleMode);
#if BUILD_ARCADE_VERSION
// Need to paint over the scoreboard black.
SetGWorld(boardSrcMap, nil);
PaintRect(&boardSrcRect);
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&boardSrcRect, &boardDestRect, srcCopy, 0L);
{
Rect bounds;
PicHandle thePicture;
SInt16 hOffset;
if (boardSrcRect.right >= 640)
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
else
hOffset = -576;
thePicture = GetPicture(kScoreboardPictID);
if (!thePicture)
RedAlert(kErrFailedGraphicLoad);
HLock((Handle)thePicture);
bounds = (*thePicture)->picFrame;
HUnlock((Handle)thePicture);
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, hOffset, 0);
DrawPicture(thePicture, &bounds);
ReleaseResource((Handle)thePicture);
}
#else
// ShowMenuBarOld(); // TEMP
#endif
if (mortals < 0)
DoDiedGameOver();
else
DoGameOver();
SetGWorld(wasCPort, wasWorld);
}
}
}
#if BUILD_ARCADE_VERSION
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(boardSrcMap, nil);
PaintRect(&boardSrcRect);
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&boardSrcRect, &boardDestRect, srcCopy, 0L);
SetGWorld(wasCPort, wasWorld);
}
{
Rect bounds;
PicHandle thePicture;
SInt16 hOffset;
if (boardSrcRect.right >= 640)
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
else
hOffset = -576;
thePicture = GetPicture(kScoreboardPictID);
if (!thePicture)
RedAlert(kErrFailedGraphicLoad);
HLock((Handle)thePicture);
bounds = (*thePicture)->picFrame;
HUnlock((Handle)thePicture);
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, hOffset, 0);
DrawPicture(thePicture, &bounds);
ReleaseResource((Handle)thePicture);
}
#else
// ShowMenuBarOld(); // TEMP
#endif
}
//-------------------------------------------------------------- SetObjectsToDefaults
void SetObjectsToDefaults (void)
{
houseType *thisHousePtr;
short numRooms;
short r, i;
char wasState;
Boolean initState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
for (r = 0; r < numRooms; r++)
{
thisHousePtr->rooms[r].visited = false;
for (i = 0; i < kMaxRoomObs; i++)
{
switch (thisHousePtr->rooms[r].objects[i].what)
{
case kFloorVent:
case kCeilingVent:
case kFloorBlower:
case kCeilingBlower:
case kLeftFan:
case kRightFan:
case kSewerGrate:
case kInvisBlower:
case kGrecoVent:
case kSewerBlower:
case kLiftArea:
thisHousePtr->rooms[r].objects[i].data.a.state =
thisHousePtr->rooms[r].objects[i].data.a.initial;
break;
case kRedClock:
case kBlueClock:
case kYellowClock:
case kCuckoo:
case kPaper:
case kBattery:
case kBands:
case kGreaseRt:
case kGreaseLf:
case kFoil:
case kInvisBonus:
case kStar:
case kSparkle:
case kHelium:
thisHousePtr->rooms[r].objects[i].data.c.state =
thisHousePtr->rooms[r].objects[i].data.c.initial;
break;
case kDeluxeTrans:
initState = (thisHousePtr->rooms[r].objects[i].data.d.wide & 0xF0) >> 4;
thisHousePtr->rooms[r].objects[i].data.d.wide &= 0xF0;
thisHousePtr->rooms[r].objects[i].data.d.wide += initState;
break;
case kCeilingLight:
case kLightBulb:
case kTableLamp:
case kHipLamp:
case kDecoLamp:
case kFlourescent:
case kTrackLight:
case kInvisLight:
thisHousePtr->rooms[r].objects[i].data.f.state =
thisHousePtr->rooms[r].objects[i].data.f.initial;
break;
case kStereo:
thisHousePtr->rooms[r].objects[i].data.g.state = isPlayMusicGame;
break;
case kShredder:
case kToaster:
case kMacPlus:
case kGuitar:
case kTV:
case kCoffee:
case kOutlet:
case kVCR:
case kMicrowave:
thisHousePtr->rooms[r].objects[i].data.g.state =
thisHousePtr->rooms[r].objects[i].data.g.initial;
break;
case kBalloon:
case kCopterLf:
case kCopterRt:
case kDartLf:
case kDartRt:
case kBall:
case kDrip:
case kFish:
thisHousePtr->rooms[r].objects[i].data.h.state =
thisHousePtr->rooms[r].objects[i].data.h.initial;
break;
}
}
}
HSetState((Handle)thisHouse, wasState);
}
//-------------------------------------------------------------- HideGlider
void HideGlider (gliderPtr thisGlider)
{
Rect tempRect;
tempRect = thisGlider->whole;
QOffsetRect(&tempRect, playOriginH, playOriginV);
CopyRectWorkToMain(&tempRect);
if (hasMirror)
{
QOffsetRect(&tempRect, -20, -16);
CopyRectWorkToMain(&tempRect);
}
tempRect = thisGlider->wholeShadow;
QOffsetRect(&tempRect, playOriginH, playOriginV);
CopyRectWorkToMain(&tempRect);
}
//-------------------------------------------------------------- InitTelephone
void InitTelephone (void)
{
thePhone.nextRing = RandomInt(kRingSpread) + kRingBaseDelay;
thePhone.rings = RandomInt(3) + 3;
thePhone.delay = kRingDelay;
theChimes.nextRing = RandomInt(kChimeDelay) + 1;
}
//-------------------------------------------------------------- HandleTelephone
void HandleTelephone (void)
{
short delayTime;
if (!phoneBitSet)
{
if (thePhone.nextRing == 0)
{
if (thePhone.delay == 0)
{
thePhone.delay = kRingDelay;
PlayPrioritySound(kPhoneRingSound, kPhoneRingPriority);
thePhone.rings--;
if (thePhone.rings == 0)
{
thePhone.nextRing = RandomInt(kRingSpread) + kRingBaseDelay;
thePhone.rings = RandomInt(3) + 3;
}
}
else
thePhone.delay--;
}
else
thePhone.nextRing--;
}
// handle also the wind chimes (if they are present)
if (numChimes > 0)
{
if (theChimes.nextRing == 0)
{
if (RandomInt(2) == 0)
PlayPrioritySound(kChime1Sound, kChime1Priority);
else
PlayPrioritySound(kChime2Sound, kChime2Priority);
delayTime = kChimeDelay / numChimes;
if (delayTime < 2)
delayTime = 2;
theChimes.nextRing = RandomInt(delayTime) + 1;
}
else
theChimes.nextRing--;
}
}
//-------------------------------------------------------------- StrikeChime
void StrikeChime (void)
{
theChimes.nextRing = 0;
}
//-------------------------------------------------------------- RestoreEntireGameScreen
void RestoreEntireGameScreen (void)
{
Rect tempRect;
HideCursor();
#if !BUILD_ARCADE_VERSION
// HideMenuBarOld(); // TEMP
#endif
SetPort((GrafPtr)mainWindow);
tempRect = thisMac.screen;
PaintRect(&tempRect);
DrawLocale();
RefreshScoreboard(kNormalTitleMode);
// if (quickerTransitions)
// DissBitsChunky(&justRoomsRect);
// else
// DissBits(&justRoomsRect);
}

13
GpApp/Play.h Normal file
View File

@@ -0,0 +1,13 @@
//============================================================================
//----------------------------------------------------------------------------
// Play.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr glidSrcMap;
extern GWorldPtr glid2SrcMap;
extern GWorldPtr glidMaskMap;

1605
GpApp/Player.cpp Normal file

File diff suppressed because it is too large Load Diff

12
GpApp/Player.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// Player.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr shadowSrcMap;
extern GWorldPtr shadowMaskMap;

0
Prefix.h → GpApp/Prefix.h Executable file → Normal file
View File

269
GpApp/Prefs.cpp Normal file
View File

@@ -0,0 +1,269 @@
//============================================================================
//----------------------------------------------------------------------------
// Prefs.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#define kPrefCreatorType 'ozm5'
#define kPrefFileType 'gliP'
#define kPrefFileName PSTR("Glider Prefs")
#define kDefaultPrefFName PSTR("Preferences")
#define kPrefsStringsID 160
#define kNewPrefsAlertID 160
#define kPrefsFNameIndex 1
Boolean CanUseFindFolder (void);
Boolean GetPrefsFPath (long *, short *);
Boolean CreatePrefsFolder (short *);
Boolean WritePrefs (long *, short *, prefsInfo *);
OSErr ReadPrefs (long *, short *, prefsInfo *);
Boolean DeletePrefs (long *, short *);
void BringUpDeletePrefsAlert (void);
//============================================================== Functions
//-------------------------------------------------------------- CanUseFindFolder
Boolean CanUseFindFolder (void)
{
return true;
}
//-------------------------------------------------------------- GetPrefsFPath
Boolean GetPrefsFPath (long *prefDirID, short *systemVolRef)
{
OSErr theErr;
theErr = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
systemVolRef, prefDirID);
if (theErr != noErr)
return(false);
return(true);
}
//-------------------------------------------------------------- CreatePrefsFolder
Boolean CreatePrefsFolder (short *systemVolRef)
{
HFileParam fileParamBlock;
Str255 folderName;
OSErr theErr;
GetIndString(folderName, kPrefsStringsID, kPrefsFNameIndex);
fileParamBlock.ioVRefNum = *systemVolRef;
fileParamBlock.ioDirID = 0;
fileParamBlock.ioNamePtr = folderName;
fileParamBlock.ioCompletion = nil;
theErr = PBDirCreate(&fileParamBlock, false);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(false);
}
return(true);
}
//-------------------------------------------------------------- WritePrefs
Boolean WritePrefs (long *prefDirID, short *systemVolRef, prefsInfo *thePrefs)
{
OSErr theErr;
short fileRefNum;
long byteCount;
FSSpec theSpecs;
Str255 fileName;
PasStringCopy(kPrefFileName, fileName);
theErr = FSMakeFSSpec(*systemVolRef, *prefDirID, fileName, &theSpecs);
if (theErr != noErr)
{
if (theErr != fnfErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(false);
}
theErr = FSpCreate(&theSpecs, kPrefCreatorType, kPrefFileType, smSystemScript);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(false);
}
}
theErr = FSpOpenDF(&theSpecs, fsRdWrPerm, &fileRefNum);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(false);
}
byteCount = sizeof(*thePrefs);
theErr = FSWrite(fileRefNum, &byteCount, thePrefs);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(false);
}
theErr = FSClose(fileRefNum);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(false);
}
return(true);
}
//-------------------------------------------------------------- SavePrefs
Boolean SavePrefs (prefsInfo *thePrefs, short versionNow)
{
long prefDirID;
short systemVolRef;
thePrefs->prefVersion = versionNow;
if (!GetPrefsFPath(&prefDirID, &systemVolRef))
return(false);
if (!WritePrefs(&prefDirID, &systemVolRef, thePrefs))
return(false);
return(true);
}
//-------------------------------------------------------------- ReadPrefs
OSErr ReadPrefs (long *prefDirID, short *systemVolRef, prefsInfo *thePrefs)
{
OSErr theErr;
short fileRefNum;
long byteCount;
FSSpec theSpecs;
Str255 fileName;
PasStringCopy(kPrefFileName, fileName);
theErr = FSMakeFSSpec(*systemVolRef, *prefDirID, fileName, &theSpecs);
if (theErr != noErr)
{
if (theErr == fnfErr)
return(theErr);
else
{
CheckFileError(theErr, PSTR("Preferences"));
return(theErr);
}
}
theErr = FSpOpenDF(&theSpecs, fsRdWrPerm, &fileRefNum);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(theErr);
}
byteCount = sizeof(*thePrefs);
theErr = FSRead(fileRefNum, &byteCount, thePrefs);
if (theErr != noErr)
{
if (theErr == eofErr)
theErr = FSClose(fileRefNum);
else
{
CheckFileError(theErr, PSTR("Preferences"));
theErr = FSClose(fileRefNum);
}
return(theErr);
}
theErr = FSClose(fileRefNum);
if (theErr != noErr)
{
CheckFileError(theErr, PSTR("Preferences"));
return(theErr);
}
return(theErr);
}
//-------------------------------------------------------------- DeletePrefs
Boolean DeletePrefs (long *dirID, short *volRef)
{
FSSpec theSpecs;
Str255 fileName;
OSErr theErr;
PasStringCopy(kPrefFileName, fileName);
theErr = FSMakeFSSpec(*volRef, *dirID, fileName, &theSpecs);
if (theErr != noErr)
return(false);
else
theErr = FSpDelete(&theSpecs);
if (theErr != noErr)
return(false);
return(true);
}
//-------------------------------------------------------------- LoadPrefs
Boolean LoadPrefs (prefsInfo *thePrefs, short versionNeed)
{
long prefDirID;
OSErr theErr;
short systemVolRef;
Boolean noProblems;
noProblems = GetPrefsFPath(&prefDirID, &systemVolRef);
if (!noProblems)
return(false);
theErr = ReadPrefs(&prefDirID, &systemVolRef, thePrefs);
if (theErr == eofErr)
{
BringUpDeletePrefsAlert();
noProblems = DeletePrefs(&prefDirID, &systemVolRef);
return (false);
}
else if (theErr != noErr)
return (false);
if (thePrefs->prefVersion != versionNeed)
{
BringUpDeletePrefsAlert();
noProblems = DeletePrefs(&prefDirID, &systemVolRef);
return(false);
}
return (true);
}
//-------------------------------------------------------------- BringUpDeletePrefsAlert
void BringUpDeletePrefsAlert (void)
{
short whoCares;
InitCursor();
// CenterAlert(kNewPrefsAlertID);
whoCares = Alert(kNewPrefsAlertID, nil);
}

318
GpApp/RectUtils.cpp Normal file
View File

@@ -0,0 +1,318 @@
//============================================================================
//----------------------------------------------------------------------------
// RectUtils.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "RectUtils.h"
//============================================================== Functions
//-------------------------------------------------------------- FrameWHRect
// Given the top left corner and a width and height, this function<6F>
// simply creates the necessary rectangle and frames it.
void FrameWHRect (short left, short top, short wide, short high)
{
Rect theRect;
theRect.left = left;
theRect.top = top;
theRect.right = left + wide;
theRect.bottom = top + high;
FrameRect(&theRect);
}
//-------------------------------------------------------------- NormalizeRect
// This function ensures that a rect's top is less than it's bottom<6F>
// and that left is less than right.
void NormalizeRect (Rect *theRect)
{
short tempSide;
if (theRect->left > theRect->right)
{
tempSide = theRect->left;
theRect->left = theRect->right;
theRect->right = tempSide;
}
if (theRect->top > theRect->bottom)
{
tempSide = theRect->top;
theRect->top = theRect->bottom;
theRect->bottom = tempSide;
}
}
//-------------------------------------------------------------- ZeroRectCorner
// The rect passed in is slid over so that its top left corner is<69>
// at coordinates (0, 0).
void ZeroRectCorner (Rect *theRect) // Offset rect to (0, 0)
{
theRect->right -= theRect->left;
theRect->bottom -= theRect->top;
theRect->left = 0;
theRect->top = 0;
}
//-------------------------------------------------------------- CenterRectOnPoint
// Given a rectangle and a point, this function centers the rectangle<6C>
// on that point.
void CenterRectOnPoint (Rect *theRect, Point where)
{
ZeroRectCorner(theRect);
QOffsetRect(theRect, -HalfRectWide(theRect), -HalfRectTall(theRect));
QOffsetRect(theRect, where.h, where.v);
}
//-------------------------------------------------------------- HalfRectWide
// Given a rectangle, this function returns the rect's width divided by 2.
short HalfRectWide (Rect *theRect)
{
return ((theRect->right - theRect->left) / 2);
}
//-------------------------------------------------------------- HalfRectTall
// Given a rectangle, this function returns the rect's height divided by 2.
short HalfRectTall (Rect *theRect)
{
return ((theRect->bottom - theRect->top) / 2);
}
//-------------------------------------------------------------- RectWide
// Given a rectangle, this simple function returns the rect's width.
short RectWide (Rect *theRect)
{
return (theRect->right - theRect->left);
}
//-------------------------------------------------------------- RectTall
// Given a rectangle, this simple function returns the rect's height.
short RectTall (Rect *theRect)
{
return (theRect->bottom - theRect->top);
}
//-------------------------------------------------------------- GlobalToLocalRect
// This function offsets a rectangle from global to local coordinates.
// The "local" coordinate system is assumed to be the current port (window).
void GlobalToLocalRect (Rect *theRect)
{
Point upperLeftPt;
upperLeftPt.h = 0;
upperLeftPt.v = 0;
GlobalToLocal(&upperLeftPt);
QOffsetRect(theRect, upperLeftPt.h, upperLeftPt.v);
}
//-------------------------------------------------------------- LocalToGlobalRect
// This function offsets a rectangle from local to global coordinates.
// The "local" coordinate system is assumed to be the current port (window).
void LocalToGlobalRect (Rect *theRect)
{
Point upperLeftPt;
upperLeftPt.h = 0;
upperLeftPt.v = 0;
LocalToGlobal(&upperLeftPt);
QOffsetRect(theRect, upperLeftPt.h, upperLeftPt.v);
}
//-------------------------------------------------------------- CenterRectInRect
// Given two rectangles, this function centers the first rectangle<6C>
// within the second. The second rect is unchanged.
void CenterRectInRect (Rect *rectA, Rect *rectB)
{
short widthA, tallA;
widthA = RectWide(rectA);
tallA = RectTall(rectA);
rectA->left = rectB->left + (RectWide(rectB) - widthA) / 2;
rectA->right = rectA->left + widthA;
rectA->top = rectB->top + (RectTall(rectB) - tallA) / 2;
rectA->bottom = rectA->top + tallA;
}
//-------------------------------------------------------------- HOffsetRect
// Just a simple function to offset a rectangle horizontally only.
void HOffsetRect (Rect *theRect, short h)
{
theRect->left += h;
theRect->right += h;
}
//-------------------------------------------------------------- VOffsetRect
// Just a simple function to offset a rectangle vertically only.
void VOffsetRect (Rect *theRect, short v)
{
theRect->top += v;
theRect->bottom += v;
}
//-------------------------------------------------------------- IsRectLeftOfRect
// Given two rects, this function returns true if the first rectangle<6C>
// is to the left of the second.
Boolean IsRectLeftOfRect (Rect *rect1, Rect *rect2)
{
short offset;
offset = (rect1->right - rect1->left) - (rect2->right - rect2->left) / 2;
if ((rect1->left) < (rect2->left + offset))
return (true);
else
return (false);
}
//-------------------------------------------------------------- QOffsetRect
// This duplicates a Mac ToolBox call, but since it's local, it's faster.
// It offsets a rectangle both vertically and horizontally.
void QOffsetRect (Rect *theRect, short h, short v)
{
theRect->right += h;
theRect->left += h;
theRect->bottom += v;
theRect->top += v;
}
//-------------------------------------------------------------- QSetRect
// This also duplicates a ToolBox call. It's needed often though, so<73>
// any gains in speed are nice. It sets up a rect structure.
void QSetRect (Rect *theRect, short l, short t, short r, short b)
{
theRect->left = l;
theRect->top = t;
theRect->right = r;
theRect->bottom = b;
}
//-------------------------------------------------------------- ForceRectInRect
// Given a source rectangle and a bounding rectangle, this function<6F>
// will clip the source rect so that it is entirely within the bounding<6E>
// rect. It returns true if any clippiung was necessary.
Boolean ForceRectInRect (Rect *small, Rect *large)
{
SInt16 hOff, vOff;
Boolean changed;
changed = false;
NormalizeRect(small);
if ((small->bottom - small->top) > (large->bottom - large->top))
{
small->bottom = small->top + (large->bottom - large->top);
changed = true;
}
if ((small->right - small->left) > (large->right - large->left))
{
small->right = small->left + (large->right - large->left);
changed = true;
}
hOff = large->left - small->left;
if (hOff > 0)
{
OffsetRect(small, hOff, 0);
changed = true;
}
hOff = large->right - small->right;
if (hOff < 0)
{
OffsetRect(small, hOff, 0);
changed = true;
}
vOff = large->top - small->top;
if (vOff > 0)
{
OffsetRect(small, 0, vOff);
changed = true;
}
vOff = large->bottom - small->bottom;
if (vOff < 0)
{
OffsetRect(small, 0, vOff);
changed = true;
}
return changed;
}
//-------------------------------------------------------------- QUnionSimilarRect
// Given 2 rects that are assumed to have the same width and height,<2C>
// this function returns a 3rd rect that is the union of those two.
void QUnionSimilarRect (Rect *rectA, Rect *rectB, Rect *rectC)
{
if (rectA->left < rectB->left)
rectC->left = rectA->left;
else
rectC->left = rectB->left;
if (rectA->top < rectB->top)
rectC->top = rectA->top;
else
rectC->top = rectB->top;
if (rectA->right > rectB->right)
rectC->right = rectA->right;
else
rectC->right = rectB->right;
if (rectA->bottom > rectB->bottom)
rectC->bottom = rectA->bottom;
else
rectC->bottom = rectB->bottom;
}
//-------------------------------------------------------------- FrameRectSansCorners
// This is similar to the ToolBox FrameRect() call. However, it doesn't<>
// draw the pixels in the 4 corners of the Rect.
void FrameRectSansCorners (Rect *theRect)
{
MoveTo(theRect->left + 1, theRect->top);
LineTo(theRect->right - 2, theRect->top);
MoveTo(theRect->right - 1, theRect->top + 1);
LineTo(theRect->right - 1, theRect->bottom - 2);
MoveTo(theRect->left + 1, theRect->bottom - 1);
LineTo(theRect->right - 2, theRect->bottom - 1);
MoveTo(theRect->left, theRect->top + 1);
LineTo(theRect->left, theRect->bottom - 2);
}

33
GpApp/RectUtils.h Normal file
View File

@@ -0,0 +1,33 @@
//============================================================================
//----------------------------------------------------------------------------
// RectUtils.h
//----------------------------------------------------------------------------
//============================================================================
#pragma once
#include "PLQuickdraw.h"
void FrameWHRect (short, short, short, short);
void NormalizeRect (Rect *);
void ZeroRectCorner (Rect *);
void CenterRectOnPoint (Rect *, Point);
short HalfRectWide (Rect *);
short HalfRectTall (Rect *);
short RectWide (Rect *);
short RectTall (Rect *);
void GlobalToLocalRect (Rect *);
void LocalToGlobalRect (Rect *);
void CenterRectInRect (Rect *, Rect *);
void HOffsetRect (Rect *, short);
void VOffsetRect (Rect *, short);
Boolean IsRectLeftOfRect (Rect *, Rect *);
void QOffsetRect (Rect *, short, short);
void QSetRect (Rect *, short, short, short, short);
Boolean ForceRectInRect (Rect *, Rect *);
void QUnionSimilarRect (Rect *, Rect *, Rect *);
void FrameRectSansCorners (Rect *);
void SetEraseRect (short, short, short, short);

772
GpApp/Render.cpp Normal file
View File

@@ -0,0 +1,772 @@
//============================================================================
//----------------------------------------------------------------------------
// Render.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "Play.h"
#include "Player.h"
#include "RectUtils.h"
#include "Room.h"
#include "RubberBands.h"
#define kMaxGarbageRects 48
void DrawReflection (gliderPtr, Boolean);
void RenderFlames (void);
void RenderPendulums (void);
void RenderFlyingPoints (void);
void RenderSparkles (void);
void RenderStars (void);
void RenderBands (void);
void RenderShreds (void);
void CopyRectsQD (void);
void CopyRectsAssm (void);
Rect work2MainRects[kMaxGarbageRects];
Rect back2WorkRects[kMaxGarbageRects];
Rect shieldRect;
RgnHandle mirrorRgn;
Point shieldPt;
long nextFrame;
short numWork2Main, numBack2Work;
Boolean hasMirror;
extern bandPtr bands;
extern sparklePtr sparkles;
extern flyingPtPtr flyingPoints;
extern flamePtr flames, tikiFlames, bbqCoals;
extern pendulumPtr pendulums;
extern starPtr theStars;
extern shredPtr shreds;
extern Rect sparkleSrc[];
extern Rect pointsSrc[];
extern Rect bandRects[];
extern savedType savedMaps[];
extern Rect shadowSrc[], justRoomsRect, movieRect;
extern short numBands, numStars, numShredded;
extern short numSparkles, numFlyingPts, numPendulums, clockFrame;
extern short numFlames, numSavedMaps, numTikiFlames, numCoals;
extern Boolean evenFrame, shadowVisible, twoPlayerGame, tvOn;
//============================================================== Functions
//-------------------------------------------------------------- AddRectToWorkRects
void AddRectToWorkRects (Rect *theRect)
{
if (numWork2Main < (kMaxGarbageRects - 1))
{
work2MainRects[numWork2Main] = *theRect;
if (work2MainRects[numWork2Main].left < justRoomsRect.left)
work2MainRects[numWork2Main].left = justRoomsRect.left;
else if (work2MainRects[numWork2Main].right > justRoomsRect.right)
work2MainRects[numWork2Main].right = justRoomsRect.right;
if (work2MainRects[numWork2Main].top < justRoomsRect.top)
work2MainRects[numWork2Main].top = justRoomsRect.top;
else if (work2MainRects[numWork2Main].bottom > justRoomsRect.bottom)
work2MainRects[numWork2Main].bottom = justRoomsRect.bottom;
numWork2Main++;
}
}
//-------------------------------------------------------------- AddRectToBackRects
void AddRectToBackRects (Rect *theRect)
{
if (numBack2Work < (kMaxGarbageRects - 1))
{
back2WorkRects[numBack2Work] = *theRect;
if (back2WorkRects[numBack2Work].left < 0)
back2WorkRects[numBack2Work].left = 0;
else if (back2WorkRects[numBack2Work].right > workSrcRect.right)
back2WorkRects[numBack2Work].right = workSrcRect.right;
if (back2WorkRects[numBack2Work].top < 0)
back2WorkRects[numBack2Work].top = 0;
else if (back2WorkRects[numBack2Work].bottom > workSrcRect.bottom)
back2WorkRects[numBack2Work].bottom = workSrcRect.bottom;
numBack2Work++;
}
}
//-------------------------------------------------------------- AddRectToWorkRectsWhole
void AddRectToWorkRectsWhole (Rect *theRect)
{
if (numWork2Main < (kMaxGarbageRects - 1))
{
if ((theRect->right <= workSrcRect.left) ||
(theRect->bottom <= workSrcRect.top) ||
(theRect->left >= workSrcRect.right) ||
(theRect->top >= workSrcRect.bottom))
return;
work2MainRects[numWork2Main] = *theRect;
if (work2MainRects[numWork2Main].left < workSrcRect.left)
work2MainRects[numWork2Main].left = workSrcRect.left;
else if (work2MainRects[numWork2Main].right > workSrcRect.right)
work2MainRects[numWork2Main].right = workSrcRect.right;
if (work2MainRects[numWork2Main].top < workSrcRect.top)
work2MainRects[numWork2Main].top = workSrcRect.top;
else if (work2MainRects[numWork2Main].bottom > workSrcRect.bottom)
work2MainRects[numWork2Main].bottom = workSrcRect.bottom;
if ((work2MainRects[numWork2Main].right ==
work2MainRects[numWork2Main].left) ||
(work2MainRects[numWork2Main].top ==
work2MainRects[numWork2Main].bottom))
return;
numWork2Main++;
}
}
//-------------------------------------------------------------- DrawReflection
void DrawReflection (gliderPtr thisGlider, Boolean oneOrTwo)
{
RgnHandle wasClip;
Rect src, dest;
short which;
if (thisGlider->dontDraw)
return;
if (thisGlider->facing == kFaceRight)
which = 0;
else
which = 1;
dest = thisGlider->dest;
QOffsetRect(&dest, playOriginH - 20, playOriginV - 16);
wasClip = NewRgn();
if (wasClip == nil)
return;
SetPort((GrafPtr)workSrcMap);
GetClip(wasClip);
SetClip(mirrorRgn);
if (oneOrTwo)
{
if (showFoil)
CopyMask((BitMap *)*GetGWorldPixMap(glid2SrcMap),
(BitMap *)*GetGWorldPixMap(glidMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&thisGlider->src, &thisGlider->mask, &dest);
else
CopyMask((BitMap *)*GetGWorldPixMap(glidSrcMap),
(BitMap *)*GetGWorldPixMap(glidMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&thisGlider->src, &thisGlider->mask, &dest);
}
else
{
CopyMask((BitMap *)*GetGWorldPixMap(glid2SrcMap),
(BitMap *)*GetGWorldPixMap(glidMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&thisGlider->src, &thisGlider->mask, &dest);
}
SetClip(wasClip);
DisposeRgn(wasClip);
src =thisGlider->whole;
QOffsetRect(&src, playOriginH - 20, playOriginV - 16);
AddRectToWorkRects(&src);
AddRectToBackRects(&dest);
}
//-------------------------------------------------------------- RenderFlames
void RenderFlames (void)
{
short i;
if ((numFlames == 0) && (numTikiFlames == 0) && (numCoals == 0))
return;
for (i = 0; i < numFlames; i++)
{
flames[i].mode++;
flames[i].src.top += 15;
flames[i].src.bottom += 15;
if (flames[i].mode >= kNumCandleFlames)
{
flames[i].mode = 0;
flames[i].src.top = 0;
flames[i].src.bottom = 15;
}
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[flames[i].who].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&flames[i].src, &flames[i].dest, srcCopy, nil);
AddRectToWorkRects(&flames[i].dest);
}
for (i = 0; i < numTikiFlames; i++)
{
tikiFlames[i].mode++;
tikiFlames[i].src.top += 10;
tikiFlames[i].src.bottom += 10;
if (tikiFlames[i].mode >= kNumTikiFlames)
{
tikiFlames[i].mode = 0;
tikiFlames[i].src.top = 0;
tikiFlames[i].src.bottom = 10;
}
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[tikiFlames[i].who].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&tikiFlames[i].src, &tikiFlames[i].dest, srcCopy, nil);
AddRectToWorkRects(&tikiFlames[i].dest);
}
for (i = 0; i < numCoals; i++)
{
bbqCoals[i].mode++;
bbqCoals[i].src.top += 9;
bbqCoals[i].src.bottom += 9;
if (bbqCoals[i].mode >= kNumBBQCoals)
{
bbqCoals[i].mode = 0;
bbqCoals[i].src.top = 0;
bbqCoals[i].src.bottom = 9;
}
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[bbqCoals[i].who].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&bbqCoals[i].src, &bbqCoals[i].dest, srcCopy, nil);
AddRectToWorkRects(&bbqCoals[i].dest);
}
}
//-------------------------------------------------------------- RenderPendulums
void RenderPendulums (void)
{
short i;
Boolean playedTikTok;
playedTikTok = false;
if (numPendulums == 0)
return;
clockFrame++;
if ((clockFrame == 10) || (clockFrame == 15))
{
if (clockFrame >= 15)
clockFrame = 0;
for (i = 0; i < numPendulums; i++)
{
if (pendulums[i].active)
{
if (pendulums[i].toOrFro)
{
pendulums[i].mode++;
pendulums[i].src.top += 28;
pendulums[i].src.bottom += 28;
if (pendulums[i].mode >= 2)
{
pendulums[i].toOrFro = !pendulums[i].toOrFro;
if (!playedTikTok)
{
PlayPrioritySound(kTikSound, kTikPriority);
playedTikTok = true;
}
}
}
else
{
pendulums[i].mode--;
pendulums[i].src.top -= 28;
pendulums[i].src.bottom -= 28;
if (pendulums[i].mode <= 0)
{
pendulums[i].toOrFro = !pendulums[i].toOrFro;
if (!playedTikTok)
{
PlayPrioritySound(kTokSound, kTokPriority);
playedTikTok = true;
}
}
}
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[pendulums[i].who].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&pendulums[i].src, &pendulums[i].dest, srcCopy, nil);
AddRectToWorkRects(&pendulums[i].dest);
}
}
}
}
//-------------------------------------------------------------- RenderFlyingPoints
void RenderFlyingPoints (void)
{
short i;
if (numFlyingPts == 0)
return;
for (i = 0; i < kMaxFlyingPts; i++)
{
if (flyingPoints[i].mode != -1)
{
if (flyingPoints[i].mode > flyingPoints[i].stop)
{
flyingPoints[i].mode = flyingPoints[i].start;
flyingPoints[i].loops++;
}
if (flyingPoints[i].loops >= kMaxFlyingPointsLoop)
{
AddRectToWorkRects(&flyingPoints[i].dest);
flyingPoints[i].mode = -1;
numFlyingPts--;
}
else
{
flyingPoints[i].dest.left += flyingPoints[i].hVel;
flyingPoints[i].dest.right += flyingPoints[i].hVel;
if (flyingPoints[i].hVel > 0)
flyingPoints[i].whole.right = flyingPoints[i].dest.right;
else
flyingPoints[i].whole.left = flyingPoints[i].dest.left;
flyingPoints[i].dest.top += flyingPoints[i].vVel;
flyingPoints[i].dest.bottom += flyingPoints[i].vVel;
if (flyingPoints[i].vVel > 0)
flyingPoints[i].whole.bottom = flyingPoints[i].dest.bottom;
else
flyingPoints[i].whole.top = flyingPoints[i].dest.top;
CopyMask((BitMap *)*GetGWorldPixMap(pointsSrcMap),
(BitMap *)*GetGWorldPixMap(pointsMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&pointsSrc[flyingPoints[i].mode],
&pointsSrc[flyingPoints[i].mode],
&flyingPoints[i].dest);
AddRectToWorkRects(&flyingPoints[i].whole);
AddRectToBackRects(&flyingPoints[i].dest);
flyingPoints[i].whole = flyingPoints[i].dest;
flyingPoints[i].mode++;
}
}
}
}
//-------------------------------------------------------------- RenderSparkles
void RenderSparkles (void)
{
short i;
if (numSparkles == 0)
return;
for (i = 0; i < kMaxSparkles; i++)
{
if (sparkles[i].mode != -1)
{
if (sparkles[i].mode >= kNumSparkleModes)
{
AddRectToWorkRects(&sparkles[i].bounds);
sparkles[i].mode = -1;
numSparkles--;
}
else
{
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap *)*GetGWorldPixMap(bonusMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&sparkleSrc[sparkles[i].mode],
&sparkleSrc[sparkles[i].mode],
&sparkles[i].bounds);
AddRectToWorkRects(&sparkles[i].bounds);
AddRectToBackRects(&sparkles[i].bounds);
sparkles[i].mode++;
}
}
}
}
//-------------------------------------------------------------- RenderStars
void RenderStars (void)
{
short i;
if (numStars == 0)
return;
for (i = 0; i < numStars; i++)
{
if (theStars[i].mode != -1)
{
theStars[i].mode++;
theStars[i].src.top += 31;
theStars[i].src.bottom += 31;
if (theStars[i].mode >= 6)
{
theStars[i].mode = 0;
theStars[i].src.top = 0;
theStars[i].src.bottom = 31;
}
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[theStars[i].who].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&theStars[i].src, &theStars[i].dest, srcCopy, nil);
AddRectToWorkRects(&theStars[i].dest);
}
}
}
//-------------------------------------------------------------- RenderGlider
void RenderGlider (gliderPtr thisGlider, Boolean oneOrTwo)
{
Rect src, dest;
short which;
if (thisGlider->dontDraw)
return;
if (thisGlider->facing == kFaceRight)
which = 0;
else
which = 1;
if (shadowVisible)
{
dest = thisGlider->destShadow;
QOffsetRect(&dest, playOriginH, playOriginV);
if ((thisGlider->mode == kGliderComingUp) ||
(thisGlider->mode == kGliderGoingDown))
{
src = shadowSrc[which];
src.right = src.left + (dest.right - dest.left);
CopyMask((BitMap *)*GetGWorldPixMap(shadowSrcMap),
(BitMap *)*GetGWorldPixMap(shadowMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
}
else if (thisGlider->mode == kGliderComingDown)
{
src = shadowSrc[which];
src.left = src.right - (dest.right - dest.left);
CopyMask((BitMap *)*GetGWorldPixMap(shadowSrcMap),
(BitMap *)*GetGWorldPixMap(shadowMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
}
else
CopyMask((BitMap *)*GetGWorldPixMap(shadowSrcMap),
(BitMap *)*GetGWorldPixMap(shadowMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&shadowSrc[which], &shadowSrc[which], &dest);
src =thisGlider->wholeShadow;
QOffsetRect(&src, playOriginH, playOriginV);
AddRectToWorkRects(&src);
AddRectToBackRects(&dest);
}
dest = thisGlider->dest;
QOffsetRect(&dest, playOriginH, playOriginV);
if (oneOrTwo)
{
if ((!twoPlayerGame) && (showFoil))
CopyMask((BitMap *)*GetGWorldPixMap(glid2SrcMap),
(BitMap *)*GetGWorldPixMap(glidMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&thisGlider->src, &thisGlider->mask, &dest);
else
CopyMask((BitMap *)*GetGWorldPixMap(glidSrcMap),
(BitMap *)*GetGWorldPixMap(glidMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&thisGlider->src, &thisGlider->mask, &dest);
}
else
{
CopyMask((BitMap *)*GetGWorldPixMap(glid2SrcMap),
(BitMap *)*GetGWorldPixMap(glidMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&thisGlider->src, &thisGlider->mask, &dest);
}
src =thisGlider->whole;
QOffsetRect(&src, playOriginH, playOriginV);
AddRectToWorkRects(&src);
AddRectToBackRects(&dest);
}
//-------------------------------------------------------------- RenderBands
void RenderBands (void)
{
Rect dest;
short i;
if (numBands == 0)
return;
for (i = 0; i < numBands; i++)
{
dest = bands[i].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
CopyMask((BitMap *)*GetGWorldPixMap(bandsSrcMap),
(BitMap *)*GetGWorldPixMap(bandsMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&bandRects[bands[i].mode],
&bandRects[bands[i].mode], &dest);
AddRectToWorkRects(&dest);
AddRectToBackRects(&dest);
}
}
//-------------------------------------------------------------- RenderShreds
void RenderShreds (void)
{
Rect src, dest;
short i, high;
if (numShredded > 0)
{
for (i = 0; i < numShredded; i++)
{
if (shreds[i].frame == 0)
{
shreds[i].bounds.bottom += 1;
high = shreds[i].bounds.bottom - shreds[i].bounds.top;
if (high >= 35)
shreds[i].frame = 1;
src = shredSrcRect;
src.top = src.bottom - high;
dest = shreds[i].bounds;
QOffsetRect(&dest, playOriginH, playOriginV);
CopyMask((BitMap *)*GetGWorldPixMap(shredSrcMap),
(BitMap *)*GetGWorldPixMap(shredMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &src, &dest);
AddRectToBackRects(&dest);
dest.top--;
AddRectToWorkRects(&dest);
PlayPrioritySound(kShredSound, kShredPriority);
}
else if (shreds[i].frame < 20)
{
shreds[i].bounds.top += 4;
shreds[i].bounds.bottom += 4;
dest = shreds[i].bounds;
QOffsetRect(&dest, playOriginH, playOriginV);
shreds[i].frame++;
if (shreds[i].frame < 20)
{
CopyMask((BitMap *)*GetGWorldPixMap(shredSrcMap),
(BitMap *)*GetGWorldPixMap(shredMaskMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&shredSrcRect, &shredSrcRect, &dest);
}
else
{
AddSparkle(&shreds[i].bounds);
PlayPrioritySound(kFadeOutSound, kFadeOutPriority);
}
AddRectToBackRects(&dest);
dest.top -= 4;
AddRectToWorkRects(&dest);
}
}
}
}
//-------------------------------------------------------------- CopyRectsQD
void CopyRectsQD (void)
{
short i;
for (i = 0; i < numWork2Main; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&work2MainRects[i], &work2MainRects[i],
srcCopy, nil);
}
for (i = 0; i < numBack2Work; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&back2WorkRects[i], &back2WorkRects[i],
srcCopy, nil);
}
}
//-------------------------------------------------------------- RenderFrame
void RenderFrame (void)
{
if (hasMirror)
{
DrawReflection(&theGlider, true);
if (twoPlayerGame)
DrawReflection(&theGlider2, false);
}
HandleGrease();
RenderPendulums();
if (evenFrame)
RenderFlames();
else
RenderStars();
RenderDynamics();
RenderFlyingPoints();
RenderSparkles();
RenderGlider(&theGlider, true);
if (twoPlayerGame)
RenderGlider(&theGlider2, false);
RenderShreds();
RenderBands();
while (TickCount() < nextFrame)
{
}
nextFrame = TickCount() + kTicksPerFrame;
CopyRectsQD();
numWork2Main = 0;
numBack2Work = 0;
}
//-------------------------------------------------------------- InitGarbageRects
void InitGarbageRects (void)
{
short i;
numWork2Main = 0;
numBack2Work = 0;
numSparkles = 0;
for (i = 0; i < kMaxSparkles; i++)
sparkles[i].mode = -1;
numFlyingPts = 0;
for (i = 0; i < kMaxFlyingPts; i++)
flyingPoints[i].mode = -1;
nextFrame = TickCount() + kTicksPerFrame;
}
//-------------------------------------------------------------- CopyRectBackToWork
void CopyRectBackToWork (Rect *theRect)
{
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
theRect, theRect, srcCopy, nil);
}
//-------------------------------------------------------------- CopyRectWorkToBack
void CopyRectWorkToBack (Rect *theRect)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
theRect, theRect, srcCopy, nil);
}
//-------------------------------------------------------------- CopyRectWorkToMain
void CopyRectWorkToMain (Rect *theRect)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
theRect, theRect, srcCopy, nil);
}
//-------------------------------------------------------------- CopyRectMainToWork
void CopyRectMainToWork (Rect *theRect)
{
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
(BitMap *)*GetGWorldPixMap(workSrcMap),
theRect, theRect, srcCopy, nil);
}
//-------------------------------------------------------------- CopyRectMainToBack
void CopyRectMainToBack (Rect *theRect)
{
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
(BitMap *)*GetGWorldPixMap(backSrcMap),
theRect, theRect, srcCopy, nil);
}
//-------------------------------------------------------------- AddToMirrorRegion
void AddToMirrorRegion (Rect *theRect)
{
RgnHandle tempRgn;
if (mirrorRgn == nil)
{
mirrorRgn = NewRgn();
if (mirrorRgn != nil)
RectRgn(mirrorRgn, theRect);
}
else
{
tempRgn = NewRgn();
if (tempRgn != nil)
{
RectRgn(tempRgn, theRect);
UnionRgn(mirrorRgn, tempRgn, mirrorRgn);
DisposeRgn(tempRgn);
}
}
hasMirror = true;
}
//-------------------------------------------------------------- ZeroMirrorRegion
void ZeroMirrorRegion (void)
{
if (mirrorRgn != nil)
DisposeRgn(mirrorRgn);
mirrorRgn = nil;
hasMirror = false;
}

1207
GpApp/Room.cpp Normal file

File diff suppressed because it is too large Load Diff

12
GpApp/Room.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// Room.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr backSrcMap;

461
GpApp/RoomGraphics.cpp Normal file
View File

@@ -0,0 +1,461 @@
//============================================================================
//----------------------------------------------------------------------------
// RoomGraphics.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "Room.h"
#define kManholeThruFloor 3957
void LoadGraphicSpecial (short);
void DrawRoomBackground (short, short, short);
void DrawFloorSupport (void);
void ReadyBackMap (void);
void RestoreWorkMap (void);
void DrawLighting (void);
Rect suppSrcRect;
GWorldPtr suppSrcMap;
Rect localRoomsDest[9];
Rect houseRect;
short numNeighbors, numLights, thisTiles[kNumTiles];
short localNumbers[9], thisBackground;
Boolean isStructure[9], wardBitSet;
extern Rect tempManholes[];
extern short numTempManholes, tvWithMovieNumber;
extern Boolean shadowVisible, takingTheStairs;
//============================================================== Functions
//-------------------------------------------------------------- DrawLocale
void DrawLocale (void)
{
short i, roomV;
char wasState;
CGrafPtr wasCPort;
GDHandle wasWorld;
ZeroFlamesAndTheLike();
ZeroDinahs();
KillAllBands();
ZeroMirrorRegion();
ZeroTriggers();
numTempManholes = 0;
FlushAnyTriggerPlaying();
DumpTriggerSound();
tvInRoom = false;
tvWithMovieNumber = -1;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
roomV = (*thisHouse)->rooms[thisRoomNumber].floor;
HSetState((Handle)thisHouse, wasState);
for (i = 0; i < 9; i++)
{
localNumbers[i] = GetNeighborRoomNumber(i);
isStructure[i] = IsRoomAStructure(localNumbers[i]);
}
ListAllLocalObjects();
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
PaintRect(&backSrcRect);
if (numNeighbors > 3)
{
numLights = GetNumberOfLights(localNumbers[kNorthWestRoom]);
DrawRoomBackground(localNumbers[kNorthWestRoom], kNorthWestRoom, roomV + 1);
DrawARoomsObjects(kNorthWestRoom, false);
numLights = GetNumberOfLights(localNumbers[kNorthEastRoom]);
DrawRoomBackground(localNumbers[kNorthEastRoom], kNorthEastRoom, roomV + 1);
DrawARoomsObjects(kNorthEastRoom, false);
numLights = GetNumberOfLights(localNumbers[kNorthRoom]);
DrawRoomBackground(localNumbers[kNorthRoom], kNorthRoom, roomV + 1);
DrawARoomsObjects(kNorthRoom, false);
numLights = GetNumberOfLights(localNumbers[kSouthWestRoom]);
DrawRoomBackground(localNumbers[kSouthWestRoom], kSouthWestRoom, roomV - 1);
DrawARoomsObjects(kSouthWestRoom, false);
numLights = GetNumberOfLights(localNumbers[kSouthEastRoom]);
DrawRoomBackground(localNumbers[kSouthEastRoom], kSouthEastRoom, roomV - 1);
DrawARoomsObjects(kSouthEastRoom, false);
numLights = GetNumberOfLights(localNumbers[kSouthRoom]);
DrawRoomBackground(localNumbers[kSouthRoom], kSouthRoom, roomV - 1);
DrawARoomsObjects(kSouthRoom, false);
}
if (numNeighbors > 1)
{
numLights = GetNumberOfLights(localNumbers[kWestRoom]);
DrawRoomBackground(localNumbers[kWestRoom], kWestRoom, roomV);
DrawARoomsObjects(kWestRoom, false);
DrawLighting();
numLights = GetNumberOfLights(localNumbers[kEastRoom]);
DrawRoomBackground(localNumbers[kEastRoom], kEastRoom, roomV);
DrawARoomsObjects(kEastRoom, false);
DrawLighting();
}
numLights = GetNumberOfLights(localNumbers[kCentralRoom]);
DrawRoomBackground(localNumbers[kCentralRoom], kCentralRoom, roomV);
DrawARoomsObjects(kCentralRoom, false);
DrawLighting();
if (numNeighbors > 3)
DrawFloorSupport();
RestoreWorkMap();
shadowVisible = IsShadowVisible();
takingTheStairs = false;
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- LoadGraphicSpecial
void LoadGraphicSpecial (short resID)
{
Rect bounds;
PicHandle thePicture;
thePicture = GetPicture(resID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', resID);
if (thePicture == nil)
{
thePicture = GetPicture(2000);
if (thePicture == nil)
RedAlert(kErrFailedGraphicLoad);
}
}
HLock((Handle)thePicture);
bounds = (*thePicture)->picFrame;
HUnlock((Handle)thePicture);
OffsetRect(&bounds, -bounds.left, -bounds.top);
DrawPicture(thePicture, &bounds);
ReleaseResource((Handle)thePicture);
}
//-------------------------------------------------------------- DrawRoomBackground
void DrawRoomBackground (short who, short where, short elevation)
{
Rect src, dest;
short i, pictID;
short tiles[kNumTiles];
char wasState;
if (where == kCentralRoom)
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisBackground = (*thisHouse)->rooms[who].background;
for (i = 0; i < kNumTiles; i++)
thisTiles[i] = (*thisHouse)->rooms[who].tiles[i];
HSetState((Handle)thisHouse, wasState);
}
if ((numLights == 0) && (who != kRoomIsEmpty))
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
PaintRect(&localRoomsDest[where]);
SetGWorld(wasCPort, wasWorld);
return;
}
if (who == kRoomIsEmpty) // This call should be smarter than this
{
if (wardBitSet)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
PaintRect(&localRoomsDest[where]);
SetGWorld(wasCPort, wasWorld);
return;
}
if (elevation > 1)
{
pictID = kSky;
for (i = 0; i < kNumTiles; i++)
tiles[i] = 2;
}
else if (elevation == 1)
{
pictID = kMeadow;
for (i = 0; i < kNumTiles; i++)
tiles[i] = 0;
}
else
{
pictID = kDirt;
for (i = 0; i < kNumTiles; i++)
tiles[i] = 0;
}
}
else
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
pictID = (*thisHouse)->rooms[who].background;
for (i = 0; i < kNumTiles; i++)
tiles[i] = (*thisHouse)->rooms[who].tiles[i];
HSetState((Handle)thisHouse, wasState);
}
SetPort((GrafPtr)workSrcMap);
LoadGraphicSpecial(pictID);
QSetRect(&src, 0, 0, kTileWide, kTileHigh);
QSetRect(&dest, 0, 0, kTileWide, kTileHigh);
QOffsetRect(&dest, localRoomsDest[where].left, localRoomsDest[where].top);
for (i = 0; i < kNumTiles; i++)
{
src.left = tiles[i] * kTileWide;
src.right = src.left + kTileWide;
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
QOffsetRect(&dest, kTileWide, 0);
}
}
//-------------------------------------------------------------- DrawFloorSupport
void DrawFloorSupport (void)
{
Rect src, dest, whoCares;
short i;
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
src = suppSrcRect;
if (isStructure[kNorthWestRoom])
{
dest = suppSrcRect; // left room's ceiling
QOffsetRect(&dest, localRoomsDest[kWestRoom].left,
localRoomsDest[kCentralRoom].top - suppSrcRect.bottom);
CopyBits((BitMap *)*GetGWorldPixMap(suppSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
for (i = 0; i < numTempManholes; i++)
if (SectRect(&dest, &tempManholes[i], &whoCares))
{
tempManholes[i].top = dest.top;
tempManholes[i].bottom = dest.bottom;
LoadScaledGraphic(kManholeThruFloor, &tempManholes[i]);
}
}
if (isStructure[kWestRoom])
{
dest = suppSrcRect; // left room's floor
QOffsetRect(&dest, localRoomsDest[kWestRoom].left,
localRoomsDest[kCentralRoom].bottom);
CopyBits((BitMap *)*GetGWorldPixMap(suppSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
for (i = 0; i < numTempManholes; i++)
if (SectRect(&dest, &tempManholes[i], &whoCares))
{
tempManholes[i].top = dest.top;
tempManholes[i].bottom = dest.bottom;
LoadScaledGraphic(kManholeThruFloor, &tempManholes[i]);
}
}
if (isStructure[kNorthRoom])
{
dest = suppSrcRect; // directly above main room
QOffsetRect(&dest, localRoomsDest[kCentralRoom].left,
localRoomsDest[kCentralRoom].top - suppSrcRect.bottom);
CopyBits((BitMap *)*GetGWorldPixMap(suppSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
for (i = 0; i < numTempManholes; i++)
if (SectRect(&dest, &tempManholes[i], &whoCares))
{
tempManholes[i].top = dest.top;
tempManholes[i].bottom = dest.bottom;
LoadScaledGraphic(kManholeThruFloor, &tempManholes[i]);
}
}
if (isStructure[kCentralRoom])
{
dest = suppSrcRect; // directly below main room
QOffsetRect(&dest, localRoomsDest[kCentralRoom].left,
localRoomsDest[kCentralRoom].bottom);
CopyBits((BitMap *)*GetGWorldPixMap(suppSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
for (i = 0; i < numTempManholes; i++)
if (SectRect(&dest, &tempManholes[i], &whoCares))
{
tempManholes[i].top = dest.top;
tempManholes[i].bottom = dest.bottom;
LoadScaledGraphic(kManholeThruFloor, &tempManholes[i]);
}
}
if (isStructure[kNorthEastRoom])
{
dest = suppSrcRect;
QOffsetRect(&dest, localRoomsDest[kEastRoom].left,
localRoomsDest[kCentralRoom].top - suppSrcRect.bottom);
CopyBits((BitMap *)*GetGWorldPixMap(suppSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
for (i = 0; i < numTempManholes; i++)
if (SectRect(&dest, &tempManholes[i], &whoCares))
{
tempManholes[i].top = dest.top;
tempManholes[i].bottom = dest.bottom;
LoadScaledGraphic(kManholeThruFloor, &tempManholes[i]);
}
}
if (isStructure[kEastRoom])
{
dest = suppSrcRect;
QOffsetRect(&dest, localRoomsDest[kEastRoom].left,
localRoomsDest[kCentralRoom].bottom);
CopyBits((BitMap *)*GetGWorldPixMap(suppSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &dest, srcCopy, nil);
for (i = 0; i < numTempManholes; i++)
if (SectRect(&dest, &tempManholes[i], &whoCares))
{
tempManholes[i].top = dest.top;
tempManholes[i].bottom = dest.bottom;
LoadScaledGraphic(kManholeThruFloor, &tempManholes[i]);
}
}
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- ReadyBackMap
void ReadyBackMap (void)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&workSrcRect, &workSrcRect, srcCopy, nil);
}
//-------------------------------------------------------------- RestoreWorkMap
void RestoreWorkMap (void)
{
Rect dest;
dest = backSrcRect;
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&backSrcRect, &backSrcRect, srcCopy, nil);
}
//-------------------------------------------------------------- ReadyLevel
void ReadyLevel (void)
{
NilSavedMaps();
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom))
{
tvInRoom = false;
tvWithMovieNumber = -1;
StopMovie(theMovie);
}
#endif
DetermineRoomOpenings();
DrawLocale();
InitGarbageRects();
}
//-------------------------------------------------------------- DrawLighting
void DrawLighting (void)
{
if (numLights == 0)
return;
else
{
// for future construction
}
}
//-------------------------------------------------------------- RedrawRoomLighting
void RedrawRoomLighting (void)
{
short roomV;
char wasState;
Boolean wasLit, isLit;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
roomV = (*thisHouse)->rooms[thisRoomNumber].floor;
HSetState((Handle)thisHouse, wasState);
wasLit = numLights > 0;
numLights = GetNumberOfLights(localNumbers[kCentralRoom]);
isLit = numLights > 0;
if (wasLit != isLit)
{
DrawRoomBackground(localNumbers[kCentralRoom], kCentralRoom, roomV);
DrawARoomsObjects(kCentralRoom, true);
DrawLighting();
UpdateOutletsLighting(localNumbers[kCentralRoom], numLights);
if (numNeighbors > 3)
DrawFloorSupport();
RestoreWorkMap();
AddRectToWorkRects(&localRoomsDest[kCentralRoom]);
shadowVisible = IsShadowVisible();
}
}

11
GpApp/RoomGraphics.h Normal file
View File

@@ -0,0 +1,11 @@
//============================================================================
//----------------------------------------------------------------------------
// RoomGraphics.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr suppSrcMap;

908
GpApp/RoomInfo.cpp Normal file
View File

@@ -0,0 +1,908 @@
//============================================================================
//----------------------------------------------------------------------------
// RoomInfo.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLResources.h"
#include "PLSound.h"
#include "PLPasStr.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "RectUtils.h"
#include "Utilities.h"
#define kRoomInfoDialogID 1003
#define kOriginalArtDialogID 1016
#define kNoPICTFoundAlert 1036
#define kRoomNameItem 3
#define kRoomLocationBox 6
#define kRoomTilesBox 10
#define kRoomPopupItem 11
#define kRoomDividerLine 12
#define kRoomTilesBox2 15
#define kRoomFirstCheck 17
#define kLitUnlitText 18
#define kMiniTileWide 16
#define kBoundsButton 19
#define kOriginalArtworkItem 19
#define kPICTIDItem 5
#define kFloorSupportCheck 12
void UpdateRoomInfoDialog (DialogPtr);
void DragMiniTile (Point, short *);
void HiliteTileOver (Point);
Boolean RoomFilter (DialogPtr, EventRecord *, short *);
short ChooseOriginalArt (short);
void UpdateOriginalArt (DialogPtr);
Boolean OriginalArtFilter (DialogPtr, EventRecord *, short *);
Boolean PictIDExists (short);
short GetFirstPICT (void);
void BitchAboutPICTNotFound (void);
Rect tileSrc, tileDest, tileSrcRect, editTETextBox;
Rect leftBound, topBound, rightBound, bottomBound;
CGrafPtr tileSrcMap;
short tempTiles[kNumTiles];
short tileOver, tempBack, cursorIs;
Boolean originalLeftOpen, originalTopOpen, originalRightOpen, originalBottomOpen;
Boolean originalFloor;
extern Cursor handCursor, beamCursor;
extern short houseResFork, lastBackground;
//============================================================== Functions
//-------------------------------------------------------------- UpdateRoomInfoDialog
#ifndef COMPILEDEMO
void UpdateRoomInfoDialog (DialogPtr theDialog)
{
Rect src, dest;
short i;
DrawDialog(theDialog);
if (tempBack >= kUserBackground)
SetPopUpMenuValue(theDialog, kRoomPopupItem, kOriginalArtworkItem);
else
SetPopUpMenuValue(theDialog, kRoomPopupItem,
(tempBack - kBaseBackgroundID) + 1);
CopyBits(GetPortBitMapForCopyBits(tileSrcMap),
GetPortBitMapForCopyBits(GetDialogPort(theDialog)),
&tileSrcRect, &tileSrc, srcCopy, nil);
/*
CopyBits(&((GrafPtr)tileSrcMap)->portBits,
&(((GrafPtr)theDialog)->portBits),
&tileSrcRect, &tileSrc, srcCopy, nil);
*/
dest = tileDest;
dest.right = dest.left + kMiniTileWide;
for (i = 0; i < kNumTiles; i++)
{
QSetRect(&src, 0, 0, kMiniTileWide, 80);
QOffsetRect(&src, tempTiles[i] * kMiniTileWide, 0);
CopyBits(GetPortBitMapForCopyBits(tileSrcMap),
GetPortBitMapForCopyBits(GetDialogPort(theDialog)),
&src, &dest, srcCopy, nil);
/*
CopyBits(&((GrafPtr)tileSrcMap)->portBits,
&(((GrafPtr)theDialog)->portBits),
&src, &dest, srcCopy, nil);
*/
QOffsetRect(&dest, kMiniTileWide, 0);
}
if (GetNumberOfLights(thisRoomNumber) == 0)
SetDialogString(theDialog, kLitUnlitText, PSTR("(Room Is Dark)"));
else
SetDialogString(theDialog, kLitUnlitText, PSTR("(Room Is Lit)"));
FrameDialogItemC(theDialog, kRoomLocationBox, kRedOrangeColor8);
FrameDialogItem(theDialog, kRoomTilesBox);
FrameDialogItemC(theDialog, kRoomDividerLine, kRedOrangeColor8);
FrameDialogItem(theDialog, kRoomTilesBox2);
}
#endif
//-------------------------------------------------------------- DragMiniTile
#ifndef COMPILEDEMO
void DragMiniTile (Point mouseIs, short *newTileOver)
{
Rect dragRect;
Point mouseWas;
short wasTileOver;
Pattern dummyPattern;
tileOver = (mouseIs.h - tileSrc.left) / kMiniTileWide;
wasTileOver = -1;
QSetRect(&dragRect, 0, 0, kMiniTileWide, 80);
QOffsetRect(&dragRect,
tileSrc.left + (tileOver * kMiniTileWide),
tileSrc.top);
PenMode(patXor);
PenPat(GetQDGlobalsGray(&dummyPattern));
FrameRect(&dragRect);
mouseWas = mouseIs;
while (WaitMouseUp()) // loop until mouse button let up
{
GetMouse(&mouseIs); // get mouse coords
if (DeltaPoint(mouseWas, mouseIs) != 0L) // the mouse has moved
{
FrameRect(&dragRect);
QOffsetRect(&dragRect, mouseIs.h - mouseWas.h, 0);
FrameRect(&dragRect);
if (PtInRect(mouseIs, &tileDest)) // is cursor in the drop rect
{
*newTileOver = (mouseIs.h - tileDest.left) / kMiniTileWide;
if (*newTileOver != wasTileOver)
{
PenNormal();
PenSize(1, 2);
ForeColor(blueColor);
MoveTo(tileDest.left + (*newTileOver * kMiniTileWide),
tileDest.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileDest.left + (*newTileOver * kMiniTileWide),
tileDest.bottom + 1);
Line(kMiniTileWide, 0);
if (wasTileOver != -1)
{
ForeColor(whiteColor);
MoveTo(tileDest.left + (wasTileOver * kMiniTileWide),
tileDest.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileDest.left + (wasTileOver * kMiniTileWide),
tileDest.bottom + 1);
Line(kMiniTileWide, 0);
}
ForeColor(blackColor);
PenNormal();
PenMode(patXor);
PenPat(GetQDGlobalsGray(&dummyPattern));
wasTileOver = *newTileOver;
}
}
else
{
*newTileOver = -1; // we're not in the drop zone
if (wasTileOver != -1)
{
PenNormal();
PenSize(1, 2);
ForeColor(whiteColor);
MoveTo(tileDest.left + (wasTileOver * kMiniTileWide),
tileDest.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileDest.left + (wasTileOver * kMiniTileWide),
tileDest.bottom + 1);
Line(kMiniTileWide, 0);
ForeColor(blackColor);
PenNormal();
PenMode(patXor);
PenPat(GetQDGlobalsGray(&dummyPattern));
wasTileOver = -1;
}
}
mouseWas = mouseIs;
}
}
if (wasTileOver != -1)
{
PenNormal();
PenSize(1, 2);
ForeColor(whiteColor);
MoveTo(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.bottom + 1);
Line(kMiniTileWide, 0);
ForeColor(blackColor);
PenNormal();
PenMode(patXor);
PenPat(GetQDGlobalsGray(&dummyPattern));
wasTileOver = -1;
}
FrameRect(&dragRect);
PenNormal();
}
#endif
//-------------------------------------------------------------- HiliteTileOver
#ifndef COMPILEDEMO
void HiliteTileOver (Point mouseIs)
{
short newTileOver;
if (PtInRect(mouseIs, &tileSrc))
{
if (cursorIs != kHandCursor)
{
SetCursor(&handCursor);
cursorIs = kHandCursor;
}
newTileOver = (mouseIs.h - tileSrc.left) / kMiniTileWide;
if (newTileOver != tileOver)
{
PenSize(1, 2);
ForeColor(redColor);
MoveTo(tileSrc.left + (newTileOver * kMiniTileWide), tileSrc.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileSrc.left + (newTileOver * kMiniTileWide), tileSrc.bottom + 1);
Line(kMiniTileWide, 0);
if (tileOver != -1)
{
ForeColor(whiteColor);
MoveTo(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.bottom + 1);
Line(kMiniTileWide, 0);
}
ForeColor(blackColor);
PenNormal();
tileOver = newTileOver;
}
}
else
{
if (tileOver != -1)
{
PenSize(1, 2);
ForeColor(whiteColor);
MoveTo(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.top - 3);
Line(kMiniTileWide, 0);
MoveTo(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.bottom + 1);
Line(kMiniTileWide, 0);
ForeColor(blackColor);
PenNormal();
tileOver = -1;
}
if (PtInRect(mouseIs, &editTETextBox))
{
if (cursorIs != kBeamCursor)
{
SetCursor(&beamCursor);
cursorIs = kBeamCursor;
}
}
else
{
if (cursorIs != kArrowCursor)
{
InitCursor();
cursorIs = kArrowCursor;
}
}
}
}
#endif
//-------------------------------------------------------------- RoomFilter
#ifndef COMPILEDEMO
Boolean RoomFilter (DialogPtr dial, EventRecord *event, short *item)
{
Point mouseIs;
short newTileOver;
switch (event->what)
{
case keyDown:
switch ((event->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
case kEscapeKeyASCII:
FlashDialogButton(dial, kCancelButton);
*item = kCancelButton;
return(true);
break;
case kTabKeyASCII:
SelectDialogItemText(dial, kRoomNameItem, 0, 1024);
return(true);
break;
default:
return(false);
}
break;
case mouseDown:
mouseIs = event->where;
GlobalToLocal(&mouseIs);
if (PtInRect(mouseIs, &tileSrc))
{
if (StillDown())
{
DragMiniTile(mouseIs, &newTileOver);
if ((newTileOver >= 0) && (newTileOver < kNumTiles))
{
tempTiles[newTileOver] = tileOver;
UpdateRoomInfoDialog(dial);
}
}
return(true);
}
else
return(false);
break;
case mouseUp:
return(false);
break;
case updateEvt:
SetPort((GrafPtr)dial);
BeginUpdate(GetDialogWindow(dial));
UpdateRoomInfoDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
GetMouse(&mouseIs);
HiliteTileOver(mouseIs);
return(false);
break;
}
}
#endif
//-------------------------------------------------------------- DoRoomInfo
void DoRoomInfo (void)
{
#ifndef COMPILEDEMO
#define kBackgroundsMenuID 140
DialogPtr roomInfoDialog;
MenuHandle backgroundsMenu;
Str255 floorStr, suiteStr, objectsStr, tempStr;
short item, i, newBack;
char wasState;
Boolean leaving, wasFirstRoom, forceDraw;
ModalFilterUPP roomFilterUPP;
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
roomFilterUPP = NewModalFilterUPP(RoomFilter);
tileOver = -1;
cursorIs = kArrowCursor;
tempBack = thisRoom->background;
backgroundsMenu = GetMenu(kBackgroundsMenuID);
// SetMenuItemTextStyle(backgroundsMenu, kOriginalArtworkItem, italic);
if (HouseHasOriginalPicts())
EnableMenuItem(backgroundsMenu, kOriginalArtworkItem);
NumToString(thisRoom->floor, floorStr);
NumToString(thisRoom->suite, suiteStr);
NumToString(thisRoom->numObjects, objectsStr);
ParamText(floorStr, suiteStr, objectsStr, PSTR(""));
theErr = CreateOffScreenGWorld(&tileSrcMap, &tileSrcRect, kPreferredDepth);
SetGWorld(tileSrcMap, nil);
// CreateOffScreenPixMap(&tileSrcRect, &tileSrcMap);
// SetPort((GrafPtr)tileSrcMap);
if ((tempBack > kStars) && (!PictIDExists(tempBack)))
{
BitchAboutPICTNotFound();
tempBack = kSimpleRoom;
}
if ((tempBack == 2002) || (tempBack == 2011) ||
(tempBack == 2016) || (tempBack == 2017))
LoadScaledGraphic(tempBack - 800, &tileSrcRect);
else
LoadScaledGraphic(tempBack, &tileSrcRect);
SetGWorld(wasCPort, wasWorld);
for (i = 0; i < kNumTiles; i++)
tempTiles[i] = thisRoom->tiles[i];
// CenterDialog(kRoomInfoDialogID);
roomInfoDialog = GetNewDialog(kRoomInfoDialogID, nil, kPutInFront);
if (roomInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort((GrafPtr)roomInfoDialog);
// Fix this later. TEMP
// AddMenuToPopUp(roomInfoDialog, kRoomPopupItem, backgroundsMenu);
if (tempBack >= kUserBackground)
SetPopUpMenuValue(roomInfoDialog, kRoomPopupItem, kOriginalArtworkItem);
else
SetPopUpMenuValue(roomInfoDialog, kRoomPopupItem,
(tempBack - kBaseBackgroundID) + 1);
SetDialogString(roomInfoDialog, kRoomNameItem, thisRoom->name);
GetDialogItemRect(roomInfoDialog, kRoomTilesBox, &tileSrc);
GetDialogItemRect(roomInfoDialog, kRoomTilesBox2, &tileDest);
GetDialogItemRect(roomInfoDialog, kRoomNameItem, &editTETextBox);
SelectDialogItemText(roomInfoDialog, kRoomNameItem, 0, 1024);
ShowWindow(GetDialogWindow(roomInfoDialog));
DrawDefaultButton(roomInfoDialog);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
wasFirstRoom = ((*thisHouse)->firstRoom == thisRoomNumber);
HSetState((Handle)thisHouse, wasState);
SetDialogItemValue(roomInfoDialog, kRoomFirstCheck, (short)wasFirstRoom);
if (tempBack >= kUserBackground)
MyEnableControl(roomInfoDialog, kBoundsButton);
else
MyDisableControl(roomInfoDialog, kBoundsButton);
leaving = false;
while (!leaving)
{
ModalDialog(roomFilterUPP, &item);
if (item == kOkayButton)
{
for (i = 0; i < kNumTiles; i++)
thisRoom->tiles[i] = tempTiles[i];
GetDialogString(roomInfoDialog, kRoomNameItem, tempStr);
PasStringCopyNum(tempStr, thisRoom->name, 27);
if (wasFirstRoom)
{
HLock((Handle)thisHouse);
(*thisHouse)->firstRoom = thisRoomNumber;
HUnlock((Handle)thisHouse);
}
thisRoom->background = tempBack;
if (tempBack < kUserBackground)
lastBackground = tempBack;
CopyThisRoomToRoom();
ReflectCurrentRoom(false);
fileDirty = true;
UpdateMenus(false);
leaving = true;
}
else if (item == kCancelButton)
{
leaving = true;
}
else if (item == kRoomFirstCheck)
{
wasFirstRoom = !wasFirstRoom;
SetDialogItemValue(roomInfoDialog, kRoomFirstCheck, (short)wasFirstRoom);
}
else if (item == kRoomPopupItem)
{
GetPopUpMenuValue(roomInfoDialog, kRoomPopupItem, &newBack);
if (newBack == kOriginalArtworkItem) // original art item selected?
{
if (tempBack < kUserBackground) // was previous bg built-in?
{
tempBack = GetFirstPICT(); // then assign 1st PICT
forceDraw = true;
}
else
forceDraw = false;
newBack = ChooseOriginalArt(tempBack); // bring up dialog
if ((tempBack != newBack) || (forceDraw))
{
tempBack = newBack;
SetPort((GrafPtr)tileSrcMap);
LoadScaledGraphic(tempBack, &tileSrcRect);
InvalWindowRect(GetDialogWindow(roomInfoDialog), &tileSrc);
InvalWindowRect(GetDialogWindow(roomInfoDialog), &tileDest);
}
}
else
{
newBack += (kBaseBackgroundID - 1); // adjust to get real PICT ID
if (newBack != tempBack) // if background has changed
SetInitialTiles(newBack, false);
}
if (newBack >= kUserBackground)
{
MyEnableControl(roomInfoDialog, kBoundsButton);
if (newBack != tempBack) // if background has changed
SetInitialTiles(newBack, false);
}
else
MyDisableControl(roomInfoDialog, kBoundsButton);
if (newBack != tempBack)
{
tempBack = newBack;
SetPort((GrafPtr)tileSrcMap);
if ((tempBack == 2002) || (tempBack == 2011) ||
(tempBack == 2016) || (tempBack == 2017))
LoadScaledGraphic(tempBack - 800, &tileSrcRect);
else
LoadScaledGraphic(tempBack, &tileSrcRect);
InvalWindowRect(GetDialogWindow(roomInfoDialog), &tileSrc);
InvalWindowRect(GetDialogWindow(roomInfoDialog), &tileDest);
}
}
else if (item == kBoundsButton)
{
newBack = ChooseOriginalArt(tempBack);
if (tempBack != newBack)
{
tempBack = newBack;
SetPort((GrafPtr)tileSrcMap);
LoadScaledGraphic(tempBack, &tileSrcRect);
InvalWindowRect(GetDialogWindow(roomInfoDialog), &tileSrc);
InvalWindowRect(GetDialogWindow(roomInfoDialog), &tileDest);
}
}
}
InitCursor();
DisposeDialog(roomInfoDialog);
DisposeModalFilterUPP(roomFilterUPP);
// KillOffScreenPixMap(tileSrcMap);
DisposeGWorld(tileSrcMap);
tileSrcMap = nil;
#endif
}
//-------------------------------------------------------------- UpdateOriginalArt
#ifndef COMPILEDEMO
void UpdateOriginalArt (DialogPtr theDialog)
{
Pattern dummyPattern;
DrawDialog(theDialog);
DrawDefaultButton(theDialog);
PenSize(2, 1);
if (!originalLeftOpen)
BorderDialogItem(theDialog, 7, 8);
else
{
PenPat(GetQDGlobalsGray(&dummyPattern));
BorderDialogItem(theDialog, 7, 8);
PenPat(GetQDGlobalsBlack(&dummyPattern));
}
PenSize(1, 2);
if (!originalTopOpen)
BorderDialogItem(theDialog, 8, 4);
else
{
PenPat(GetQDGlobalsGray(&dummyPattern));
BorderDialogItem(theDialog, 8, 4);
PenPat(GetQDGlobalsBlack(&dummyPattern));
}
PenSize(2, 1);
if (!originalRightOpen)
BorderDialogItem(theDialog, 9, 1);
else
{
PenPat(GetQDGlobalsGray(&dummyPattern));
BorderDialogItem(theDialog, 9, 1);
PenPat(GetQDGlobalsBlack(&dummyPattern));
}
PenSize(1, 2);
if (!originalBottomOpen)
BorderDialogItem(theDialog, 10, 2);
else
{
PenPat(GetQDGlobalsGray(&dummyPattern));
BorderDialogItem(theDialog, 10, 2);
PenPat(GetQDGlobalsBlack(&dummyPattern));
}
PenSize(1, 1);
}
#endif
//-------------------------------------------------------------- OriginalArtFilter
#ifndef COMPILEDEMO
Boolean OriginalArtFilter (DialogPtr dial, EventRecord *event, short *item)
{
Point mouseIs;
switch (event->what)
{
case keyDown:
switch ((event->message) & charCodeMask)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
case kEscapeKeyASCII:
FlashDialogButton(dial, kCancelButton);
*item = kCancelButton;
return(true);
break;
case kTabKeyASCII:
SelectDialogItemText(dial, kPICTIDItem, 0, 1024);
return(true);
break;
default:
return(false);
}
break;
case mouseDown:
mouseIs = event->where;
GlobalToLocal(&mouseIs);
if (PtInRect(mouseIs, &leftBound))
{
*item = 7;
return(true);
}
else if (PtInRect(mouseIs, &topBound))
{
*item = 8;
return(true);
}
else if (PtInRect(mouseIs, &rightBound))
{
*item = 9;
return(true);
}
else if (PtInRect(mouseIs, &bottomBound))
{
*item = 10;
return(true);
}
else
return(false);
break;
case mouseUp:
return(false);
break;
case updateEvt:
SetPort((GrafPtr)dial);
BeginUpdate(GetDialogWindow(dial));
UpdateOriginalArt(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
return(false);
break;
}
}
#endif
//-------------------------------------------------------------- ChooseOriginalArt
#ifndef COMPILEDEMO
short ChooseOriginalArt (short was)
{
DialogPtr theDialog;
long longID;
short item, newPictID, tempShort, wasPictID;
Boolean leaving;
ModalFilterUPP originalArtFilterUPP;
originalArtFilterUPP = NewModalFilterUPP(OriginalArtFilter);
if (was < kUserBackground)
was = kUserBackground;
InitCursor();
BringUpDialog(&theDialog, kOriginalArtDialogID);
if (was >= kOriginalArtworkItem)
{
newPictID = was;
wasPictID = was;
}
else
{
newPictID = kUserBackground;
wasPictID = 0;
}
SetDialogNumToStr(theDialog, kPICTIDItem, (long)newPictID);
SelectDialogItemText(theDialog, kPICTIDItem, 0, 16);
GetDialogItemRect(theDialog, 7, &leftBound);
GetDialogItemRect(theDialog, 8, &topBound);
GetDialogItemRect(theDialog, 9, &rightBound);
GetDialogItemRect(theDialog, 10, &bottomBound);
tempShort = thisRoom->bounds >> 1; // version 2.0 house
originalLeftOpen = ((tempShort & 1) == 1);
originalTopOpen = ((tempShort & 2) == 2);
originalRightOpen = ((tempShort & 4) == 4);
originalBottomOpen = ((tempShort & 8) == 8);
originalFloor = ((tempShort & 16) == 16);
SetDialogItemValue(theDialog, kFloorSupportCheck, (short)originalFloor);
leaving = false;
while (!leaving)
{
ModalDialog(originalArtFilterUPP, &item);
if (item == kOkayButton)
{
GetDialogNumFromStr(theDialog, kPICTIDItem, &longID);
if ((longID >= 3000) && (longID < 3800) && (PictIDExists((short)longID)))
{
newPictID = (short)longID;
if (newPictID != wasPictID)
SetInitialTiles(tempBack, false);
tempShort = 0;
if (originalLeftOpen)
tempShort += 1;
if (originalTopOpen)
tempShort += 2;
if (originalRightOpen)
tempShort += 4;
if (originalBottomOpen)
tempShort += 8;
if (originalFloor)
tempShort += 16;
tempShort = tempShort << 1; // shift left 1 bit
tempShort += 1; // flag that says orginal bounds used
thisRoom->bounds = tempShort;
leaving = true;
}
else
{
SysBeep(1);
SetDialogNumToStr(theDialog, kPICTIDItem, (long)newPictID);
}
}
else if (item == kCancelButton)
{
newPictID = was;
leaving = true;
}
else if (item == 7)
{
originalLeftOpen = !originalLeftOpen;
UpdateOriginalArt(theDialog);
}
else if (item == 8)
{
originalTopOpen = !originalTopOpen;
UpdateOriginalArt(theDialog);
}
else if (item == 9)
{
originalRightOpen = !originalRightOpen;
UpdateOriginalArt(theDialog);
}
else if (item == 10)
{
originalBottomOpen = !originalBottomOpen;
UpdateOriginalArt(theDialog);
}
else if (item == kFloorSupportCheck)
{
originalFloor = !originalFloor;
ToggleDialogItemValue(theDialog, kFloorSupportCheck);
}
}
DisposeDialog(theDialog);
DisposeModalFilterUPP(originalArtFilterUPP);
return (newPictID);
}
#endif
//-------------------------------------------------------------- PictIDExists
Boolean PictIDExists (short theID)
{
PicHandle thePicture;
// Handle resHandle;
// Str255 resName;
// ResType resType;
// short numPicts, i;
// short resID;
Boolean foundIt;
foundIt = true;
thePicture = GetPicture(theID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', theID);
if (thePicture == nil)
{
foundIt = false;
}
else
ReleaseResource((Handle)thePicture);
}
else
ReleaseResource((Handle)thePicture);
// foundIt = false;
// numPicts = Count1Resources('PICT');
// for (i = 1; i <= numPicts; i++)
// {
// resHandle = Get1IndResource('PICT', i);
// if (resHandle != nil)
// {
// GetResInfo(resHandle, &resID, &resType, resName);
// ReleaseResource(resHandle);
// if (resID == theID)
// {
// foundIt = true;
// break;
// }
// }
// }
return (foundIt);
}
//-------------------------------------------------------------- GetFirstPICT
short GetFirstPICT (void)
{
Handle resHandle;
Str255 resName;
ResType resType;
short resID;
resHandle = Get1IndResource('PICT', 1);
if (resHandle != nil)
{
GetResInfo(resHandle, &resID, &resType, resName);
ReleaseResource(resHandle);
return (resID);
}
else
return (-1);
}
//-------------------------------------------------------------- BitchAboutPICTNotFound
#ifndef COMPILEDEMO
void BitchAboutPICTNotFound (void)
{
short hitWhat;
// CenterAlert(kNoPICTFoundAlert);
hitWhat = Alert(kNoPICTFoundAlert, nil);
}
#endif

318
GpApp/RubberBands.cpp Normal file
View File

@@ -0,0 +1,318 @@
//============================================================================
//----------------------------------------------------------------------------
// RubberBands.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "RectUtils.h"
#define kRubberBandVelocity 20
#define kBandFallCount 4
#define kKillBandMode -1
void CheckBandCollision (short);
void KillBand (short);
bandPtr bands;
Rect bandsSrcRect;
Rect bandRects[3];
GWorldPtr bandsSrcMap;
GWorldPtr bandsMaskMap;
short numBands, bandHitLast;
extern hotPtr hotSpots;
extern long gameFrame;
extern short nHotSpots, leftThresh, rightThresh;
extern Boolean twoPlayerGame, onePlayerLeft, playerDead;
//============================================================== Functions
//-------------------------------------------------------------- CheckBandCollision
void CheckBandCollision (short who)
{
short i, action, whoLinked;
Boolean collided, nothingCollided;
nothingCollided = true;
if ((leftThresh == kLeftWallLimit) && (bands[who].dest.left < kLeftWallLimit))
{
if (bands[who].hVel < 0)
bands[who].hVel = -bands[who].hVel;
bands[who].dest.left = kLeftWallLimit;
bands[who].dest.right = bands[who].dest.left + 16;
PlayPrioritySound(kBandReboundSound, kBandReboundPriority);
collided = true;
}
else if ((rightThresh == kRightWallLimit) && (bands[who].dest.right > kRightWallLimit))
{
if (bands[who].hVel > 0)
bands[who].hVel = -bands[who].hVel;
bands[who].dest.right = kRightWallLimit;
bands[who].dest.left = bands[who].dest.right - 16;
PlayPrioritySound(kBandReboundSound, kBandReboundPriority);
collided = true;
}
for (i = 0; i < nHotSpots; i++)
{
if (hotSpots[i].isOn)
{
action = hotSpots[i].action;
if ((action == kDissolveIt) || (action == kRewardIt) ||
(action == kSwitchIt) || (action == kTriggerIt) ||
(action == kBounceIt))
{
if (bands[who].dest.bottom < hotSpots[i].bounds.top)
collided = false;
else if (bands[who].dest.top > hotSpots[i].bounds.bottom)
collided = false;
else if (bands[who].dest.right < hotSpots[i].bounds.left)
collided = false;
else if (bands[who].dest.left > hotSpots[i].bounds.right)
collided = false;
else
collided = true;
if (collided)
{
nothingCollided = false; // we have detected a collision
if (bandHitLast != i) // don't count it if same as last frame
{ // we don't want rapid on/off toggles
bandHitLast = i; // note who so we don't double-toggle it
if ((action == kDissolveIt) || (action == kBounceIt))
{
if (bands[who].hVel > 0)
{
if ((bands[who].dest.right - bands[who].hVel) <
hotSpots[i].bounds.left)
{
bands[who].hVel = -bands[who].hVel;
bands[who].dest.right = hotSpots[i].bounds.left;
bands[who].dest.left = bands[who].dest.right - 16;
}
else
bands[who].mode = kKillBandMode;
}
else
{
if ((bands[who].dest.left - bands[who].hVel) >
hotSpots[i].bounds.right)
{
bands[who].hVel = -bands[who].hVel;
bands[who].dest.left = hotSpots[i].bounds.right;
bands[who].dest.right = bands[who].dest.left + 16;
}
else
bands[who].mode = kKillBandMode;
}
PlayPrioritySound(kBandReboundSound, kBandReboundPriority);
break;
}
else if (action == kRewardIt)
{
whoLinked = hotSpots[i].who;
if ((masterObjects[whoLinked].theObject.what == kGreaseRt) ||
(masterObjects[whoLinked].theObject.what == kGreaseLf))
{
if (SetObjectState(thisRoomNumber,
masterObjects[whoLinked].objectNum, 0, whoLinked))
SpillGrease(masterObjects[whoLinked].dynaNum,
masterObjects[whoLinked].hotNum);
hotSpots[i].isOn = false;
}
}
else if (action == kSwitchIt)
{
HandleSwitches(&hotSpots[i]);
}
else if (action == kTriggerIt)
{
ArmTrigger(&hotSpots[i]);
}
}
}
}
}
}
if (nothingCollided) // the rubberband has hit nothing
bandHitLast = -1; // so make note of that for the next time
if (bands[who].hVel != 0)
{
if (bands[who].dest.bottom < theGlider.dest.top)
collided = false;
else if (bands[who].dest.top > theGlider.dest.bottom)
collided = false;
else if (bands[who].dest.right < theGlider.dest.left)
collided = false;
else if (bands[who].dest.left > theGlider.dest.right)
collided = false;
else
collided = true;
if (collided)
{
if ((!twoPlayerGame) || (!onePlayerLeft) || (playerDead == kPlayer2))
{
theGlider.hVel += (bands[who].hVel / 2);
bands[who].hVel = 0;
PlayPrioritySound(kHitWallSound, kHitWallPriority);
}
}
if (twoPlayerGame)
{
if (bands[who].dest.bottom < theGlider2.dest.top)
collided = false;
else if (bands[who].dest.top > theGlider2.dest.bottom)
collided = false;
else if (bands[who].dest.right < theGlider2.dest.left)
collided = false;
else if (bands[who].dest.left > theGlider2.dest.right)
collided = false;
else
collided = true;
if (collided)
{
if ((!onePlayerLeft) || (playerDead == kPlayer1))
{
theGlider2.hVel += (bands[who].hVel / 2);
bands[who].hVel = 0;
PlayPrioritySound(kHitWallSound, kHitWallPriority);
}
}
}
}
if ((bands[who].dest.left < kLeftWallLimit) ||
(bands[who].dest.right > kRightWallLimit))
{
bands[who].mode = kKillBandMode;
}
else if (bands[who].dest.bottom > kFloorLimit)
{
bands[who].mode = kKillBandMode;
}
}
//-------------------------------------------------------------- HandleBands
void HandleBands (void)
{
Rect dest;
short i, count;
if (numBands == 0)
return;
for (i = 0; i < numBands; i++)
{
bands[i].mode++;
if (bands[i].mode > 2)
bands[i].mode = 0;
bands[i].count++;
if (bands[i].count >= kBandFallCount)
{
bands[i].vVel++;
bands[i].count = 0;
}
dest = bands[i].dest;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
bands[i].dest.left += bands[i].hVel;
bands[i].dest.right += bands[i].hVel;
bands[i].dest.top += bands[i].vVel;
bands[i].dest.bottom += bands[i].vVel;
CheckBandCollision(i);
}
count = 0;
do
{
while (bands[count].mode == kKillBandMode)
{
bands[count].mode = 0;
KillBand(count);
}
count++;
}
while (count < numBands);
}
//-------------------------------------------------------------- AddBand
Boolean AddBand (gliderPtr thisGlider, short h, short v, Boolean direction)
{
if (numBands >= kMaxRubberBands)
return (false);
bands[numBands].mode = 0;
bands[numBands].count = 0;
if (thisGlider->tipped)
bands[numBands].vVel = -2;
else
bands[numBands].vVel = 0;
bands[numBands].dest.left = h - 8;
bands[numBands].dest.right = h + 8;
bands[numBands].dest.top = v - 3;
bands[numBands].dest.bottom = v + 3;
if (direction == kFaceLeft)
{
bands[numBands].dest.left -= 32;
bands[numBands].dest.right -= 32;
bands[numBands].hVel = -kRubberBandVelocity;
}
else
{
bands[numBands].dest.left += 32;
bands[numBands].dest.right += 32;
bands[numBands].hVel = kRubberBandVelocity;
}
thisGlider->hVel -= (bands[numBands].hVel / 2);
numBands++;
PlayPrioritySound(kFireBandSound, kFireBandPriority);
return (true);
}
//-------------------------------------------------------------- KillBand
void KillBand (short which)
{
short lastBand;
lastBand = numBands - 1;
if (which != lastBand)
bands[which] = bands[lastBand];
numBands--;
}
//-------------------------------------------------------------- KillAllBands
void KillAllBands (void)
{
short i;
for (i = 0; i < kMaxRubberBands; i++)
{
bands[i].mode = 0;
}
numBands = 0;
}

12
GpApp/RubberBands.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// RubberBands.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr bandsSrcMap;
extern GWorldPtr bandsMaskMap;

352
GpApp/SavedGames.cpp Normal file
View File

@@ -0,0 +1,352 @@
//============================================================================
//----------------------------------------------------------------------------
// SavedGames.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLStringCompare.h"
#include "Externs.h"
#include "House.h"
#define kSavedGameVersion 0x0200
void SavedGameMismatchError (StringPtr);
gameType smallGame;
extern FSSpecPtr theHousesSpecs;
extern short numStarsRemaining, thisHouseIndex;
extern Boolean twoPlayerGame;
//============================================================== Functions
//-------------------------------------------------------------- SaveGame2
void SaveGame2 (void)
{
// Add NavServices later.
/*
StandardFileReply theReply;
FSSpec tempSpec;
Str255 gameNameStr;
Size byteCount;
OSErr theErr;
houseType *thisHousePtr;
roomType *srcRoom;
savedRoom *destRoom;
gamePtr savedGame;
short r, i, numRooms, gameRefNum;
char wasState;
FlushEvents(everyEvent, 0);
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
numRooms = thisHousePtr->nRooms;
HSetState((Handle)thisHouse, wasState);
byteCount = sizeof(game2Type) + sizeof(savedRoom) * numRooms;
savedGame = (gamePtr)NewPtr(byteCount);
if (savedGame == nil)
{
YellowAlert(kYellowFailedSaveGame, MemError());
return;
}
GetFirstWordOfString(thisHouseName, gameNameStr);
if (gameNameStr[0] > 23)
gameNameStr[0] = 23;
PasStringConcat(gameNameStr, "\p Game");
StandardPutFile("\pSave Game As:", gameNameStr, &theReply);
if (!theReply.sfGood)
return;
if (theReply.sfReplacing)
{
theErr = FSMakeFSSpec(theReply.sfFile.vRefNum, theReply.sfFile.parID,
theReply.sfFile.name, &tempSpec);
if (!CheckFileError(theErr, "\pSaved Game"))
return;
theErr = FSpDelete(&tempSpec);
if (!CheckFileError(theErr, "\pSaved Game"))
return;
}
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
savedGame->house = theHousesSpecs[thisHouseIndex];
savedGame->version = kSavedGameVersion;
savedGame->wasStarsLeft = numStarsRemaining;
savedGame->timeStamp = thisHousePtr->timeStamp;
savedGame->where.h = theGlider.dest.left;
savedGame->where.v = theGlider.dest.top;
savedGame->score = theScore;
savedGame->unusedLong = 0L;
savedGame->unusedLong2 = 0L;
savedGame->energy = batteryTotal;
savedGame->bands = bandsTotal;
savedGame->roomNumber = thisRoomNumber;
savedGame->gliderState = theGlider.mode;
savedGame->numGliders = mortals;
savedGame->foil = foilTotal;
savedGame->nRooms = numRooms;
savedGame->facing = theGlider.facing;
savedGame->showFoil = showFoil;
for (r = 0; r < numRooms; r++)
{
destRoom = &(savedGame->savedData[r]);
srcRoom = &(thisHousePtr->rooms[r]);
destRoom->unusedShort = 0;
destRoom->unusedByte = 0;
destRoom->visited = srcRoom->visited;
for (i = 0; i < kMaxRoomObs; i++)
destRoom->objects[i] = srcRoom->objects[i];
}
HSetState((Handle)thisHouse, wasState);
theErr = FSpCreate(&theReply.sfFile, 'ozm5', 'gliG', theReply.sfScript);
if (CheckFileError(theErr, "\pSaved Game"))
{
theErr = FSpOpenDF(&theReply.sfFile, fsCurPerm, &gameRefNum);
if (CheckFileError(theErr, "\pSaved Game"))
{
theErr = SetFPos(gameRefNum, fsFromStart, 0L);
if (CheckFileError(theErr, "\pSaved Game"))
{
theErr = FSWrite(gameRefNum, &byteCount, (Ptr)savedGame);
if (CheckFileError(theErr, "\pSaved Game"))
{
theErr = SetEOF(gameRefNum, byteCount);
if (CheckFileError(theErr, "\pSaved Game"))
{
}
}
}
theErr = FSClose(gameRefNum);
if (CheckFileError(theErr, "\pSaved Game"))
{
}
}
}
DisposePtr((Ptr)savedGame);
*/
}
//-------------------------------------------------------------- SavedGameMismatchError
void SavedGameMismatchError (StringPtr gameName)
{
#define kSavedGameErrorAlert 1044
short whoCares;
InitCursor();
// CenterAlert(kSavedGameErrorAlert);
ParamText(gameName, thisHouseName, PSTR(""), PSTR(""));
whoCares = Alert(kSavedGameErrorAlert, nil);
}
//-------------------------------------------------------------- OpenSavedGame
Boolean OpenSavedGame (void)
{
return false; // TEMP fix this iwth NavServices
/*
StandardFileReply theReply;
SFTypeList theList;
houseType *thisHousePtr;
roomType *destRoom;
savedRoom *srcRoom;
gamePtr savedGame;
long byteCount;
OSErr theErr;
short r, i, gameRefNum;
char wasState;
theList[0] = 'gliG';
StandardGetFile(nil, 1, theList, &theReply);
if (!theReply.sfGood)
return(false);
theErr = FSpOpenDF(&theReply.sfFile, fsCurPerm, &gameRefNum);
if (!CheckFileError(theErr, "\pSaved Game"))
return(false);
theErr = GetEOF(gameRefNum, &byteCount);
if (!CheckFileError(theErr, "\pSaved Game"))
{
theErr = FSClose(gameRefNum);
return(false);
}
savedGame = (gamePtr)NewPtr(byteCount);
if (savedGame == nil)
{
YellowAlert(kYellowFailedSaveGame, MemError());
theErr = FSClose(gameRefNum);
return(false);
}
theErr = SetFPos(gameRefNum, fsFromStart, 0L);
if (!CheckFileError(theErr, "\pSaved Game"))
{
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
return(false);
}
theErr = FSRead(gameRefNum, &byteCount, savedGame);
if (!CheckFileError(theErr, "\pSaved Game"))
{
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
return(false);
}
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
if (!EqualString(savedGame->house.name, thisHouseName, true, true))
{
SavedGameMismatchError(savedGame->house.name);
HSetState((Handle)thisHouse, wasState);
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
return(false);
}
else if (thisHousePtr->timeStamp != savedGame->timeStamp)
{
YellowAlert(kYellowSavedTimeWrong, 0);
HSetState((Handle)thisHouse, wasState);
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
return(false);
}
else if (savedGame->version != kSavedGameVersion)
{
YellowAlert(kYellowSavedVersWrong, kSavedGameVersion);
HSetState((Handle)thisHouse, wasState);
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
return(false);
}
else if (savedGame->nRooms != thisHousePtr->nRooms)
{
YellowAlert(kYellowSavedRoomsWrong, savedGame->nRooms - thisHousePtr->nRooms);
HSetState((Handle)thisHouse, wasState);
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
return(false);
}
else
{
smallGame.wasStarsLeft = savedGame->wasStarsLeft;
smallGame.where.h = savedGame->where.h;
smallGame.where.v = savedGame->where.v;
smallGame.score = savedGame->score;
smallGame.unusedLong = savedGame->unusedLong;
smallGame.unusedLong2 = savedGame->unusedLong2;
smallGame.energy = savedGame->energy;
smallGame.bands = savedGame->bands;
smallGame.roomNumber = savedGame->roomNumber;
smallGame.gliderState = savedGame->gliderState;
smallGame.numGliders = savedGame->numGliders;
smallGame.foil = savedGame->foil;
smallGame.unusedShort = 0;
smallGame.facing = savedGame->facing;
smallGame.showFoil = savedGame->showFoil;
for (r = 0; r < savedGame->nRooms; r++)
{
srcRoom = &(savedGame->savedData[r]);
destRoom = &(thisHousePtr->rooms[r]);
destRoom->visited = srcRoom->visited;
for (i = 0; i < kMaxRoomObs; i++)
destRoom->objects[i] = srcRoom->objects[i];
}
}
HSetState((Handle)thisHouse, wasState);
DisposePtr((Ptr)savedGame);
theErr = FSClose(gameRefNum);
if (!CheckFileError(theErr, "\pSaved Game"))
return (false);
return (true);
*/
}
//-------------------------------------------------------------- SaveGame
// This is probably about 3 days away from becoming the "old" function<6F>
// for saving games.
void SaveGame (Boolean doSave)
{
houseType *thisHousePtr;
UInt32 stamp;
char wasState;
if (twoPlayerGame)
return;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
if (doSave)
{
thisHousePtr->savedGame.version = kSavedGameVersion;
thisHousePtr->savedGame.wasStarsLeft = numStarsRemaining;
GetDateTime(&stamp);
thisHousePtr->savedGame.timeStamp = (long)stamp;
thisHousePtr->savedGame.where.h = theGlider.dest.left;
thisHousePtr->savedGame.where.v = theGlider.dest.top;
thisHousePtr->savedGame.score = theScore;
thisHousePtr->savedGame.unusedLong = 0L;
thisHousePtr->savedGame.unusedLong2 = 0L;
thisHousePtr->savedGame.energy = batteryTotal;
thisHousePtr->savedGame.bands = bandsTotal;
thisHousePtr->savedGame.roomNumber = thisRoomNumber;
thisHousePtr->savedGame.gliderState = theGlider.mode;
thisHousePtr->savedGame.numGliders = mortals;
thisHousePtr->savedGame.foil = foilTotal;
thisHousePtr->savedGame.unusedShort = 0;
thisHousePtr->savedGame.facing = theGlider.facing;
thisHousePtr->savedGame.showFoil = showFoil;
thisHousePtr->hasGame = true;
}
else
{
thisHousePtr->hasGame = false;
}
HSetState((Handle)thisHouse, wasState);
if (doSave)
{
if (!WriteHouse(theMode == kEditMode))
YellowAlert(kYellowFailedWrite, 0);
}
}

458
GpApp/Scoreboard.cpp Normal file
View File

@@ -0,0 +1,458 @@
//============================================================================
//----------------------------------------------------------------------------
// Scoreboard.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "RectUtils.h"
#define kGrayBackgroundColor 251
#define kGrayBackgroundColor4 10
#define kFoilBadge 0
#define kBandsBadge 1
#define kBatteryBadge 2
#define kHeliumBadge 3
#define kScoreRollAmount 13
void RefreshRoomTitle (short);
void RefreshNumGliders (void);
void RefreshPoints (void);
Rect boardSrcRect, badgeSrcRect, boardDestRect;
GWorldPtr boardSrcMap, badgeSrcMap;
Rect boardTSrcRect, boardTDestRect;
GWorldPtr boardTSrcMap;
Rect boardGSrcRect, boardGDestRect;
GWorldPtr boardGSrcMap;
Rect boardPSrcRect, boardPDestRect;
Rect boardPQDestRect, boardGQDestRect;
Rect badgesBlankRects[4], badgesBadgesRects[4];
Rect badgesDestRects[4];
GWorldPtr boardPSrcMap;
long displayedScore;
short wasScoreboardMode;
Boolean doRollScore;
extern Rect localRoomsDest[], justRoomsRect;
extern long gameFrame;
extern short numNeighbors, otherPlayerEscaped;
extern Boolean evenFrame, onePlayerLeft;
//============================================================== Functions
//-------------------------------------------------------------- RefreshScoreboard
void RefreshScoreboard (short mode)
{
doRollScore = true;
RefreshRoomTitle(mode);
RefreshNumGliders();
RefreshPoints();
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&boardSrcRect, &boardDestRect, srcCopy, 0L);
QuickBatteryRefresh(false);
QuickBandsRefresh(false);
QuickFoilRefresh(false);
}
//-------------------------------------------------------------- HandleDynamicScoreboard
void HandleDynamicScoreboard (void)
{
#define kFoilLow 2 // 25%
#define kBatteryLow 17 // 25%
#define kHeliumLow -38 // 25%
#define kBandsLow 2 // 25%
long whosTurn;
if (theScore > displayedScore)
{
if (doRollScore)
{
displayedScore += kScoreRollAmount;
if (displayedScore > theScore)
displayedScore = theScore;
}
else
displayedScore = theScore;
PlayPrioritySound(kScoreTikSound, kScoreTikPriority);
QuickScoreRefresh();
}
whosTurn = gameFrame & 0x00000007;
switch (whosTurn)
{
case 0: // show foil
if ((foilTotal > 0) && (foilTotal < kFoilLow))
QuickFoilRefresh(false);
break;
case 1: // hide battery
if ((batteryTotal > 0) && (batteryTotal < kBatteryLow))
QuickBatteryRefresh(true);
else if ((batteryTotal < 0) && (batteryTotal > kHeliumLow))
QuickBatteryRefresh(true);
break;
case 2: // show rubber bands
if ((bandsTotal > 0) && (bandsTotal < kBandsLow))
QuickBandsRefresh(false);
break;
case 4: // show battery
if ((batteryTotal > 0) && (batteryTotal < kBatteryLow))
QuickBatteryRefresh(false);
else if ((batteryTotal < 0) && (batteryTotal > kHeliumLow))
QuickBatteryRefresh(false);
break;
case 5: // hide foil
if ((foilTotal > 0) && (foilTotal < kFoilLow))
QuickFoilRefresh(true);
break;
case 7: // hide rubber bands
if ((bandsTotal > 0) && (bandsTotal < kBandsLow))
QuickBandsRefresh(true);
break;
}
}
//-------------------------------------------------------------- RefreshRoomTitle
void RefreshRoomTitle (short mode)
{
RGBColor theRGBColor, wasColor;
SetPort((GrafPtr)boardTSrcMap);
GetForeColor(&wasColor);
if (thisMac.isDepth == 4)
Index2Color(kGrayBackgroundColor4, &theRGBColor);
else
Index2Color(kGrayBackgroundColor, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(&boardTSrcRect);
RGBForeColor(&wasColor);
MoveTo(1, 10);
ForeColor(blackColor);
switch (mode)
{
case kEscapedTitleMode:
DrawString(PSTR("Hit Delete key if unable to Follow"));
break;
case kSavingTitleMode:
DrawString(PSTR("Saving Game<6D>"));
break;
default:
DrawString(thisRoom->name);
break;
}
MoveTo(0, 9);
ForeColor(whiteColor);
switch (mode)
{
case kEscapedTitleMode:
DrawString(PSTR("Hit Delete key if unable to Follow"));
break;
case kSavingTitleMode:
DrawString(PSTR("Saving Game<6D>"));
break;
default:
DrawString(thisRoom->name);
break;
}
ForeColor(blackColor);
CopyBits((BitMap *)*GetGWorldPixMap(boardTSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
&boardTSrcRect, &boardTDestRect, srcCopy, nil);
}
//-------------------------------------------------------------- RefreshNumGliders
void RefreshNumGliders (void)
{
RGBColor theRGBColor, wasColor;
Str255 nGlidersStr;
long displayMortals;
SetPort((GrafPtr)boardGSrcMap);
GetForeColor(&wasColor);
if (thisMac.isDepth == 4)
Index2Color(kGrayBackgroundColor4, &theRGBColor);
else
Index2Color(kGrayBackgroundColor, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(&boardGSrcRect);
RGBForeColor(&wasColor);
displayMortals = mortals;
if (displayMortals < 0)
displayMortals = 0;
NumToString(displayMortals, nGlidersStr);
MoveTo(1, 10);
ForeColor(blackColor);
DrawString(nGlidersStr);
MoveTo(0, 9);
ForeColor(whiteColor);
DrawString(nGlidersStr);
ForeColor(blackColor);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
&boardGSrcRect, &boardGDestRect, srcCopy, nil);
}
//-------------------------------------------------------------- RefreshPoints
void RefreshPoints (void)
{
RGBColor theRGBColor, wasColor;
Str255 scoreStr;
SetPort((GrafPtr)boardPSrcMap);
GetForeColor(&wasColor);
if (thisMac.isDepth == 4)
Index2Color(kGrayBackgroundColor4, &theRGBColor);
else
Index2Color(kGrayBackgroundColor, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(&boardPSrcRect);
RGBForeColor(&wasColor);
NumToString(theScore, scoreStr);
MoveTo(1, 10);
ForeColor(blackColor);
DrawString(scoreStr);
MoveTo(0, 9);
ForeColor(whiteColor);
DrawString(scoreStr);
ForeColor(blackColor);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
&boardPSrcRect, &boardPDestRect, srcCopy, nil);
displayedScore = theScore;
}
//-------------------------------------------------------------- QuickGlidersRefresh
void QuickGlidersRefresh (void)
{
RGBColor theRGBColor, wasColor;
Str255 nGlidersStr;
SetPort((GrafPtr)boardGSrcMap);
GetForeColor(&wasColor);
if (thisMac.isDepth == 4)
Index2Color(kGrayBackgroundColor4, &theRGBColor);
else
Index2Color(kGrayBackgroundColor, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(&boardGSrcRect);
RGBForeColor(&wasColor);
NumToString((long)mortals, nGlidersStr);
MoveTo(1, 10);
ForeColor(blackColor);
DrawString(nGlidersStr);
MoveTo(0, 9);
ForeColor(whiteColor);
DrawString(nGlidersStr);
ForeColor(blackColor);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&boardGSrcRect, &boardGQDestRect, srcCopy, nil);
}
//-------------------------------------------------------------- QuickScoreRefresh
void QuickScoreRefresh (void)
{
RGBColor theRGBColor, wasColor;
Str255 scoreStr;
SetPort((GrafPtr)boardPSrcMap);
GetForeColor(&wasColor);
if (thisMac.isDepth == 4)
Index2Color(kGrayBackgroundColor4, &theRGBColor);
else
Index2Color(kGrayBackgroundColor, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(&boardPSrcRect);
RGBForeColor(&wasColor);
NumToString(displayedScore, scoreStr);
MoveTo(1, 10);
ForeColor(blackColor);
DrawString(scoreStr);
MoveTo(0, 9);
ForeColor(whiteColor);
DrawString(scoreStr);
ForeColor(blackColor);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&boardPSrcRect, &boardPQDestRect, srcCopy, nil);
}
//-------------------------------------------------------------- QuickBatteryRefresh
void QuickBatteryRefresh (Boolean flash)
{
if ((batteryTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBadgesRects[kBatteryBadge],
&badgesDestRects[kBatteryBadge],
srcCopy, nil);
}
else if ((batteryTotal < 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBadgesRects[kHeliumBadge],
&badgesDestRects[kHeliumBadge],
srcCopy, nil);
}
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBlankRects[kBatteryBadge],
&badgesDestRects[kBatteryBadge],
srcCopy, nil);
}
}
//-------------------------------------------------------------- QuickBandsRefresh
void QuickBandsRefresh (Boolean flash)
{
if ((bandsTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBadgesRects[kBandsBadge],
&badgesDestRects[kBandsBadge],
srcCopy, nil);
}
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBlankRects[kBandsBadge],
&badgesDestRects[kBandsBadge],
srcCopy, nil);
}
}
//-------------------------------------------------------------- QuickFoilRefresh
void QuickFoilRefresh (Boolean flash)
{
if ((foilTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBadgesRects[kFoilBadge],
&badgesDestRects[kFoilBadge],
srcCopy, nil);
}
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&badgesBlankRects[kFoilBadge],
&badgesDestRects[kFoilBadge],
srcCopy, nil);
}
}
//-------------------------------------------------------------- AdjustScoreboardHeight
void AdjustScoreboardHeight (void)
{
short offset, newMode;
if (numNeighbors == 9)
newMode = kScoreboardHigh;
else
newMode = kScoreboardLow;
if (wasScoreboardMode != newMode)
{
switch (newMode)
{
case kScoreboardHigh: // 9 neighbors
offset = localRoomsDest[kCentralRoom].top;
offset = -offset;
justRoomsRect = workSrcRect;
break;
case kScoreboardLow: // 1 or 3 neighbors
offset = localRoomsDest[kCentralRoom].top;
justRoomsRect = workSrcRect;
justRoomsRect.top = localRoomsDest[kCentralRoom].top;
justRoomsRect.bottom = localRoomsDest[kCentralRoom].bottom;
break;
}
QOffsetRect(&boardDestRect, 0, offset);
QOffsetRect(&boardGQDestRect, 0, offset);
QOffsetRect(&boardPQDestRect, 0, offset);
QOffsetRect(&badgesDestRects[kBatteryBadge], 0, offset);
QOffsetRect(&badgesDestRects[kBandsBadge], 0, offset);
QOffsetRect(&badgesDestRects[kFoilBadge], 0, offset);
QOffsetRect(&badgesDestRects[kHeliumBadge], 0, offset);
wasScoreboardMode = newMode;
}
}
//-------------------------------------------------------------- BlackenScoreboard
void BlackenScoreboard (void)
{
UpdateMenuBarWindow();
}

15
GpApp/Scoreboard.h Normal file
View File

@@ -0,0 +1,15 @@
//============================================================================
//----------------------------------------------------------------------------
// Scoreboard.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr boardSrcMap;
extern GWorldPtr badgeSrcMap;
extern GWorldPtr boardTSrcMap;
extern GWorldPtr boardGSrcMap;
extern GWorldPtr boardPSrcMap;

0
Sources/Scrap.c → GpApp/Scrap.c Executable file → Normal file
View File

676
GpApp/SelectHouse.cpp Normal file
View File

@@ -0,0 +1,676 @@
//============================================================================
//----------------------------------------------------------------------------
// SelectHouse.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLAliases.h"
#include "PLResources.h"
#include "PLSound.h"
#include "PLStringCompare.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "RectUtils.h"
#define kLoadHouseDialogID 1000
#define kDispFiles 12
#define kLoadTitlePictItem 3
#define kLoadNameFirstItem 5
#define kLoadNameLastItem 16
#define kLoadIconFirstItem 17
#define kLoadIconLastItem 28
#define kScrollUpItem 29
#define kScrollDownItem 30
#define kLoadTitlePict1 1001
#define kLoadTitlePict8 1002
#define kDefaultHousePict1 1003
#define kDefaultHousePict8 1004
#define kGrayedOutUpArrow 1052
#define kGrayedOutDownArrow 1053
#define kMaxExtraHouses 8
void UpdateLoadDialog (DialogPtr);
void PageUpHouses (DialogPtr);
void PageDownHouses (DialogPtr);
Boolean LoadFilter (DialogPtr, EventRecord *, short *);
void SortHouseList (void);
void DoDirSearch (void);
Rect loadHouseRects[12];
FSSpecPtr theHousesSpecs;
FSSpec extraHouseSpecs[kMaxExtraHouses];
long lastWhenClick;
Point lastWhereClick;
short housesFound, thisHouseIndex, maxFiles, willMaxFiles;
short housePage, demoHouseIndex, numExtraHouses;
char fileFirstChar[12];
extern UInt32 doubleTime;
//============================================================== Functions
//-------------------------------------------------------------- UpdateLoadWindow
#ifndef COMPILEDEMO
void UpdateLoadDialog (DialogPtr theDialog)
{
Rect tempRect, dialogRect, dummyRect;
short houseStart, houseStop, i, wasResFile, isResFile, count;
// char wasState;
WindowRef theWindow;
// RgnHandle theRegion;
theWindow = GetDialogWindow(theDialog);
GetWindowBounds(theWindow, kWindowContentRgn, &dialogRect);
/*
wasState = HGetState((Handle)(((DialogPeek)theDialog)->window).port.visRgn);
HLock((Handle)(((DialogPeek)theDialog)->window).port.visRgn);
dialogRect = (**((((DialogPeek)theDialog)->window).port.visRgn)).rgnBBox;
HSetState((Handle)(((DialogPeek)theDialog)->window).port.visRgn, wasState);
*/
DrawDialog(theDialog);
ColorFrameWHRect(8, 39, 413, 184, kRedOrangeColor8); // box around files
houseStart = housePage;
houseStop = housesFound;
if ((houseStop - houseStart) > kDispFiles)
houseStop = houseStart + kDispFiles;
wasResFile = CurResFile();
count = 0;
for (i = 0; i < 12; i++)
fileFirstChar[i] = 0x7F;
for (i = houseStart; i < houseStop; i++)
{
SpinCursor(1);
GetDialogItemRect(theDialog, kLoadIconFirstItem + i - housePage,
&tempRect);
if (SectRect(&dialogRect, &tempRect, &dummyRect))
{
isResFile = HOpenResFile(theHousesSpecs[i].vRefNum,
theHousesSpecs[i].parID, theHousesSpecs[i].name, fsRdPerm);
if (isResFile != -1)
{
if (Get1Resource('icl8', -16455) != nil)
{
LargeIconPlot(&tempRect, -16455);
}
else
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
kDefaultHousePict8);
CloseResFile(isResFile);
}
else
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
kDefaultHousePict8);
}
fileFirstChar[count] = theHousesSpecs[i].name[1];
if ((fileFirstChar[count] <= 0x7A) && (fileFirstChar[count] > 0x60))
fileFirstChar[count] -= 0x20;
count++;
DrawDialogUserText(theDialog, kLoadNameFirstItem + i - housePage,
theHousesSpecs[i].name, i == (thisHouseIndex + housePage));
}
InitCursor();
UseResFile(wasResFile);
}
#endif
//-------------------------------------------------------------- PageUpHouses
#ifndef COMPILEDEMO
void PageUpHouses (DialogPtr theDial)
{
Rect tempRect;
if (housePage < kDispFiles)
{
SysBeep(1);
return;
}
housePage -= kDispFiles;
thisHouseIndex = kDispFiles - 1;
ShowDialogItem(theDial, kScrollDownItem);
if (housePage < kDispFiles)
{
GetDialogItemRect(theDial, kScrollUpItem, &tempRect);
HideDialogItem(theDial, kScrollUpItem);
DrawCIcon(kGrayedOutUpArrow, tempRect.left, tempRect.top);
}
QSetRect(&tempRect, 8, 39, 421, 223);
EraseRect(&tempRect);
InvalWindowRect(GetDialogWindow(theDial), &tempRect);
}
#endif
//-------------------------------------------------------------- PageDownHouses
#ifndef COMPILEDEMO
void PageDownHouses (DialogPtr theDial)
{
Rect tempRect;
if (housePage >= (housesFound - kDispFiles))
{
SysBeep(1);
return;
}
housePage += kDispFiles;
thisHouseIndex = 0;
ShowDialogItem(theDial, kScrollUpItem);
if (housePage >= (housesFound - kDispFiles))
{
GetDialogItemRect(theDial, kScrollDownItem, &tempRect);
HideDialogItem(theDial, kScrollDownItem);
DrawCIcon(kGrayedOutDownArrow, tempRect.left, tempRect.top);
}
QSetRect(&tempRect, 8, 39, 421, 223);
EraseRect(&tempRect);
InvalWindowRect(GetDialogWindow(theDial), &tempRect);
}
#endif
//-------------------------------------------------------------- LoadFilter
#ifndef COMPILEDEMO
Boolean LoadFilter (DialogPtr dial, EventRecord *event, short *item)
{
short screenCount, i, wasIndex;
char theChar;
switch (event->what)
{
case keyDown:
theChar = (event->message) & charCodeMask;
switch (theChar)
{
case kReturnKeyASCII:
case kEnterKeyASCII:
FlashDialogButton(dial, kOkayButton);
*item = kOkayButton;
return(true);
break;
case kEscapeKeyASCII:
FlashDialogButton(dial, kCancelButton);
*item = kCancelButton;
return(true);
break;
case kPageUpKeyASCII:
*item = kScrollUpItem;
return (true);
break;
case kPageDownKeyASCII:
*item = kScrollDownItem;
return (true);
break;
case kUpArrowKeyASCII:
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
thisHouseIndex -= 4;
if (thisHouseIndex < 0)
{
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
thisHouseIndex += 4;
thisHouseIndex = (((screenCount - 1) / 4) * 4) +
(thisHouseIndex % 4);
if (thisHouseIndex >= screenCount)
thisHouseIndex -= 4;
}
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
return(true);
break;
case kDownArrowKeyASCII:
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
thisHouseIndex += 4;
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
if (thisHouseIndex >= screenCount)
thisHouseIndex %= 4;
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
return(true);
break;
case kLeftArrowKeyASCII:
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
thisHouseIndex--;
if (thisHouseIndex < 0)
{
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
thisHouseIndex = screenCount - 1;
}
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
return(true);
break;
case kTabKeyASCII:
case kRightArrowKeyASCII:
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
thisHouseIndex++;
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
if (thisHouseIndex >= screenCount)
thisHouseIndex = 0;
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
return(true);
break;
default:
if (((theChar > 0x40) && (theChar <= 0x5A)) ||
((theChar > 0x60) && (theChar <= 0x7A)))
{
if ((theChar > 0x60) && (theChar <= 0x7A))
theChar -= 0x20;
wasIndex = thisHouseIndex;
thisHouseIndex = -1;
i = 0;
do
{
if ((fileFirstChar[i] >= theChar) && (fileFirstChar[i] != 0x7F))
thisHouseIndex = i;
i++;
}
while ((thisHouseIndex == -1) && (i < 12));
if (thisHouseIndex == -1)
{
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
thisHouseIndex = screenCount - 1;
}
if (wasIndex != thisHouseIndex)
{
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[wasIndex]);
InvalWindowRect(GetDialogWindow(dial), &loadHouseRects[thisHouseIndex]);
}
return(true);
}
else
return(false);
}
break;
case mouseDown:
lastWhenClick = event->when - lastWhenClick;
SubPt(event->where, &lastWhereClick);
return(false);
break;
case mouseUp:
lastWhenClick = event->when;
lastWhereClick = event->where;
return(false);
break;
case updateEvt:
BeginUpdate(GetDialogWindow(dial));
UpdateLoadDialog(dial);
EndUpdate(GetDialogWindow(dial));
event->what = nullEvent;
return(false);
break;
default:
return(false);
break;
}
}
#endif
//-------------------------------------------------------------- DoLoadHouse
#ifndef COMPILEDEMO
void DoLoadHouse (void)
{
Rect tempRect;
DialogPtr theDial;
short i, item, wasIndex, screenCount;
Boolean leaving, whoCares;
ModalFilterUPP loadFilterUPP;
loadFilterUPP = NewModalFilterUPP(LoadFilter);
BringUpDialog(&theDial, kLoadHouseDialogID);
if (housesFound <= kDispFiles)
{
GetDialogItemRect(theDial, kScrollUpItem, &tempRect);
HideDialogItem(theDial, kScrollUpItem);
DrawCIcon(kGrayedOutUpArrow, tempRect.left, tempRect.top);
GetDialogItemRect(theDial, kScrollDownItem, &tempRect);
HideDialogItem(theDial, kScrollDownItem);
DrawCIcon(kGrayedOutDownArrow, tempRect.left, tempRect.top);
}
else
{
if (thisHouseIndex < kDispFiles)
{
GetDialogItemRect(theDial, kScrollUpItem, &tempRect);
HideDialogItem(theDial, kScrollUpItem);
DrawCIcon(kGrayedOutUpArrow, tempRect.left, tempRect.top);
}
else if (thisHouseIndex > (housesFound - kDispFiles))
{
GetDialogItemRect(theDial, kScrollDownItem, &tempRect);
HideDialogItem(theDial, kScrollDownItem);
DrawCIcon(kGrayedOutDownArrow, tempRect.left, tempRect.top);
}
}
wasIndex = thisHouseIndex;
housePage = (thisHouseIndex / kDispFiles) * kDispFiles;
thisHouseIndex -= housePage;
for (i = 0; i < 12; i++)
{
GetDialogItemRect(theDial, kLoadNameFirstItem + i,
&loadHouseRects[i]);
GetDialogItemRect(theDial, kLoadIconFirstItem + i,
&tempRect);
loadHouseRects[i].top = tempRect.top;
loadHouseRects[i].bottom++;
}
leaving = false;
while (!leaving)
{
ModalDialog(loadFilterUPP, &item);
if (item == kOkayButton)
{
thisHouseIndex += housePage;
if (thisHouseIndex != wasIndex)
{
whoCares = CloseHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].name,
thisHouseName);
if (OpenHouse())
whoCares = ReadHouse();
}
leaving = true;
}
else if (item == kCancelButton)
{
thisHouseIndex = wasIndex;
leaving = true;
}
else if ((item >= kLoadNameFirstItem) &&
(item <= kLoadNameLastItem))
{
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
if ((item - kLoadNameFirstItem != thisHouseIndex) &&
(item - kLoadNameFirstItem < screenCount))
{
InvalWindowRect(GetDialogWindow(theDial), &loadHouseRects[thisHouseIndex]);
thisHouseIndex = item - kLoadNameFirstItem;
InvalWindowRect(GetDialogWindow(theDial), &loadHouseRects[thisHouseIndex]);
}
if (lastWhereClick.h < 0)
lastWhereClick.h = -lastWhereClick.h;
if (lastWhereClick.v < 0)
lastWhereClick.v = -lastWhereClick.v;
if ((lastWhenClick < doubleTime) && (lastWhereClick.h < 5) &&
(lastWhereClick.v < 5))
{
thisHouseIndex += housePage;
if (thisHouseIndex != wasIndex)
{
MyDisableControl(theDial, kOkayButton);
MyDisableControl(theDial, kCancelButton);
whoCares = CloseHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].name,
thisHouseName);
if (OpenHouse())
whoCares = ReadHouse();
}
leaving = true;
}
}
else if ((item >= kLoadIconFirstItem) &&
(item <= kLoadIconLastItem))
{
screenCount = housesFound - housePage;
if (screenCount > kDispFiles)
screenCount = kDispFiles;
if ((item - kLoadIconFirstItem != thisHouseIndex) &&
(item - kLoadIconFirstItem < screenCount))
{
InvalWindowRect(GetDialogWindow(theDial), &loadHouseRects[thisHouseIndex]);
thisHouseIndex = item - kLoadIconFirstItem;
InvalWindowRect(GetDialogWindow(theDial), &loadHouseRects[thisHouseIndex]);
}
if (lastWhereClick.h < 0)
lastWhereClick.h = -lastWhereClick.h;
if (lastWhereClick.v < 0)
lastWhereClick.v = -lastWhereClick.v;
if ((lastWhenClick < doubleTime) && (lastWhereClick.h < 5) &&
(lastWhereClick.v < 5))
{
thisHouseIndex += housePage;
if (thisHouseIndex != wasIndex)
{
MyDisableControl(theDial, kOkayButton);
MyDisableControl(theDial, kCancelButton);
whoCares = CloseHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].name,
thisHouseName);
if (OpenHouse())
whoCares = ReadHouse();
}
leaving = true;
}
}
else if (item == kScrollUpItem)
{
PageUpHouses(theDial);
}
else if (item == kScrollDownItem)
{
PageDownHouses(theDial);
}
}
DisposeDialog(theDial);
DisposeModalFilterUPP(loadFilterUPP);
}
#endif
//-------------------------------------------------------------- SortHouseList
void SortHouseList (void)
{
FSSpec tempSpec;
short i, h, whosFirst;
i = 0; // remove exact duplicate houses
while (i < housesFound)
{
h = i + 1;
while (h < housesFound)
{
if ((EqualString(theHousesSpecs[i].name, theHousesSpecs[h].name, true, true)) &&
(theHousesSpecs[i].vRefNum == theHousesSpecs[i].vRefNum) &&
(theHousesSpecs[i].parID == theHousesSpecs[i].parID))
{
theHousesSpecs[h] = theHousesSpecs[housesFound - 1];
housesFound--;
}
h++;
}
i++;
}
for (i = 0; i < housesFound - 1; i++)
{
for (h = 0; h < (housesFound - i - 1); h++)
{
whosFirst = WhichStringFirst(theHousesSpecs[h].name,
theHousesSpecs[h + 1].name);
if (whosFirst == 1)
{
tempSpec = theHousesSpecs[h + 1];
theHousesSpecs[h + 1] = theHousesSpecs[h];
theHousesSpecs[h] = tempSpec;
}
}
}
}
//-------------------------------------------------------------- DoDirSearch
void DoDirSearch (void)
{
#define kMaxDirectories 32
CInfoPBRec theBlock;
Str255 nameString;
long theDirs[kMaxDirectories];
OSErr theErr, notherErr;
short count, i, currentDir, numDirs;
for (i = 0; i < kMaxDirectories; i++)
theDirs[i] = 0L;
currentDir = 0;
theDirs[currentDir] = thisMac.dirID;
numDirs = 1;
theBlock.hFileInfo.ioCompletion = nil;
theBlock.hFileInfo.ioVRefNum = thisMac.vRefNum;
theBlock.hFileInfo.ioNamePtr = nameString;
while ((currentDir < numDirs) && (currentDir < kMaxDirectories))
{
count = 1;
theErr = noErr;
while (theErr == noErr)
{
SpinCursor(1);
theBlock.hFileInfo.ioFDirIndex = count;
theBlock.hFileInfo.ioDirID = theDirs[currentDir];
theErr = PBGetCatInfo(&theBlock, false);
if (theErr == noErr)
{
if ((theBlock.hFileInfo.ioFlAttrib & 0x10) == 0x00)
{
if ((theBlock.hFileInfo.ioFlFndrInfo.fdType == 'gliH') &&
(theBlock.hFileInfo.ioFlFndrInfo.fdCreator == 'ozm5') &&
(housesFound < maxFiles))
{
notherErr = FSMakeFSSpec(thisMac.vRefNum,
theBlock.hFileInfo.ioFlParID, nameString,
&theHousesSpecs[housesFound]);
if (notherErr == noErr)
housesFound++;
}
}
else if ((theBlock.hFileInfo.ioFlAttrib & 0x10) == 0x10)
{
if (numDirs < kMaxDirectories)
{
theDirs[numDirs] = theBlock.hFileInfo.ioDirID;
numDirs++;
}
}
count++;
}
}
currentDir++;
}
if (housesFound < 1)
{
thisHouseIndex = -1;
YellowAlert(kYellowNoHouses, 0);
}
else
{
SortHouseList();
thisHouseIndex = 0;
for (i = 0; i < housesFound; i++)
{
if (EqualString(theHousesSpecs[i].name, thisHouseName, false, true))
{
thisHouseIndex = i;
break;
}
}
PasStringCopy(theHousesSpecs[thisHouseIndex].name, thisHouseName);
demoHouseIndex = -1;
for (i = 0; i < housesFound; i++)
{
if (EqualString(theHousesSpecs[i].name, PSTR("Demo House"), false, true))
{
demoHouseIndex = i;
break;
}
}
}
}
//-------------------------------------------------------------- BuildHouseList
void BuildHouseList (void)
{
short i;
if (thisMac.hasSystem7)
{
housesFound = 0; // zero the number of houses found
for (i = 0; i < numExtraHouses; i++) // 1st, insert extra houses into list
{
theHousesSpecs[housesFound] = extraHouseSpecs[i];
housesFound++;
}
DoDirSearch(); // now, search folders for the rest
}
}
//-------------------------------------------------------------- AddExtraHouse
void AddExtraHouse (FSSpec *newHouse)
{
if (numExtraHouses >= kMaxExtraHouses)
return;
extraHouseSpecs[numExtraHouses] = *newHouse;
numExtraHouses++;
}

1482
GpApp/Settings.cpp Normal file

File diff suppressed because it is too large Load Diff

511
GpApp/Sound.cpp Normal file
View File

@@ -0,0 +1,511 @@
//============================================================================
//----------------------------------------------------------------------------
// Sound.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLSound.h"
#include "Externs.h"
#define kBaseBufferSoundID 1000
#define kMaxSounds 64
#define kNoSoundPlaying -1
void CallBack0 (SndChannelPtr, SndCommand *);
void CallBack1 (SndChannelPtr, SndCommand *);
void CallBack2 (SndChannelPtr, SndCommand *);
OSErr LoadBufferSounds (void);
void DumpBufferSounds (void);
OSErr OpenSoundChannels (void);
OSErr CloseSoundChannels (void);
SndCallBackUPP callBack0UPP, callBack1UPP, callBack2UPP;
SndChannelPtr channel0, channel1, channel2;
Ptr theSoundData[kMaxSounds];
short numSoundsLoaded, priority0, priority1, priority2;
short soundPlaying0, soundPlaying1, soundPlaying2;
Boolean soundLoaded[kMaxSounds], dontLoadSounds;
Boolean channelOpen, isSoundOn, failedSound;
//============================================================== Functions
//-------------------------------------------------------------- PlayPrioritySound
void PlayPrioritySound (short which, short priority)
{
short lowestPriority, whosLowest;
if (failedSound || dontLoadSounds)
return;
if ((priority == kTriggerPriority) &&
((priority0 == kTriggerPriority) ||
((priority1 == kTriggerPriority)) ||
((priority2 == kTriggerPriority))))
return;
whosLowest = 0;
lowestPriority = priority0;
if (priority1 < lowestPriority)
{
lowestPriority = priority1;
whosLowest = 1;
}
if (priority2 < lowestPriority)
{
lowestPriority = priority2;
whosLowest = 2;
}
if (priority >= lowestPriority)
{
switch (whosLowest)
{
case 0:
PlaySound0(which, priority);
break;
case 1:
PlaySound1(which, priority);
break;
case 2:
PlaySound2(which, priority);
break;
}
}
}
//-------------------------------------------------------------- FlushAnyTriggerPlaying
void FlushAnyTriggerPlaying (void)
{
SndCommand theCommand;
OSErr theErr;
if (priority0 == kTriggerPriority)
{
theCommand.cmd = quietCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoImmediate(channel0, &theCommand);
theCommand.cmd = flushCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoImmediate(channel0, &theCommand);
}
if (priority1 == kTriggerPriority)
{
theCommand.cmd = quietCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoImmediate(channel1, &theCommand);
theCommand.cmd = flushCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoImmediate(channel1, &theCommand);
}
if (priority2 == kTriggerPriority)
{
theCommand.cmd = quietCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoImmediate(channel2, &theCommand);
theCommand.cmd = flushCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoImmediate(channel2, &theCommand);
}
}
//-------------------------------------------------------------- PlaySound0
void PlaySound0 (short soundID, short priority)
{
SndCommand theCommand;
OSErr theErr;
if (failedSound || dontLoadSounds)
return;
theErr = noErr;
if (isSoundOn)
{
priority0 = priority;
soundPlaying0 = soundID;
theCommand.cmd = bufferCmd;
theCommand.param1 = 0;
theCommand.param2 = (intptr_t)(theSoundData[soundID]);
theErr = SndDoImmediate(channel0, &theCommand);
theCommand.cmd = callBackCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoCommand(channel0, &theCommand, true);
}
}
//-------------------------------------------------------------- PlaySound1
void PlaySound1 (short soundID, short priority)
{
SndCommand theCommand;
OSErr theErr;
if (failedSound || dontLoadSounds)
return;
theErr = noErr;
if (isSoundOn)
{
priority1 = priority;
soundPlaying1 = soundID;
theCommand.cmd = bufferCmd;
theCommand.param1 = 0;
theCommand.param2 = (intptr_t)(theSoundData[soundID]);
theErr = SndDoImmediate(channel1, &theCommand);
theCommand.cmd = callBackCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoCommand(channel1, &theCommand, true);
}
}
//-------------------------------------------------------------- PlaySound2
void PlaySound2 (short soundID, short priority)
{
SndCommand theCommand;
OSErr theErr;
if (failedSound || dontLoadSounds)
return;
theErr = noErr;
if (isSoundOn)
{
theCommand.cmd = bufferCmd;
theCommand.param1 = 0;
theCommand.param2 = (intptr_t)(theSoundData[soundID]);
theErr = SndDoImmediate(channel2, &theCommand);
theCommand.cmd = callBackCmd;
theCommand.param1 = 0;
theCommand.param2 = 0;
theErr = SndDoCommand(channel2, &theCommand, true);
priority2 = priority;
soundPlaying2 = soundID;
}
}
//-------------------------------------------------------------- CallBack0
void CallBack0 (SndChannelPtr theChannel, SndCommand *theCommand)
{
priority0 = 0;
soundPlaying0 = kNoSoundPlaying;
}
//-------------------------------------------------------------- CallBack1
void CallBack1 (SndChannelPtr theChannel, SndCommand *theCommand)
{
priority1 = 0;
soundPlaying1 = kNoSoundPlaying;
}
//-------------------------------------------------------------- CallBack2
void CallBack2 (SndChannelPtr theChannel, SndCommand *theCommand)
{
priority2 = 0;
soundPlaying2 = kNoSoundPlaying;
}
//-------------------------------------------------------------- LoadTriggerSound
OSErr LoadTriggerSound (short soundID)
{
Handle theSound;
long soundDataSize;
OSErr theErr;
if ((dontLoadSounds) || (theSoundData[kMaxSounds - 1] != nil))
theErr = -1;
else
{
// FlushAnyTriggerPlaying();
theErr = noErr;
theSound = GetResource('snd ', soundID);
if (theSound == nil)
{
theErr = -1;
}
else
{
soundDataSize = GetHandleSize(theSound) - 20L;
theSoundData[kMaxSounds - 1] = NewPtr(soundDataSize);
HLock(theSound);
if (theSoundData[kMaxSounds - 1] == nil)
{
ReleaseResource(theSound);
theErr = MemError();
}
else
{
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[kMaxSounds - 1], soundDataSize);
ReleaseResource(theSound);
}
}
}
return (theErr);
}
//-------------------------------------------------------------- DumpTriggerSound
void DumpTriggerSound (void)
{
if (theSoundData[kMaxSounds - 1] != nil)
DisposePtr(theSoundData[kMaxSounds - 1]);
theSoundData[kMaxSounds - 1] = nil;
}
//-------------------------------------------------------------- LoadBufferSounds
OSErr LoadBufferSounds (void)
{
Handle theSound;
long soundDataSize;
OSErr theErr;
short i;
theErr = noErr;
for (i = 0; i < kMaxSounds - 1; i++)
{
theSound = GetResource('snd ', i + kBaseBufferSoundID);
if (theSound == nil)
return (MemError());
HLock(theSound);
soundDataSize = GetHandleSize(theSound) - 20L;
HUnlock(theSound);
theSoundData[i] = NewPtr(soundDataSize);
if (theSoundData[i] == nil)
return (MemError());
HLock(theSound);
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[i], soundDataSize);
ReleaseResource(theSound);
}
theSoundData[kMaxSounds - 1] = nil;
return (theErr);
}
//-------------------------------------------------------------- DumpBufferSounds
void DumpBufferSounds (void)
{
short i;
for (i = 0; i < kMaxSounds; i++)
{
if (theSoundData[i] != nil)
DisposePtr(theSoundData[i]);
theSoundData[i] = nil;
}
}
//-------------------------------------------------------------- OpenSoundChannels
OSErr OpenSoundChannels (void)
{
OSErr theErr;
callBack0UPP = NewSndCallBackProc(CallBack0);
callBack1UPP = NewSndCallBackProc(CallBack1);
callBack2UPP = NewSndCallBackProc(CallBack2);
theErr = noErr;
if (channelOpen)
return (theErr);
theErr = SndNewChannel(&channel0,
sampledSynth, initNoInterp + initMono,
(SndCallBackUPP)callBack0UPP);
if (theErr == noErr)
channelOpen = true;
else
return (theErr);
theErr = SndNewChannel(&channel1,
sampledSynth, initNoInterp + initMono,
(SndCallBackUPP)callBack1UPP);
if (theErr == noErr)
channelOpen = true;
else
return (theErr);
theErr = SndNewChannel(&channel2,
sampledSynth, initNoInterp + initMono,
(SndCallBackUPP)callBack2UPP);
if (theErr == noErr)
channelOpen = true;
return (theErr);
}
//-------------------------------------------------------------- CloseSoundChannels
OSErr CloseSoundChannels (void)
{
OSErr theErr;
theErr = noErr;
if (!channelOpen)
return (theErr);
if (channel0 != nil)
theErr = SndDisposeChannel(channel0, true);
channel0 = nil;
if (channel1 != nil)
theErr = SndDisposeChannel(channel1, true);
channel1 = nil;
if (channel2 != nil)
theErr = SndDisposeChannel(channel2, true);
channel2 = nil;
if (theErr == noErr)
channelOpen = false;
DisposeSndCallBackUPP(callBack0UPP);
DisposeSndCallBackUPP(callBack1UPP);
DisposeSndCallBackUPP(callBack2UPP);
return (theErr);
}
//-------------------------------------------------------------- InitSound
void InitSound (void)
{
OSErr theErr;
if (dontLoadSounds)
return;
failedSound = false;
channel0 = nil;
channel1 = nil;
channel2 = nil;
priority0 = 0;
priority1 = 0;
priority2 = 0;
soundPlaying0 = kNoSoundPlaying;
soundPlaying1 = kNoSoundPlaying;
soundPlaying2 = kNoSoundPlaying;
theErr = LoadBufferSounds();
if (theErr != noErr)
{
YellowAlert(kYellowFailedSound, theErr);
failedSound = true;
}
if (!failedSound)
{
theErr = OpenSoundChannels();
if (theErr != noErr)
{
YellowAlert(kYellowFailedSound, theErr);
failedSound = true;
}
}
}
//-------------------------------------------------------------- KillSound
void KillSound (void)
{
OSErr theErr;
if (dontLoadSounds)
return;
DumpBufferSounds();
theErr = CloseSoundChannels();
}
//-------------------------------------------------------------- SoundBytesNeeded
long SoundBytesNeeded (void)
{
Handle theSound;
long totalBytes;
short i;
totalBytes = 0L;
SetResLoad(false);
for (i = 0; i < kMaxSounds - 1; i++)
{
theSound = GetResource('snd ', i + kBaseBufferSoundID);
if (theSound == nil)
{
SetResLoad(true);
return ((long)ResError());
}
totalBytes += GetMaxResourceSize(theSound);
// ReleaseResource(theSound);
}
SetResLoad(true);
return totalBytes;
}
//-------------------------------------------------------------- TellHerNoSounds
void TellHerNoSounds (void)
{
#define kNoMemForSoundsAlert 1039
short hitWhat;
// CenterAlert(kNoMemForSoundsAlert);
hitWhat = Alert(kNoMemForSoundsAlert, nil);
}
//-------------------------------------------------------------- BitchAboutSM3
void BitchAboutSM3 (void)
{
#define kNoSoundManager3Alert 1030
short hitWhat;
// CenterAlert(kNoSoundManager3Alert);
hitWhat = Alert(kNoSoundManager3Alert, nil);
}

304
GpApp/StringUtils.cpp Normal file
View File

@@ -0,0 +1,304 @@
//============================================================================
//----------------------------------------------------------------------------
// StringUtils.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLPasStr.h"
#include "Externs.h"
#include <string.h>
//============================================================== Functions
//-------------------------------------------------------------- PasStringCopy
// Given a source string and storage for a second, this function<6F>
// copies from one to the other. It assumes Pascal style strings.
void PasStringCopy (StringPtr p1, StringPtr p2)
{
register short stringLength;
stringLength = *p2++ = *p1++;
while (--stringLength >= 0)
*p2++ = *p1++;
}
//-------------------------------------------------------------- WhichStringFirst
// This is a sorting function that handles two Pascal strings. It<49>
// will return a 1 to indicate the 1st string is "greater", a 1 to<74>
// indicate the 2nd was greater and a 0 to indicate that the strings<67>
// are equal.
short WhichStringFirst (StringPtr p1, StringPtr p2)
{
short smallestLength, seek, greater;
char char1, char2;
Boolean foundIt;
smallestLength = p1[0];
if (p2[0] < smallestLength)
smallestLength = p2[0];
greater = 0; // neither are greater, they are equal
seek = 1; // start at character #1
foundIt = false;
do
{
char1 = p1[seek]; // make upper case (if applicable)
if ((char1 > 0x60) && (char1 < 0x7B))
char1 -= 0x20;
char2 = p2[seek]; // make upper case (if applicable)
if ((char2 > 0x60) && (char2 < 0x7B))
char2 -= 0x20;
if (char1 > char2) // first string is greater
{
greater = 1;
foundIt = true;
}
else if (char1 < char2) // second string is greater
{
greater = 2;
foundIt = true;
}
seek++;
if (seek > smallestLength) // we've reached the end of the line
{
if (!foundIt)
{
if (p1[0] < p2[0]) // shortest string wins
greater = 1;
else if (p1[0] > p2[0])
greater = 2;
}
foundIt = true;
}
}
while (!foundIt);
return (greater);
}
//-------------------------------------------------------------- PasStringCopyNum
// This function copies a specified number of characters from one<6E>
// Pascal string to another.
void PasStringCopyNum (StringPtr p1, StringPtr p2, short charsToCopy)
{
short i;
if (charsToCopy > *p1) // if trying to copy more chars than there are
charsToCopy = *p1; // reduce the number of chars to copy to this size
*p2 = static_cast<unsigned char>(charsToCopy);
*p2++;
*p1++;
for (i = 0; i < charsToCopy; i++)
*p2++ = *p1++;
}
//-------------------------------------------------------------- PasStringConcat
// This function concatenates the second Pascal string to the end of<6F>
// the first Pascal string.
void PasStringConcat (StringPtr p1, const PLPasStr &p2)
{
short wasLength, addedLength;
wasLength = *p1;
if (wasLength > 255)
wasLength = 255;
addedLength = p2.Length();
if ((wasLength + addedLength) > 255)
addedLength = 255 - wasLength;
*p1 = wasLength + addedLength;
p1 += (1 + wasLength);
memcpy(p1, p2.Chars(), addedLength);
}
//-------------------------------------------------------------- GetLineOfText
// This function walks through a source string and looks for an<61>
// entire line of text. A "line" of text is assumed to be bounded<65>
// by carriage returns. The index variable indicates which line<6E>
// is sought.
void GetLineOfText (StringPtr srcStr, short index, StringPtr textLine)
{
short i, srcLength, count, start, stop;
Boolean foundIt;
PasStringCopy(PSTR(""), textLine);
srcLength = srcStr[0];
if (index == 0) // walk through to "index"
start = 1;
else
{
start = 0;
count = 0;
i = 0;
foundIt = false;
do
{
i++;
if (srcStr[i] == kReturnKeyASCII)
{
count++;
if (count == index)
{
start = i + 1;
foundIt = true;
}
}
}
while ((i < srcLength) && (!foundIt));
}
if (start != 0)
{
i = start;
foundIt = false;
do
{
if (srcStr[i] == kReturnKeyASCII)
{
stop = i;
foundIt = true;
}
i++;
}
while ((i < srcLength) && (!foundIt));
if (!foundIt)
{
if (start > srcLength)
{
start = srcLength;
stop = srcLength - 1;
}
else
stop = i;
}
count = 0;
for (i = start; i <= stop; i++)
{
count++;
textLine[count] = srcStr[i];
}
textLine[0] = static_cast<unsigned char>(count);
}
}
//-------------------------------------------------------------- WrapText
// Given a string and the maximum number of characters to put on<6F>
// one line, this function goes through and inserts carriage returns<6E>
// in order to ensure that no line of text exceeds maxChars.
void WrapText (StringPtr theText, short maxChars)
{
short lastChar, count, chars, spaceIs;
Boolean foundEdge, foundSpace;
lastChar = theText[0];
count = 0;
do
{
chars = 0;
foundEdge = false;
foundSpace = false;
do
{
count++;
chars++;
if (theText[count] == kReturnKeyASCII)
foundEdge = true;
else if (theText[count] == kSpaceBarASCII)
{
foundSpace = true;
spaceIs = count;
}
}
while ((count < lastChar) && (chars < maxChars) && (!foundEdge));
if ((!foundEdge) && (count < lastChar) && (foundSpace))
{
theText[spaceIs] = kReturnKeyASCII;
count = spaceIs + 1;
}
}
while (count < lastChar);
}
//-------------------------------------------------------------- GetFirstWordOfString
// Walks a string looking for a space (denoting first word of string).
void GetFirstWordOfString (StringPtr stringIn, StringPtr stringOut)
{
short isLong, spaceAt, i;
isLong = stringIn[0];
spaceAt = isLong;
for (i = 1; i < isLong; i++)
{
if ((stringIn[i] == ' ') && (spaceAt == isLong))
spaceAt = i - 1;
}
if (spaceAt <= 0)
PasStringCopy(PSTR(""), stringOut);
else
PasStringCopyNum(stringIn, stringOut, spaceAt);
}
//-------------------------------------------------------------- CollapseStringToWidth
// Given a string and a maximum width (in pixels), this function<6F>
// calculates how wide the text would be drawn with the current<6E>
// font. If the text would exceed our width limit, characters<72>
// are dropped off the end of the string and "<22>" appended.
void CollapseStringToWidth (StringPtr theStr, short wide)
{
short dotsWide;
Boolean tooWide;
dotsWide = StringWidth(PSTR("<EFBFBD>"));
tooWide = StringWidth(theStr) > wide;
while (tooWide)
{
theStr[0]--;
tooWide = ((StringWidth(theStr) + dotsWide) > wide);
if (!tooWide)
PasStringConcat(theStr, PSTR("<EFBFBD>"));
}
}
//-------------------------------------------------------------- GetLocalizedString
StringPtr GetLocalizedString (short index, StringPtr theString)
{
#define kLocalizedStringsID 150
GetIndString(theString, kLocalizedStringsID, index);
return (theString);
}

726
GpApp/StructuresInit.cpp Normal file
View File

@@ -0,0 +1,726 @@
//============================================================================
//----------------------------------------------------------------------------
// StructuresInit.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "Externs.h"
#include "Objects.h"
#include "Play.h"
#include "Player.h"
#include "RectUtils.h"
#include "RubberBands.h"
#include "Scoreboard.h"
#include "Utilities.h"
#define kShadowPictID 3998
#define kBlowerPictID 4000
#define kFurniturePictID 4001
#define kBonusPictID 4002
#define kSwitchPictID 4003
#define kLightPictID 4004
#define kAppliancePictID 4005
#define kPointsPictID 4006
#define kRubberBandsPictID 4007
#define kTransportPictID 4008
#define kToastPictID 4009
#define kShreddedPictID 4010
#define kBalloonPictID 4011
#define kCopterPictID 4012
#define kDartPictID 4013
#define kBallPictID 4014
#define kDripPictID 4015
#define kEnemyPictID 4016
#define kFishPictID 4017
#define kBadgePictID 1996
extern Rect glidSrcRect, leftStartGliderSrc, rightStartGliderSrc;
extern Rect gliderSrc[], shadowSrcRect, shadowSrc[];
extern Rect bandsSrcRect, bandRects[], boardSrcRect, boardDestRect;
extern Rect boardTSrcRect, boardTDestRect, badgeSrcRect;
extern Rect boardGSrcRect, boardGDestRect, boardPSrcRect, boardPDestRect;
extern Rect boardPQDestRect, boardGQDestRect, badgesBlankRects[];
extern Rect badgesBadgesRects[], badgesDestRects[];
extern Rect nailSrcRect, sparkleSrc[];
extern Rect pointsSrc[], breadSrc[];
extern short wasScoreboardMode;
//============================================================== Functions
//-------------------------------------------------------------- InitScoreboardMap
// Any graphics and structures relating to the scoreboard that appears<72>
// across the top of the game are initialized and loaded up here.
void InitScoreboardMap (void)
{
Rect bounds;
PicHandle thePicture;
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
short hOffset;
GetGWorld(&wasCPort, &wasWorld);
wasScoreboardMode = kScoreboardHigh;
boardSrcRect = houseRect;
ZeroRectCorner(&boardSrcRect);
boardSrcRect.bottom = kScoreboardTall;
theErr = CreateOffScreenGWorld(&boardSrcMap, &boardSrcRect, kPreferredDepth);
SetGWorld(boardSrcMap, nil);
if (boardSrcRect.right >= 640)
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
else
hOffset = -576;
thePicture = GetPicture(kScoreboardPictID);
if (thePicture == nil)
RedAlert(kErrFailedGraphicLoad);
HLock((Handle)thePicture);
bounds = (*thePicture)->picFrame;
HUnlock((Handle)thePicture);
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, hOffset, 0);
DrawPicture(thePicture, &bounds);
ReleaseResource((Handle)thePicture);
QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels
theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredDepth);
SetGWorld(badgeSrcMap, nil);
LoadGraphic(kBadgePictID);
boardDestRect = boardSrcRect;
QOffsetRect(&boardDestRect, 0, -kScoreboardTall);
hOffset = (RectWide(&houseRect) - 640) / 2;
if (hOffset < 0)
hOffset = -128;
QSetRect(&boardTSrcRect, 0, 0, 256, 12); // room title
theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredDepth);
SetGWorld(boardTSrcMap, nil);
boardTDestRect = boardTSrcRect;
QOffsetRect(&boardTDestRect, 137 + hOffset, 5);
TextFont(applFont);
TextSize(12);
TextFace(bold);
QSetRect(&boardGSrcRect, 0, 0, 20, 10); // # gliders
theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredDepth);
SetGWorld(boardGSrcMap, nil);
boardGDestRect = boardGSrcRect;
QOffsetRect(&boardGDestRect, 526 + hOffset, 5);
TextFont(applFont);
TextSize(12);
TextFace(bold);
QSetRect(&boardPSrcRect, 0, 0, 64, 10); // points
theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredDepth);
SetGWorld(boardPSrcMap, nil);
boardPDestRect = boardPSrcRect;
QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels
boardPQDestRect = boardPDestRect;
QOffsetRect(&boardPQDestRect, 0, -kScoreboardTall);
boardGQDestRect = boardGDestRect;
QOffsetRect(&boardGQDestRect, 0, -kScoreboardTall);
TextFont(applFont);
TextSize(12);
TextFace(bold);
QSetRect(&badgesBlankRects[0], 0, 0, 16, 16); // foil
QOffsetRect(&badgesBlankRects[0], 0, 0);
QSetRect(&badgesBlankRects[1], 0, 0, 16, 16); // rubber bands
QOffsetRect(&badgesBlankRects[1], 0, 16);
QSetRect(&badgesBlankRects[2], 0, 0, 16, 17); // battery
QOffsetRect(&badgesBlankRects[2], 0, 32);
QSetRect(&badgesBlankRects[3], 0, 0, 16, 17); // helium
QOffsetRect(&badgesBlankRects[3], 0, 49);
QSetRect(&badgesBadgesRects[0], 0, 0, 16, 16); // foil
QOffsetRect(&badgesBadgesRects[0], 16, 0);
QSetRect(&badgesBadgesRects[1], 0, 0, 16, 16); // rubber bands
QOffsetRect(&badgesBadgesRects[1], 16, 16);
QSetRect(&badgesBadgesRects[2], 0, 0, 16, 17); // battery
QOffsetRect(&badgesBadgesRects[2], 16, 32);
QSetRect(&badgesBadgesRects[3], 0, 0, 16, 17); // helium
QOffsetRect(&badgesBadgesRects[3], 16, 49);
QSetRect(&badgesDestRects[0], 0, 0, 16, 16); // foil
QOffsetRect(&badgesDestRects[0], 432 + hOffset, 2 - kScoreboardTall);
QSetRect(&badgesDestRects[1], 0, 0, 16, 16); // rubber bands
QOffsetRect(&badgesDestRects[1], 449 + hOffset, 2 - kScoreboardTall);
QSetRect(&badgesDestRects[2], 0, 0, 16, 17); // battery
QOffsetRect(&badgesDestRects[2], 467 + hOffset, 1 - kScoreboardTall);
QSetRect(&badgesDestRects[3], 0, 0, 16, 17); // helium
QOffsetRect(&badgesDestRects[3], 467 + hOffset, 1 - kScoreboardTall);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitGliderMap
// Graphics and structures relating to the little paper glider (the<68>
// player) are cretaed, loaded up and initialized here.
void InitGliderMap (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
short i;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&glidSrcRect, 0, 0, kGliderWide, 668); // 32112 pixels
theErr = CreateOffScreenGWorld(&glidSrcMap, &glidSrcRect, kPreferredDepth);
SetGWorld(glidSrcMap, nil);
LoadGraphic(kGliderPictID);
theErr = CreateOffScreenGWorld(&glid2SrcMap, &glidSrcRect, kPreferredDepth);
SetGWorld(glid2SrcMap, nil);
LoadGraphic(kGlider2PictID);
theErr = CreateOffScreenGWorld(&glidMaskMap, &glidSrcRect, 1);
SetGWorld(glidMaskMap, nil);
LoadGraphic(kGliderPictID + 1000);
for (i = 0; i <= 20; i++)
{
QSetRect(&gliderSrc[i], 0, 0, kGliderWide, kGliderHigh);
QOffsetRect(&gliderSrc[i], 0, kGliderHigh * i);
}
for (i = 21; i <= 28; i++)
{
QSetRect(&gliderSrc[i], 0, 0, kGliderWide, kGliderBurningHigh);
QOffsetRect(&gliderSrc[i], 0, 420 + (kGliderBurningHigh * (i - 21)));
}
QSetRect(&gliderSrc[29], 0, 0, kGliderWide, kGliderHigh);
QOffsetRect(&gliderSrc[29], 0, 628);
QSetRect(&gliderSrc[30], 0, 0, kGliderWide, kGliderHigh);
QOffsetRect(&gliderSrc[30], 0, 648);
QSetRect(&shadowSrcRect, 0, 0, kGliderWide, kShadowHigh * kNumShadowSrcRects);
theErr = CreateOffScreenGWorld(&shadowSrcMap, &shadowSrcRect, kPreferredDepth);
SetGWorld(shadowSrcMap, nil);
LoadGraphic(kShadowPictID);
theErr = CreateOffScreenGWorld(&shadowMaskMap, &shadowSrcRect, 1);
SetGWorld(shadowMaskMap, nil);
LoadGraphic(kShadowPictID + 1000);
for (i = 0; i < kNumShadowSrcRects; i++)
{
QSetRect(&shadowSrc[i], 0, 0, kGliderWide, kShadowHigh);
QOffsetRect(&shadowSrc[i], 0, kShadowHigh * i);
}
QSetRect(&bandsSrcRect, 0, 0, 16, 18); // 304 pixels
theErr = CreateOffScreenGWorld(&bandsSrcMap, &bandsSrcRect, kPreferredDepth);
SetGWorld(bandsSrcMap, nil);
LoadGraphic(kRubberBandsPictID);
theErr = CreateOffScreenGWorld(&bandsMaskMap, &bandsSrcRect, 1);
SetGWorld(bandsMaskMap, nil);
LoadGraphic(kRubberBandsPictID + 1000);
for (i = 0; i < 3; i++)
{
QSetRect(&bandRects[i], 0, 0, 16, 6);
QOffsetRect(&bandRects[i], 0, 6 * i);
}
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitBlowers
// All blower graphics and structures are loaded up and initialized here.
// Blowers include vents, ducts, candles, fans, etc.
void InitBlowers (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
short i;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&blowerSrcRect, 0, 0, 48, 402); // 19344 pixels
theErr = CreateOffScreenGWorld(&blowerSrcMap, &blowerSrcRect, kPreferredDepth);
SetGWorld(blowerSrcMap, nil);
LoadGraphic(kBlowerPictID);
theErr = CreateOffScreenGWorld(&blowerMaskMap, &blowerSrcRect, 1);
SetGWorld(blowerMaskMap, nil);
LoadGraphic(kBlowerPictID + 1000);
for (i = 0; i < kNumCandleFlames; i++)
{
QSetRect(&flame[i], 0, 0, 16, 15);
QOffsetRect(&flame[i], 32, 179 + (i * 15));
}
for (i = 0; i < kNumTikiFlames; i++)
{
QSetRect(&tikiFlame[i], 0, 0, 8, 10);
QOffsetRect(&tikiFlame[i], 40, 69 + (i * 10));
}
for (i = 0; i < kNumBBQCoals; i++)
{
QSetRect(&coals[i], 0, 0, 32, 9);
QOffsetRect(&coals[i], 0, 304 + (i * 9));
}
QSetRect(&leftStartGliderSrc, 0, 0, 48, 16);
QOffsetRect(&leftStartGliderSrc, 0, 358);
QSetRect(&rightStartGliderSrc, 0, 0, 48, 16);
QOffsetRect(&rightStartGliderSrc, 0, 374);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitFurniture
// Structures and graphics relating to the furniture is loaded up.
// Furniture includes tables, cabinets, shelves, etc.
void InitFurniture (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&furnitureSrcRect, 0, 0, 64, 278); // 17856 pixels
theErr = CreateOffScreenGWorld(&furnitureSrcMap, &furnitureSrcRect, kPreferredDepth);
SetGWorld(furnitureSrcMap, nil);
LoadGraphic(kFurniturePictID);
theErr = CreateOffScreenGWorld(&furnitureMaskMap, &furnitureSrcRect, 1);
SetGWorld(furnitureMaskMap, nil);
LoadGraphic(kFurniturePictID + 1000);
QSetRect(&tableSrc, 0, 0, 64, 22);
QOffsetRect(&tableSrc, 0, 0);
QSetRect(&shelfSrc, 0, 0, 16, 21);
QOffsetRect(&shelfSrc, 0, 22);
QSetRect(&hingeSrc, 0, 0, 4, 16);
QOffsetRect(&hingeSrc, 16, 22);
QSetRect(&handleSrc, 0, 0, 4, 21);
QOffsetRect(&handleSrc, 20, 22);
QSetRect(&knobSrc, 0, 0, 8, 8);
QOffsetRect(&knobSrc, 24, 22);
QSetRect(&leftFootSrc, 0, 0, 16, 16);
QOffsetRect(&leftFootSrc, 32, 22);
QSetRect(&rightFootSrc, 0, 0, 16, 16);
QOffsetRect(&rightFootSrc, 48, 22);
QSetRect(&deckSrc, 0, 0, 64, 21);
QOffsetRect(&deckSrc, 0, 162);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitPrizes
// Structures and graphics relating to the prizes (bonuses) are loaded up.
// Prizes includes clocks, rubber bands, extra gliders, etc.
void InitPrizes (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
short i;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&bonusSrcRect, 0, 0, 88, 378); // 33264 pixels
theErr = CreateOffScreenGWorld(&bonusSrcMap, &bonusSrcRect, kPreferredDepth);
SetGWorld(bonusSrcMap, nil);
LoadGraphic(kBonusPictID);
theErr = CreateOffScreenGWorld(&bonusMaskMap, &bonusSrcRect, 1);
SetGWorld(bonusMaskMap, nil);
LoadGraphic(kBonusPictID + 1000);
for (i = 0; i < 11; i++)
{
QSetRect(&digits[i], 0, 0, 4, 6);
QOffsetRect(&digits[i], 28, i * 6);
}
for (i = 0; i < 3; i++)
{
QSetRect(&pendulumSrc[i], 0, 0, 32, 28);
QOffsetRect(&pendulumSrc[i], 56, 186 + (i * 28));
}
QSetRect(&greaseSrcRt[0], 0, 0, 32, 27);
QOffsetRect(&greaseSrcRt[0], 0, 243);
QSetRect(&greaseSrcRt[1], 0, 0, 32, 27);
QOffsetRect(&greaseSrcRt[1], 0, 270);
QSetRect(&greaseSrcRt[2], 0, 0, 32, 27);
QOffsetRect(&greaseSrcRt[2], 0, 297);
QSetRect(&greaseSrcRt[3], 0, 0, 32, 27);
QOffsetRect(&greaseSrcRt[3], 32, 297);
QSetRect(&greaseSrcLf[0], 0, 0, 32, 27);
QOffsetRect(&greaseSrcLf[0], 0, 324);
QSetRect(&greaseSrcLf[1], 0, 0, 32, 27);
QOffsetRect(&greaseSrcLf[1], 32, 324);
QSetRect(&greaseSrcLf[2], 0, 0, 32, 27);
QOffsetRect(&greaseSrcLf[2], 0, 351);
QSetRect(&greaseSrcLf[3], 0, 0, 32, 27);
QOffsetRect(&greaseSrcLf[3], 32, 351);
for (i = 0; i < 6; i++)
{
QSetRect(&starSrc[i], 0, 0, 32, 31);
QOffsetRect(&starSrc[i], 48, i * 31);
}
for (i = 0; i < 3; i++)
{
QSetRect(&sparkleSrc[i + 2], 0, 0, 20, 19);
QOffsetRect(&sparkleSrc[i + 2], 0, 70 + (i * 19));
}
sparkleSrc[0] = sparkleSrc[4];
sparkleSrc[1] = sparkleSrc[3];
QSetRect(&pointsSrcRect, 0, 0, 24, 120); // 2880 pixels
theErr = CreateOffScreenGWorld(&pointsSrcMap, &pointsSrcRect, kPreferredDepth);
SetGWorld(pointsSrcMap, nil);
LoadGraphic(kPointsPictID);
theErr = CreateOffScreenGWorld(&pointsMaskMap, &pointsSrcRect, 1);
SetGWorld(pointsMaskMap, nil);
LoadGraphic(kPointsPictID + 1000);
for (i = 0; i < 15; i++)
{
QSetRect(&pointsSrc[i], 0, 0, 24, 8);
QOffsetRect(&pointsSrc[i], 0, i * 8);
}
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitTransports
// Structures and graphics relating to the transports is loaded up.
// Transports includes transport ducts, mailboxes, etc.
void InitTransports (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld); // GlidePort: this line was missing?
QSetRect(&transSrcRect, 0, 0, 56, 32); // 1848 pixels
theErr = CreateOffScreenGWorld(&transSrcMap, &transSrcRect, kPreferredDepth);
SetGWorld(transSrcMap, nil);
LoadGraphic(kTransportPictID);
theErr = CreateOffScreenGWorld(&transMaskMap, &transSrcRect, 1);
SetGWorld(transMaskMap, nil);
LoadGraphic(kTransportPictID + 1000);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitSwitches
// Structures and graphics relating to switches are loaded up.
// Switches includes triggers, light switches, etc.
void InitSwitches (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&switchSrcRect, 0, 0, 32, 104); // 3360 pixels
theErr = CreateOffScreenGWorld(&switchSrcMap, &switchSrcRect, kPreferredDepth);
SetGWorld(switchSrcMap, nil);
LoadGraphic(kSwitchPictID);
QSetRect(&lightSwitchSrc[0], 0, 0, 15, 24);
QOffsetRect(&lightSwitchSrc[0], 0, 0);
QSetRect(&lightSwitchSrc[1], 0, 0, 15, 24);
QOffsetRect(&lightSwitchSrc[1], 16, 0);
QSetRect(&machineSwitchSrc[0], 0, 0, 16, 24);
QOffsetRect(&machineSwitchSrc[0], 0, 24);
QSetRect(&machineSwitchSrc[1], 0, 0, 16, 24);
QOffsetRect(&machineSwitchSrc[1], 16, 24);
QSetRect(&thermostatSrc[0], 0, 0, 15, 24);
QOffsetRect(&thermostatSrc[0], 0, 48);
QSetRect(&thermostatSrc[1], 0, 0, 15, 24);
QOffsetRect(&thermostatSrc[1], 16, 48);
QSetRect(&powerSrc[0], 0, 0, 8, 8);
QOffsetRect(&powerSrc[0], 0, 72);
QSetRect(&powerSrc[1], 0, 0, 8, 8);
QOffsetRect(&powerSrc[1], 8, 72);
QSetRect(&knifeSwitchSrc[0], 0, 0, 16, 24);
QOffsetRect(&knifeSwitchSrc[0], 0, 80);
QSetRect(&knifeSwitchSrc[1], 0, 0, 16, 24);
QOffsetRect(&knifeSwitchSrc[1], 16, 80);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitLights
// Structures and graphics relating to lights are loaded up.
// Lights includes table lamps, flourescent lights, track lights, etc.
void InitLights (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
short i;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&lightSrcRect, 0, 0, 72, 126); // 9144 pixels
theErr = CreateOffScreenGWorld(&lightSrcMap, &lightSrcRect, kPreferredDepth);
SetGWorld(lightSrcMap, nil);
LoadGraphic(kLightPictID);
theErr = CreateOffScreenGWorld(&lightMaskMap, &lightSrcRect, 1);
SetGWorld(lightMaskMap, nil);
LoadGraphic(kLightPictID + 1000);
QSetRect(&flourescentSrc1, 0, 0, 16, 12);
QOffsetRect(&flourescentSrc1, 0, 78);
QSetRect(&flourescentSrc2, 0, 0, 16, 12);
QOffsetRect(&flourescentSrc2, 0, 90);
for (i = 0; i < kNumTrackLights; i++)
{
QSetRect(&trackLightSrc[i], 0, 0, 24, 24);
QOffsetRect(&trackLightSrc[i], 24 * i, 102);
}
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitAppliances
// Structures and graphics relating to appliances are loaded up.
// Appliances includes toasters, T.V.s, etc.
void InitAppliances (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
short i;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&applianceSrcRect, 0, 0, 80, 269); // 21600 pixels
theErr = CreateOffScreenGWorld(&applianceSrcMap, &applianceSrcRect, kPreferredDepth);
SetGWorld(applianceSrcMap, nil);
LoadGraphic(kAppliancePictID);
theErr = CreateOffScreenGWorld(&applianceMaskMap, &applianceSrcRect, 1);
SetGWorld(applianceMaskMap, nil);
LoadGraphic(kAppliancePictID + 1000);
QSetRect(&toastSrcRect, 0, 0, 32, 174); // 5600 pixels
theErr = CreateOffScreenGWorld(&toastSrcMap, &toastSrcRect, kPreferredDepth);
SetGWorld(toastSrcMap, nil);
LoadGraphic(kToastPictID);
theErr = CreateOffScreenGWorld(&toastMaskMap, &toastSrcRect, 1);
SetGWorld(toastMaskMap, nil);
LoadGraphic(kToastPictID + 1000);
QSetRect(&shredSrcRect, 0, 0, 40, 35); // 1440 pixels
theErr = CreateOffScreenGWorld(&shredSrcMap, &shredSrcRect, kPreferredDepth);
SetGWorld(shredSrcMap, nil);
LoadGraphic(kShreddedPictID);
theErr = CreateOffScreenGWorld(&shredMaskMap, &shredSrcRect, 1);
SetGWorld(shredMaskMap, nil);
LoadGraphic(kShreddedPictID + 1000);
QSetRect(&plusScreen1, 0, 0, 32, 22);
QOffsetRect(&plusScreen1, 48, 127);
QSetRect(&plusScreen2, 0, 0, 32, 22);
QOffsetRect(&plusScreen2, 48, 149);
QSetRect(&tvScreen1, 0, 0, 64, 49);
QOffsetRect(&tvScreen1, 0, 171);
QSetRect(&tvScreen2, 0, 0, 64, 49);
QOffsetRect(&tvScreen2, 0, 220);
QSetRect(&coffeeLight1, 0, 0, 8, 4);
QOffsetRect(&coffeeLight1, 72, 171);
QSetRect(&coffeeLight2, 0, 0, 8, 4);
QOffsetRect(&coffeeLight2, 72, 175);
for (i = 0; i < kNumOutletPicts; i++)
{
QSetRect(&outletSrc[i], 0, 0, 16, 24);
QOffsetRect(&outletSrc[i], 64, 22 + (i * 24));
}
for (i = 0; i < kNumBreadPicts; i++)
{
QSetRect(&breadSrc[i], 0, 0, 32, 29);
QOffsetRect(&breadSrc[i], 0, i * 29);
}
QSetRect(&vcrTime1, 0, 0, 16, 4);
QOffsetRect(&vcrTime1, 64, 179);
QSetRect(&vcrTime2, 0, 0, 16, 4);
QOffsetRect(&vcrTime2, 64, 183);
QSetRect(&stereoLight1, 0, 0, 4, 1);
QOffsetRect(&stereoLight1, 68, 171);
QSetRect(&stereoLight2, 0, 0, 4, 1);
QOffsetRect(&stereoLight2, 68, 172);
QSetRect(&microOn, 0, 0, 16, 35);
QOffsetRect(&microOn, 64, 222);
QSetRect(&microOff, 0, 0, 16, 35);
QOffsetRect(&microOff, 64, 187);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitEnemies
// Structures and graphics relating to enemies are loaded up.
// Enemies includes darts, balloons, fish, etc.
void InitEnemies (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
short i;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&balloonSrcRect, 0, 0, 24, 30 * kNumBalloonFrames);
theErr = CreateOffScreenGWorld(&balloonSrcMap, &balloonSrcRect, kPreferredDepth);
SetGWorld(balloonSrcMap, nil);
LoadGraphic(kBalloonPictID);
theErr = CreateOffScreenGWorld(&balloonMaskMap, &balloonSrcRect, 1);
SetGWorld(balloonMaskMap, nil);
LoadGraphic(kBalloonPictID + 1000);
QSetRect(&copterSrcRect, 0, 0, 32, 30 * kNumCopterFrames);
theErr = CreateOffScreenGWorld(&copterSrcMap, &copterSrcRect, kPreferredDepth);
SetGWorld(copterSrcMap, nil);
LoadGraphic(kCopterPictID);
theErr = CreateOffScreenGWorld(&copterMaskMap, &copterSrcRect, 1);
SetGWorld(copterMaskMap, nil);
LoadGraphic(kCopterPictID + 1000);
QSetRect(&dartSrcRect, 0, 0, 64, 19 * kNumDartFrames);
theErr = CreateOffScreenGWorld(&dartSrcMap, &dartSrcRect, kPreferredDepth);
SetGWorld(dartSrcMap, nil);
LoadGraphic(kDartPictID);
theErr = CreateOffScreenGWorld(&dartMaskMap, &dartSrcRect, 1);
SetGWorld(dartMaskMap, nil);
LoadGraphic(kDartPictID + 1000);
QSetRect(&ballSrcRect, 0, 0, 32, 32 * kNumBallFrames);
theErr = CreateOffScreenGWorld(&ballSrcMap, &ballSrcRect, kPreferredDepth);
SetGWorld(ballSrcMap, nil);
LoadGraphic(kBallPictID);
theErr = CreateOffScreenGWorld(&ballMaskMap, &ballSrcRect, 1);
SetGWorld(ballMaskMap, nil);
LoadGraphic(kBallPictID + 1000);
QSetRect(&dripSrcRect, 0, 0, 16, 12 * kNumDripFrames);
theErr = CreateOffScreenGWorld(&dripSrcMap, &dripSrcRect, kPreferredDepth);
SetGWorld(dripSrcMap, nil);
LoadGraphic(kDripPictID);
theErr = CreateOffScreenGWorld(&dripMaskMap, &dripSrcRect, 1);
SetGWorld(dripMaskMap, nil);
LoadGraphic(kDripPictID + 1000);
QSetRect(&enemySrcRect, 0, 0, 36, 33);
theErr = CreateOffScreenGWorld(&enemySrcMap, &enemySrcRect, kPreferredDepth);
SetGWorld(enemySrcMap, nil);
LoadGraphic(kEnemyPictID);
theErr = CreateOffScreenGWorld(&enemyMaskMap, &enemySrcRect, 1);
SetGWorld(enemyMaskMap, nil);
LoadGraphic(kEnemyPictID + 1000);
QSetRect(&fishSrcRect, 0, 0, 16, 16 * kNumFishFrames);
theErr = CreateOffScreenGWorld(&fishSrcMap, &fishSrcRect, kPreferredDepth);
SetGWorld(fishSrcMap, nil);
LoadGraphic(kFishPictID);
theErr = CreateOffScreenGWorld(&fishMaskMap, &fishSrcRect, 1);
SetGWorld(fishMaskMap, nil);
LoadGraphic(kFishPictID + 1000);
for (i = 0; i < kNumBalloonFrames; i++)
{
QSetRect(&balloonSrc[i], 0, 0, 24, 30);
QOffsetRect(&balloonSrc[i], 0, 30 * i);
}
for (i = 0; i < kNumCopterFrames; i++)
{
QSetRect(&copterSrc[i], 0, 0, 32, 30);
QOffsetRect(&copterSrc[i], 0, 30 * i);
}
for (i = 0; i < kNumDartFrames; i++)
{
QSetRect(&dartSrc[i], 0, 0, 64, 19);
QOffsetRect(&dartSrc[i], 0, 19 * i);
}
for (i = 0; i < kNumBallFrames; i++)
{
QSetRect(&ballSrc[i], 0, 0, 32, 32);
QOffsetRect(&ballSrc[i], 0, 32 * i);
}
for (i = 0; i < kNumDripFrames; i++)
{
QSetRect(&dripSrc[i], 0, 0, 16, 12);
QOffsetRect(&dripSrc[i], 0, 12 * i);
}
for (i = 0; i < kNumFishFrames; i++)
{
QSetRect(&fishSrc[i], 0, 0, 16, 16);
QOffsetRect(&fishSrc[i], 0, 16 * i);
}
SetGWorld(wasCPort, wasWorld);
}

477
GpApp/StructuresInit2.cpp Normal file
View File

@@ -0,0 +1,477 @@
//============================================================================
//----------------------------------------------------------------------------
// StructuresInit2.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "Externs.h"
#include "Environ.h"
#include "GameOver.h"
#include "MainWindow.h"
#include "Objects.h"
#include "RectUtils.h"
#include "Room.h"
#include "RoomGraphics.h"
#include "Utilities.h"
#define kAngelPictID 1019
#define kSupportPictID 1999
#define kClutterPictID 4018
void InitClutter (void);
void InitSupport (void);
void InitAngel (void);
extern Rect suppSrcRect, justRoomsRect;
extern Rect tileSrcRect, angelSrcRect;
extern GDHandle thisGDevice;
extern CGrafPtr tileSrcMap;
extern FSSpecPtr theHousesSpecs;
extern hotPtr hotSpots;
extern sparklePtr sparkles;
extern flyingPtPtr flyingPoints;
extern flamePtr flames, tikiFlames, bbqCoals;
extern pendulumPtr pendulums;
extern bandPtr bands;
extern greasePtr grease;
extern starPtr theStars;
extern shredPtr shreds;
extern dynaPtr dinahs;
extern demoPtr demoData;
extern short maxFiles;
//============================================================== Functions
//-------------------------------------------------------------- InitClutter
// Structures and graphics relating to clutter are loaded up.
// Clutter includes mirrors, teddy bears, fireplaces, calendars, etc.
void InitClutter (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&clutterSrcRect, 0, 0, 128, 69);
theErr = CreateOffScreenGWorld(&clutterSrcMap, &clutterSrcRect, kPreferredDepth);
SetGWorld(clutterSrcMap, nil);
LoadGraphic(kClutterPictID);
theErr = CreateOffScreenGWorld(&clutterMaskMap, &clutterSrcRect, 1);
SetGWorld(clutterMaskMap, nil);
LoadGraphic(kClutterPictID + 1000);
QSetRect(&flowerSrc[0], 0, 0, 10, 28);
QOffsetRect(&flowerSrc[0], 0, 23);
QSetRect(&flowerSrc[1], 0, 0, 24, 35);
QOffsetRect(&flowerSrc[1], 10, 16);
QSetRect(&flowerSrc[2], 0, 0, 34, 35);
QOffsetRect(&flowerSrc[2], 34, 16);
QSetRect(&flowerSrc[3], 0, 0, 27, 23);
QOffsetRect(&flowerSrc[3], 68, 14);
QSetRect(&flowerSrc[4], 0, 0, 27, 14);
QOffsetRect(&flowerSrc[4], 68, 37);
QSetRect(&flowerSrc[5], 0, 0, 32, 51);
QOffsetRect(&flowerSrc[5], 95, 0);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitSupport
// The floor support grphic is loaded up. It is only visible when<65>
// playing in 9-room mode. It is the horizontal wooden beam that<61>
// seperates floors from one another.
void InitSupport (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&suppSrcRect, 0, 0, kRoomWide, kFloorSupportTall); // 44
theErr = CreateOffScreenGWorld(&suppSrcMap, &suppSrcRect, kPreferredDepth);
SetGWorld(suppSrcMap, nil);
LoadGraphic(kSupportPictID);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- InitAngel
// This loads the graphic of the girl riding the glider. It is seen<65>
// only upon completing a house. She flies across the screen dropping<6E>
// stars below.
void InitAngel (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&angelSrcRect, 0, 0, 96, 44);
theErr = CreateOffScreenGWorld(&angelSrcMap, &angelSrcRect, kPreferredDepth);
SetGWorld(angelSrcMap, nil);
LoadGraphic(kAngelPictID);
theErr = CreateOffScreenGWorld(&angelMaskMap, &angelSrcRect, 1);
SetGWorld(angelMaskMap, nil);
LoadGraphic(kAngelPictID + 1);
SetGWorld(wasCPort, wasWorld);
}
//-------------------------------------------------------------- CreateOffscreens
// All "utility" or "work" offscreen pix/bit maps are created here.
// These would be offscreens that are reused throughout a game - they<65>
// are not static (mere repositories for graphics). Most are used<65>
// to facilitate the animation when a game is in progress.
void CreateOffscreens (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
GetGWorld(&wasCPort, &wasWorld);
justRoomsRect = houseRect;
ZeroRectCorner(&justRoomsRect);
workSrcRect = houseRect; // Set up work map
ZeroRectCorner(&workSrcRect);
theErr = CreateOffScreenGWorld(&workSrcMap, &workSrcRect, kPreferredDepth);
backSrcRect = houseRect; // Set up background map
ZeroRectCorner(&backSrcRect);
theErr = CreateOffScreenGWorld(&backSrcMap, &backSrcRect, kPreferredDepth);
InitScoreboardMap(); SpinCursor(1);
InitGliderMap(); SpinCursor(1);
InitBlowers(); SpinCursor(1);
InitFurniture(); SpinCursor(1);
InitPrizes(); SpinCursor(1);
InitTransports(); SpinCursor(1);
InitSwitches(); SpinCursor(1);
InitLights(); SpinCursor(1);
InitAppliances(); SpinCursor(1);
InitEnemies(); SpinCursor(1);
InitClutter(); SpinCursor(1);
InitSupport(); SpinCursor(1);
InitAngel(); SpinCursor(1);
QSetRect(&tileSrcRect, 0, 0, 128, 80);
tileSrcMap = nil;
// ????
}
//-------------------------------------------------------------- CreatePointers
// This function allocates other large structures. Pointers to hold<6C>
// large arrays, etc.
void CreatePointers (void)
{
Handle tempHandle;
thisRoom = nil;
thisRoom = (roomPtr)NewPtr(sizeof(roomType));
if (thisRoom == nil)
RedAlert(kErrNoMemory);
hotSpots = nil;
hotSpots = (hotPtr)NewPtr(sizeof(hotObject) * kMaxHotSpots);
if (hotSpots == nil)
RedAlert(kErrNoMemory);
sparkles = nil;
sparkles = (sparklePtr)NewPtr(sizeof(sparkleType) * kMaxSparkles);
if (sparkles == nil)
RedAlert(kErrNoMemory);
flyingPoints = nil;
flyingPoints = (flyingPtPtr)NewPtr(sizeof(flyingPtType) * kMaxFlyingPts);
if (flyingPoints == nil)
RedAlert(kErrNoMemory);
flames = nil;
flames = (flamePtr)NewPtr(sizeof(flameType) * kMaxCandles);
if (flames == nil)
RedAlert(kErrNoMemory);
tikiFlames = nil;
tikiFlames = (flamePtr)NewPtr(sizeof(flameType) * kMaxTikis);
if (tikiFlames == nil)
RedAlert(kErrNoMemory);
bbqCoals = nil;
bbqCoals = (flamePtr)NewPtr(sizeof(flameType) * kMaxCoals);
if (bbqCoals == nil)
RedAlert(kErrNoMemory);
pendulums = nil;
pendulums = (pendulumPtr)NewPtr(sizeof(pendulumType) * kMaxPendulums);
if (pendulums == nil)
RedAlert(kErrNoMemory);
// GlidePort: This is broken code, savedMaps is a flat buffer
/*
savedMaps = nil;
savedMaps = (savedPtr)NewPtr(sizeof(savedType) * kMaxSavedMaps);
if (savedMaps == nil)
RedAlert(kErrNoMemory);
for (i = 0; i < kMaxSavedMaps; i++)
savedMaps[i].map = nil;
*/
bands = nil;
bands = (bandPtr)NewPtr(sizeof(bandType) * kMaxRubberBands);
if (bands == nil)
RedAlert(kErrNoMemory);
grease = nil;
grease = (greasePtr)NewPtr(sizeof(greaseType) * kMaxGrease);
if (grease == nil)
RedAlert(kErrNoMemory);
theStars = nil;
theStars = (starPtr)NewPtr(sizeof(starType) * kMaxStars);
if (theStars == nil)
RedAlert(kErrNoMemory);
shreds = nil;
shreds = (shredPtr)NewPtr(sizeof(shredType) * kMaxShredded);
if (shreds == nil)
RedAlert(kErrNoMemory);
dinahs = nil;
dinahs = (dynaPtr)NewPtr(sizeof(dynaType) * kMaxDynamicObs);
if (dinahs == nil)
RedAlert(kErrNoMemory);
masterObjects = nil;
masterObjects = (objDataPtr)NewPtr(sizeof(objDataType) * kMaxMasterObjects);
if (masterObjects == nil)
RedAlert(kErrNoMemory);
srcRects = nil;
srcRects = (Rect *)NewPtr(sizeof(Rect) * kNumSrcRects);
if (srcRects == nil)
RedAlert(kErrNoMemory);
theHousesSpecs = nil;
theHousesSpecs = (FSSpecPtr)NewPtr(sizeof(FSSpec) * maxFiles);
if (theHousesSpecs == nil)
RedAlert(kErrNoMemory);
#ifdef CREATEDEMODATA
demoData = nil;
demoData = (demoPtr)NewPtr(sizeof(demoType) * 2000);
if (demoData == nil)
RedAlert(kErrNoMemory);
#else
demoData = nil;
demoData = (demoPtr)NewPtr(kDemoLength);
if (demoData == nil)
RedAlert(kErrNoMemory);
tempHandle = GetResource('demo', 128);
if (tempHandle == nil)
RedAlert(kErrNoMemory);
else
{
BlockMove(*tempHandle, demoData, kDemoLength);
ReleaseResource(tempHandle);
}
#endif
}
//-------------------------------------------------------------- InitSrcRects
// This is a nasty, ugly function that initializes all global rectangles<65>
// used in Glider PRO.
void InitSrcRects (void)
{
QSetRect(&srcRects[kFloorVent], 0, 0, 48, 11); // Blowers
QOffsetRect(&srcRects[kFloorVent], 0, 0);
QSetRect(&srcRects[kCeilingVent], 0, 0, 48, 11);
QOffsetRect(&srcRects[kCeilingVent], 0, 11);
QSetRect(&srcRects[kFloorBlower], 0, 0, 48, 15);
QOffsetRect(&srcRects[kFloorBlower], 0, 22);
QSetRect(&srcRects[kCeilingBlower], 0, 0, 48, 15);
QOffsetRect(&srcRects[kCeilingBlower], 0, 37);
QSetRect(&srcRects[kSewerGrate], 0, 0, 48, 17);
QOffsetRect(&srcRects[kSewerGrate], 0, 52);
QSetRect(&srcRects[kLeftFan], 0, 0, 40, 55);
QOffsetRect(&srcRects[kLeftFan], 0, 69);
QSetRect(&srcRects[kRightFan], 0, 0, 40, 55);
QOffsetRect(&srcRects[kRightFan], 0, 124);
QSetRect(&srcRects[kTaper], 0, 0, 20, 59);
QOffsetRect(&srcRects[kTaper], 0, 209);
QSetRect(&srcRects[kCandle], 0, 0, 32, 30);
QOffsetRect(&srcRects[kCandle], 0, 179);
QSetRect(&srcRects[kStubby], 0, 0, 20, 36);
QOffsetRect(&srcRects[kStubby], 0, 268);
QSetRect(&srcRects[kTiki], 0, 0, 27, 28);
QOffsetRect(&srcRects[kTiki], 21, 268);
QSetRect(&srcRects[kBBQ], 0, 0, 64, 33);
QSetRect(&srcRects[kInvisBlower], 0, 0, 24, 24);
QSetRect(&srcRects[kGrecoVent], 0, 0, 48, 18);
QOffsetRect(&srcRects[kGrecoVent], 0, 340);
QSetRect(&srcRects[kSewerBlower], 0, 0, 32, 12);
QOffsetRect(&srcRects[kSewerBlower], 0, 390);
QSetRect(&srcRects[kLiftArea], 0, 0, 64, 32);
QSetRect(&srcRects[kTable], 0, 0, 64, kTableThick); // Furniture
QSetRect(&srcRects[kShelf], 0, 0, 64, kShelfThick);
QSetRect(&srcRects[kCabinet], 0, 0, 64, 64);
QSetRect(&srcRects[kFilingCabinet], 0, 0, 74, 107);
QSetRect(&srcRects[kWasteBasket], 0, 0, 64, 61);
QOffsetRect(&srcRects[kWasteBasket], 0, 43);
QSetRect(&srcRects[kMilkCrate], 0, 0, 64, 58);
QOffsetRect(&srcRects[kMilkCrate], 0, 104);
QSetRect(&srcRects[kCounter], 0, 0, 128, 64);
QSetRect(&srcRects[kDresser], 0, 0, 128, 64);
QSetRect(&srcRects[kDeckTable], 0, 0, 64, kTableThick);
QSetRect(&srcRects[kStool], 0, 0, 48, 38);
QOffsetRect(&srcRects[kStool], 0, 183);
QSetRect(&srcRects[kTrunk], 0, 0, 144, 80);
QSetRect(&srcRects[kInvisObstacle], 0, 0, 64, 64);
QSetRect(&srcRects[kManhole], 0, 0, 123, 22);
QSetRect(&srcRects[kBooks], 0, 0, 64, 51);
QSetRect(&srcRects[kInvisBounce], 0, 0, 64, 64);
QSetRect(&srcRects[kRedClock], 0, 0, 28, 17); // Prizes
QSetRect(&srcRects[kBlueClock], 0, 0, 28, 25);
QOffsetRect(&srcRects[kBlueClock], 0, 17);
QSetRect(&srcRects[kYellowClock], 0, 0, 28, 28);
QOffsetRect(&srcRects[kYellowClock], 0, 42);
QSetRect(&srcRects[kCuckoo], 0, 0, 40, 80);
QOffsetRect(&srcRects[kCuckoo], 0, 148);
QSetRect(&srcRects[kPaper], 0, 0, 48, 21);
QOffsetRect(&srcRects[kPaper], 0, 127);
QSetRect(&srcRects[kBattery], 0, 0, 16, 25);
QOffsetRect(&srcRects[kBattery], 32, 0);
QSetRect(&srcRects[kBands], 0, 0, 28, 23);
QOffsetRect(&srcRects[kBands], 20, 70);
QSetRect(&srcRects[kGreaseRt], 0, 0, 32, 27);
QOffsetRect(&srcRects[kGreaseRt], 0, 243);
QSetRect(&srcRects[kGreaseLf], 0, 0, 32, 27);
QOffsetRect(&srcRects[kGreaseLf], 0, 324);
QSetRect(&srcRects[kFoil], 0, 0, 55, 15);
QOffsetRect(&srcRects[kFoil], 0, 228);
QSetRect(&srcRects[kInvisBonus], 0, 0, 24, 24);
QSetRect(&srcRects[kStar], 0, 0, 32, 31);
QOffsetRect(&srcRects[kStar], 48, 0);
QSetRect(&srcRects[kSparkle], 0, 0, 20, 19);
QOffsetRect(&srcRects[kSparkle], 0, 70);
QSetRect(&srcRects[kHelium], 0, 0, 56, 16);
QOffsetRect(&srcRects[kHelium], 32, 270);
QSetRect(&srcRects[kSlider], 0, 0, 64, 16);
QSetRect(&srcRects[kUpStairs], 0, 0, 160, 267); // Transport
QSetRect(&srcRects[kDownStairs], 0, 0, 160, 267);
QSetRect(&srcRects[kMailboxLf], 0, 0, 94, 80);
QSetRect(&srcRects[kMailboxRt], 0, 0, 94, 80);
QSetRect(&srcRects[kFloorTrans], 0, 0, 56, 15);
QOffsetRect(&srcRects[kFloorTrans], 0, 1);
QSetRect(&srcRects[kCeilingTrans], 0, 0, 56, 15);
QOffsetRect(&srcRects[kCeilingTrans], 0, 16);
QSetRect(&srcRects[kDoorInLf], 0, 0, 144, 322);
QSetRect(&srcRects[kDoorInRt], 0, 0, 144, 322);
QSetRect(&srcRects[kDoorExRt], 0, 0, 16, 322);
QSetRect(&srcRects[kDoorExLf], 0, 0, 16, 322);
QSetRect(&srcRects[kWindowInLf], 0, 0, 20, 170);
QSetRect(&srcRects[kWindowInRt], 0, 0, 20, 170);
QSetRect(&srcRects[kWindowExRt], 0, 0, 16, 170);
QSetRect(&srcRects[kWindowExLf], 0, 0, 16, 170);
QSetRect(&srcRects[kInvisTrans], 0, 0, 64, 32);
QSetRect(&srcRects[kDeluxeTrans], 0, 0, 64, 64);
QSetRect(&srcRects[kLightSwitch], 0, 0, 15, 24); // Switch
QSetRect(&srcRects[kMachineSwitch], 0, 0, 16, 24);
QOffsetRect(&srcRects[kMachineSwitch], 0, 48);
QSetRect(&srcRects[kThermostat], 0, 0, 15, 24);
QOffsetRect(&srcRects[kThermostat], 0, 48);
QSetRect(&srcRects[kPowerSwitch], 0, 0, 8, 8);
QOffsetRect(&srcRects[kPowerSwitch], 0, 72);
QSetRect(&srcRects[kKnifeSwitch], 0, 0, 16, 24);
QOffsetRect(&srcRects[kKnifeSwitch], 0, 80);
QSetRect(&srcRects[kInvisSwitch], 0, 0, 12, 12);
QSetRect(&srcRects[kTrigger], 0, 0, 12, 12);
QSetRect(&srcRects[kLgTrigger], 0, 0, 48, 48);
QSetRect(&srcRects[kSoundTrigger], 0, 0, 32, 32);
QSetRect(&srcRects[kCeilingLight], 0, 0, 64, 20); // Lights
QOffsetRect(&srcRects[kCeilingLight], 0, 0);
QSetRect(&srcRects[kLightBulb], 0, 0, 16, 28);
QOffsetRect(&srcRects[kLightBulb], 0, 20);
QSetRect(&srcRects[kTableLamp], 0, 0, 48, 70);
QOffsetRect(&srcRects[kTableLamp], 16, 20);
QSetRect(&srcRects[kHipLamp], 0, 0, 72, 276);
QSetRect(&srcRects[kDecoLamp], 0, 0, 64, 212);
QSetRect(&srcRects[kFlourescent], 0, 0, 64, 12);
QSetRect(&srcRects[kTrackLight], 0, 0, 64, 24);
QSetRect(&srcRects[kInvisLight], 0, 0, 16, 16);
QSetRect(&srcRects[kShredder], 0, 0, 73, 22); // Appliances
QSetRect(&srcRects[kToaster], 0, 0, 48, 27);
QOffsetRect(&srcRects[kToaster], 0, 22);
QSetRect(&srcRects[kMacPlus], 0, 0, 48, 58);
QOffsetRect(&srcRects[kMacPlus], 0, 49);
QSetRect(&srcRects[kGuitar], 0, 0, 64, 172);
QSetRect(&srcRects[kTV], 0, 0, 92, 77);
QSetRect(&srcRects[kCoffee], 0, 0, 43, 64);
QOffsetRect(&srcRects[kCoffee], 0, 107);
QSetRect(&srcRects[kOutlet], 0, 0, 16, 24);
QOffsetRect(&srcRects[kOutlet], 64, 22);
QSetRect(&srcRects[kVCR], 0, 0, 96, 22);
QSetRect(&srcRects[kStereo], 0, 0, 128, 53);
QSetRect(&srcRects[kMicrowave], 0, 0, 92, 59);
QSetRect(&srcRects[kCinderBlock], 0, 0, 40, 62);
QSetRect(&srcRects[kFlowerBox], 0, 0, 80, 32);
QSetRect(&srcRects[kCDs], 0, 0, 16, 30);
QOffsetRect(&srcRects[kCDs], 48, 22);
QSetRect(&srcRects[kCustomPict], 0, 0, 72, 34);
QSetRect(&srcRects[kBalloon], 0, 0, 24, 30); // Enemies
QSetRect(&srcRects[kCopterLf], 0, 0, 32, 30);
QSetRect(&srcRects[kCopterRt], 0, 0, 32, 30);
QSetRect(&srcRects[kDartLf], 0, 0, 64, 19);
QSetRect(&srcRects[kDartRt], 0, 0, 64, 19);
QSetRect(&srcRects[kBall], 0, 0, 32, 32);
QSetRect(&srcRects[kDrip], 0, 0, 16, 12);
QSetRect(&srcRects[kFish], 0, 0, 36, 33);
QSetRect(&srcRects[kCobweb], 0, 0, 54, 45);
QSetRect(&srcRects[kOzma], 0, 0, 102, 92); // Clutter
QSetRect(&srcRects[kMirror], 0, 0, 64, 64);
QSetRect(&srcRects[kMousehole], 0, 0, 10, 11);
QSetRect(&srcRects[kFireplace], 0, 0, 180, 142);
QSetRect(&srcRects[kWallWindow], 0, 0, 64, 80);
QSetRect(&srcRects[kBear], 0, 0, 56, 58);
QSetRect(&srcRects[kCalendar], 0, 0, 63, 92);
QSetRect(&srcRects[kVase1], 0, 0, 36, 45);
QSetRect(&srcRects[kVase2], 0, 0, 35, 57);
QSetRect(&srcRects[kBulletin], 0, 0, 80, 58);
QSetRect(&srcRects[kCloud], 0, 0, 128, 30);
QSetRect(&srcRects[kFaucet], 0, 0, 56, 18);
QOffsetRect(&srcRects[kFaucet], 0, 51);
QSetRect(&srcRects[kRug], 0, 0, 144, 18);
QSetRect(&srcRects[kChimes], 0, 0, 28, 74);
}

546
GpApp/Tools.cpp Normal file
View File

@@ -0,0 +1,546 @@
//============================================================================
//----------------------------------------------------------------------------
// Tools.c
//----------------------------------------------------------------------------
//============================================================================
#include "PLTextUtils.h"
#include "PLControlDefinitions.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "RectUtils.h"
#include "Utilities.h"
#define kToolsHigh 4
#define kToolsWide 4
#define kTotalTools 16 // kToolsHigh * kToolsWide
#define kPopUpControl 129
#define kFirstBlower 1
#define kLastBlower 15
#define kBlowerBase 1
#define kFirstFurniture 1
#define kLastFurniture 15
#define kFurnitureBase 21
#define kFirstBonus 1
#define kLastBonus 15
#define kBonusBase 41
#define kFirstTransport 1
#define kLastTransport 12
#define kTransportBase 61
#define kFirstSwitch 1
#define kLastSwitch 9
#define kSwitchBase 81
#define kFirstLight 1
#define kLastLight 8
#define kLightBase 101
#define kFirstAppliance 1
#define kLastAppliance 14
#define kApplianceBase 121
#define kFirstEnemy 1
#define kLastEnemy 9
#define kEnemyBase 141
#define kFirstClutter 1
#define kLastClutter 15
#define kClutterBase 161
#define kToolsPictID 1011
void CreateToolsOffscreen (void);
void KillToolsOffscreen (void);
void FrameSelectedTool (void);
void DrawToolName (void);
void DrawToolTiles (void);
void SwitchToolModes (short);
Rect toolsWindowRect, toolSrcRect, toolTextRect;
Rect toolRects[kTotalTools];
ControlHandle classPopUp;
GWorldPtr toolSrcMap;
WindowPtr toolsWindow;
short isToolsH, isToolsV;
short toolSelected, toolMode;
short firstTool, lastTool, objectBase;
Boolean isToolsOpen;
//============================================================== Functions
//-------------------------------------------------------------- CreateToolsOffscreen
#ifndef COMPILEDEMO
void CreateToolsOffscreen (void)
{
CGrafPtr wasCPort;
GDHandle wasWorld;
OSErr theErr;
if (toolSrcMap == nil)
{
GetGWorld(&wasCPort, &wasWorld);
QSetRect(&toolSrcRect, 0, 0, 360, 216);
theErr = CreateOffScreenGWorld(&toolSrcMap, &toolSrcRect, kPreferredDepth);
SetGWorld(toolSrcMap, nil);
LoadGraphic(kToolsPictID);
SetGWorld(wasCPort, wasWorld);
}
}
#endif
//-------------------------------------------------------------- KillToolsOffscreen
#ifndef COMPILEDEMO
void KillToolsOffscreen (void)
{
if (toolSrcMap != nil)
{
DisposeGWorld(toolSrcMap);
// KillOffScreenPixMap(toolSrcMap);
toolSrcMap = nil;
}
}
#endif
//-------------------------------------------------------------- FrameSelectedTool
#ifndef COMPILEDEMO
void FrameSelectedTool (void)
{
Rect theRect;
short toolIcon;
toolIcon = toolSelected;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))
{
toolIcon--;
}
else if ((toolMode == kTransportMode) && (toolIcon >= 7))
{
if (toolIcon >= 15)
toolIcon -= 4;
else
toolIcon = ((toolIcon - 7) / 2) + 7;
}
theRect = toolRects[toolIcon];
PenSize(2, 2);
ForeColor(redColor);
FrameRect(&theRect);
PenNormal();
ForeColor(blackColor);
}
#endif
//-------------------------------------------------------------- DrawToolName
#ifndef COMPILEDEMO
void DrawToolName (void)
{
Str255 theString;
if (toolSelected == 0)
PasStringCopy(PSTR("Selection Tool"), theString);
else
GetIndString(theString, kObjectNameStrings,
toolSelected + ((toolMode - 1) * 0x0010));
EraseRect(&toolTextRect);
MoveTo(toolTextRect.left + 3, toolTextRect.bottom - 6);
TextFont(applFont);
TextSize(9);
TextFace(bold);
ColorText(theString, 171L);
}
#endif
//-------------------------------------------------------------- DrawToolTiles
#ifndef COMPILEDEMO
void DrawToolTiles (void)
{
Rect srcRect, destRect;
short i;
DrawCIcon(2000, toolRects[0].left, toolRects[0].top); // Selection Tool
for (i = 0; i < 15; i++) // Other tools
{
QSetRect(&srcRect, 0, 0, 24, 24);
QSetRect(&destRect, 0, 0, 24, 24);
QOffsetRect(&srcRect, i * 24, (toolMode - 1) * 24);
QOffsetRect(&destRect, toolRects[i + 1].left + 2, toolRects[i + 1].top + 2);
CopyBits((BitMap *)*GetGWorldPixMap(toolSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(toolsWindow)),
&srcRect, &destRect, srcCopy, nil);
}
}
#endif
//-------------------------------------------------------------- EraseSelectedTool
void EraseSelectedTool (void)
{
#ifndef COMPILEDEMO
Rect theRect;
short toolIcon;
if (toolsWindow == nil)
return;
SetPort((GrafPtr)toolsWindow);
toolIcon = toolSelected;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))
{
toolIcon--;
}
else if ((toolMode == kTransportMode) && (toolIcon >= 7))
{
if (toolIcon >= 15)
toolIcon -= 4;
else
toolIcon = ((toolIcon - 7) / 2) + 7;
}
theRect = toolRects[toolIcon];
PenSize(2, 2);
ForeColor(whiteColor);
FrameRect(&theRect);
#endif
}
//-------------------------------------------------------------- SelectTool
void SelectTool (short which)
{
#ifndef COMPILEDEMO
Rect theRect;
short toolIcon;
if (toolsWindow == nil)
return;
SetPort((GrafPtr)toolsWindow);
toolIcon = which;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))
{
toolIcon--;
}
else if ((toolMode == kTransportMode) && (toolIcon >= 7))
{
if (toolIcon >= 15)
toolIcon -= 4;
else
toolIcon = ((toolIcon - 7) / 2) + 7;
}
theRect = toolRects[toolIcon];
ForeColor(redColor);
FrameRect(&theRect);
PenNormal();
ForeColor(blackColor);
toolSelected = which;
DrawToolName();
#endif
}
//-------------------------------------------------------------- UpdateToolsWindow
void UpdateToolsWindow (void)
{
#ifndef COMPILEDEMO
if (toolsWindow == nil)
return;
SetPortWindowPort(toolsWindow);
DrawControls(toolsWindow);
DkGrayForeColor();
MoveTo(4, 25);
Line(108, 0);
ForeColor(blackColor);
DrawToolTiles();
FrameSelectedTool();
DrawToolName();
#endif
}
//-------------------------------------------------------------- OpenToolsWindow
void OpenToolsWindow (void)
{
#ifndef COMPILEDEMO
Rect src, dest;
Point globalMouse;
short h, v;
if (toolsWindow == nil)
{
QSetRect(&toolsWindowRect, 0, 0, 116, 152); // 143
QSetRect(&toolTextRect, 0, 0, 116, 12);
InsetRect(&toolTextRect, -1, -1);
QOffsetRect(&toolTextRect, 0, 157 - 15);
if (thisMac.hasColor)
toolsWindow = NewCWindow(nil, &toolsWindowRect,
PSTR("Tools"), false, kWindoidWDEF, kPutInFront, true, 0L);
else
toolsWindow = NewWindow(nil, &toolsWindowRect,
PSTR("Tools"), false, kWindoidWDEF, kPutInFront, true, 0L);
if (toolsWindow == nil)
RedAlert(kErrNoMemory);
// if (OptionKeyDown())
// {
// isToolsH = qd.screenBits.bounds.right - 120;
// isToolsV = 35;
// }
MoveWindow(toolsWindow, isToolsH, isToolsV, true);
globalMouse = MyGetGlobalMouse();
QSetRect(&src, 0, 0, 1, 1);
QOffsetRect(&src, globalMouse.h, globalMouse.v);
GetWindowRect(toolsWindow, &dest);
BringToFront(toolsWindow);
ShowHide(toolsWindow, true);
// FlagWindowFloating(toolsWindow); TEMP - use flaoting windows
HiliteAllWindows();
classPopUp = GetNewControl(kPopUpControl, toolsWindow);
if (classPopUp == nil)
RedAlert(kErrFailedResourceLoad);
SetControlValue(classPopUp, toolMode);
for (v = 0; v < kToolsHigh; v++)
for (h = 0; h < kToolsWide; h++)
{
QSetRect(&toolRects[(v * kToolsWide) + h], 2, 29, 30, 57);
QOffsetRect(&toolRects[(v * kToolsWide) + h], h * 28, v * 28);
}
CreateToolsOffscreen();
SwitchToolModes(toolMode);
toolSelected = kSelectTool;
}
UpdateToolsCheckmark(true);
#endif
}
//-------------------------------------------------------------- CloseToolsWindow
void CloseToolsWindow (void)
{
#ifndef COMPILEDEMO
CloseThisWindow(&toolsWindow);
KillToolsOffscreen();
UpdateToolsCheckmark(false);
#endif
}
//-------------------------------------------------------------- ToggleToolsWindow
void ToggleToolsWindow (void)
{
#ifndef COMPILEDEMO
if (toolsWindow == nil)
{
OpenToolsWindow();
isToolsOpen = true;
}
else
{
CloseToolsWindow();
isToolsOpen = true;
}
#endif
}
//-------------------------------------------------------------- SwitchToolModes
#ifndef COMPILEDEMO
void SwitchToolModes (short newMode)
{
if (toolsWindow == nil)
return;
SelectTool(kSelectTool);
switch (newMode)
{
case kBlowerMode:
firstTool = kFirstBlower;
lastTool = kLastBlower;
objectBase = kBlowerBase;
break;
case kFurnitureMode:
firstTool = kFirstFurniture;
lastTool = kLastFurniture;
objectBase = kFurnitureBase;
break;
case kBonusMode:
firstTool = kFirstBonus;
lastTool = kLastBonus;
objectBase = kBonusBase;
break;
case kTransportMode:
firstTool = kFirstTransport;
lastTool = kLastTransport;
objectBase = kTransportBase;
break;
case kSwitchMode:
firstTool = kFirstSwitch;
lastTool = kLastSwitch;
objectBase = kSwitchBase;
break;
case kLightMode:
firstTool = kFirstLight;
lastTool = kLastLight;
objectBase = kLightBase;
break;
case kApplianceMode:
firstTool = kFirstAppliance;
lastTool = kLastAppliance;
objectBase = kApplianceBase;
break;
case kEnemyMode:
firstTool = kFirstEnemy;
lastTool = kLastEnemy;
objectBase = kEnemyBase;
break;
case kClutterMode:
firstTool = kFirstClutter;
lastTool = kLastClutter;
objectBase = kClutterBase;
break;
}
toolMode = newMode;
InvalWindowRect(toolsWindow, &toolsWindowRect);
}
#endif
//-------------------------------------------------------------- HandleToolsClick
void HandleToolsClick (Point wherePt)
{
#ifndef COMPILEDEMO
ControlHandle theControl;
short i, part, newMode, toolIcon;
if (toolsWindow == nil)
return;
SetPortWindowPort(toolsWindow);
GlobalToLocal(&wherePt);
part = FindControl(wherePt, toolsWindow, &theControl);
if ((theControl != nil) && (part != 0))
{
part = TrackControl(theControl, wherePt, (ControlActionUPP)-1L);
if (part != 0)
{
newMode = GetControlValue(theControl);
if (newMode != toolMode)
{
EraseSelectedTool();
SwitchToolModes(newMode);
}
}
}
else
{
for (i = 0; i < kTotalTools; i++)
if ((PtInRect(wherePt, &toolRects[i])) && (i <= lastTool))
{
EraseSelectedTool();
toolIcon = i;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))
{
toolIcon++;
}
if ((toolMode == kTransportMode) && (toolIcon >= 7))
{
if (toolIcon >= 11)
toolIcon += 4;
else
toolIcon = ((toolIcon - 7) * 2) + 7;
}
SelectTool(toolIcon);
break;
}
}
#endif
}
//-------------------------------------------------------------- NextToolMode
void NextToolMode (void)
{
#ifndef COMPILEDEMO
if (toolsWindow == nil)
return;
if ((theMode == kEditMode) && (toolMode < kClutterMode))
{
EraseSelectedTool();
toolMode++;
SetControlValue(classPopUp, toolMode);
SwitchToolModes(toolMode);
toolSelected = kSelectTool;
}
#endif
}
//-------------------------------------------------------------- PrevToolMode
void PrevToolMode (void)
{
#ifndef COMPILEDEMO
if (toolsWindow == nil)
return;
if ((theMode == kEditMode) && (toolMode > kBlowerMode))
{
EraseSelectedTool();
toolMode--;
SetControlValue(classPopUp, toolMode);
SwitchToolModes(toolMode);
toolSelected = kSelectTool;
}
#endif
}
//-------------------------------------------------------------- SetSpecificToolMode
void SetSpecificToolMode (short modeToSet)
{
#ifndef COMPILEDEMO
if ((toolsWindow == nil) || (theMode != kEditMode))
return;
EraseSelectedTool();
toolMode = modeToSet;
SetControlValue(classPopUp, toolMode);
SwitchToolModes(toolMode);
toolSelected = kSelectTool;
#endif
}

12
GpApp/Tools.h Normal file
View File

@@ -0,0 +1,12 @@
//============================================================================
//----------------------------------------------------------------------------
// Tools.h
//----------------------------------------------------------------------------
//============================================================================
#include "PLQDOffscreen.h"
extern GWorldPtr toolSrcMap;
extern WindowPtr toolsWindow;

558
GpApp/Transit.cpp Normal file
View File

@@ -0,0 +1,558 @@
//============================================================================
//----------------------------------------------------------------------------
// Transit.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "RectUtils.h"
void HandleRoomVisitation (void);
short linkedToWhat;
Boolean takingTheStairs, firstPlayer;
extern Rect justRoomsRect, transRect;
extern short transRoom, otherPlayerEscaped;
extern short localNumbers[9];
extern Boolean topOpen, twoPlayerGame, onePlayerLeft;
extern Boolean playerDead, playerSuicide, tvOn;
//============================================================== Functions
//-------------------------------------------------------------- WhatAreWeLinkedTo
short WhatAreWeLinkedTo (short where, Byte who)
{
short what, whatType;
char wasState;
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
what = (*thisHouse)->rooms[where].objects[who].what;
HSetState((Handle)thisHouse, wasState);
switch (what)
{
case kMailboxLf:
whatType = kLinkedToLeftMailbox;
break;
case kMailboxRt:
whatType = kLinkedToRightMailbox;
break;
case kCeilingTrans:
whatType = kLinkedToCeilingDuct;
break;
default:
whatType = kLinkedToOther;
break;
}
return (whatType);
}
//-------------------------------------------------------------- ReadyGliderFromTransit
void ReadyGliderFromTransit (gliderPtr thisGlider, short toWhat)
{
Rect tempRect;
if ((twoPlayerGame) && (onePlayerLeft) && (thisGlider->which == playerDead))
return;
FlagGliderNormal(thisGlider);
switch (toWhat)
{
case kLinkedToOther:
StartGliderTransportingIn(thisGlider); // set glider's mode
tempRect = thisGlider->dest; // position glider
CenterRectInRect(&tempRect, &transRect);
thisGlider->dest.left = tempRect.left;
thisGlider->dest.right = tempRect.right;
thisGlider->dest.top = tempRect.top;
thisGlider->dest.bottom = tempRect.bottom;
thisGlider->destShadow.left = tempRect.left;
thisGlider->destShadow.right = tempRect.right;
thisGlider->whole = thisGlider->dest;
thisGlider->wholeShadow = thisGlider->destShadow;
thisGlider->enteredRect = thisGlider->dest;
break;
case kLinkedToLeftMailbox:
StartGliderMailingOut(thisGlider);
thisGlider->clip = transRect; // fix clip
thisGlider->clip.right -= 64;
thisGlider->clip.bottom -= 25;
tempRect = thisGlider->dest;
thisGlider->dest.left = thisGlider->clip.right;
thisGlider->dest.right = thisGlider->dest.left;
thisGlider->dest.bottom = thisGlider->clip.bottom - 4;
thisGlider->dest.top = thisGlider->dest.bottom - RectTall(&tempRect);
thisGlider->destShadow.left = thisGlider->dest.left;
thisGlider->destShadow.right = thisGlider->dest.right;
thisGlider->whole = thisGlider->dest;
thisGlider->wholeShadow = thisGlider->destShadow;
break;
case kLinkedToRightMailbox:
StartGliderMailingOut(thisGlider);
thisGlider->clip = transRect; // fix clip
thisGlider->clip.left += 79;
thisGlider->clip.bottom -= 25;
tempRect = thisGlider->dest;
thisGlider->dest.right = thisGlider->clip.left;
thisGlider->dest.left = thisGlider->dest.right;
thisGlider->dest.bottom = thisGlider->clip.bottom - 4;
thisGlider->dest.top = thisGlider->dest.bottom - RectTall(&tempRect);
thisGlider->destShadow.left = thisGlider->dest.left;
thisGlider->destShadow.right = thisGlider->dest.right;
thisGlider->whole = thisGlider->dest;
thisGlider->wholeShadow = thisGlider->destShadow;
break;
case kLinkedToCeilingDuct:
StartGliderDuctingIn(thisGlider);
tempRect = thisGlider->dest; // set glider's position
CenterRectInRect(&tempRect, &transRect);
thisGlider->dest.left = tempRect.left;
thisGlider->dest.right = tempRect.right;
thisGlider->dest.top = tempRect.top;
thisGlider->dest.bottom = thisGlider->dest.top;
QOffsetRect(&thisGlider->dest, 0, -RectTall(&tempRect));
thisGlider->destShadow.left = tempRect.left;
thisGlider->destShadow.right = tempRect.right;
thisGlider->whole = thisGlider->dest;
thisGlider->wholeShadow = thisGlider->destShadow;
break;
case kLinkedToFloorDuct:
break;
default:
break;
}
if ((twoPlayerGame) && (thisGlider->which != firstPlayer))
TagGliderIdle(thisGlider);
}
//-------------------------------------------------------------- MoveRoomToRoom
void MoveRoomToRoom (gliderPtr thisGlider, short where)
{
Rect enterRect;
HandleRoomVisitation();
switch (where)
{
case kToRight:
SetMusicalMode(kProdGameScoreMode);
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider);
UndoGliderLimbo(&theGlider2);
InsureGliderFacingRight(&theGlider);
InsureGliderFacingRight(&theGlider2);
}
else
InsureGliderFacingRight(thisGlider);
ForceThisRoom(localNumbers[kEastRoom]);
if (twoPlayerGame)
{
OffsetGlider(&theGlider, kToLeft);
OffsetGlider(&theGlider2, kToLeft);
QSetRect(&enterRect, 0, 0, 48, 20);
QOffsetRect(&enterRect, 0,
kGliderStartsDown + (short)thisRoom->leftStart - 2);
theGlider.enteredRect = enterRect;
theGlider2.enteredRect = enterRect;
}
else
{
OffsetGlider(thisGlider, kToLeft);
QSetRect(&enterRect, 0, 0, 48, 20);
QOffsetRect(&enterRect, 0,
kGliderStartsDown + (short)thisRoom->leftStart - 2);
thisGlider->enteredRect = enterRect;
}
break;
case kToLeft:
SetMusicalMode(kProdGameScoreMode);
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider);
UndoGliderLimbo(&theGlider2);
InsureGliderFacingLeft(&theGlider);
InsureGliderFacingLeft(&theGlider2);
}
else
InsureGliderFacingLeft(thisGlider);
ForceThisRoom(localNumbers[kWestRoom]);
if (twoPlayerGame)
{
OffsetGlider(&theGlider, kToRight);
OffsetGlider(&theGlider2, kToRight);
QSetRect(&enterRect, 0, 0, 48, 20);
QOffsetRect(&enterRect, kRoomWide - 48,
kGliderStartsDown + (short)thisRoom->rightStart - 2);
theGlider.enteredRect = enterRect;
theGlider2.enteredRect = enterRect;
}
else
{
OffsetGlider(thisGlider, kToRight);
QSetRect(&enterRect, 0, 0, 48, 20);
QOffsetRect(&enterRect, kRoomWide - 48,
kGliderStartsDown + (short)thisRoom->rightStart - 2);
thisGlider->enteredRect = enterRect;
}
break;
case kAbove:
SetMusicalMode(kKickGameScoreMode);
ForceThisRoom(localNumbers[kNorthRoom]);
if (!takingTheStairs)
{
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider);
UndoGliderLimbo(&theGlider2);
OffsetGlider(&theGlider, kBelow);
OffsetGlider(&theGlider2, kBelow);
theGlider.enteredRect = theGlider.dest;
theGlider2.enteredRect = theGlider2.dest;
}
else
{
OffsetGlider(thisGlider, kBelow);
thisGlider->enteredRect = thisGlider->dest;
}
}
else
{
if (twoPlayerGame)
{
ReadyGliderForTripUpStairs(&theGlider);
ReadyGliderForTripUpStairs(&theGlider2);
}
else
ReadyGliderForTripUpStairs(thisGlider);
}
break;
case kBelow:
SetMusicalMode(kKickGameScoreMode);
ForceThisRoom(localNumbers[kSouthRoom]);
if (!takingTheStairs)
{
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider);
UndoGliderLimbo(&theGlider2);
OffsetGlider(&theGlider, kAbove);
OffsetGlider(&theGlider2, kAbove);
theGlider.enteredRect = theGlider.dest;
theGlider2.enteredRect = theGlider2.dest;
}
else
{
OffsetGlider(thisGlider, kAbove);
thisGlider->enteredRect = thisGlider->dest;
}
}
else
{
if (twoPlayerGame)
{
ReadyGliderForTripDownStairs(&theGlider);
ReadyGliderForTripDownStairs(&theGlider2);
}
else
ReadyGliderForTripDownStairs(thisGlider);
}
break;
default:
break;
}
if ((twoPlayerGame) && (!onePlayerLeft))
{
if (firstPlayer == kPlayer1)
TagGliderIdle(&theGlider2);
else
TagGliderIdle(&theGlider);
}
ReadyLevel();
RefreshScoreboard(kNormalTitleMode);
WipeScreenOn(where, &justRoomsRect);
#ifdef COMPILEQT
RenderFrame();
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) && (tvOn))
{
GoToBeginningOfMovie(theMovie);
StartMovie(theMovie);
}
#endif
}
//-------------------------------------------------------------- TransportRoomToRoom
void TransportRoomToRoom (gliderPtr thisGlider)
{
Boolean sameRoom;
SetMusicalMode(kKickGameScoreMode);
HandleRoomVisitation();
sameRoom = (transRoom == thisRoomNumber);
if (!sameRoom)
ForceThisRoom(transRoom);
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider); // turn off limbo if needed
UndoGliderLimbo(&theGlider2); // turn off limbo if needed
ReadyGliderFromTransit(&theGlider, linkedToWhat);
ReadyGliderFromTransit(&theGlider2, linkedToWhat);
}
else
ReadyGliderFromTransit(thisGlider, linkedToWhat);
if (!sameRoom)
ReadyLevel();
RefreshScoreboard(kNormalTitleMode);
if (!sameRoom)
WipeScreenOn(kAbove, &justRoomsRect);
#ifdef COMPILEQT
RenderFrame();
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) && (tvOn))
{
GoToBeginningOfMovie(theMovie);
StartMovie(theMovie);
}
#endif
}
//-------------------------------------------------------------- MoveDuctToDuct
void MoveDuctToDuct (gliderPtr thisGlider)
{
Boolean sameRoom;
SetMusicalMode(kKickGameScoreMode);
HandleRoomVisitation();
sameRoom = (transRoom == thisRoomNumber);
if (!sameRoom)
ForceThisRoom(transRoom);
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider); // turn off limbo if needed
UndoGliderLimbo(&theGlider2); // turn off limbo if needed
ReadyGliderFromTransit(&theGlider, linkedToWhat);
ReadyGliderFromTransit(&theGlider2, linkedToWhat);
}
else
ReadyGliderFromTransit(thisGlider, linkedToWhat);
if (!sameRoom)
ReadyLevel();
RefreshScoreboard(kNormalTitleMode);
if (!sameRoom)
WipeScreenOn(kAbove, &justRoomsRect);
#ifdef COMPILEQT
RenderFrame();
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) && (tvOn))
{
GoToBeginningOfMovie(theMovie);
StartMovie(theMovie);
}
#endif
}
//-------------------------------------------------------------- MoveMailToMail
void MoveMailToMail (gliderPtr thisGlider)
{
Boolean sameRoom;
SetMusicalMode(kKickGameScoreMode);
HandleRoomVisitation();
sameRoom = (transRoom == thisRoomNumber);
if (!sameRoom)
ForceThisRoom(transRoom);
if (twoPlayerGame)
{
UndoGliderLimbo(&theGlider); // turn off limbo if needed
UndoGliderLimbo(&theGlider2); // turn off limbo if needed
ReadyGliderFromTransit(&theGlider, linkedToWhat);
ReadyGliderFromTransit(&theGlider2, linkedToWhat);
}
else
ReadyGliderFromTransit(thisGlider, linkedToWhat);
if (!sameRoom)
ReadyLevel();
RefreshScoreboard(kNormalTitleMode);
if (!sameRoom)
WipeScreenOn(kAbove, &justRoomsRect);
#ifdef COMPILEQT
RenderFrame();
if ((thisMac.hasQT) && (hasMovie) && (tvInRoom) && (tvOn))
{
GoToBeginningOfMovie(theMovie);
StartMovie(theMovie);
}
#endif
}
//-------------------------------------------------------------- HandleRoomVisitation
void HandleRoomVisitation (void)
{
houseType *thisHousePtr;
char wasState;
if (!thisRoom->visited)
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
thisHousePtr->rooms[localNumbers[kCentralRoom]].visited = true;
HSetState((Handle)thisHouse, wasState);
theScore += kRoomVisitScore;
thisRoom->visited = true;
}
}
//-------------------------------------------------------------- ForceKillGlider
void ForceKillGlider (void)
{
if (theGlider.mode == kGliderInLimbo)
{
if (theGlider2.mode != kGliderFadingOut)
{
StartGliderFadingOut(&theGlider2);
PlayPrioritySound(kFadeOutSound, kFadeOutPriority);
playerSuicide = true;
}
}
else if (theGlider2.mode == kGliderInLimbo)
{
if (theGlider.mode != kGliderFadingOut)
{
StartGliderFadingOut(&theGlider);
PlayPrioritySound(kFadeOutSound, kFadeOutPriority);
playerSuicide = true;
}
}
}
//-------------------------------------------------------------- FollowTheLeader
void FollowTheLeader (void)
{
short wasEscaped;
Boolean oneOrTwo;
playerSuicide = false;
wasEscaped = otherPlayerEscaped;
otherPlayerEscaped = kNoOneEscaped;
if (theGlider.mode == kGliderInLimbo)
{
oneOrTwo = true;
theGlider2.dest = theGlider.dest;
theGlider2.destShadow = theGlider.destShadow;
theGlider2.whole = theGlider2.dest;
theGlider2.wholeShadow = theGlider2.destShadow;
}
else if (theGlider2.mode == kGliderInLimbo)
{
oneOrTwo = false;
theGlider.dest = theGlider2.dest;
theGlider.destShadow = theGlider2.destShadow;
theGlider.whole = theGlider.dest;
theGlider.wholeShadow = theGlider.destShadow;
}
switch (wasEscaped)
{
case kPlayerEscapedUp:
case kPlayerEscapingUpStairs:
case kPlayerEscapedUpStairs:
if (oneOrTwo)
MoveRoomToRoom(&theGlider2, kAbove);
else
MoveRoomToRoom(&theGlider, kAbove);
break;
case kPlayerEscapedDown:
case kPlayerEscapingDownStairs:
case kPlayerEscapedDownStairs:
if (oneOrTwo)
MoveRoomToRoom(&theGlider2, kBelow);
else
MoveRoomToRoom(&theGlider, kBelow);
break;
case kPlayerEscapedLeft:
if (oneOrTwo)
MoveRoomToRoom(&theGlider2, kToLeft);
else
MoveRoomToRoom(&theGlider, kToLeft);
break;
case kPlayerEscapedRight:
if (oneOrTwo)
MoveRoomToRoom(&theGlider2, kToRight);
else
MoveRoomToRoom(&theGlider, kToRight);
break;
case kPlayerTransportedOut:
if (oneOrTwo)
TransportRoomToRoom(&theGlider2);
else
TransportRoomToRoom(&theGlider);
break;
case kPlayerMailedOut:
if (oneOrTwo)
MoveMailToMail(&theGlider2);
else
MoveMailToMail(&theGlider);
break;
case kPlayerDuckedOut:
if (oneOrTwo)
MoveDuctToDuct(&theGlider2);
else
MoveDuctToDuct(&theGlider);
break;
default:
break;
}
}

145
GpApp/Transitions.cpp Normal file
View File

@@ -0,0 +1,145 @@
//============================================================================
//----------------------------------------------------------------------------
// Transitions.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "RectUtils.h"
//============================================================== Functions
//-------------------------------------------------------------- PourScreenOn
void PourScreenOn (Rect *theRect)
{
#define kMaxColumnsWide 96
#define kChipHigh 20
#define kChipWide 16
Rect columnRects[kMaxColumnsWide];
short columnProgress[kMaxColumnsWide];
short i, colsComplete, colWide, rowTall;
Boolean working;
colWide = theRect->right / kChipWide; // determine # of cols
rowTall = (theRect->bottom / kChipHigh) + 1; // determine # of rows
working = true;
colsComplete = 0;
for (i = 0; i < colWide; i++)
{
columnProgress[i] = 0;
QSetRect(&columnRects[i], 0, 0, kChipWide, kChipHigh);
QOffsetRect(&columnRects[i], (i * kChipWide) + theRect->left, theRect->top);
}
while (working)
{
do
{
i = RandomInt(colWide);
}
while (columnProgress[i] >= rowTall);
if (columnRects[i].left < theRect->left)
columnRects[i].left = theRect->left;
if (columnRects[i].top < theRect->top)
columnRects[i].top = theRect->top;
if (columnRects[i].right > theRect->right)
columnRects[i].right = theRect->right;
if (columnRects[i].bottom > theRect->bottom)
columnRects[i].bottom = theRect->bottom;
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&columnRects[i], &columnRects[i], srcCopy, nil);
QOffsetRect(&columnRects[i], 0, kChipHigh);
columnProgress[i]++;
if (columnProgress[i] >= rowTall)
{
colsComplete++;
if (colsComplete >= colWide)
working = false;
}
}
}
//-------------------------------------------------------------- WipeScreenOn
void WipeScreenOn (short direction, Rect *theRect)
{
#define kWipeRectThick 4
Rect wipeRect;
RgnHandle dummyRgn;
short hOffset, vOffset;
short i, count;
wipeRect = *theRect;
switch (direction)
{
case kAbove:
wipeRect.bottom = wipeRect.top + kWipeRectThick;
hOffset = 0;
vOffset = kWipeRectThick;
count = ((theRect->bottom - theRect->top) / kWipeRectThick) + 1;
break;
case kToRight:
wipeRect.left = wipeRect.right - kWipeRectThick;
hOffset = -kWipeRectThick;
vOffset = 0;
count = workSrcRect.right / kWipeRectThick;
break;
case kBelow:
wipeRect.top = wipeRect.bottom - kWipeRectThick;
hOffset = 0;
vOffset = -kWipeRectThick;
count = ((theRect->bottom - theRect->top) / kWipeRectThick) + 1;
break;
case kToLeft:
wipeRect.right = wipeRect.left + kWipeRectThick;
hOffset = kWipeRectThick;
vOffset = 0;
count = workSrcRect.right / kWipeRectThick;
break;
}
dummyRgn = NewRgn();
for (i = 0; i < count; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&wipeRect, &wipeRect, srcCopy, GetPortVisibleRegion(GetWindowPort(mainWindow), dummyRgn));
QOffsetRect(&wipeRect, hOffset, vOffset);
if (wipeRect.top < theRect->top)
wipeRect.top = theRect->top;
else if (wipeRect.top > theRect->bottom)
wipeRect.top = theRect->bottom;
if (wipeRect.bottom < theRect->top)
wipeRect.bottom = theRect->top;
else if (wipeRect.bottom > theRect->bottom)
wipeRect.bottom = theRect->bottom;
}
DisposeRgn(dummyRgn);
}
//-------------------------------------------------------------- DumpScreenOn
void DumpScreenOn (Rect *theRect)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
theRect, theRect, srcCopy, nil);
}

205
GpApp/Triggers.cpp Normal file
View File

@@ -0,0 +1,205 @@
//============================================================================
//----------------------------------------------------------------------------
// Triggers.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#define kMaxTriggers 16
typedef struct
{
short object, room;
short index, timer;
short what;
Boolean armed;
} trigType, *trigPtr;
short FindEmptyTriggerSlot (void);
void FireTrigger (short);
trigType triggers[kMaxTriggers];
//============================================================== Functions
//-------------------------------------------------------------- ArmTrigger
void ArmTrigger (hotPtr who)
{
short where, whoLinked;
if (who->stillOver)
return;
where = FindEmptyTriggerSlot();
if (where != -1)
{
whoLinked = who->who; // what is trigger's obj. #
triggers[where].room = masterObjects[whoLinked].roomLink;
triggers[where].object = masterObjects[whoLinked].objectLink;
triggers[where].index = whoLinked;
triggers[where].timer = masterObjects[whoLinked].theObject.data.e.delay * 3;
triggers[where].what = masterObjects[triggers[where].object].theObject.what;
triggers[where].armed = true;
}
who->stillOver = true;
}
//-------------------------------------------------------------- FindEmptyTriggerSlot
short FindEmptyTriggerSlot (void)
{
short where, i;
where = -1;
for (i = 0; i < kMaxTriggers; i++)
{
if (!triggers[i].armed)
{
where = i;
break;
}
}
return (where);
}
//-------------------------------------------------------------- HandleTriggers
void HandleTriggers (void)
{
short i;
for (i = 0; i < kMaxTriggers; i++)
{
if (triggers[i].armed)
{
triggers[i].timer--;
if (triggers[i].timer <= 0)
{
triggers[i].timer = 0;
triggers[i].armed = false;
FireTrigger(i);
}
}
}
}
//-------------------------------------------------------------- FireTrigger
void FireTrigger (short index)
{
short triggerIs, triggeredIs;
char wasState;
triggerIs = triggers[index].index;
if (masterObjects[triggerIs].localLink != -1)
{
triggeredIs = masterObjects[triggerIs].localLink;
switch (masterObjects[triggeredIs].theObject.what)
{
case kGreaseRt:
case kGreaseLf:
if (SetObjectState(triggers[index].room, triggers[index].object,
kForceOn, triggeredIs))
{
SpillGrease(masterObjects[triggeredIs].dynaNum,
masterObjects[triggeredIs].hotNum);
}
break;
case kLightSwitch:
case kMachineSwitch:
case kThermostat:
case kPowerSwitch:
case kKnifeSwitch:
case kInvisSwitch:
TriggerSwitch(masterObjects[triggeredIs].dynaNum);
break;
case kSoundTrigger:
PlayPrioritySound(kChordSound, kChordPriority); // Change me
break;
case kToaster:
TriggerToast(masterObjects[triggeredIs].dynaNum);
break;
case kGuitar:
PlayPrioritySound(kChordSound, kChordPriority);
break;
case kCoffee:
PlayPrioritySound(kCoffeeSound, kCoffeePriority);
break;
case kOutlet:
TriggerOutlet(masterObjects[triggeredIs].dynaNum);
break;
case kBalloon:
TriggerBalloon(masterObjects[triggeredIs].dynaNum);
break;
case kCopterLf:
case kCopterRt:
TriggerCopter(masterObjects[triggeredIs].dynaNum);
break;
case kDartLf:
case kDartRt:
TriggerDart(masterObjects[triggeredIs].dynaNum);
break;
case kDrip:
TriggerDrip(masterObjects[triggeredIs].dynaNum);
break;
case kFish:
TriggerFish(masterObjects[triggeredIs].dynaNum);
break;
}
}
else
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
triggeredIs = masterObjects[triggerIs].localLink;
switch ((*thisHouse)->rooms[triggers[index].room].
objects[triggers[index].object].what)
{
case kGreaseRt:
case kGreaseLf:
if (SetObjectState(triggers[index].room, triggers[index].object,
kForceOn, triggeredIs))
{
SpillGrease(masterObjects[triggeredIs].dynaNum,
masterObjects[triggeredIs].hotNum);
}
break;
}
HSetState((Handle)thisHouse, wasState);
}
}
//-------------------------------------------------------------- ZeroTriggers
void ZeroTriggers (void)
{
short i;
for (i = 0; i < kMaxTriggers; i++)
triggers[i].armed = false;
}

Some files were not shown because too many files have changed in this diff Show More