Thursday, February 10, 2011

Invaders from Mars!

Dev Log 09/02/2011

14:00
Ok, so I decided to do something reaaaaaaly retro. Space Invaders. I’m going to have a go at recreating the (an) arcade version as closely as possible on the C64.

First up was working out how much and when everything moves. To do this I used the MAME video output then converted the resulting file into a series of PNGs. After that it was possible to single step through the series of frames (losless luckily) and see how the screen is updated.

What happens is only one enemy ship is drawn per frame. They move 2 pixels left/right and also switch between the two animation frames every update, the period of which depends on how many enemy ships are left to be drawn. ie 55 ships takes 55 frames, 10 ships, 10 frames, down to the single ship.. The dum dum dum dum sound is also updated at set times during the update so that speeds up too.

I’d thought about doing it all with character graphics and if I cheated a bit and made the screen wider I could space out the ships more so there was always a character gap between them. Not good enough imo. I’ve decided to do it “properly” on a bitmap. Characters would've still been possible but seems like as much hassle to sort it all out as it is to do it right.

The way I’m going to draw the ships is by having 4 sets of each ship (*3 ships) each offset 2 pixels and switching anim every frame like 1/2/1/2. They’re laid out in C64 bitmap (same as characters) format as 3 characters wide as this is needed for the lower largest ship (the top ones are only 8 pixels). I’m then creating a mask from those which is basically solid filled outside of the width of the graphic (not an inverse because that will leave the last frames graphic behind when it moves ) which masks the background before dumping the new data on so that neighbouring ships don’t get wiped out.

--PAUSE FOR FOODS--
16:00
After a bit of coding I’ve now got a method in place to draw the ships, properly masking, moving and animating. The “bases” or “shields” are also drawn into the bitmap. The plot sprite routine takes about 10 scanlines (so much for this being hard because the arcade is 2mhz lol). The top/bottom border is also turned off ready for the score/lives etc. This is necessary for arcade completeness because The arcade screen is 260 pixels high while the C64 is 200. unfortunately there’s not quiiiiiite enough sprites to fit the whole top line of text in :( I’ve got 192 pixels of sprite to play with and it needs 208, there’s not even the possibility to shift a sprite in X because the 2 characater spaces either side of HI-SCORE aren’t on the edges of new sprites.. It might be possible to squeeze the font up a bit as it seems it’s only 6 pixels wide but it’s drawn every 8 pixels. Doing it every 7 pixels instead still leaves a pixel gap and might make the difference but without working it out I don’t know (still depends on how many sprites each string takes)

18:00
Checking out bullets now. Your ships are 4 pixels and travel 4 pixels per frame. To draw these it’ll be a similar(ish) method to everything else, mask, draw only there will be an extra step, collision mask. This will logically AND the background data with the bullet, if there’s anything but 0 you’ve hit something, from there I can work out what you’ve hit by the X and Y positions of the bullet and the enemy ships. The enemy bullets will work similarly but they seem to only move (and animate) every 4 frames (so 3 frames of each position/frame).


19:00
Grabbed the “tank” graphic. It’s being done in the same way as the enemy ships so 4 offsets of 2 pixels each, no animation built in this time though.. Doing it like this means I can reuse the enemy drawing code to draw the tank too, so now he’s “type 4” 0 being nothing, 1-3 the 3 normal enemy types, no doubt 5 will be the mother ship and probably some explosions will get shoved into the list too..

--Interruption for 2hr phonecall and some life stuff--

21:30
Realised I’d broken something after adding in the colour ram rows for the red top, white middle and green bottom. I was calling the subroutine with the interrupts running and both routines used the same ZP locations... CLI now comes AFTER all setup :)

Need to snag the mothership now..... Done. Same format, 4 offsets. It probably doesn’t need that many as it moves fairly fast, I’ll have to check...

23:30
Enemy “sheet” now draws, moves, animates. Looks ok, could be faster, I think the arcade is 60fps.. oh well. The mothership is leaving a couple of pixels behind it, no doubt because it’s a full 16 pixels wide so as it moves character (8 pixels wide) it leaves the 2 pixels from the end of the previous character behind. This is because I wrote the code to use the fact the ships weren’t 16 wide to allow the edges of them to clear the previous frames data...


--I went to bed--

No comments:

Post a Comment