I was surprised to notice that I’ve gone a whole week without posting an update about this Retrochallenge project. It feels like it’s only been a few days, and I’ve been busily poking away at things. No new graphics to share right now, but a lot of progress behind the scenes. I’ll just quickly run through the changes, and then get back to work!
- I’ve kind of gone all-in on the map editor part of this project. Last time I wrote I was looking to move on to the entity subsystem (monsters, NPCs, towns and dungeons, and so on) and I did get some of that built. I quickly realized that in order to really work with entities I needed more map functionality. And that’s okay.
- I’ve added the ability to switch between the “map editor” mode, where the camera moves freely and I can lay down new map tiles, and a “gameplay” mode, where the player can move around on screen, gets blocked by intraversable terrain, and eventually will be able to interact with other entities (not quite there yet!).
- In order to quickly render the map when there are entities on it, each one-byte map tile now contains either an index to the list of entities (hard capped at 127) or a terrain tile (starting at 128 for water and possibly going up as high as 255). This can form a singly-linked list of entities occupying a particular position, with the original terrain value at the end of the list. I want entities to be able to overlap so that the character can step onto a town, for example, and then try to enter it.
- The set of entities on each map now get saved with the map. The player’s entity is a special case, and it gets added into each map when it’s loaded.
- The map editor now has support for creating new maps, and reading in and saving existing maps. I still need options to delete maps and a few other special functions.
- In order to save new maps with different sizes, I was forced to confront the problems with the 1541’s block-allocate once again. When everything was in a fixed position on disk I could just ignore the bugs in the 1541 ROM, but now I’ve written my own routine to read the BAM (block availability map) into memory, parse it, and allocate an arbitrary number of disk blocks. Getting that to work was a challenge. The bitwise manipulation used in the table wasn’t too bad, but I had trouble getting my changes to reflect on disk. Apparently the 1541 was caching the BAM, so the second time I allocated a set of blocks it would send me the original BAM entry again, instead of the modified version I saved after the first allocate call. Right now, I’m dealing with that by reinitializing the drive after updating the BAM, but it’d be nice to find a better solution.
So what’s next? Off the top of my head, here are a few things that are still really needed for this game engine:
- Deleting maps in the map editor. Of course, that means I need to come up with a BAM deallocator to recover the disk space I’m using. If being able to save 256 bytes to each block wasn’t such a huge advantage (over using regular files with 254 bytes of data per block) I’d think I was going about this the wrong way.
- Now that I can have multiple maps, I need a way to move between them in gameplay mode. That means I should add “town” or “dungeon” icons to the map which the player can enter (and exit somehow as well).
- Monsters! How can I call this thing an RPG engine if there isn’t anything that I can kill for experience points?
12 days to go, so we’ll just have to see how far I get!