Bouncy Ball 2 Progress Report #1

Bouncy Ball 2 Progress Report 1. First things first. We need to get the Coco 3 into it’s high resolution graphics mode, then display a little something. To start out small, I decided to create a program that sets the video mode, uses the MMU to map in the video memory, then clears the screen. That part was easy, although understanding the MMU was a little whacky.

 

In simple terms, the MMU simply maps 8K blocks into the 6809’s 64K memory space. The following table shows the memory blocks.

Page   GIME Address   CPU Address   Standard contents
-----------------------------------------------------
$00-2F $00000-$5FFFF                512K upgrade RAM
$30    $60000-$61FFF                Hi-res page 1
$31    $62000-$63FFF                Hi-res page 2
$32    $64000-$65FFF                Hi-res page 3
$33    $66000-$67FFF                Hi-res page 4
$34    $68000-$69FFF                HGET/HPUT buffer
$35    $6A000-$6BFFF                Seciondary stack
$36    $6C000-$6DFFF                Hi-res text screen ram
$37    $6E000-$6FFFF                unused
$38    $70000-$71FFF  $0000-$1FFF   Basic memory
$39    $72000-$73FFF  $2000-$3FFF   Basic memory
$3A    $74000-$75FFF  $4000-$5FFF   Basic memory
$3B    $76000-$77FFF  $6000-$7FFF   Basic memory
$3C    $78000-$79FFF  $8000-$9FFF   Extended Basic Interpreter
$3D    $7A000-$7BFFF  $A000-$BFFF   Color Basic Interpreter
$3E    $7C000-$7DFFF  $C000-$DFFF   Disk Basic Interpreter
$3F    $7E000-$7FFFF  $E000-$FFFF   Super Basic, GIME regs, 
                                    I/O, Interrupts

Table 1 (from Chris Lomont’s guide)

The next table shows the MMU back register and the 64K address space it controls.

MMU Reg Address block in 64K
FFA0 Bank at $0000-$1FFF
FFA1 Bank at $2000-$3FFF
FFA2 Bank at $4000-$5FFF
FFA3 Bank at $6000-$7FFF
FFA4 Bank at $8000-$9FFF
FFA5 Bank at $A000-$BFFF
FFA6 Bank at $C000-$DFFF
FFA7 Bank at $E000-$FFFF
Table 2 (from Sock’s GIME ref)

Let’s say you want to write to the memory at $60000-$61FFF from table 1. We simply map that block of memory into one of the blocks in table 2. To map $60000-$61FFF to $C000-$DFFF, you store page number $30 to MMU reg $FFA6. Later if you wanted $6C000-$6DFFF in $C000-$DFFF, put page number $36 in MMU reg $FFA6.

The next step was to create a basic blit routine. Which is to say, a routine that will display a graphic image. After 3 nights of pulling out my hair, fixing and breaking and re fixing it, my blit routine finally worked. I also added center points to my routine, to help with animation.

Once that I had that working, I turned my attention to a tile bliting routine. A tile differs from a sprite in that it will never have any transparent pixels, doesn’t use a center point, and they will always be a fixed size.

The result of combining the sprite blit and tile blit was rather pleasing. The colors are a little monochromatic. You can see the ball is displayed over the background and because of transparent pixels around the sprite, it displays a nice round ball instead of a block of pixels.

Once things were blitting, it was time to try scrolling. After a talking with Simon and playing around with the GIME registers, I was able to get smooth 1 pixel scrolling. Only problem was, I wanted horizontal scrolling and I ended up with vertical scrolling!

In the video, you can see the screen go from the 32×16 text mode, to the hires graphics mode, then it is filled with the tile, the big ball is blitted, and finally the display is scrolled via hardware up and down.

Note that the flickers and tearing are not present on real hardware.

Next week we plan to play around with animation, and hardware horizontal scrolling.