Since my last post I’ve made some fairly significant changes to the on screen map display for my C64 CRPG. Firstly I’ve changed the display from a full screen map to a window onto the map. In addition I’ve changed the code to display each map tile using 4 characters rather than a single one.
Ignoring my example “tiles” above which are using characters to get the initial map and tile code working correctly, this is working very well for my initial attempt. Once I had this working I expanded the view.
Here’s a slightly modified version with a simple “water” type tile and a highlight to represent a player tile. I’m finding that my code changes are coming along nicely now that I’m using C code again so that’s been a very positive change without the performance drop that I was concerned about.
Despite appearances the characters that make up the display are set up to be easily replaced with redefined characters. I’ll put some simple tiles in just to provide a better idea of how the display with look. I’m very pleased with how quickly some of these changes are coming along which has surprised me a lot.
One of the challenges of creating a CRPG for the Commodore 64 is deciding what sort of visual style I would like for the game. I’m working with an overhead view as I think that plays well to the C64’s capabilities and I’m a big fan of top down games such as the Ultima series and Legacy of the Ancients.
Whilst my options with the C64 are more limited than modern machines, I still have many decisions to make on the visuals front (putting aside my lack of artistic talent for a moment).
The C64 has a number of display modes with a maximum screen resolution of 320 x 200 pixels (or 40 x 25 character cells) in a choice of 16 colours. If I’m willing to sacrifice the horizontal resolution of the display then I can increase the number of colours I can use in each 8 x 8 pixel “character” cell from 2 colours to 4 colours but this will double the horizontal size of each “pixel”. You can see this in the image below. You also have the choice of bitmap versus character modes. This is a big over simplification of the capabilities of the machine but will hopefully suffice for this post.
Currently I’m using character mode to redefine the 256 character set with my own characters and then piece them together to build up maps on the screen. The player moves around the map and can move to other map sections when the end of the current map is reached.
If I required more colour in each character cell I could use multi-colour mode but this tends to make the graphics look more “chunky”. If I require more detailed graphics then I could use bitmap mode but at the cost of additional memory (8Kb for a full 320×200 screen).
One of the other challenges I’m facing is trying to make interesting displays with individual character cells which are only 8 x 8 pixels wide. Now the Ultima games and most CRPGs of the 1980’s typically used 4 character cells to build each of it’s map tiles, doubling the resolution of each tile but halving the number of tiles you can display on screen. The Ultima display also kept the party icon centred in the map display with the map being redrawn around the player after every move.
One of the things I like about using the individual characters as tiles rather than 2 x 2 characters per tile, is that it allows me to display more of the map on screen at a time but at the loss of some graphical detail. I’ve started playing around with some of the redefined characters and colours in the CBM PRG Studio screen editor which is great for creating simple graphics and prototyping screen displays. Programming single characters as tiles is also a lot easier for me as well and will perform more smoothly in play.
I’ve included a sample image above of my brief sketches so far. Regardless of what screen mode and tile size I eventually use I’m also likely going to use the C64’s sprites as a means of adding higher resolution images for the player character, NPCs and monsters. These have the benefit of being independent of the screen display so can have their own colours, hires or multi-colour mode option so can be used to add some further interest to the display.
Since my last post I’ve revisited the CC65 cross compiler which you can use to write C programs on 6502 based systems such as the Commodore 64, Apple II and Atari 8bit.
I had been using CC65 for a few months, sketching out the beginnings of a C64 CRPG but had run into problems managing the memory configuration required for custom graphics. I’d moved onto using CBM PRG Studio and programming in 6502 assembly code which meant my code ran very quick but I was finding was slowing down my development time compared to using C in the past.
Now I’m not much of a programmer in any sense of the word but I probably have the most experience of using the C language overall so I was finding 6502 assembly language time consuming to use and my game development time is very limited and I’m not really trying to do anything fancy technically by the standards of C64 games.
There is a lot of documentation online for CC65 but I was lacking an example of how to do a simple custom character set and use code overlays for swapping code in and out of the C64’s 64K of memory from disk. Most of the famous CRPGs I grew up with such as Ultima and Alternate Reality use this method to make the most of the machine’s limited memory by modern standards. I just couldn’t get this to work and gave up frustrated.
I noticed this week that CC65 had been used to create some of the code in Ultima IV Remastered for the C64. After this I came across a CC65 example online that included both a custom character set and code overlays and worked out how to compile it with a custom linker file. This determines how the memory map for the program is set up and where any external data files or graphic data should go. Once I had this working it was relatively easy to load in my modified character set and recreate my map code in C, display it on the screen and have a player marker move around the example map. I also was able to automate my compilation process with a single key press from within Notepad++ and run the resulting program in the Vice emulator which felt pretty smooth.
The main reason I was originally attracted to CC65 was that I love the idea of using C and being able to then reuse the code on other 6502 based platforms as well as modern PCs and operating systems. CC65 also has special support for some systems including the C64 so that you reference the C64 hardware directly within your C code. As CC65 includes a full assembler in its tool chain, you still have the option of using assembly language within your C program where extra performance is needed and tweaking the generated code. I’ll post more about CC65 in a future post; where to get it and provide a brief example and possibly a video of how to do the things I was struggling with in the hope they help others get started.
At the age of 11 I became the proud owner of a Commodore 64 home computer and before long, started to draw out dozens of game designs on paper. Whilst I wrote some initial BASIC coding for many of these, it usually wasn’t long before I hit some roadblock and moved onto the next idea. Many years later the Commodore 64 was sold but it kept a special place in my heart and my desire to create a game for the computer never really went away.
Roll on 2019 and I received a C64 Mini as a Christmas present. Opinions vary on this system but personally I think it’s a great recreation of the system, especially since the firmware has been updated to allow the use of the thousands of disk images available online via a USB stick.
I had been playing around with the CC65 C cross compiler for a number of months. This allows you to write C code which can then be cross compiled to a Commodore 64 executable. Whilst I thought this was great in many ways my C code wasn’t as fast as I expected it to be and I struggled to understand how to deal with some of the memory management that CC65 requires. It just didn’t feel the same as programming the C64 with its original BASIC or with machine code (which I’ve dabbled briefly with).
I made a decision to switch over to the CBM PRG Studio which I found to have a number of nice features built in including support for BASIC and assembly language programming, character set editor and a screen editor as well as many others.
Much to my delight I was able to fairly quickly put together a machine code program and gradually add to it – displaying a map on the screen, reading the keyboard, moving a player character around the map and redefining the default character set. I also found that my code ran very quickly – amazingly so compared to my BASIC programming I did about a year ago. My map below displays in an instant whereas my BASIC program took more than a minute to display and colour a smaller map. Most importantly of all I’m having a lot of fun putting this together.
The game itself is not a million miles away from one of those early C64 games I started writing all those years ago. It currently presents a map of a City which you can move around exploring various locations (above and below ground). Currently the game is set on a single 40×20 “cell” map but I may expand the City map to flip to another 40×20 section when the map border is reached. The player is currently shown on the map as an @ – as in a roguelike game. I’ll work on some more interesting graphics and visuals once I have some more gameplay features implemented.
I’ll shortly be adding some characters, places to visit and items but I’m pleased with the progress I’m making and I’ve managed to sort out all my assembly challenges to date without too much pain, though it’s a very different way of coding for someone who is more familiar with C or C++. Content wise don’t be too surprised if there is a bit of Ultima or Alternate Reality type inspiration in the game. It’s very straightforward to play C64 games on a modern PC using an emulator like Vice so accessibility for players isn’t really a concern for me just now. The game is still in its early stages but I have a good idea in my head where I want to go with it next.