Command disabled: backlink
 
Available Languages?:

Video game with PIC18

Intro

PIC18 is not quite effective controller to drive VGA monitor, but they are able to be implemented for these purposes. This example shows how to use PIC18F2550 to build video game. In 2004 I developed VGA-terminal, where I used PIC18 to produce VGA control signals to form text data on the screen. When I was a boy (in early 80-th) I had a ZX Spectrum. My favorite game was a Bulder Dash by First Star Software. Now I tried to encode this game woth PIC18 controller. Here are source code, video and description of my works.

Source codes: vga_game.rar

All modules in this program were written in C (HT-PICC18), except interrupt service routine - it was fully written in assembler. Program controlled by RTOS OSA.

Program specification:

Controller PIC18F2550
Fosc 48 MHz (12 MIPS)
RTOS OSA
VGA 256x200 pixels, 15 colors
Polyphony 5 voices (4 for music, 1 for game effects). Sample rate = 15 KHz
Game field 40x20 objects
Viewable field size 16x12 objects

Video (34 Mb)

Here is a small video. The quality is not very well since I used low-cost web-camera. Sound was recorded through line-in.



Unfortunately I could not to record video in better way. In fact, the picture is more clearly:

Description

Scheme

The principal scheme it rather simple:

Logically, scheme can be splitted into four parts:

  1. microcontroller - device's heart;
  2. 3 resistors and 6 diodes to form RGB-signals;
  3. low noize filter to produce sound;
  4. 5 buttons with pull-up resistors.

How to form image on VGA-monitor is described here.

Here is device's photo:

Controller's resources

As you can see, controller should to do many jobs simultaneously: sync signals for VGA generating, RGB-signals generating, multyvoice sound generating. All these jobs should be synchronized to within a cycle, otherwise the picture on the monitor will shake. Besides, the game should work in real-time: buttons reading, animation, objects moving, music playing, soung effects and ect.

I decided to put all time critical processes into interrupt service routine, and all other to put into OS tasks functions.

These tasks are placed into ISR:

  • VGA sync pulses generating;
  • RGB-singals generating;
  • sound sinthesizer;
  • button read with debounce.

Other tasks are placed in remaining program part:

  • making animation;
  • game rules;
  • music and sound effects forming.

(UNFINISHED)

(see russian text)

 
en/osa/articles/vga_game.txt · Last modified: 03.01.2010 22:08 by osa_chief
 
Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki