PSX64 – Rev B (ATmega168) Firmware Update

Since no boards with the ATmega168 have been shipped out, this shouldn’t affect anyone, but if you happened to build your own board in the last few days and used firmware 1.1b for it – you’ll want to update it to 1.2b found here.

The ATmega168 appears to access its flash memory at a different speed (perhaps due to increased size), which slowed down macro playback to a noticeable degree. This firmware updates the playback speed to put it back in line with the ATmega8.

Again, this firmware is only for the ATmega168, so if you bought your board, you won’t need this firmware.

10 Reasons the Commodore 64 Will Never Die

As some of you might have guessed by now, I’m pretty heavily into retro computers. I love them all in different ways, but the C64 holds a very special place in my heart in particular. It was my very first computer (and my only machine for 8 years) – and it introduced me into a world which I never escaped. I learned how to program on it, played my first computer game on it, and spent a great deal of my childhood on it. So while I might be biased as I write this, I’ll try to be as objective as possible.

1. The Game Library

The C64 has always been known as a gaming machine, and for good reason. While the computer has been used across all areas of computing, from music composition and graphic design to business management and financial accounting, its library of games is MASSIVE. Estimates come in at over 21,000 titles, and new titles are still being developed all the time (Check out the most comprehensive database at GB64). And like any media, from music to movies, just because the title is older doesn’t mean it’s not still enjoyable – there are some simply great games for the C64 that are still lots of fun to play.

2. Quantity Produced

The Commodore 64 is still the best selling computer to this day – and most likely will be forever. Saying it sold well would be a gross understatement – it crushed the home computer market. Jack Tramiel, founder of Commodore, did a lot of things right in his day, and one was the price point of the machine. While it started at $595, it eventually dropped to $200, and estimates of units sold range from 17 to 30 MILLION. Even with a large portion of owners throwing their machine away over time, 30 million computers simply don’t disappear. It is still extremely easy to pick up a C64 off of eBay, Craigslist, or other online sites.

3. The Community

While this is true of a lot of the classic computers, it is especially true of the Commodore line – there is still a huge following for this machine. It’s likely if you look enough online, you’ll still find a user’s group, yearly convention, or informal get-together that includes, or even focuses on, the C64. I’ve personally attended a couple conferences (TPUG‘s World of Commodore and ECCC), and have been in close contact with other groups (Commodore Computer Club and Users Group in Vancouver, WA) – and they’re all friendly guys and gals who have a common love for all things Commodore (and Amiga, and Apple, and Atari, etc…). They are the true heart that continues to drive the C64 onward!

4. The SID Chip

The MOS 6581/8580 SID is arguably one of the greatest sound chips to ever be produced. During its time, there was no other 8-bit computer that had the sound capabilities of the C64. Even in contemporary times, the unique sound quality of the SID is still a desired effect that modern musicians seek to take advantage of. Newer dedicated hardware, such as the SIDStation, has been used by groups such as Timbaland and Machinae Supremacy to produce the sweet C64-style synth sounds that can’t be gotten anywhere else.

5. Hackability

While computers today can render 3D worlds while playing a 20 part symphony and downloading a set of encyclopedias, this comes at a cost – and that cost is complexity. The beauty of a machine like the C64 is a hardware or software developer’s ability to interact directly with the machine. You can read and write directly from/to memory, tie into the system bus, and do a whole other array of low level things that 62 layers of hardware and operating system don’t allow you to do on a new PC. For those who love to tinker, this is a dream.

6. New Capabilities

Due in large part to #2 and #5, new hardware still being made constantly, which breathes incredible new life into the machine. From SD/CF card readers and Ethernet adapters, to mp3 players and accelerators, the Commodore 64 of today is a different beast than in its 80s heyday. When a machine with a 1 MHz processor and 64K of RAM can surf the web, tweet on Twitter, and can access files on an 160GB IDE hard drive, that’s truly amazing.

7. Strong Emulator Support

Using a Commodore 64 doesn’t necessarily mean you need the hardware anymore. Since the advent of faster machines with emulation capabilities, many developers have been working on virtual versions of the hardware counterpart. Many years have passed, and these are now solid, amazing, and free applications that allow you to use a C64 on a variety of devices, from computers and laptops to PSPs and iPhones. Even if all the hardware one day disappeared, emulators never will. Two of the most popular ones are VICE and CCS64).

8. FPGA Implementations

In the same vein as #7, some hardware wizards have gone the emulation route, but instead of producing a software version, have reimplemented the machine in FPGA hardware. In this manner, the C64 exists as firmware on a programmable chip, which allows for smaller, cheaper, and easily upgradable/hackable versions of the C64. And since the machine exists as firmware, many of these devices have different models of computers on the same device – flip the switch and go from using a C64 to an Amiga 500. Examples include Jeri Ellsworth’s DTV and the MCC (Multiple Classic Computer).

9. The Scene

Since the beginning, due to its powerful sound and graphics capability, the C64 has been used to demonstrate elite programming skills through dazzling shows of animation and music. While it started in large part as intros to software cracks, the demo scene grew into a beast all of itself. Some of the greatest artistic, musical, and programming talent to ever hit a computer has gone into software demos. And to this day, programming gurus continue to show off their talents on the C64 – not only because it’s a great platform to program for, but feats are all the more impressive when accomplished in minimal space/computation. A list of upcoming Demo parties can be found at Demo Party.net

10. The Shameless Plug

And the C64 is the only place to find Shredz64 (Guitar Hero for the C64)! ๐Ÿ˜‰ It’s just fun to show your friends that a machine made in 1982 can do the same things that a new PS3 or Wii can do. (Sorry, had to do it)

So if you’ve never tried a C64, or haven’t touched one for a long time – find an emulator, pick one up off eBay, or borrow a friend’s – and find out for yourself why it’s still the most amazing computer ever made!

PSX64 – New MCU (and Firmware)

For whatever reason, Digikey and Mouser’s supply of the Atmega8-16 MCU is completely out of stock. I’ve seen differing reports whether this chip is End-Of-Life’d, but that certainly seems like it might be the case – neither site indicates that a future stock will be available. With this in mind, all new PSX64s produced will be using the Atmega168 instead. Really, this will functionally make no difference. The 168 can run faster and has more memory, but I’m driving it with the same 16 MHz crystal and with the same code. And luckily, the two chips are pin compatible, so no rework of the PCB is necessary.

The Atmega168 does have different fuses and slightly different architecture, and the firmware needed to be recompiled. I made a PSX64 with the ATmega168 tonight, and recompiled the firmware, and life is good. If you’re building a new board with an ATmega168, or (in the future) need to reflash your PSX64, the new revision B firmware is available here. (i.e. psx64fw11.hex is version 1.1 for the ATmega8, and psx64fw11b.hex is version 1.1 for the ATmega168).

Fun Ways to Sharpen Your CS Skills

If you’re anything like me, once you learned how to code, you would take any chance you could get to write little programs for fun. I remember once I finally “got” BASIC on my Commodore 64 growing up, I would spend hours writing the cheeziest (looking back) programs. A favorite of mine was writing countless “Question and Answer” programs, where the computer would ask “How are you?” and depending on your answer, the program would issue a different (and probably inappropriate given my age at the time) response.

Time Marches On

As time went on though, and I got better at programming, learned the fundamentals, studied Computer Science – things started to change. I still loved to program, but my goals became larger and more complex. Pet projects would take days to complete, then weeks, then months. Once I started doing it professionally, that added a whole new level, where the projects were for money, and project management, sustainability, fiscal viability, etc, all became factors. I had to specialize and focus on specific areas to remain competitive. And the technology changed – whereas once I was communicating directly with the processor and memory I/O, now I was communicating 17 levels up to a a COM object or framework API. It was just a different ballgame – which isn’t necessarily a bad thing, but sometimes working at such a high level for different purposes can make you lose site of the underlying CS. Sometimes it’s important to keep your CS skills as fresh and sharp as your software engineering ones.

Some Fun Ways to Up Your CS Game

Luckily, there are some sites out there that are awesome for keeping those little grey CS cells active in your head.

Project Euler
This is by far my favorite one. Euler offers a large number of problems (currently 300) that require a computer program to solve. They are generally geared toward mathematics of different levels and areas (generally the higher the problem, the more difficult it is), and you can solve them using any method or programming language you wish. The website keeps track of how many you’ve solved and how you’re faring with the rest of the members, but really you’re competing with yourself to write the best program you can. As you get into later problems, even your efficiency matters, as your first solution might take 3 days to complete, whereas the better one takes .25 seconds. They have discussion forums for each problem as well (once you’ve solved it), where people show their solutions and help each other out. Some example problems on the site:

1. Add all the natural numbers below one thousand that are multiples of 3 or 5.
7. Find the 10001st prime.
15. Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner?
109. How many distinct ways can a player checkout in the game of darts with a score of less than 100?
157. Solving the diophantine equation 1/a+1/b= p/10n

As you can see, there are a large range of problems targeting different areas and algorithms. I’ve solved 34 to date – sometimes I’ll spend a lunch hour working on a problem, they’re great fun and you can do them at your own pace – and learn new techniques in the process.

Hack This Site!
No, that wasn’t an invitation! Hack This Site . Org is an interesting site that offers a number of security, reverse engineering, and application development missions. While I’m actually against the practice of unauthorized computer access (especially being a IT Manager by day) – penetration testing is a great thing for a network administrator to know, and reverse engineering is a fantastic thing for a programmer to know. In the high-level development world we now live in, getting back to the processor and memory level is definitely a plus – and studying the binary structure of an executable certainly achieves that. Not only does it strengthen your machine language skills, but it also gives you great insight into how compilers work, how operating systems link DLLs, management memory, and achieve IPC.

Many More

Project Euler and Hack This Site are the two I focus on (and between the two of them, there are enough problems to keep me busy for years), but if they aren’t your cup of tea, here are a list of other programming problem related sites:

Bright Shadows
Electrica
Programming Challenges
Python Challenge
TopCoder

Have fun, and get your CS in shape!

Follow Along On Twitter!

For those interested, I finally bit the bullet and created a Twitter account. Follow all the programming, retrocomputer, and engineering madness!

@ToniWestbrook
http://www.twitter.com/ToniWestbrook

Shredz64 – New Disk Labels

I decided to spruce up the hand written labels with a little MS Word mail merge label action. Not the fanciest in the world, but a little nicer looking!

Blackberry – Mixing 2 or More Sounds Together (Concept Video)

An Audio Issue

One thing that I (and many others judging by forum posts) have run into is the fact that the Blackberry isn’t very good at mixing more than one sound together. You’ll be listening to music, or playing a game with music, and suddenly you’ll get a text message, and it will simply terminate the current sound and play the new one. If you’ve got a friendly application, it will restart/resume the original audio, but it’s a jarring audio experience.

What I’m about to post won’t fix that. However – developers also run into the issue when they want to mix sounds together in their applications and games. Play 2 or more sound effects simultaneously and/or while music is playing. I’ve seen official RIM developers comment that certain devices can achieve two simultaneous sounds by instantiating the Player class twice – but from what I gather, this is on GSM only phones – and still limited to two. On CDMA devices, you’re completely out of luck.

The Cheap and Quick Workaround

In my 6 part tutorial on writing a Blackberry game, in the audio article, I mentioned how the Alert.startAudio method can be used for simple sound effects (tone/duration pairs) that will play simultaneously while your midi or mp3 music plays in the background. For many applications, this is enough if you don’t need sophisticated sound effects.

The Start of a Mixer

I’m guessing that the limitation is imposed by the audio chipset/DAC inside of CDMA devices, and perhaps RIM realizes the CPU time involved in a software based audio mixer would slow the phone down too much. However, I think the software option should be there, and developers can use it if they’d like – they might not need a large amount of CPU, or might be dealing with low quality sound files – there are a few scenarios where a software mixer would just be a nice options.

Tonight I sat down and wrote a quick and dirty proof of concept application showing a PCM audio mixer in action. I loaded in 3 audio 44.1khz 8bit mono files and mixed them together in real time. I didn’t normalize the audio at all, so its a little soft, but the code works, and could be expanded on quite a bit to make a full featured mixer. Maybe I’ll run into problems down the road that RIM already has, but it’ll be interesting nonetheless.

Here is the video of the test:

Shredz64 – Video of New Bonus Track “Still Alive (Portal Credits)”

With Valve releasing Portal 2 fairly soon, and after realizing a SID version of “Still Alive (Portal Credits)” existed, I realized I had no choice but to make it a bonus track and post a video of it in action.

This and all tracks are available at Synthetic Dreams.

(PS – If you haven’t played Portal yet – go and do it now. It’s a fantastic game, and a fantastic ending song.)

Blackberry Programming: Increasing Video Speed Through Prerendering

A Problem of Efficiency

As I finishing up the full version of Galactic Blast (screenshots on this soon, its a fully fleshed out game inspired by the demo, to be released on App World) – I ran into an issue in a strange area. The animation was smooth throughout the game, except oddly enough, on the instructions screen.

The instructions screen in Galactic Blast includes some text describing the storyline, some text describing the keyboard controls, bitmaps showing each of the enemies and power ups with description text, and some credits at the end. Since there’s much more than can fit on a single screen, the user can scroll up and down – nothing fancy, just your basic instructions screen. However, the scrolling was anything but smooth. As I debugged more, I found out that redrawing all the bitmaps and text at each scroll was simply taking too long – all the function and helper calls involved in rendering everything was just too much for the processor.

The Solution

As I thought more about it, I realized that it would be much better to simply render one item instead of 20-30 items each time. And since instructions are static in nature (they don’t change or animate), it was a prime candidate for prerendering all the text and bitmaps to a single, big bitmap. However, I wanted the program to prerender the items automatically at runtime – I didn’t want to have to create the bitmap manually (which would be a huge pain anytime I needed to edit something – like adding a new line of text in). The code below achieves this by creating a bitmap in memory and rendering all the desired text/images to it at the start of the program, and then simply displays (and scrolls) this bitmap on the instructions screen.

The Code

I’ve removed the specific text, bitmaps, and positioning from the code to make things a little clearer:


// _instructionsBM is the large bitmap we will be rendering all our text 
// and images to.  This is the bitmap we will actually
// display on the instructions screen, thereby increasing efficiency
// since we're only redrawing one bitmap each time the 
// player scrolls instead of a bunch of bitmaps.
private static Bitmap _instructionsBM;

   public static void prerenderInstructions() {
      Graphics tempGraphics;
      String objectiveString;
      Bitmap tempBitmap;
      Object castArray[][];     
      
      // Populate a string with the objective of the game
      objectiveString = "Text describing the objective of the game  ";
      
      // Populate an array with the enemy bitmaps, their names,
      // and how many points they are
      castArray = new Object[2][];
      castArray[0] = new Object[] { enemyBitmap1, "Enemy 1", "50 Points" };
      castArray[1] = new Object[] { enemyBitmap2, "Enemy 2", "75 Points" };
   
 

        // Initialize the bitmap, and then give it an alpha channel for
        // transparency, allowing the background to show through 
        // behind the text and bitmaps
       _instructionsBM = new Bitmap(Bitmap.ROWWISE_16BIT_COLOR, WIDTH, HEIGHT);
       _instructionsBM.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP); 

        // Start with a blank, completely transparent image
      _instructionsBM.setARGB(new int[_instructionsBM.getWidth()*_instructionsBM.getHeight()], 0,               
                                             _instructionsBM.getWidth(), 0, 0, 
                                             _instructionsBM.getWidth(), _instructionsBM.getHeight());

      // The Graphics object acts a surface that drawing operations 
      // can be performed on.  By calling the Graphics constructor
      // with the bitmap as an argument, all drawing operations
      // will be performed upon the bitmap itself.
      tempGraphics = new Graphics(_instructionsBM);

      // All operations to follow will be fully opaque (so pixels not 
      //acted upon will stay transparent, while any text/images drawn
      // will be solid.
      tempGraphics.setGlobalAlpha(255);
            
      // Draw the text onto the bitmap
      tempGraphics.setColor(Color.YELLOW);
      tempGraphics.drawText(objectiveString, 5, 5);    
      
      // Draw enemy bitmaps onto the bitmap
      for (int lcv = 0 ; lcv < castArray.length ; lcv++) {
         tempBitmap = (Bitmap) castArray[lcv][0];
         tempGraphics.drawBitmap(Utils.getDimension(5, 50+lcv*50, 
                                                tempBitmap.getWidth(), tempBitmap.getHeight(), tempBitmap, 0, 0);
         tempGraphics.drawText((String) castArray[lcv][1], 100, 50+lcv*50);  
         tempGraphics.drawText((String) castArray[lcv][1], 200, 50+lcv*50);  
      }
   }

Shredz64 – New Disk Images and Firmware Posted

For those who want to download the NTSC or PAL version of Shredz64, I updated the disk images available online to include the latest track selection.

Additionally, the link on the blog to the PSX64 firmware now points to version 1.1, the latest update which incorporates the macro and speed fixes. For archival purposes, I’ve left 1.0 and 1.0a in the download directory as well.

Also, hopefully another new track soon, maybe even this weekend!