Chapter 16- October 10, 2014
Tile design and mapping
I love public holidays! A day when I can stay home and do what I want and still be paid!
I work 5 days in the week and spend the 2 day weekend doing all those house chores. By the time they're done and I've settled down and rested, it's Monday again and time to go to work! Sounds like Groundhog week!
So that extra day off is a chance to get on the CoCo and get some real work done! :)
Job 1 - Tiling
I decided to start creating some of the graphics for the new tile based landscape scrolling routine. I figured I needed some tiles to scroll and so powered up my trusty Amiga and started experimenting with graphics ideas and tile sizes. I eventually settled on a size of 8 bytes (16 pixels) wide by 16 bytes high. This fits nicely in each MMU block allowing me to stack each block with 2 tiles vertically. Because I'm using the Horizontal Virtual Enable mode, each block is 256 bytes wide and 32 bytes high... hense I can fit 2 x 16 byte high tiles within a MMU block without worrying about overlapping blocks.
It's important to find ways that ease the programming in order not to waste CPU time in order to achieve an optimal overall framerate for the game.
I have decided to create 4 simple themed zones in the game, Open Skies, Underground Caverns, Stormy Weather and Future Tech. Below is my progress so far.
I have allocated 2 x 8K MMU blocks for the tiles and other graphics, the top 8K contains the font and game graphics while the lower 8K contains up to 60 tiles. This makes it easy to bank in the desired graphics when needed into a reserved 8K area of the 64K 6809 address space.
You can see various tiles I have created for creating the ground landscape (with grass tops), several brick tiles for the more solid areas, water regions and some pipework for the Future Tech zone with more to come.
Job 2 - Mapping
I have also been giving some thought to the mapping system for the new landscape routine and have come up with the following:
BIT 7 COLUMN START: 1=YES 0=NO BIT 6 BLOCK ID: 0=SKIP 1=TILE BIT 5 IF BLOCK ID=0: NUMBER OF TILES TO SKIP IF BLOCK ID=1: TILE GFX INDEX POINTER BIT 4 BIT 3 BIT 2 BIT 1 BIT 0
COLUMN START: 1=YES 0=NO
BLOCK ID: 0=SKIP 1=TILE
IF BLOCK ID=0: NUMBER OF TILES TO SKIP
IF BLOCK ID=1: TILE GFX INDEX POINTER
The landscape that scrolls in from the right will be encoded with 10 bytes per column representing 10 vertically stacked tiles (20 columns). This equates to 200 bytes decoded per visible screen area. This would allow 40 visible screens per 8K MMU block. I was hoping for more since this would not take long to scroll through during gameplay.
I needed more compression and started thinking of a way to skip the non-tile (open space) regions of the screen to avoid wasting memory.
I therefore added a skip option that will skip a set number of title positions. Since almost every screen will start with a tile at the bottom of the screen (the ground) there will always be the first byte being a tile and this is defined as a Block ID=1 (tile). During the Open Skies zone, that may end up being the last tile in that column so rather than fill the remaining 9 bytes with a blank tile, I make the next byte a Block ID=0 (skip) and the number represented in Bits 0-5 are the number of tile locations to skip (9 max). When the last tile position is reached, the decoding will restart at the bottom for the next column.
There will be screens that have a ground and a ceiling (the Underground Caverns zone). In this case , after the ground tiles are done, it will skip the required number of blank tiles then revert to tiles for the ceiling until it reaches the top of that column.
This hopefully will at least double the number of screens I can have but I will continue to look for ideas to compress it further.
A column start flag is also included. This is so that if I need to restart the game play (after dying for example) I can roll back through the data encoding and find a new column start point easily.
Job 3 - Painting
I was tiring of the blue readout panels and thought a brighter color change was in order. Green looked nice and adds a touch of CoCo to the look. :)
It's good to be green!
Job 4 - Pest Control
The 225 scanline bug I had on the Title page came back to haunt me once the game screen came up. Time to roll my sleeves up and squash this GIME bug for a second time!
Again, that line was appearing at the bottom of the screen. I ascertained that it was a duplication of the top line. It would seem that the GIME is designed to actually only produce 224 scanlines (exactly 7 MMU blocks in HVEN mode). When it draws the 225th line, the internal counters must reset to the start of screen, hence the duplication. That's my theory anyway.
Simple fix, don't draw on the first line, leave it black and start on the next. Now both top and bottom scanlines are black and not visible.
Next on my agenda is to continue creating tiles, give some more thought on how to compress the map data further and then design a Tile Editor in Basic to help me design the levels.
Copyright 2013 by Nickolas Marentes