Академический Документы
Профессиональный Документы
Культура Документы
Group Number: 4
Group Members:
Page 1
ELEC254 Project Report Group 4
Table of Content
Introduction
Description of hardware
LCD
Description of software
Data structure
Game Algorithm
Appendix
LCD screen
Motion sensor
Page 2
ELEC254 Project Report Group 4
Introduction
EXstream is a re-implementation of Snake, which is a video game that gained
popularity in the 1990s since its inclusion on mobile phones. In the game, the
player controls a long, thin line, resembling the flow of water in streams (or a
snake in the game Snake), which roams around on a bordered plane, submerges
obstacles, trying to avoid overlapping its own route or the "dams" that surround
the playing area.
Page 3
ELEC254 Project Report Group 4
Hardware components:
1. 8051 emulator
2. 128 x 64 dot matrix LCD display
3. Motion Sensor – ADXL311
4. Analog to digital converter – ADC0804
5. Speaker
6. Inverter – 74LS05
Software components:
1. Display on LCD
2. Move Stream
3. Generate target
4. Update score and level
5. Play background music
Page 4
ELEC254 Project Report Group 4
Operating Instructions
1. Welcome picture is shown on the LCD. Select a playing mode using left or right
button. And press start button to start game.
2. Press the direction buttons when the button mode is selected. Tilt the motion
sensor when the motion mode is selected.
3. Score and level will be displayed on the left side of screen.
4. When score satisfies the upgrade score, level increment and the moving speed
will be faster under button mode.
5. If game is over, it will return to the welcome picture and condition.
6. Repeat from step 1.
Page 5
ELEC254 Project Report Group 4
It’s better to store the value in a variable before check it so that a new value can
be get during checking the previous value.
There is no recording system to record the highest score and previous score which
is not user-friendly enough.
It’s better to store the previous score and highest simply use variables so that
users may want to challenge themselves again and againg.
The motion sensor is not sensitive enough because the sensor is too small to
solder steadily. So the value given by motion sensor (via ADC) is not stable
which may cause undesirable manipulation.
A suitable socket is needed so that soldering can be omitted. The value given by
motion sensor will be more stable and contain less noise.
More tones and coherent melody is desirable. Users may feel more comfortable
and relaxed when they are playing.
The final product is lacking of decoration and looks not beautiful and shiny.
If some decoration, such as blinking LED etc, can be added, users can enjoy the
game and love it more.
Page 6
ELEC254 Project Report Group 4
Description of Hardware
Page 7
ELEC254 Project Report Group 4
LCD
The LCD we use in the experiment is a standard 128 x 64 dot matrix display.
Page 8
ELEC254 Project Report Group 4
Motion Sensor
ADXL311
Page 9
ELEC254 Project Report Group 4
Background music
Page 10
ELEC254 Project Report Group 4
Description of Software
Data structure
There is a 14x14 matrix to represent the grids that stream (snake) can reach. Each
grid has an unique coordinate value from (0, 0) to (13, 13), (0, 0) to (D, D) in Hex.
There is an array in the internal memory starting from the location 30H to represent
the coordinates that the stream (snake) occupies sequentially. The memory location
Page 11
ELEC254 Project Report Group 4
30H will always store the head position of this stream (snake). The variable
LENGTH will store the length of the stream (snake) which is initially 4 and
increased by 1 when the stream (snake) hits the target. The memory location (30H +
LENGTH) will store the tail position.
The higher 4 bits of a memory location will store the x coordinate value and the
lower 4 bits stores the y coordinate value.
Game Algorithm
Page 12
ELEC254 Project Report Group 4
The Game has two playing mode. One is button mode and the other is motion mode.
Users can choose the playing mode when the welcome picture shown on the screen.
Choosing the button mode will enter the conventional Snake playing mode which is
to control the movement of the snake by buttons. Choosing the motion mode will
enter the innovative ExStream playing mode which is to control the movement by
motion sensor.
An arrow will point to the chose mode.
When the movement direction is decided, new head position will be computed.
Up – subtract 01h on current head value
Down - add 01h on current head value
Left – subtract 10h
Right – add 10h
Store the new head value in variable NEW_HEAD.
In button mode if no press-event occurs the stream (snake) will move to the
previous direction. There is a variable PREV_DIR indicating the current direction.
The default moving direction is right. The opposite direction button will be disabled
by software.
Check if the stream (snake) hit itself using function VALID_MOVE. Compare the
new head value with the value stored in memory location from 30H to 30H +
LENGTH. If there exists a value in this array which is equal to new head value,
game is over and jump to the welcome picture to start a new game.
Check if the stream (snake) hit the wall using function VALID_MOVE. Do the
logic operation AND between new head value and 11110000B, 00001111B. If the
value out of the range of (0, D), game is over and jump to the welcome picture to
start a new game.
If the movement is valid, call the function DISPLAY_UNIT.
Shift all the previous value stored from 30H to 30H + LENGTH backward and
insert the new head value at memory location 30H.
Check if the head value is the same as the target value. If they are equal, the
LENGTH will be increment and finish the movement function. If they are not equal,
clear the memory location at 30H + LENGTH + 1 and call the function
CLEAR_UNIT.
Page 13
ELEC254 Project Report Group 4
Page 14
ELEC254 Project Report Group 4
upper 4 bits if the value is larger than 5, on the right side. Multiply 4 to the value of
upper 4 bits and then subtracted from 03FH if the value is smaller than 6, on the left
side.
Check the lower 4 bits to decide the position is in which X page. Divide the lower 4
bits value by 2 in order to get the X page number. Check the value in register B, if
the position is in odd line, it should be displayed on the upper half page (4*4 pixels)
otherwise it should be displayed on the lower half page (4*4 pixels). Then compare
the other half page coordinate with the stream (snake) body array and the target
position to decide whether the whole page is occupied. If it is nether occupied by
the body of stream (snake) nor the target, check whether it’s occupied by the
boundary. If not, just display a unit (4*4 pixels) on half page at the computed page
number and Y address. If the full page is occupied, display 2 units (4*8 pixels) at
the computed page and Y address. Repeat displaying 4 times and increment the Y
address simultaneously.
Function CLEAR_UNIT is used to clear the unit which is not valid any more. The
address calculation is the same as function DISPLAY_UNIT. The difference here is
to display a blank unit (4*4 pixels). That also need to check the other half page is
being occupied or not in order to decide to write 2 blank units (4*8 pixels) or 1
blank unit (4*4 pixels).
Page 15
ELEC254 Project Report Group 4
Page 16
ELEC254 Project Report Group 4
Appendix
12864 dot matrix LCD
ADXL311 motion sensor
Page 17