Zilog z80 to Motorola 6809 Transcode – Part 006 – VideoRAM layout and Sprite engine

After many many hours of work I finally have a screen that can show this…

screen-shot-2017-01-08-at-1-14-08-am

That is just a test of my Pac Man character display routine.  It isn’t from the actual z80 code but the screen pointer is the same as the original code points to which was a big head ache.  Thanks to this website for the explanation of how the PacMan screen RAM is displayed.   The website also made me realize the Pac Man really only uses 28 out of a possible 32 character wide display which means the on screen display only needs to be 28*8=224 pixels wide.  Too bad the CoCo 3 doesn’t have a screen resolution of 224 x 225… I also tried to explain the Pac Man screen info in my source code, which one day I hope to be able to share with everyone.  See below:

* Draws a 8 x 8 bit 16 colour character on the screen
* U = Destination location in Video RAM (Pac man screen memory $4000-$43FF) - Screen is rotated left so we have to acount for that location and rotation
* of the characters
* A = Character ASCII Code
* Handling of Pac Man Video RAM
* We Have a screen 32x36 total in an 8 pixel x 8 pixel location Pac Man uses only 28x36 leaving the left two chracters blank and the right two characters blank
*
* CoCo Screen
* $6E00------$6E7F
* |              |
* |              |
* |              |
* |              |
* |              |
* |              |
* |              |
* |              |
* |              |
* |              |
* |              |
* $FD80------$FDFF
*
* Pac Man screen
* $43DD------$43C2   Line 1
* $43FD------$43E2   Line 2
* 4             44
* 3             00
* A             64
* 0             00
* |              |
* |              |
* |              |
* |              |
* 4             44
* 3             00
* B             75
* F             FF
* $401D------$4002    Line 3
* $403D------$4022    Line 4
*
* Addresses that aren't shown on screen are:
* 4000,4001,401E,401F
* 4020,4021,403E,403F
* 43C0,43C1,43DE,43DF
* 43E0,43E1,43FE,43FF
*
DrawCharacter:

I also wrote a sprite engine over the last few days to see how fast I can move 5 sprites that are 16 bits x 16 bits x 16 colours around the screen at the same time.  I’ve used some optimized code with some cool stack tricks that I read about from this great article – A Great Old-Timey Game-Programming Hack.  I highly recommend checking out that article, it’s a neat story even if you don’t care about coding too much.  The good news is that the sprites are flying around the screen super fast.  The bad news is I’m running out of memory.  Optimized sprite rendering takes up a lot of space as do the sprites themselves and the buffering behind them.  After the screen is loaded I only have 27k of RAM for the code and data.  The sprites take up 8k and I will still have to add more since I can’t swap the colour of the ghosts when I load them I’ll have to have them pre drawn as sprites.  The character data is another 8k, I might be able to swap these out to other memory pages since I don’t think they will be used much other then the numbers and fruit while the game is running.  I wanted to leave the original ROM data from $0000-$4000 in place with it’s own table and pointers but I don’t think that’s going to be possible anymore.  That means a lot more decoding…

Advertisements
This entry was posted in CoCo Programming, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s