SpaceInvadersClone Mac OS

Welcome, to the Space Invaders project, in this docuemnt you find information about how to compile and run the application. Space Junkie, an old mac game I used to play when I was a kid in the 90's.

It would later see release on the Mac OS X operating system in 2010 and was released on Linux in 2012 as well. By 2011, it controlled 70% of the market for downloadable PC games, with a userbase of about 40 million accounts. Space Invaders is a true giant of the arcade world - a classic shooting game where the player fires a laser at rows of descending space aliens. Now you can play the classic old school game right in. Space Invaders clone made in 2001 using METAL Engine. Works on both Mac OS 9 and Mac OS X. And it requires an insane amount of RAM to run! Download Space Invaders (2001) for Mac SpaceInvaders.sit (170.22 KiB / 174.31 KB).

I just finished porting a Space Invaders clone to run on an AVR microcontroller. The clone is called Classic Invaders, made by the No Quarter Arcade. I have a functional bare-bones version of the game running now. It has the core game without any sound, scoreboard, main menu, etc.

NOTE: The purpose of this article is to describe the steps I took to port the game from PC to AVR. It does NOT describe the custom hardware I used to generate the video output. I will blog about that later.

For those who are really interested, come to Maker Faire in the Bay Area on May 18-19, 2013. I will be presenting my hardware there.

First, some stats on the game and embedded platform:

Original Classic Invaders game:

  • Language: C++
  • Platforms: Windows, Linux, Mac OS.
  • Graphics library: SDL (http://www.libsdl.org/)
  • Other libraries used: Boost (http://www.boost.org/)

Embedded system:

  • Architecture: Atmel AVR, 8-bit microcontroller
  • Device: Atmega 128A
  • Speed: 8 MHz @ 3.3V
  • Data memory: 4 KB
  • Program memory: 128 KB
  • Input: SNES gamepad via SPI

I will post the source code later.

1. Eliminate the non-essentials.

Removed all the code to handle sound, UI, status, and fonts. These aren’t necessary for the operation of the game.

Removed the main menu. Go directly into the gameplay.

These non-essential elements can be added back when the game core is completely ported.

2. Remove advanced C++ code.

Classes are okay because they’re just glorified structs. However, these had to go:

  • STL containers: replaced with static arrays. The number of objects is known at compile time.
  • Dynamic allocation: replacedwith static allocation. Same idea as above
  • Shared pointers from boost library: No longer necessary without dynamic allocation.
  • Random number generators from Boost library: Replaced with custom functions to call rand().

Class inheritance was also a problem as derived classes require dynamic allocation. In Classic Invaders, there are different classes for various game object types: aliens, player, shots, etc. They all derive from a common game object class. There weren’t many variables unique to the derived classes, so I removed all the derived classes and put derived members into the base class. The object type is now identified by a “type” member variable.

3. Stub out higher-level libraries.

Classic Invaders used the SDL library to provide graphics, sound, input, and timing functions. I put all calls to SDL into wrapper classes and functions. Their contents were enclosed by “#ifndef __AVR__” so they could be built for AVR without including SDL. Meanwhile, the game could still be compiled and run on PC platforms to verify that my other changes didn’t break anything.

4. Use fixed point numbers instead of floating points.

Embedded microcontrollers tend not to have floating point units. I replaced the floats with a “12.4” fixed point integer type. You can read about fixed point math here: http://en.wikipedia.org/wiki/Fixed-point_arithmetic.

With these changes, the game builds and runs on the AVR. But it crashes due to memory limitations. So the work continues.

5. Reduce variable sizes.

The default int size on AVR is 16 bits. In many places, only 8 bits are required. I replaced all ints with size-specific types from stdint.h.

In some cases, the data can be packed even more using bit fields. I did this for boolean flags and very small integer variables.

6. Move common variables out of the game object class.

Many values were the same across all game objects of one type. For example, the aliens move at the same speed, their shots travel at the same speed, and they have the same image size. I put these common properties into structures and variables outside the game object class.

7. Store some game objects as a simpler structure.

The shield pieces were originally stored as game objects like everything else. As static objects placed in a regular grid, they didn’t need to store pixel coordinates, animation frame count, etc. I replaced them with the following struct that took one byte instead of nine:

I don’t have the data size before all these changes. I do know that at one point after making a few reductions, the game data required over 3.5 KB. Throw in local variables and data used by standard C libraries, and the program easily exceeded the 4 KB memory limit.

At the time of this writing, after much more space optimization, the game data takes only about 1.6 KB.

Steps #1 thru #7 produce a program that runs without crashing. But it’s also a program that doesn’t do anything except crunch numbers. If you remember Step #3, some important infrastructure was stubbed out. I had to re-implement them for the AVR platform.

8. Enable graphics, timing, and input.

There’s no reading of image files when your system has no hard disk. The image and palette data are instead stored as raw data in the AVR’s program memory. They are written to the external video hardware, which produces the final video output.

Timekeeping is done using the AVR’s internal timers. I wrote some code to increment a counter once per millisecond, plus a function that returns the counter value. This matches the operation of SDL_GetTicks().

Instead of a keyboard, I used a SNES gamepad for input. I read it over the AVR’s SPI interface. It replaces the function of SDL_GetKeystate().

9. Optimize for speed.

The original collision detection code was very inefficient. It checked every object of in group A against every object in group B. On a PC, this inefficiency doesn’t hurt because the system takes little time to brute-force its way through a few dozen objects. But on a 8-bit microcontroller running at 8 MHz, every microsecond counts.

I made the collision detection more localized. For example, the shield pieces are arranged in a grid within three rectangular clusters. If a shot does not collide with a cluster, it is not checked against individual shield pieces within that cluster. The same is done for alien-shot and alien-shield collisions, as the aliens are also in a regular grid. The shield collision optimization decreased the number of collision checks per game loop from 4000 to 300.

Another improvement in speed came from using a common speed for each type of object (see step #6). Objects are moved according to the formula:

The multiplication and division of large integers are expensive. By computing one movement value per object type instead, the time spent in game logic per loop decreased from 20 ms to 14 ms:

In an earlier stage, I had seen game loop times of 60 ms when there were many collisions. This translates to a choppy 16 fps.

After all the optimizations, the game loop was no more than 10 ms. The result was a smooth 60 fps, synchronized to the LCD monitor refresh. With this final step, I considered my game port to be complete.

Dec 21, 2020 • Filed to: Solve Mac Problems • Proven solutions

Apple claims that its Mac OS is fully equipped to assist its users for day-to-day PC activities, and they seem to have proven the same over the years. Since Mac users save a lot of important data on it, it is necessary to keep all such information secure. Mac Disk Utility does exactly that with the help of its 'Restore' option. This function teaches you how to Clone a Mac's Drive with Disk Utility.

In this article, learn how to copy all the data and clone a Mac's Drive (internal/external) easily. Read and know more about Mac Disk Utility, its 'Restore' function, how to clone a Mac's Drive with Disk Utility, and a simple way torecover your Mac's Drive.

Part 1: Why You Need to Clone a Mac's Drive?

'What is the need to clone a Mac's Drive?' This thought must have crossed your mind atlas once while using Mac. To be precise, cloning of hard drives protects your important data which is under possible risk of physical destruction, loss, etc.

Spaceinvadersclone Mac Os Catalina

No matter how new or of what quality your hard drive is, you cannot say for sure that it will last forever and never crash or suffer from a system failure. Old hard drive or one suffering from mechanical, firmware, or electrical error can permanently destroy your data, such as photos, documents, videos, music, and other files. Also, if important personal documents and business files are misplaced in the process, retrieving them is next to impossible.

Therefore, to prevent these and many more situations that may arise due to data loss, we recommend that you always know how to Clone a Mac's Drive using Disk Utility. Mac Disk Utility and its 'Restore' functions can keep your data, important information, and files secure by literally copying it from your Mac Drive.

Difference Between Time Machine Backup and Cloning Hard Drive

If you're wondering whether to use Time Machine or Mac Disk Utility to clone a Mac's Drive, let us clear the confusion for you. Time Machine is a built-in application to back up and make an up-to-date copy of the data you save on the Mac. Its unique feature is that it makes real-time backups to recover files easily whenever needed. When set-up for the first time, Time Machine performs a full backup of the Mac and its contents. Time Machine keeps, hourly, daily and monthly backups all categorized separately.

If Time Machine can do so much, then why consider using Mac Disk Utility?

To start the discussion, Mac Disk Utility is free and also comes built-in with every Mac OS version. It has various new features that make it more suitable than the Time Machine. Say, for example, its 'Restore' option does something what is called block copy and make the entire cloning process swifter. It is also capable of making an almost cut to cut an exact copy of the contents of the Drive. No important files, documents, or data are left behind using Mac Disk Utility. It works in blocks and does not involve file to file transfer.

Spaceinvadersclone mac os downloads

Some changes have been introduced in the Mac Disk Utility toolkit which makes more accurate cloning and copying data from the Drive.

Spaceinvadersclone Mac Os Downloads

Part 2: How to Clone Mac's Drive using Disk Utility?

Curious to know how to clone a Mac's Drive with Disk Utility? Follow these simple steps and you're good to go:

Related: If need be, learn how touse Disk Utility to resize Mac volume.
  1. Open Mac Disk Utility on your Mac from Utilities or Applications.
  1. Click 'Erase' from the top of the Disk Utility interface.
  2. Now chose a media on the left panel to make it your backup drive.
  3. At the drop-down list which has 'Format' options, choose Mac OS Extended (Journaled). Then hit 'Erase' again and wait for the drive to remount on Mac.
  4. Then at the Mac Disk Utility interface, click 'Restore'.
  5. Now comes the tricky bit. Select the target drive, drag it and drop it at the 'Source' field.
  6. Now drag and drop the destination Disk/Drive and leave it at the 'Destination' field.
  7. Hit 'Restore' once and for all. The contents of the drive will be copied and saved on the destination drive.

Part 3: How to Recover Mac's Drive Data?

What does one do if some data is lost during cloning the mac's Drive? Don't worry. The loss isn't permanent and the destroyed data can be recovered with the help ofRecoverit for Mac. It is a recovery tool for MacBook, iMac, Hard Drives, Flash Drives, Memory Cards, phones, cameras, and camcorders. It can instantly retrieve the lost contents from the Mac Drive and provide reliable data recovery solutions. It can recover documents, images, videos, audio files, emails and archives files.

Download MacDownload Win

The steps given below will help you use Recoverit for Mac to recover Mac's Drive:

  1. Download, install and launch Recoverit hard drive recovery software. Now choose the target drive where the data gets lost, and click 'Start' to recover lost data.
  1. And then the data recovery tool will set in motion an all-around scan to search the lost files.
  1. Finally, you can preview the whole scanned results, select the ones which need to be restored, click 'Recover' as shown below, and save the recovered data in another drive/disk to keep it secure for future.

Conclusion

The bottom line, we have attempted to answer a commonly asked question on online forums, i.e., how to clone a Mac's Drive with Disk Utility. We hope you will find this red useful and now be able to clone your Mac's drive and keeps its contents safe.

Also, the Recoverit drive data recovery toolkit is a safe, effective, and trustworthy medium to retrieve your lost documents and file. So go ahead and follow the instructions in this guide to clone Mac's drive orrecover hard drive datadeleted accidentally during its process.

What's Wrong with Mac

Recover Your Mac
Fix Your Mac
Delete Your Mac
Learn Mac Hacks