Tetris

 

I wrote this Tetris implementation as my first VIC 20 program of the new age. It was quite challenging because I had forgotten almost everything about VIC 20 programming; all I remembered was some vague concept about definable characters and about the three voices of the VIC sound chip. Furthermore, I had previously only programmed the VIC in Basic, but in these twenty years that have passed, I've learned machine language among many other languages. All I had to do was to adapt myself to the 6502 istruction set, and to the way of doing things with an 8 bit processor. At first, it was tedious because I hadn't realized the 6502 was so limited, with its 8-bit addressing and the limited number of registers. But later, I got used to that and even started to like 6502's bare simplicity.

I choose this game because of its simple graphics and because there was no VIC-20 implementation (after, I discovered there was one called Zapactris). Not having any previous 6502 programming experience, I started with the Quetzalcoatl compiler using its assembler feature. After several annoying bugs, later I switched to Dasm, which seems to be the assembler everyone uses on Vic 20 for cross-platform compiling. I started writing small pieces of code in assembler and calling them from basic. For example I had one SYS for piece moving left, one for moving right and so on. I used page zero PEEK() locations to communicate from ML to Basic. When the program was completed, I slowly converted basic lines into assembler, until my whole basic program was reduced to just one line: 10 SYS4109.

One thing that I've learned is that VIC-20 is incredibly fast when programmed in machine language. You can't see objects moving on the screen if you don't deliberately slow it down. On the contrary, Basic programs are very slow and most basic based games are not very playable.

I had lot of fun programming this game, and I tried to write it the best I could. I tried to use all the Vic features, e.g. the screen overscan (useful for a vertical playfield) or the screen vertical position that I use to make a "shake" effect when a tetris line is completed. I also have written my own bitmapped characters and an intelligent keyboard routine with auto repeat and definable keys. I have also an IRQ routine that plays sound effects without halting the game.

The result is a quite enjoyable game, but it's up to you to judge it!

Tetris it's for the unexpanded VIC, and you can download it from here:

(Tetris.prg, 3537 bytes)
(Tetris_sources.zip, 10,309 bytes)

Have fun!

 

© 1998-2006 Nino Porcino iz8bly@yahoo.it