In the 80s MSX was a really popular home computer; the scene was huge in Europe and Japan. It was based on the glorious Z80 CPU and it was a sort of open standard (released by Microsoft and ASCII Corporation). You could have bought an MSX built by Philips, Sony, Mitsubishi, Toshiba, Hitachi, Canon, Casio or any other manufacturer. An MSX built in Japan by Toshiba was 100% compatible with an MSX built in Europe by Philips!
The universal programming language to develop on this glorious machine was Basic..and of course the Z80 machine code.
I was 10 years old and Basic language was already advanced enough for me…but I knew that video games were developed in machine code (50x-100 times faster). Internet was not yet available and books on machine code programming were not so common (in Japan ASCII Corporation was publishing many books about this topic…in Japanese language!).
I recently found out how the best websites, books, tools, compilers, disassemblers for Z80 CPU are Dutch. Even the best video game ever on MSX, HYPE, was by a Dutch developer (Ronald Pieket Weeserik)!
So I decided to reverse engineer a bit that game to relax a bit and to prepare for the weekend! My goal was to get infinite lives and play the game till the end (as a kid I was not able to survive more than 2 minutes).
Basic language is an interesting one: it is a high level, interpreted language, but at the same time allows you to read and write directly to any memory location with the commands PEEK and POKE (VPOKE to write directly into the video memory). You can easily write a Basic program to inject machine code in memory and execute it in less than 100 lines of code [practical MSX machine code programming, by Steve Webb]…if you don’t get what I mean..just trust me…this is amazing :)
After playing around a bit I found out the location in memory where the game stores the variable containing the lives you have in the game: 0xC5C6. That means that on every MSX, from any manufacturer, the game will store at that location the remaining lives you have. So overwriting that number with something bigger (POKE 0xC5C6 128) will let you cheat and hopefully complete the game. It is interesting to note how the maximum number of lives is 128; I would have expected 256 (Z80 registers are 8 bit, HL BC and DE are 16 bit!), but apparently the developer used a signed BYTE to store the value. Overwriting it with 129, or 256 will overflow it by giving you a negative number of lives (meaning you have a game over)!
The most disappointing finding for me was to realise how the game is simply not completed! After playing for 128 levels (always the same bunch of levels repeating over and over)…the game starts playing from level 0! It was quite a common practice to build video games too difficult to finish so that nobody could realise that the developer did not have time and budget to complete his masterpiece [The untold history of Japanese game developers].
Now I finally know after 35 years that my favourite video games of all times…never ends!
I hope this short story motivated you to play some retro game…or maybe now you want to know more about old school machine language, the Z80 CPU or the video game scene in the 80s!
Personal take aways from this story are:
- My life has always been in some way or another bound to the Netherlands (my old MSX was from Philips, the best game I played in the 80s was from a Dutch developer..and by coincidence I am currently living in the Netherlands)
- Basic language is way more powerful than we think!
- Reversing old software is really relaxing
- Z80 machine code is relaxing too (check the following books):
PS: If you are Ronald Pieket Weeserik…please tell me why you did not finish the game..why did you do this to us! :)