373 Invader & Scope
Home
High Level Design
Hardware Design
Software Design
Project Result

Software design

Both programs that we created relies heavily on the timer interrupt to update the memory content of the display buffers.

Many of the program status registers are mapped to a specific memory location. This serves as global variable that is accessible anywhere in the software. Memory mapping variables makes things easier by not having to pass variables into functions. If a function needs to read a global variable value, it would just need to create a pointer variable and make it point to that specific location in the memory.

We also created graphic library to aid with the images displayed, and any changes in the graphics is totally transparent to program. Some of the graphic libraries that we created includes numbers, spaceship, bullets, enemies, health bar and score board. To update the graphics on the screen, we would just need to know the x and y value of the location of the object, and the graphic functions paint starting that location. ( x and y values refers to the x and y position in the LCD buffer range).

 

373 invader

The 373 invader program is updated at every interrupt that is generated by the timer, and behaves as follow:

•  Clear display buffer

Upon entering the interrupt, the buffer needs to be cleared. This is to remove any pixels already drawn on the screen, so that we can re-draw the display.

•  Get controller status

Reads out the value from the controller buffer to get the status from the controller.

•  Check for any movement / fire shot

Parses the values read from the controller, and interpret it as any movement created on the joystick. This will check 2 different values of left (fast left or slow left) and 2 different values of right (fast right or slow right).

The controller values are also checked for whether or not the button A is pressed. This indicates the ‘fire' button.

These checked values are then stored into a global variable in the memory.

•  Check if new enemy needs to be created

Using the random logic that we created, we are able to randomly decide whether or not we are going to launch a new enemy onto the screen. The random logic uses combination of the timer and the real time clock register values. The result is surprisingly random that there is no observable pattern in the generation.

•  Update buffers

This is a c functions that update the position of the spaceship, increment any bullet position that is on the screen, decrement the enemy position that is on the screen, create new bullet, create a new enemy, update score and update health.

Towards the end of the function, it calls the draw functions to start painting the screen again to create a fresh new image.

 

Oscilloscope

The Oscilloscope program also depends heavily on the times interrupt to trigger start of conversion. It also depends heavily on IRQ7 which indicates the end of conversion of the ADC, and thus updating the display.

The program behaves as follow:

•  IRQ 1

Triggers the start of a new scan. This interrupt clears the display buffer, and enable the timer interrupt to start conversions.

•  LEVEL4

Checks every second if there is a need to start a new conversions.

•  IRQ 7

This indicates the end of conversion and the converted data is ready.

Upon receiving this interrupt, the handler will paint the LCD buffers according to the values read.