Archive for the ‘Toy Box’ Category

M.A.M.E. for SONY PlayStation 2

Monday, December 4th, 2000

As I’ve just started working on PlayStation 2 hardware and I have access to a DTL-T10000 development station (the big black monolith) I wanted to find out just how fast the main CPU, an Hitachi clone of a MIPS processor, really was.I took the source code to M.A.M.E. and xMAME and with a little tweaking ported it to the Sony PlayStation 2 without too much trouble. The emulator runs at 40fps for most of the older 1980’s ROMs with all the GNU compiler optimisations switched on, with no audio support currently. Once I have the graphics functions optimised I expect to see it running at a solid 60fps.

The other speed test I did was take the open-source 1964 Nintendo 64 Emulator that is available and to which I can claim absolutely no credit for and ported it to the PS2, I just cheekily renamed it to 2064 to bring it up to date.

Getting the N64 emulator up was a much easier task and with only a few tweaks and a little optimisation it is running a good 55fps. With some thougth given to the 3D rendering and harnessing the full power of the PS2 I expect to have an N64 emulator running at 150% to 200% of the speed of the actual console.

I’m hoping that the MAME cabinet I intend to put together wil not require a $1500 PC inside of it and I’ll be able to slip in a $300 PlayStation 2.

Please do not ask me for either of these programs as I cannot legally distribute them.

Update #1: Unfortunately for me, I was too dumb to actually take any pictures with a camera of M.A.M.E. running on the PS2 dev kit. A couple of days later I did remember to take pictures of my generic Atari 2600 VCS Emulator that I ported so you’ll just have to satisfy yourself with those.

atari2600_thumbnail1.pngUpdate #2: I ported my Atari 2600 VCS Emulator to the Sony PlayStation 2 as well.

Update #3: At least I had the presence of mind to take pictures of M.A.M.E. running on the Microsoft XBOX a year later.

Pitfall II+

Thursday, June 1st, 2000

Pitfall II+ Shortly after my time at Activision one of the things I tinkered, inspired by working on the Pitfall franchise, was to create several tools in my spare time to edit & manage Pitfall 2 levels for what I was hoping would be Pitfall II on the Nintendo Gameboy Colour. Pitfall II for GBC never happened (actually it did happen but Activision screwed around so much and wanted to pay so little it wasn’t actually worth my time finishing up Pitfall II, along with a dozen other classic Atari 2600 games that I had about 90% implemented) so I just retooled the Pitfall 2 level creation tool to allow it to re-generate the original Pitfall 2 ROM image for the Atari 2600 VCS.

The ROM image here is what I would call a beta-release. It has bugs, it lacks polish. I’m the only one who has tested it, ergo it might be easier than I think it is, or I might have made it too hard. I designed the level to be harder than the original, hence the “plus” appended to the name. So go and enjoy reliving your youth, courtesy of all my pointless efforts expended on porting almost a dozen Activision games to the Nintendo Gameboy Colour.

The current and only outstanding bug(s) in the game right now, that I know of, is when you collect the treasures spread throughout the level. The trreasures don’t actually get collected properly, if you exit the room and re-enter the treasure will have “re-spawned.” I’ll fix this when I have time after my deadline at work has been dealt with.

Something you should be aware of is that the ROM image will only run on those emulators that support the original Pitfall 2.

Click here to download the ROM image.

— Justin Lloyd

Otaku No Yen

Sunday, January 30th, 2000

This is a Gameboy emulator that I threw together over the period of about seven days. It’s been sitting around on my computer for a few weeks and I thought I should finally release it. Let’s optimistically refer to it as an “alpha” release. It’s not particularly robust or speedy right now. There’s still a lot of work to be done with it before the emulator becomes really useful to anyone.

Why another emulator? Well, I never really set out to write a Gameboy emulator, it just kind of happened over the New Year lull when I wasn’t feeling up to working on any of my other projects. I originally intended to just crank out a very basic Gameboy Colour emulator in Java and ended up deviating in to an ActiveX control. The Java version is still lurking on my machine, waiting for my return and one day I’ll get back to that too. For now, this emulator is teaching me a lot about the Gameboy that I didn’t know and that will be useful when I eventually pick up where I left off with the Java version. The C++ that this emulator is written in, is also very portable, so I might just scrap the Java code base and start over again with a fresh perspective.

What’s really different about this emulator, as you might have gathered, is that it’s an ActiveX control, yes, it’s a Window’s evil. The emulator will let you embed it in to almost anything that can use ActiveX, so you could place it inside of a web page, Microsoft Word document, or an Excel spreadsheet. You can write an interface around it to allow for source level debugging, or if you are writing an IDE for Gameboy programmers you can assemble/compile the source code and then launch straight in to the emulator with fully integrated debugging. If there is a quirky feature you want, for instance, you might want to play multi-player over the Internet on a Gameboy game, you can easily throw together a TCP/IP program that will exchange the data from the emulator. Or you could have it capture each video frame and save it to the hard drive and later take all of the frames and create a movie for download from a web site. There are a lot of possibilities.

Right now the control doesn’t do much, it has a limited number of methods, has some graphical glitches, does not run every game out there, does not support sound or save RAM or link cable. Eventually these desirable features will be added as time allows, and more importantly, as user interest prompts me to “get on with it!”

ADDITIONAL INFO

 

Methods

  • LoadROM — Load ROM specified image (v0.1)
  • ReadROM — Read a byte from ROM (v0.2)
  • WriteROM — Write a byte to ROM (v0.2)
  • ReadMemory — Read a byte from memory (v0.2)
  • WriteMemory — Write a byte to memory (v0.2)
  • Go — Begin executing ROM (v0.1)
  • Reset — Reset Gameboy (v0.1)
  • DrawTime — Get number of milliseconds last video frame took to draw (v0.3)

Properties

  • A — Get/Set accumulator (v0.2)
  • B — Get/Set register B (v0.2)
  • C — Get/Set register C (v0.2)
  • D — Get/Set register D (v0.2)
  • E — Get/Set register E (v0.2)
  • H — Get/Set register H (v0.2)
  • L — Get/Set register L (v0.2)
  • AF — Get/Set Accumulator & Status Flags (v0.2)
  • BC — Get/Set register pair BC (v0.2)
  • DE — Get/Set register pair DE (v0.2)
  • HL — Get/Set register pair HL (v0.2)
  • PC — Get/Set Program Counter (v0.2)
  • SP — Get/Set Stack Pointer (v0.2)
  • FlagZero — Get/Set Zero Flag (v0.3)
  • FlagCarry — Get/Set Carry Flag (v0.3)
  • FlagHalfCarry — Get/Set Half Carry Flag (v0.3)
  • FlagNegative — Get/Set Negative Flag (v0.3)
  • KeyCodeA — Get/Set key used for “A” button (v0.2)
  • KeyCodeB — Get/Set key used for “B” button (v0.2)
  • KeyCodeStart — Get/Set key used for “Start” button (v0.2)
  • KeyCodeSelect — Get/Set key used for “Select” button (v0.2)
  • KeyCodeUp — Get/Set key used for “Up” button (v0.2)
  • KeyCodeDown — Get/Set key used for “Down” button (v0.2)
  • KeyCodeLeft — Get/Set key used for “Left” button (v0.2)
  • KeyCodeRight — Get/Set key used for “Right” button (v0.2)

Events

  • VBL — Fires every time a Vertical Blank occurs

 

DOWNLOAD

The Otaku No Yen Gameboy emulator is totally free! The executables are free to use for personal hobby use. The only thing I ask is that you do not charge for either distributing the executables or source code, and any derivative works you give credit to the original author. That means you have to say “Thanks” to Otaku. As improvements are made to NoYen so these improvements will automatically be reflected in your product, benefiting everyone.

For any commercial or shareware package where a fee is charged you must license the NoYen ActiveX control from me.

Included in the archive is the ActiveX control, and a Microsoft Visual BASIC 6.0 project that will show the basic code needed to load a ROM image. THe file “NoYen.frm” is the one that is most interesting as it invokes the methods that actually make the emulator work.

When you open the project you may receive a message that NoYen.OCX cannot be found. You will need to add the control to the Visual BASIC project by selecting “Project.Components.Browse” and opening the NoYen.OCX file.

If you don’t have Visual BASIC you can use Delphi, C++, the Microsoft ActiveX Control Test Container that is shipped with Microsoft Developer Studio, Internet Explorer, or even Microsoft Access.

Download the current version of Otaku No Yen (v0.3 alpha)

Download a stand-alone executable version of Otaku No Yen (v0.3 alpha)

Otaku No Gameboy

Sunday, November 14th, 1999

This was another attempt to get a programming book published. I originally pitched this idea by cold calling the chief submissions editor at a major publisher directly and had “Yes” in less than 4 minutes and a preliminary contract in my e-mail inbox inside of 20 minutes.After giving the contract due consideration I didn’t feel like the publisher was offering enough money for a project that would completely occupy my time for six months so I turned down the book deal about two months in to writing it. By that time I had about 40% of the book completed.

This page exists as a small note on my second attempt at getting a computer book published. I’ve included here a brief preface and list of chapters with an overview of each one. I tried to include those subjects that I think are relevant to developers working with the Gameboy Colour and those developers who will later move on to the “Gameboy Advance.”

PREFACE

It’s doubtful that you have failed to notice the surge in popularity of handheld electronic games over the past fifteen years. Starting with the simple LED games in the early 80’s and culminating in the release last year of the Gameboy Colour from Nintendo. Today’s handheld games contain some of the most dazzling graphics, endearing characters and engrossing game play that has been seen on the (very) small screen and this book aims to show you how to achieve the same games on the Nintendo Gameboy.

What you need to know

This book is intended as a complete, self-contained text for learning to program the Nintendo Gameboy handheld console in Z80 Assembly and C with the focus on game programming. The reader should already have some programming experience with at least one of these two languages.

This text aims to provide a true level of competence to the person who wishes to program games on the Gameboy. It is based on the author’s direct experience of more than 20 years programming computers, many of them spent programming games for the entertainment industry.

This is not an introductory book, the pace at which concepts and terminology will be introduced is relatively fast. I do not dwell on explaining every piece of information that I introduce so that focus is not lost. There are many books out there that already explain much of the information more adequately than I can. You should be comfortable with the concepts of a computer’s internals, the CPU, memory, video hardware, how a picture is made up on a computer screen, hexadecimal and binary, and the distinction between compilers and assemblers.

In any subject dealing with game programming, and game programming on the Gameboy especially, there will be some assembly language involved, along with a heavy dose of hardware knowledge at a very low level.

In many sections I gloss over a lot of things. I assume you don’t want to know how the ALU connects to the barrel shifter and how it interacts with the internal and external data bus inside the CPU and can happily live without a thoroughly detailed explanation of how RAM really works. If you thirst for this kind of intimate knowledge I can suggest “Master Class Assembly Language” by (insert authors/publisher here) and ” Programming the Z80″ by Rodnay Zaks, (clean up the book references yah dope!) . The latter is now, unfortunately, out of print, but you may be able to pick up a copy either from an on-line out-of-print book search or an on-line auction for around $15.

Even if you already know how to write application software for the Gameboy console I hope that you can still learn something from this book. In addition to learning how to use C and Z80 Assembly more effectively on the Gameboy you’ll also benefit from the detailed explanations and source code solutions to common Gameboy programming problems.

Among the advanced programming concepts covered are those dealing with a re-usable sprite engine, implementing dynamic tile loading and code optimization techniques. There’s even some music and sound effects thrown in for good measure.

So, whether you have yet to be published, are working away on your first title now that someone has given you your “big break”, or are a ten-year veteran I look forward to imparting any knowledge to you that you will find useful.

CHAPTERS

What’s covered in this book are techniques for developing games on the Gameboy handheld. Its not explicitly designed to be read from cover to cover but more as a reference that you’ll dip in to as the occasion warrants. Some of the chapters logically progress from one to the next, others are isolated and, assuming you understand the material, can be read through without ever referring to a previous section or page.

REMEMBER: THESE CHAPTERS ARE IN NO PARTICULAR ORDER RIGHT NOW!

Chapter A, “Handling Player Input,” introduces you to programming the Gameboy control pad, and how to handle the player’s input once it’s received.

Chapter B, “Chosen Development Environment,” introduces you to the tools that are available, where to obtain them, and how to put them to use.

Chapter C, “Memory,” covers the organization of memory in the Gameboy, it gives an introduction to bank switching, why we need it, and the pitfalls that you will encounter whilst creating your masterpiece game.

In Chapter D, “Gameboy Overview,” you learn the basics of the Gameboy handheld, it’s a brief introduction to Nintendo’s world conquering handheld from the perspective of a programmer.

Chapter E, “Dealing with SRAM,” reveals the workings of battery backed SRAM found on some Gameboy games. You learn how to save and restore a high score table so that it remembers the player’s achievements and also how to save and restore an actual game-state so that the player can return to their position after taking a rest from your latest blockbuster game.

Chapter F, “Programming the Gameboy,” takes you through the steps required to get your code up and running. It introduces the tools used for compiling, how to set them up, specific techniques you can utilize when programming an 8-bit CPU and how to interface your C code with Assembly Language for maximum performance.

Chapter G, “Handheld Video Game Primer,” introduces you to how video games are made, the design process a video game will go through at each stage of development and the final pass through of play balancing to make sure it has all the qualities it needs to succeed. The chapter covers peculiarities of developing for the Gameboy handheld and design decisions to watch out for that go against what is known to work and not work on the Gameboy.

In Chapter H, “Interrupts,” you learn how interrupts work and what they are used for. How they apply specifically to a Gameboy game and examples of when to use them is also covered in depth.

Chapter I, “Sound and Music,” you learn how to implement computer game music and those all-important sound effects that make up the hidden 30% fun factor in any successful game.

Chapter J, “Assembly Language,” introduces you to assembly language and how to integrate it with C to produce the fastest and slickest games around.

Chapter K, “Crib Sheet,” the colourful, ever-popular, world famous, can’t live without it, Gameboy Crib Sheet is introduced. It’s the one information resource, if you do any kind of work with the Gameboy, that you will refer to time and again, no matter how many titles you’ve shipped.

Chapter L, “Sprites,” shows you the workings of hardware and software sprites and how to use them in games to represent the player, enemy, missiles and explosions.

Chapter M, “Video Display,” reveals the workings of the Gameboy video hardware, how colours are displayed on screen, how to interact with the colour palettes and tricks you can use to display more than the normal number of colours per screen.

In Chapter N, “APA Mode,” you learn how to address the video display as a regular bitmap device and draw lines, circles and dynamic special effects that can’t be achieved any other way.

Chapter O, “Collision Detection,” introduces you to detecting collisions between game objects and what to do when it happens with collision resolution. Optimisation of collision detection routines is also covered to keep your game’s frame rate as high as possible.

Chapter P, “Hardware Registers,” reveals the inner workings of the Gameboy hardware. You learn about each hardware register that the Gameboy has to control the video display, sound, joypad, interrupts, serial link, DMA and so on.

In Chapter Q, “Scoring Points,” you learn how to award points for actions the player performs, when they blow up enemies or reach a particular area of the map, and the rewards received for earning a particular score.

Chapter R, “Lives and Death,” explains how to add the element of risk into a game to make it more exciting for the player and how to track, and display, the player’s lives and what happens when they reach zero.

Chapter S, “Dynamic Tiles,” explains how to add dynamic tiles to your game engine to handle hundreds of differing sprites throughout a game and large, varied maps far bigger than could ordinarily be stored in the Gameboy video memory.

Chapter T, “Optimization Techniques,” gives you tricks and techniques to optimize your game for maximum performance, how to track down elusive bottlenecks in your code and showing where to concentrate your optimization efforts.

Chapter U, “Scrolling A Map Around,” explains how to let the player scroll around a map larger than the screen. It introduces meta-tiles and special properties you can give to parts of the background that let the player and computer controlled game objects interact with it.

Chapter V, “The Window,” shows how to display a window overlaid on the screen to use as a status bar for your game. It explains how to display multiple windows and how to achieve parallax-scrolling effects.

In Chapter W, “Rumble Pack,” you learn about putting rumble effects in your game to immerse the player deeper in to the game world and provide tactile feedback for their actions.

Chapter X, “Other Gameboy Hardware,” (probably want to break this out in to 2 or 3 separate chapters, one for each piece of hardware) shows you how to control the infra-red port to send messages between two Gameboy handheld units, and how to control your home VCR. The serial link is explained and you are given examples on how to communicate with another Gameboy in your game.

Chapter Y, “Power Consumption,” explains the power consumed by various components of the Gameboy when used in your game and how you can maximize battery life for your players.

In Chapter Z, “Random Numbers,” you learn how to introduce randomness in to your game and how to generate random numbers as efficiently as possible.

Chapter A1, “Writing a Game,” explains the general game loop and how to best approach each feature requirement from a programmer’s perspective.

Chapter B1, “Special FX,” introduces you to creating lighting effects, real-time palette changes, big explosions and on screen trickery.

— Justin Lloyd