Character encoding fixups

This commit is contained in:
elasota
2020-10-14 18:18:57 -04:00
parent 7858aff6cd
commit b682004f29
5 changed files with 118 additions and 116 deletions

View File

@@ -144,9 +144,9 @@ void DrawHighScores (DrawSurface *surface)
PortabilityLayer::RenderedFont *appFont14 = GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold, true);
PasStringCopy(PSTR("<EFBFBD> "), tempStr);
PasStringCopy(PSTR("\xa5 "), tempStr);
PasStringConcat(tempStr, thisHouseName);
PasStringConcat(tempStr, PSTR(" <EFBFBD>"));
PasStringConcat(tempStr, PSTR(" \xa5"));
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - appFont14->MeasurePStr(tempStr)) / 2) - 1, dropIt - 66);
surface->DrawString(scoreShadowPoint, tempStr, blackColor, appFont14);

View File

@@ -785,7 +785,7 @@ void ShiftWholeHouse (short howFar)
short i, h, numRooms;
char wasState;
OpenMessageWindow(PSTR("Shifting Whole House<EFBFBD>"));
OpenMessageWindow(PSTR("Shifting Whole House\xc9"));
SpinCursor(3);
CopyThisRoomToRoom();

View File

@@ -175,7 +175,7 @@ void RefreshRoomTitle (short mode)
break;
case kSavingTitleMode:
surface->DrawString(strShadowPoint, PSTR("Saving Game<EFBFBD>"), blackColor, appFont);
surface->DrawString(strShadowPoint, PSTR("Saving Game\xc9"), blackColor, appFont);
break;
default:
@@ -190,7 +190,7 @@ void RefreshRoomTitle (short mode)
break;
case kSavingTitleMode:
surface->DrawString(strPoint, PSTR("Saving Game<EFBFBD>"), whiteColor, appFont);
surface->DrawString(strPoint, PSTR("Saving Game\xc9"), whiteColor, appFont);
break;
default:

View File

@@ -14,13 +14,13 @@
//============================================================== Functions
//-------------------------------------------------------------- PasStringCopy
// Given a source string and storage for a second, this function<EFBFBD>
// Given a source string and storage for a second, this function?
// copies from one to the other. It assumes Pascal style strings.
void PasStringCopy (StringPtr p1, StringPtr p2)
{
register short stringLength;
short stringLength;
stringLength = *p2++ = *p1++;
while (--stringLength >= 0)
*p2++ = *p1++;
@@ -28,9 +28,9 @@ void PasStringCopy (StringPtr p1, StringPtr p2)
//-------------------------------------------------------------- WhichStringFirst
// This is a sorting function that handles two Pascal strings. It<EFBFBD>
// will return a 1 to indicate the 1st string is "greater", a 1 to<EFBFBD>
// indicate the 2nd was greater and a 0 to indicate that the strings<EFBFBD>
// This is a sorting function that handles two Pascal strings. It?
// will return a 1 to indicate the 1st string is "greater", a 1 to?
// indicate the 2nd was greater and a 0 to indicate that the strings?
// are equal.
short WhichStringFirst (StringPtr p1, StringPtr p2)
@@ -38,11 +38,11 @@ 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;
@@ -54,7 +54,7 @@ short WhichStringFirst (StringPtr p1, StringPtr p2)
char2 = p2[seek]; // make upper case (if applicable)
if ((char2 > 0x60) && (char2 < 0x7B))
char2 -= 0x20;
if (char1 > char2) // first string is greater
{
greater = 1;
@@ -79,69 +79,69 @@ short WhichStringFirst (StringPtr p1, StringPtr p2)
}
}
while (!foundIt);
return (greater);
}
//-------------------------------------------------------------- PasStringCopyNum
// This function copies a specified number of characters from one<EFBFBD>
// This function copies a specified number of characters from one?
// 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++;
p2++;
p1++;
for (i = 0; i < charsToCopy; i++)
*p2++ = *p1++;
}
//-------------------------------------------------------------- PasStringConcat
// This function concatenates the second Pascal string to the end of<EFBFBD>
// This function concatenates the second Pascal string to the end of?
// 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<EFBFBD>
// entire line of text. A "line" of text is assumed to be bounded<EFBFBD>
// by carriage returns. The index variable indicates which line<EFBFBD>
// This function walks through a source string and looks for an?
// entire line of text. A "line" of text is assumed to be bounded?
// by carriage returns. The index variable indicates which line?
// 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
@@ -165,11 +165,11 @@ void GetLineOfText (StringPtr srcStr, short index, StringPtr textLine)
}
while ((i < srcLength) && (!foundIt));
}
if (start != 0)
{
i = start;
foundIt = false;
do
{
@@ -181,7 +181,7 @@ void GetLineOfText (StringPtr srcStr, short index, StringPtr textLine)
i++;
}
while ((i < srcLength) && (!foundIt));
if (!foundIt)
{
if (start > srcLength)
@@ -192,9 +192,9 @@ void GetLineOfText (StringPtr srcStr, short index, StringPtr textLine)
else
stop = i;
}
count = 0;
for (i = start; i <= stop; i++)
{
count++;
@@ -206,18 +206,18 @@ void GetLineOfText (StringPtr srcStr, short index, StringPtr textLine)
//-------------------------------------------------------------- WrapText
// Given a string and the maximum number of characters to put on<EFBFBD>
// one line, this function goes through and inserts carriage returns<EFBFBD>
// Given a string and the maximum number of characters to put on?
// one line, this function goes through and inserts carriage returns?
// 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;
@@ -236,7 +236,7 @@ void WrapText (StringPtr theText, short maxChars)
}
}
while ((count < lastChar) && (chars < maxChars) && (!foundEdge));
if ((!foundEdge) && (count < lastChar) && (foundSpace))
{
theText[spaceIs] = '\r';
@@ -253,16 +253,16 @@ void WrapText (StringPtr theText, short maxChars)
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
@@ -271,24 +271,24 @@ void GetFirstWordOfString (StringPtr stringIn, StringPtr stringOut)
//-------------------------------------------------------------- CollapseStringToWidth
// Given a string and a maximum width (in pixels), this function<EFBFBD>
// calculates how wide the text would be drawn with the current<EFBFBD>
// font. If the text would exceed our width limit, characters<EFBFBD>
// are dropped off the end of the string and "<EFBFBD>" appended.
// Given a string and a maximum width (in pixels), this function?
// calculates how wide the text would be drawn with the current?
// font. If the text would exceed our width limit, characters?
// are dropped off the end of the string and "?" appended.
void CollapseStringToWidth (PortabilityLayer::RenderedFont *font, StringPtr theStr, short wide)
{
short dotsWide;
Boolean tooWide;
dotsWide = font->MeasurePStr(PSTR("<EFBFBD>"));
dotsWide = font->MeasurePStr(PSTR("\xc9"));
tooWide = font->MeasurePStr(theStr) > wide;
while (tooWide && theStr[0] > 0)
{
theStr[0]--;
tooWide = ((font->MeasurePStr(theStr) + dotsWide) > wide);
if (!tooWide)
PasStringConcat(theStr, PSTR("<EFBFBD>"));
PasStringConcat(theStr, PSTR("\xc9"));
}
}
@@ -297,7 +297,7 @@ void CollapseStringToWidth (PortabilityLayer::RenderedFont *font, StringPtr theS
StringPtr GetLocalizedString (short index, StringPtr theString)
{
#define kLocalizedStringsID 150
GetIndString(theString, kLocalizedStringsID, index);
return (theString);
}

View File

@@ -34,11 +34,11 @@ extern Boolean switchedOut;
//-------------------------------------------------------------- ToolBoxInit
// The standard ToolBox intialization that must happen when any Mac<61>
// The standard ToolBox intialization that must happen when any Mac<61>
// program first launches.
void ToolBoxInit (void)
{
{
InitCursor();
switchedOut = false;
}
@@ -48,13 +48,13 @@ void ToolBoxInit (void)
short RandomInt (short range)
{
register long rawResult;
long rawResult;
rawResult = Random();
if (rawResult < 0L)
rawResult *= -1L;
rawResult = (rawResult * (long)range) / 32768L;
return ((short)rawResult);
}
@@ -64,30 +64,30 @@ short RandomInt (short range)
long RandomLong (long range)
{
register long highWord, lowWord;
register long rawResultHi, rawResultLo;
long highWord, lowWord;
long rawResultHi, rawResultLo;
highWord = (range & 0xFFFF0000) >> 16;
lowWord = range & 0x0000FFFF;
rawResultHi = Random();
if (rawResultHi < 0L)
rawResultHi *= -1L;
rawResultHi = (rawResultHi * highWord) / 32768L;
rawResultLo = Random();
if (rawResultLo < 0L)
rawResultLo *= -1L;
rawResultLo = (rawResultLo * lowWord) / 32768L;
rawResultHi = (rawResultHi << 16) + rawResultLo;
return (rawResultHi);
}
//-------------------------------------------------------------- RedAlert
// Called when we must quit app. Brings up a dialog informing user<65>
// Called when we must quit app. Brings up a dialog informing user<65>
// of the problem and the exits to shell.
void RedAlert (short errorNumber)
@@ -97,9 +97,9 @@ void RedAlert (short errorNumber)
#define rErrMssgID 171 // string ID for death error message
short dummyInt;
Str255 errTitle, errMessage, errNumberString;
InitCursor();
if (errorNumber > 1) // <= 0 is unaccounted for
{
GetIndString(errTitle, rErrTitleID, errorNumber);
@@ -113,7 +113,7 @@ void RedAlert (short errorNumber)
NumToString((long)errorNumber, errNumberString);
DialogTextSubstitutions substitutions(errTitle, errMessage, errNumberString, PSTR(""));
// CenterAlert(rDeathAlertID);
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID, &substitutions);
//ExitToShell();
@@ -127,14 +127,14 @@ void RedAlert (short errorNumber)
void CreateOffScreenBitMap (Rect *theRect, GrafPtr *offScreen)
{
GrafPtr theBWPort;
BitMap theBitMap;
BitMap theBitMap;
long theRowBytes;
theBWPort = (GrafPtr)(NewPtr(sizeof(GrafPort)));
OpenPort(theBWPort);
theRowBytes = (long)((theRect->right - theRect->left + 15L) / 16L) * 2L;
theBitMap.rowBytes = (short)theRowBytes;
theBitMap.baseAddr = NewPtr((long)theBitMap.rowBytes *
theBitMap.baseAddr = NewPtr((long)theBitMap.rowBytes *
(theRect->bottom - theRect->top));
if (theBitMap.baseAddr == nil)
RedAlert(kErrNoMemory);
@@ -161,7 +161,7 @@ void CreateOffScreenPixMap (Rect *theRect, CGrafPtr *offScreen)
PLError_t theErr;
short thisDepth;
char wasState;
oldDevice = GetGDevice();
SetGDevice(thisGDevice);
newCGrafPtr = nil;
@@ -170,7 +170,7 @@ void CreateOffScreenPixMap (Rect *theRect, CGrafPtr *offScreen)
{
OpenCPort(newCGrafPtr);
thisDepth = (**(*newCGrafPtr).portPixMap).pixelSize;
offRowBytes = ((((long)thisDepth *
offRowBytes = ((((long)thisDepth *
(long)(theRect->right - theRect->left)) + 15L) >> 4L) << 1L;
sizeOfOff = (long)(theRect->bottom - theRect->top + 1) * offRowBytes;
// sizeOfOff = (long)(theRect->bottom - theRect->top) * offRowBytes;
@@ -196,7 +196,7 @@ void CreateOffScreenPixMap (Rect *theRect, CGrafPtr *offScreen)
}
else
{
CloseCPort(newCGrafPtr);
CloseCPort(newCGrafPtr);
DisposePtr((Ptr)newCGrafPtr);
newCGrafPtr = nil;
RedAlert(kErrNoMemory);
@@ -204,18 +204,18 @@ void CreateOffScreenPixMap (Rect *theRect, CGrafPtr *offScreen)
}
else
RedAlert(kErrNoMemory);
*offScreen = newCGrafPtr;
SetGDevice(oldDevice);
}
*/
//-------------------------------------------------------------------- CreateOffScreenGWorld
// Creates an offscreen GWorld<6C>using the depth passed in.
// Creates an offscreen GWorld<6C>using the depth passed in.
PLError_t CreateOffScreenGWorld (DrawSurface **theGWorld, Rect *bounds)
{
GpPixelFormat_t pixelFormat = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetPixelFormat();
return NewGWorld(theGWorld, pixelFormat, bounds, nil);
}
@@ -231,7 +231,7 @@ PLError_t CreateOffScreenGWorldCustomDepth(DrawSurface **theGWorld, Rect *bounds
void KillOffScreenPixMap (CGrafPtr offScreen)
{
Ptr theseBits;
if (offScreen != nil)
{
theseBits = (**(*offScreen).portPixMap).baseAddr;
@@ -257,23 +257,23 @@ void KillOffScreenBitMap (GrafPtr offScreen)
}
*/
//-------------------------------------------------------------- LoadGraphic
// Function loads the specified 'PICT' from disk and draws it to<74>
// the current port (no scaling, clipping, etc, are done). Always<79>
// Function loads the specified 'PICT' from disk and draws it to<74>
// the current port (no scaling, clipping, etc, are done). Always<79>
// draws in the upper left corner of current port.
void LoadGraphic (DrawSurface *surface, short resID)
{
Rect bounds;
THandle<BitmapImage> thePicture;
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', resID).StaticCast<BitmapImage>();
if (thePicture == nil)
RedAlert(kErrFailedGraphicLoad);
bounds = (*thePicture)->GetRect();
OffsetRect(&bounds, -bounds.left, -bounds.top);
surface->DrawPicture(thePicture, bounds);
thePicture.Dispose();
}
@@ -296,14 +296,14 @@ void LoadGraphicCustom(DrawSurface *surface, short resID)
}
//-------------------------------------------------------------- LoadScaledGraphic
// Loads the specified 'PICT' and draws it mapped to the rectangle<6C>
// specified. If this rect isn't the same size of the 'PICT', scaling<6E>
// Loads the specified 'PICT' and draws it mapped to the rectangle<6C>
// specified. If this rect isn't the same size of the 'PICT', scaling<6E>
// will occur.
void LoadScaledGraphic (DrawSurface *surface, short resID, Rect *theRect)
{
THandle<BitmapImage> thePicture;
thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', resID).StaticCast<BitmapImage>();
if (thePicture == nil)
RedAlert(kErrFailedGraphicLoad);
@@ -312,8 +312,8 @@ void LoadScaledGraphic (DrawSurface *surface, short resID, Rect *theRect)
}
//-------------------------------------------------------------- LoadScaledGraphic
// Loads the specified 'PICT' and draws it mapped to the rectangle<6C>
// specified. If this rect isn't the same size of the 'PICT', scaling<6E>
// Loads the specified 'PICT' and draws it mapped to the rectangle<6C>
// specified. If this rect isn't the same size of the 'PICT', scaling<6E>
// will occur.
void LoadScaledGraphicCustom(DrawSurface *surface, short resID, Rect *theRect)
@@ -378,7 +378,7 @@ void DrawCIcon (DrawSurface *surface, short theID, short h, short v)
if (PortabilityLayer::IconLoader::GetInstance()->LoadColorIcon(theID, colorImage, bwImage, maskImage))
{
Rect theRect;
SetRect(&theRect, 0, 0, 32, 32);
OffsetRect(&theRect, h, v);
@@ -393,27 +393,27 @@ void DrawCIcon (DrawSurface *surface, short theID, short h, short v)
//-------------------------------------------------------------- LongSquareRoot
// This is a quick and dirty square root function that returns pretty<74>
// accurate long integer results. It uses no transcendental functions or<6F>
// This is a quick and dirty square root function that returns pretty<74>
// accurate long integer results. It uses no transcendental functions or<6F>
// floating point.
long LongSquareRoot (long theNumber)
{
long currentAnswer;
long nextTrial;
if (theNumber <= 1L)
return (theNumber);
nextTrial = theNumber / 2;
do
{
currentAnswer = nextTrial;
nextTrial = (nextTrial + theNumber / nextTrial) / 2;
}
while (nextTrial < currentAnswer);
return(currentAnswer);
}
@@ -427,13 +427,13 @@ Boolean WaitForInputEvent (short seconds)
TimeTaggedVOSEvent theEvent;
long timeToBail;
Boolean waiting, didResume;
timeToBail = TickCount() + 60L * (long)seconds;
FlushEvents();
waiting = true;
didResume = false;
while (waiting)
{
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
@@ -462,9 +462,9 @@ Boolean WaitForInputEvent (short seconds)
void WaitCommandQReleased (void)
{
Boolean waiting;
waiting = true;
while (waiting)
{
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
@@ -483,20 +483,20 @@ void WaitCommandQReleased (void)
char KeyMapOffsetFromRawKey (char rawKeyCode)
{
char hiByte, loByte, theOffset;
hiByte = rawKeyCode & 0xF0;
loByte = rawKeyCode & 0x0F;
if (loByte <= 0x07)
theOffset = hiByte + (0x07 - loByte);
else
theOffset = hiByte + (0x17 - loByte);
return (theOffset);
}
//-------------------------------------------------------------- GetKeyName
// Given a keyDown event (it's message field), this function returns<6E>
// Given a keyDown event (it's message field), this function returns<6E>
// a string with that key's name (so we get "Shift" and "Esc", etc.).
static const char *gs_specialKeyNames[GpKeySpecials::kCount] =
@@ -591,6 +591,8 @@ void GetKeyName (intptr_t message, StringPtr theName)
// This should never happen
assert(false);
break;
default:
break;
}
const size_t name1Length = (name1 == nullptr) ? 0 : strlen(name1);
@@ -612,7 +614,7 @@ void GetKeyName (intptr_t message, StringPtr theName)
Boolean OptionKeyDown (void)
{
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt)))
return (true);
else
@@ -625,13 +627,13 @@ Boolean OptionKeyDown (void)
long ExtractCTSeed (CGrafPtr porter)
{
long theSeed;
theSeed = (**((**(porter->portPixMap)).pmTable)).ctSeed;
return(theSeed);
}
*/
//-------------------------------------------------------------- ForceCTSeed
// Forces the "color table seed" from a specified graf port to a<>
// Forces the "color table seed" from a specified graf port to a<>
// specified value.
/*
void ForceCTSeed (CGrafPtr porter, long newSeed)
@@ -640,25 +642,25 @@ void ForceCTSeed (CGrafPtr porter, long newSeed)
}
*/
//-------------------------------------------------------------- DelayTicks
// Lil' function that just sits and waits a specified number of<6F>
// Lil' function that just sits and waits a specified number of<6F>
// Ticks (1/60 of a second).
void DelayTicks (long howLong)
{
UInt32 whoCares;
Delay(howLong, &whoCares);
}
//-------------------------------------------------------------- UnivGetSoundVolume
// Returns the speaker volume (as set by the user) in the range of<6F>
// Returns the speaker volume (as set by the user) in the range of<6F>
// zero to seven (handles Sound Manager 3 case as well).
void UnivGetSoundVolume (short *volume, Boolean hasSM3)
{
long longVol;
PLError_t theErr;
// if (hasSM3)
// {
longVol = PortabilityLayer::SoundSystem::GetInstance()->GetVolume();
@@ -666,7 +668,7 @@ void UnivGetSoundVolume (short *volume, Boolean hasSM3)
// }
// else
// GetSoundVol(volume);
if (*volume > 7)
*volume = 7;
else if (*volume < 0)
@@ -674,18 +676,18 @@ void UnivGetSoundVolume (short *volume, Boolean hasSM3)
}
//-------------------------------------------------------------- UnivSetSoundVolume
// Sets the speaker volume to a specified value (in the range of<6F>
// Sets the speaker volume to a specified value (in the range of<6F>
// zero to seven (handles Sound Manager 3 case as well).
void UnivSetSoundVolume (short volume, Boolean hasSM3)
{
long longVol;
if (volume > 7)
volume = 7;
else if (volume < 0)
volume = 0;
// if (hasSM3)
// {
longVol = (long)volume * 0x0025;