Sep 95 Challenge
 Volume Number: 11 Issue Number: 9 Column Tag: Programmer’s Challenge

# Programmer’s Challenge

By Bob Boonstra, Westford, Massachusetts

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

## Reversible Scrambling Algorithm

According to tradition, September is Assembly Language Challenge month here at MacTech, and we continue that tradition this month. Your challenge is to do some simple arithmetic - raising a number to a power, and taking the remainder of the result modulo another number. Simple, right? To make things interesting, though, the numbers are going to be a little larger than you are used to dealing with. Hundreds of decimal digits long, in fact. “Why,” you may ask? We’ll get into that in a minute, but there are a couple of hints in the title of this month’s challenge.

The data structure to be used for the large numbers in this Challenge, and the prototype for the code you should write are:

```typedef struct BigNum {
short numDig;   /* the number of bytes in the BigNum */
unsigned char *dig; /* dig[0] is the most significant byte */
/* dig[numDig-1] is least significant */
} BigNum;

void PowerAndRemainder(
BigNum *msg,
BigNum *exp,    /* calculate msg to the exp power, */
BigNum *n, /* take the remainder modulo n */
BigNum *res/* and store the result in res */
);

```

For example, the value 1048573 (0xFFFFD) would be provided to you in a BigNum b with the values b.numDig=3, b.dig[0] = 0x0F, b.dig[1]=0xFF, and b.dig[2]=0xFD. The first three arguments will be provided as input when PowerAndRemainder is called; you are to generate both elements of the BigNum struct for the res argument. The storage for all of the BigNums in the call to PowerAndRemainder will be allocated by the caller. All BigNums will be positive integers, and none of the BigNums will be larger than 128 bytes in length (i.e., b.numDig will be no larger than 128). There is no restriction on the amount of memory you may use (within reason).

Those of you with some number theory in your background may recognize what a function like this might be used for. If the modulus n is the product of two large primes p and q, one can find values e and d for the exponent with the property that they are inverses of one another, but that neither can be easily derived from the other, provided prime numbers p and q are not divulged. If you calculate PowerAndRemainder(msg,e,n,c), and I then calculate PowerAndRemainder(c,d,n,x), then the result x turns out to be identical to the original value msg if e and d are relatively prime to (p-1)*(q-1). Now what do you suppose such a function might be useful for?

Your solution may use any combination of ANSI C and/or 68K assembly language, along with your choice of either the THINK C or MetroWerks C 68K compilers. I considered making this a PowerPC challenge, but I wasn’t confident that enough people are proficient with PPC assembly just yet - perhaps next September. In the meantime, you can look forward to a native PPC challenge next month.

If you are interested in some sample values to test your code, send me email and I’ll provide some.

Several people wrote to point out that the deadline for submitting Challenge solutions was missing from the Rules box during July and August. Unfortunately, when the rules were revised to accommodate multiple compilers and target instruction sets, the deadline was inadvertently omitted. The Challenge deadline remains the 10th of the month printed on the cover of the magazine. I received several submissions for the Chess challenge after the deadline (and after the article was submitted for publication). Because of the problem with the deadline, I would have awarded points to any fast and correct entries, but all of the late entries had problems with correctness so no additional points were awarded.

## Two Months Ago Winner

Of the nine entries to the Sprite Blitz challenge, seven of them worked correctly. Congratulations to Xan Gregg (Durham, NC) for having the fastest solution, some 30% faster than the second place entry, submitted by John Nevard. Despite the variation in run time performance, there were a number of clever and creative solutions among the top entries.

Here are the times and code sizes for the entries that worked correctly. Numbers in parens after a person’s name indicate that person’s cumulative point total for all previous Challenges, not including this one.

Name time (68K)

Xan Gregg (31) 908

John Nevard 1300

Bill Karsh (71) 3363

Jim Bumgardner (4) 3495

Jeremy Vineyard (40) 5789

Norman Basham 10164

Steve Israelson 75846

Like most of the top entries, Xan composed his screen updates offscreen. Xan uses one offscreen GWorld to hold the background and another to prepare the next animation frame. One clever trick is that the offscreen image is large enough to contain all of a sprite that overlaps a window boundary, so that clipping need only be done when updating the window. Drawing is done directly to the screen, taking advantage of alignment conditions guaranteed to hold by the problem statement. Xan does all of his copying to the screen using unrolled loops, avoiding the overhead incurred when using CopyBits or CopyMask for small copies. When reading the code, take note of the switch statement in the COPY4 macro that copies the icon based on the value of the mask, and of the longword copies in the FastCopyChunk routine.

Bill Karsh pointed out in his entry that the relative performance of CopyBits and CopyMask varies between his 68K machine and his PPC 7100, with CopyBits being faster on the former machine and CopyMask being faster on the latter. I didn’t have time to measure native performance on the PowerPC, but there was a 15% difference between the two versions in my 68K tests. Of course, as Xan’s solution shows, avoiding both can have its advantages also.

## Does Performance Matter?

I’ve received some email suggesting that the emphasis on performance in this column ought to be replaced by emphases on other things, like code portability, readability, reliability, encapsulation, or object orientation. The argument is that improvements in hardware performance make efficiency less important than it has been in the past. This is certainly a valid point of view, and there is no question that processor improvements have enabled us to sacrifice some machine cycles to achieve objectives other than performance. However, I contend that the performance of several popular personal computer applications demonstrates that software developers are capable of adding enough functionality (or generating poor enough code) to degrade performance to an unacceptable level, despite hardware advances. In my opinion, this will always be so. Certainly the techniques demonstrated in this column should not be used in all software, but they have their place in time-critical areas, and it is worth devoting more attention to efficiency than we typically do. Besides, squeezing instructions out of code is great fun! But if you are interested in seeing a column that focuses on something besides efficiency, drop me a note.

## Top 20 Contestants of All Time

Here are the Top 20 Contestants for the Programmer’s Challenges to date. The numbers below include points awarded for this month’s entrants. (Note: ties are listed alphabetically by last name - there are more than 20 people listed this month because of ties.)

1. [Name deleted] 176

2. Karsh, Bill 78

3. Munter, Ernst 70

4. Stenger, Allen 65

6. Gregg, Xan 51

7. Riha, Stepan 51

8. Goebel, James 49

9. Nepsund, Ronald 47

10. Cutts, Kevin 46

11. Mallett, Jeff 44

12. Kasparian, Raffi 42

13. Vineyard, Jeremy 42

14. Darrah, Dave 31

15. Landry, Larry 29

16. Elwertowski, Tom 24

17. Lee, Johnny 22

18. Noll, Robert 22

19. Anderson, Troy 20

20. Beith, Gary 20

21. Burgoyne, Nick 20

22. Galway, Will 20

23. Israelson, Steve 20

24. Landweber, Greg 20

25. Pinkerton, Tom 20

There are three ways to earn points: (1) scoring in the top 5 of any Challenge, (2) being the first person to find a bug in a published winning solution or, (3) being the first person to suggest a Challenge that I use. The points you can win are:

1st place 20 points

2nd place 10 points

3rd place 7 points

4th place 4 points

5th place 2 points

finding bug 2 points

suggesting Challenge 2 points

Here is Xan’s winning solution:

## Sprite Blitz

```Xan Gregg, July 1995
/*
Since “correctness” is considered before speed in judging solutions, this solution makes correctness the
top priority at the cost of speed.

I use two offscreen GWorlds.  One has the background, and another has the image to be displayed on the
screen next.  The “on deck” image is updated sprite by sprite, then it is copied to the screen for minimum
flicker.

The GWorlds are a little bigger than the screen so I don’t have to worry about sprites that overlap the edges
until copying to the screen.

Memory usage:
2 GWorlds, each 64 pixels wider and taller than window.
1K of pixel data for each sprite.
128 bytes of mask data for each sprite.
16 bytes of info for each sprite.
I set the number of sprites to 400.  The problem states a maximum of 200 present at a time, but because
a deleted sprite stays around until the next UpdateScreen() call,
I allow for 400 in case you delete all 200 then add 200 more before calling UpdateScreen().  Paranoid, but
if you’ve got the memory...

Assumptions not stated in the problem:
Enough memory available for above usage.
Window width is a multiple of 4 (confirmed by BB).
Window does not move during play.

*/

#include <QDOffscreen.h>

typedef struct
{
short  nextSlot;
short  status;
short  width;
short  height;
Point  position;
Point  lastPosition;
} SpriteInfo, *SpriteInfoPtr;

typedef struct
{
char pixData[1024];
} SpritePixData, *SpritePixDataPtr;

typedef struct
{

#define kMaxSprites400L
#define kMaxSpriteWidth   32L
#define kMaxSpriteHeight  32L

static CWindowPtrgScreenWindowP;
static GWorldPtr gBackgroundGW;
static PixMapHandlegBackgroundPixMapH;
static GWorldPtr gOnDeckGW;
static PixMapHandlegOnDeckPixMapH;
static shortgLastSpriteSlot;
static shortgFirstSpriteSlot;
static shortgSpriteCount;
static shortgWindowWidth;
static shortgWindowHeight;
static SpriteInfoPtr gSpriteInfo;
static SpritePixDataPtr gSpritePixData;
static long gOnDeckRowBytes;
static long gBkgRowBytes;
static long gScreenRowBytes;
static shortgDeletionCount;

StartGame
void StartGame(CWindowPtr windowP)
{
Rect   r;
PixMapPtrbkgPixMapP;
PixMapPtronDeckPixMapP;
PixMapPtrscreenPixMapP;

gLastSpriteSlot = -1;
gFirstSpriteSlot = -1;
gSpriteCount = 0;
gDeletionCount = 0;
gScreenWindowP = windowP;
r = windowP->portRect;
OffsetRect(&r, -r.left, -r.top);
gWindowWidth = r.right;
gWindowHeight = r.bottom;

InsetRect(&r, -kMaxSpriteWidth, -kMaxSpriteHeight);
NewGWorld(&gBackgroundGW, 0, &r, 0, 0, 0);
gBackgroundPixMapH = GetGWorldPixMap(gBackgroundGW);
LockPixels(gBackgroundPixMapH); /* always locked */
NewGWorld(&gOnDeckGW, 0, &r, 0, 0, 0);
gOnDeckPixMapH = GetGWorldPixMap(gOnDeckGW);
LockPixels(gOnDeckPixMapH);/* always locked */

gSpriteInfo = (SpriteInfoPtr) NewPtrClear
(sizeof(SpriteInfo) * kMaxSprites);
gSpritePixData = (SpritePixDataPtr) NewPtrClear
(sizeof(SpritePixData) * kMaxSprites);
gBkgRowAddr = (Ptr *) NewPtr(sizeof(Ptr) *
(gWindowHeight + kMaxSpriteHeight * 2));
gOnDeckRowAddr = (Ptr *) NewPtr(sizeof(Ptr) *
(gWindowHeight + kMaxSpriteHeight * 2));
* (long) gWindowHeight);
if (gSpriteInfo == 0 || gSpritePixData == 0
|| gBackgroundGW == 0 || gOnDeckGW == 0)
DebugStr("\p out of memory!");
InsetRect(&r, kMaxSpriteWidth, kMaxSpriteHeight);
OffsetRect(&r, kMaxSpriteWidth, kMaxSpriteHeight);
CopyBits(&((WindowPtr)windowP)->portBits,
&((WindowPtr)gBackgroundGW)->portBits,
&windowP->portRect, &r, srcCopy, NULL);
CopyBits(&((WindowPtr)windowP)->portBits,
&((WindowPtr)gOnDeckGW)->portBits,
&windowP->portRect, &r, srcCopy, NULL);

bkgPixMapP = *gBackgroundPixMapH;
onDeckPixMapP = *gOnDeckPixMapH;
gOnDeckRowBytes = onDeckPixMapP->rowBytes & 0x7fff;
+ gOnDeckRowBytes * kMaxSpriteHeight
+ kMaxSpriteWidth;
gBkgRowBytes = bkgPixMapP->rowBytes & 0x7fff;
+ gBkgRowBytes * kMaxSpriteHeight
+ kMaxSpriteWidth;
screenPixMapP = *gScreenWindowP->portPixMap;
gScreenRowBytes = screenPixMapP->rowBytes & 0x7fff;
- screenPixMapP->bounds.left
- screenPixMapP->bounds.top
* gScreenRowBytes;

long row;

for (row = -kMaxSpriteHeight;
row < gWindowHeight + kMaxSpriteHeight; row++)
{
+ row * gBkgRowBytes;
+ row * gOnDeckRowBytes;
}
for (row = 0; row < gWindowHeight; row++)
+ row * gScreenRowBytes;
}
}

/* make a copy of CIcon’s pixel and mask data */
{
short  slot;
short  i;
short  pixWidth;
short  pixBytes;
short  bitBytes;
short  height;

slot = gLastSpriteSlot + 1;
if (slot == kMaxSprites)
slot = 0;
while (gSpriteInfo[slot].status != 0)
{
slot++;
if (slot == kMaxSprites)
slot = 0;
}
gSpriteInfo[slot].status = 1;/* occupied */
height = cIconP->iconPMap.bounds.bottom
- cIconP->iconPMap.bounds.top;
pixWidth = cIconP->iconPMap.bounds.right
- cIconP->iconPMap.bounds.left;
maskWidth = (pixWidth + 7) >> 3;
gSpriteInfo[slot].width = pixWidth;
gSpriteInfo[slot].height = height;
pixBytes = cIconP->iconPMap.rowBytes & 0x7fff;
bitBytes = cIconP->iconBMap.rowBytes;
+ bitBytes * height
+ 256 * 8 + 8;  /* 8-bit color table */

pixWidth = pixWidth >> 2;
for (i = 0; i < height; i++)
{
{
register long *q = (long *) pixDstAddr;
register long *p = (long *) pixSrcAddr;
register short  j = pixWidth;
while (j > 0)
{
*q++ = *p++;
j--;
}
}
}

if (gLastSpriteSlot >= 0)
{
gSpriteInfo[gLastSpriteSlot].nextSlot = slot;
}
else
{
gFirstSpriteSlot = slot;
}
gLastSpriteSlot = slot;
gSpriteInfo[slot].nextSlot = -1;
gSpriteInfo[slot].position = startPt;
gSpriteInfo[slot].lastPosition = startPt;
gSpriteCount ++;
return slot;
}

EraseSprite
/* replace sprite with chunk from the bkg gworld */
static void EraseSprite(SpriteInfoPtr spriteInfoP)
{
short  numRows;
short  numCols;
register long *p;
register long *q;
short  h, v;
register long srcRowBytes;
register long dstRowBytes;

numRows = spriteInfoP->height;
numCols = spriteInfoP->width;
h = spriteInfoP->lastPosition.h;
v = spriteInfoP->lastPosition.v;
if (h + numCols <= 0 || h >= gWindowWidth
|| v + numRows <= 0 || v >= gWindowHeight)
return;/* totally offscreen, so skip it */

p = (long *) (gBkgRowAddr[v] + h);
q = (long *) (gOnDeckRowAddr[v] + h);
srcRowBytes = gBkgRowBytes - numCols;
dstRowBytes = gOnDeckRowBytes - numCols;
if (numCols >= 16)
if (numCols == 32)
{
while (numRows != 0)
{
numRows--;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
p = (long *) (((Ptr) p) + srcRowBytes);
q = (long *) (((Ptr) q) + dstRowBytes);
}
}
else
{
while (numRows != 0)
{
numRows--;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
p = (long *) (((Ptr) p) + srcRowBytes);
q = (long *) (((Ptr) q) + dstRowBytes);
}
}
else
{
if (numCols < 8)
while (numRows != 0)
{
numRows--;
*q = *p;
p = (long *) (((Ptr) p) + gBkgRowBytes);
q = (long *) (((Ptr) q) + gOnDeckRowBytes);
}
else /* erase 4 pixels, even if its smaller */
while (numRows != 0)
{
numRows--;
*q++ = *p++;
*q++ = *p++;
p = (long *) (((Ptr) p) + srcRowBytes);
q = (long *) (((Ptr) q) + dstRowBytes);
}
}
}

DeleteSprite

/* Don’t actually do the delete, just mark for deletion -- because we still
need to erase it in UpdateScreen()
*/
void DeleteSprite(short spriteID)
{
gSpriteInfo[spriteID].status = -1;/* to be deleted */
gDeletionCount++;
}

RemoveDeletedSprites
/* only called when there is at least one deletion */
static void RemoveDeletedSprites(void)
{
short  prevSlot = -1;
short  slot = gFirstSpriteSlot;
short  count = gDeletionCount;

while (1)
{
if (gSpriteInfo[slot].status < 0)
{/* needs to be removed */
if (prevSlot >= 0)
gSpriteInfo[prevSlot].nextSlot
= gSpriteInfo[slot].nextSlot;
else
gFirstSpriteSlot
= gSpriteInfo[slot].nextSlot;
if (slot == gLastSpriteSlot)
gLastSpriteSlot = prevSlot;
gSpriteInfo[slot].status = 0;/* available */
gSpriteCount--;
count--;
if (count == 0)
break;
}
else
{
prevSlot = slot;
}
slot = gSpriteInfo[slot].nextSlot;
}
gDeletionCount = 0;
}

MoveSprite
void MoveSprite(short spriteID, Point deltaPt)
{
gSpriteInfo[spriteID].position.h += deltaPt.h;
gSpriteInfo[spriteID].position.v += deltaPt.v;
}

EraseOldSprites
static void EraseOldSprites(void)
{
short  slot;
SpriteInfoPtr spriteInfoP;

slot = gFirstSpriteSlot;
while (slot >= 0)
{
spriteInfoP = &gSpriteInfo[slot];
EraseSprite(spriteInfoP);
slot = spriteInfoP->nextSlot;
}

}

COPY4
/* copy 4 pixels based on bits of the mask */
#define COPY4(q,p,m) \
switch ((m) & 0x0f)\
{ \
case 0x0: break;\
case 0x1: *(q+3) = *(p+3); break; \
case 0x2: *(q+2) = *(p+2); break; \
case 0x3: *(short*)(q+2) = *(short*)(p+2); break; \
case 0x4: *(q+1) = *(p+1); break; \
case 0x5: *(q+1) = *(p+1); *(q+3) = *(p+3); break;      \
case 0x6: *(short*)(q+1) = *(short*)(p+1); break; \
case 0x7: *(q+1) = *(p+1); \
*(short*)(q+2) = *(short*)(p+2); break;   \
case 0x8: *(q) = *(p); break;\
case 0x9: *(q) = *(p); *(q+3) = *(p+3); break;    \
case 0xA: *(q) = *(p); *(q+2) = *(p+2); break;    \
case 0xB: *(q) = *(p);   \
*(short*)(q+2) = *(short*)(p+2); break;   \
case 0xC: *(short*)(q) = *(short*)(p); break;     \
case 0xD: *(short*)(q) = *(short*)(p);\
*(q+3) = *(p+3); break;\
case 0xE: *(short*)(q) = *(short*)(p);\
*(q+2) = *(p+2); break;\
case 0xF: *(long*)(q) = *(long*)(p); break; \
}

COPY8
COPY4(q, p, mask >> 4)   \

DrawSprite
static void DrawSprite(short slot)
{
SpriteInfoPtr spriteInfoP;
short  numRows;
short  numCols;
register Ptr  p;
register Ptr  q;
short  srcRowBytes;
short  h, v;
short  i;
long   dstRowBytes;

spriteInfoP = &gSpriteInfo[slot];
h = spriteInfoP->position.h;
v = spriteInfoP->position.v;
numRows = spriteInfoP->height;
numCols = spriteInfoP->width;
p = (char *) &gSpritePixData[slot];

if (numCols >= 8)
{
srcRowBytes = 40 - numCols;
dstRowBytes = gOnDeckRowBytes - numCols + 8;
while (1)
{
while (1)
{
if (--i == 0)
break;
p += 8;
q += 8;
}
if (--numRows == 0)
break;
p += srcRowBytes;
q += dstRowBytes;
}
}
else
{
while (1)
{
if (--numRows == 0)
break;
p += 32;
q += gOnDeckRowBytes;
}
}
}

DrawNewSprites
static void DrawNewSprites(void)
{
register short  slot;
SpriteInfoPtr spriteInfoP;

slot = gFirstSpriteSlot;
while (slot >= 0)
{
register short  numRows;
register short  numCols;
register short  h;
register short  v;

spriteInfoP = &gSpriteInfo[slot];
if (spriteInfoP->status < 0)
goto nextSlot;  /* deleted, so skip it */
numRows = spriteInfoP->height;
numCols = spriteInfoP->width;
h = spriteInfoP->position.h;
v = spriteInfoP->position.v;
if (h + numCols <= 0 || h >= gWindowWidth
|| v + numRows <= 0 || v >= gWindowHeight)
goto nextSlot;  /* totally offscreen */

DrawSprite(slot);
nextSlot:
slot = spriteInfoP->nextSlot;
}
}

FastCopyChunk
/* count is a multiple of 4 in the range [4..44] */
static void FastCopyChunk(long *q, long *p,
short count, short rows)
{
register short  srcRowBytes;
register short  dstRowBytes;
register short  rowsLeft = rows;
register short  copy8 = count & 8;
register short  copy4 = count & 4;

srcRowBytes = gOnDeckRowBytes - count;
dstRowBytes = gScreenRowBytes - count;
if (count & 32)
{
while (rowsLeft > 0)
{
rowsLeft--;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
if (copy8)
{
*q++ = *p++;
*q++ = *p++;
}
if (copy4)
*q++ = *p++;
p = (long *) (((Ptr) p) + srcRowBytes);
q = (long *) (((Ptr) q) + dstRowBytes);
}
}
else if (count & 16)
{
while (rowsLeft > 0)
{
rowsLeft--;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
if (copy8)
{
*q++ = *p++;
*q++ = *p++;
}
if (copy4)
*q++ = *p++;
p = (long *) (((Ptr) p) + srcRowBytes);
q = (long *) (((Ptr) q) + dstRowBytes);
}
}
else
{
while (rowsLeft > 0)
{
rowsLeft--;
if (copy8)
{
*q++ = *p++;
*q++ = *p++;
}
if (copy4)
*q++ = *p++;
p = (long *) (((Ptr) p) + srcRowBytes);
q = (long *) (((Ptr) q) + dstRowBytes);
}
}
}

DrawNewSpritesToScreen

/* Here we do have to watch out for sprites that overlap the edges of the window.  We copy a rectangluar
region that includes the sprites previous and current positions.  We know they will be close sionce sprites
move at most 8 pixels per turn.
*/
static void DrawNewSpritesToScreen(void)
{
short  slot;
SpriteInfoPtr spriteInfoP;
short  numRows;
short  numCols;
register long   *p;
register long   *q;
short  hStart, hEnd;
short  vStart, vEnd;

slot = gFirstSpriteSlot;
while (slot >= 0)
{
spriteInfoP = &gSpriteInfo[slot];
numRows = spriteInfoP->height;
numCols = spriteInfoP->width;
if (spriteInfoP->position.h
< spriteInfoP->lastPosition.h)
{
hStart = spriteInfoP->position.h;
hEnd = spriteInfoP->lastPosition.h + numCols;
}
else
{
hStart = spriteInfoP->lastPosition.h;
hEnd = spriteInfoP->position.h + numCols;
}
if (hStart < 0)
hStart = 0;
else if (hEnd > gWindowWidth)
hEnd = gWindowWidth;
if (spriteInfoP->position.v
< spriteInfoP->lastPosition.v)
{
vStart = spriteInfoP->position.v;
vEnd = spriteInfoP->lastPosition.v + numRows;
}
else
{
vStart = spriteInfoP->lastPosition.v;
vEnd = spriteInfoP->position.v + numRows;
}
if (vStart < 0)
vStart = 0;
else if (vEnd > gWindowHeight)
vEnd = gWindowHeight;
hStart = hStart & -4;  /* make it a mult of 4 */
hEnd = (hEnd + 3) & -4;  /* make it a mult of 4 */

p = (long *) (gOnDeckRowAddr[vStart] + hStart);
q = (long *) (gScreenRowAddr[vStart] + hStart);

vEnd -= vStart; /* now it’s a count */
hEnd -= hStart; /* now it’s a count */
if (hEnd >= 0)
FastCopyChunk(q, p, hEnd, vEnd);

spriteInfoP->lastPosition = spriteInfoP->position;
slot = spriteInfoP->nextSlot;
}
}

{
EraseOldSprites();
DrawNewSprites();
DrawNewSpritesToScreen();
if (gDeletionCount != 0)
RemoveDeletedSprites();
}
```

Community Search:
MacTech Search:

Printopia 3.0.8 - Share Mac printers wit...
Run Printopia on your Mac to share its printers to any capable iPhone, iPad, or iPod Touch. Printopia will also add virtual printers, allowing you to save print-outs to your Mac and send to apps.... Read more
BetterTouchTool 2.417 - Customize multi-...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom... Read more
Mellel 4.1.0 - The word processor for sc...
Mellel is the leading word processor for OS X and has been widely considered the industry standard for long form documents since its inception. Mellel focuses on writers and scholars for technical... Read more
ScreenFlow 7.3 - Create screen recording...
ScreenFlow is powerful, easy-to-use screencasting software for the Mac. With ScreenFlow you can record the contents of your entire monitor while also capturing your video camera, microphone and your... Read more
Dashlane 5.9.0 - Password manager and se...
Dashlane is an award-winning service that revolutionizes the online experience by replacing the drudgery of everyday transactional processes with convenient, automated simplicity - in other words,... Read more
ForkLift 3.2 - Powerful file manager: FT...
ForkLift is a powerful file manager and ferociously fast FTP client clothed in a clean and versatile UI that offers the combination of absolute simplicity and raw power expected from a well-executed... Read more
Cocktail 11.5 - General maintenance and...
Cocktail is a general purpose utility for macOS that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
Hazel 4.2.4 - Create rules for organizin...
Hazel is your personal housekeeper, organizing and cleaning folders based on rules you define. Hazel can also manage your trash and uninstall your applications. Organize your files using a familiar... Read more
Skype 8.18.0.6 - Voice-over-internet pho...
Skype allows you to talk to friends, family, and co-workers across the Internet without the inconvenience of long distance telephone charges. Using peer-to-peer data transmission technology, Skype... Read more
Backup and Sync 3.40.8921.5350 - File ba...
Backup and Sync (was Google Drive) is a place where you can create, share, collaborate, and keep all of your stuff. Whether you're working with a friend on a joint research project, planning a... Read more

## Latest Forum Discussions

Destiny meets its mobile match - Everyth...
Shadowgun Legends is the latest game in the Shadowgun series, and it's taking the franchise in some interesting new directions. Which is good news. The even better news is that it's coming out tomorrow, so if you didn't make it into the beta you... | Read more »
How PUBG, Fortnite, and the battle royal...
The history of the battle royale genre isn't a long one. While the nascent parts of the experience have existed ever since players first started killing one another online, it's really only in the past six years that the genre has coalesced into... | Read more »
Around the Empire: What have you missed...
Oh hi nice reader, and thanks for popping in to check out our weekly round-up of all the stuff that you might have missed across the Steel Media network. Yeah, that's right, it's a big ol' network. Obviously 148Apps is the best, but there are some... | Read more »
All the best games on sale for iPhone an...
It might not have been the greatest week for new releases on the App Store, but don't let that get you down, because there are some truly incredible games on sale for iPhone and iPad right now. Seriously, you could buy anything on this list and I... | Read more »
Everything You Need to Know About The Fo...
In just over a week, Epic Games has made a flurry of announcements. First, they revealed that Fortnite—their ultra-popular PUBG competitor—is coming to mobile. This was followed by brief sign-up period for interested beta testers before sending out... | Read more »
The best games that came out for iPhone...
It's not been the best week for games on the App Store. There are a few decent ones here and there, but nothing that's really going to make you throw down what you're doing and run to the nearest WiFi hotspot in order to download it. That's not to... | Read more »
Death Coming (Games)
Death Coming 1.1.1.536 Device: iOS Universal Category: Games Price: \$1.99, Version: 1.1.1.536 (iTunes) Description: --- Background Story ---You Died. Pure and simple, but death was not the end. You have become an agent of Death: a... | Read more »
Hints, tips, and tricks for Empires and...
Empires and Puzzles is a slick match-stuff RPG that mixes in a bunch of city-building aspects to keep things fresh. And it's currently the Game of the Day over on the App Store. So, if you're picking it up for the first time today, we thought it'd... | Read more »
What You Need to Know About Sam Barlow’s...
Sam Barlow’s follow up to Her Story is #WarGames, an interactive video series that reimagines the 1983 film WarGames in a more present day context. It’s not exactly a game, but it’s definitely still interesting. Here are the top things you should... | Read more »
Pixel Plex Guide - How to Build Better T...
Pixel Plex is the latest city builder that has come to the App Store, and it takes a pretty different tact than the ones that came before it. Instead of being in charge of your own city by yourself, you have to work together with other players to... | Read more »

## Price Scanner via MacPrices.net

Back in stock! Apple’s full line of Certified...
Save \$300-\$300 on the purchase of a 2017 13″ MacBook Pro today with Certified Refurbished models at Apple. Apple’s refurbished prices are the lowest available for each model from any reseller. A... Read more
Back in stock: 13-inch 2.5GHz MacBook Pro (Ce...
Apple has Certified Refurbished 13″ 2.5GHz MacBook Pros (MD101LL/A) available for \$829, or \$270 off original MSRP. Apple’s one-year warranty is standard, and shipping is free: – 13″ 2.5GHz MacBook... Read more
Apple restocks Certified Refurbished 2017 13″...
Apple has Certified Refurbished 2017 13″ MacBook Airs available starting at \$849. An Apple one-year warranty is included with each MacBook, and shipping is free: – 13″ 1.8GHz/8GB/128GB MacBook Air (... Read more
8-Core iMac Pro on sale for \$4699, save \$300
Amazon has the 8-core iMac Pro on sale for \$4699 including free shipping. Their price is \$300 off MSRP, and it’s the currently lowest price available for an iMac Pro. For the latest up-to-date prices... Read more
10″ 512GB WiFi iPad Pros on sale for \$849, sa...
B&H Photo has Space Gray and Rose Gold 10.5″ 512GB WiFi iPad Pros on sale for \$849. Their price is \$150 off MSRP, and it’s the lowest price available for these models, new, from any Apple... Read more
MacBook Pro sale! B&H drops prices on new...
B&H Photo has dropped prices on new 2017 13″ MacBook Pros, with models now on sale for up to \$200 off MSRP. Shipping is free, and B&H charges sales tax for NY & NJ residents only. Their... Read more
13″ MacBook Airs on sale for \$100-\$150 off MS...
B&H Photo has 13″ MacBook Airs on sale for \$100-\$150 off MSRP. Shipping is free, and B&H charges sales tax for NY & NJ residents only: – 13″ 1.8GHz/128GB MacBook Air (MQD32LL/A): \$899, \$... Read more
Huge iMac sale! Apple reseller now offering 2...
B&H Photo has new 2017 21″ & 27″ iMacs on sale today for up to \$300 off MSRP. Shipping is free, and B&H charges sales tax for NY & NJ residents only: – 27″ 3.8GHz iMac (MNED2LL/A): \$... Read more
Sale! 1.4GHz Mac mini for \$399, \$100 off MSRP
B&H Photo has the 1.4GHz Mac mini on sale for \$399 for a limited time. Their price is \$100 off MSRP, and it’s the lowest price available for a mini from any Apple reseller: – 1.4GHz Mac mini (... Read more
Sale of the year continues as Apple resellers...
Adorama has new 2017 15″ MacBook Pros on sale for \$250-\$300 off MSRP. Shipping is free, and Adorama charges sales tax in NJ and NY only: – 15″ 2.8GHz Touch Bar MacBook Pro Space Gray (MPTR2LL/A): \$... Read more

## Jobs Board

*Apple* Retail Sales Associate / Service Wri...
Job DescriptioniStore is the premier retailer of Apple products and solutions. We're looking for dedicated individuals with a passion to simplify and enhance the Read more
Integration Technician, *Apple* - Zones, In...
…adapted, and grown for over 30 years. Position Overview The Apple Integration Technician will be responsible for performing customer specific configuration Read more
*Apple* Retail - Multiple Positions - Apple,...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Part Time Reseller Specialist - *Ap...
…in a reseller store, you help create the energy and excitement around Apple products, providing the right solutions and getting products into customers' hands. You Read more
*Apple* Technical Specialist - Apple, Inc. (...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more