I’ve started implementing sprites and I’ve got the red ghost animating and Pac man moon walking a little across the screen. You can’t see it from the picture below but you can see that I finally have Pac Man on screen!!!
Pac Man is a little lower then the Red Ghost which I’ll have to figure out. I’m still missing tons of code to transcode but I think once I can get this little animated scene working then a lot of the game will actually be complete.
I’m running out of memory again! The big scrolling screen really does take a lot of RAM away from the 64k available memory the CoCo3 can use at one time. I thought I’d be able to keep the sprites in main memory at all times but that is not going to be an option. The sprites take 8k of space that I can’t spare anymore. I don’t know if I’m going to have room for adding audio! Which is one thing I wanted to do since I haven’t worked on sound in assembly on the CoCo before and that would be a great thing to learn. We’ll see…
Edit – (better way to do this is described at the bottom below this section) – Another bit on transcoding (pardon the pun)… The z80 RLCA and RRCA are 7 bit rotate instructions that rotate the accumulator or memory location. If you rotate left then bit 7 goes to bit 0 and if you rotate right then bit 0 goes to bit 7. The 6809 doesn’t have this function so to get around this I use the following code:
ANDCC #$FE BITA #$80 BEQ > ORCC #$01 * Set Carry Bit ! ROLA ;0231 07 RLCA
First it clears the C – Carry flag, then checks to see if bit 7 is clear, if it is then it does a normal ROL, but if bit 7 is set then it sets the C – Carry flag which will be copied into bit 0.
I figured out a faster way to do the 7 bit shift using the LSL and BCC instructions as shown below:
LSLA BCC > ORA #$01 ;0231 07 RLCA !
Johann Klasek commented below with a way to save another byte in the code above by using INCA instead of ORA #$01. as per the code below, Thanks Johann 🙂
LSLA BCC > INCA ;0231 07 RLCA !
and for RRCA:
LSRA BCC > ORA #$80 ;0307 0F RRCA !
See you in the next post…