Professional Documents
Culture Documents
Objectives:
In this project, you are required to review the components and skills learned in your
previous lectures and mini projects and integrate them into a complete application system.
The required components consist of:
Descriptions:
In this project, you are going to design a music memory game as an interrupt service.
Rules of the game: 4 keys in the keyboard are defined. A unique music note can be played
by pressing each one of the 4 keys. By having a sequence of key hits, the player can play
a sequence of music notes. There are two players, Player I and Player II, involved. When
the game starts, Player I first hits the keys and plays a sequence of music notes. At the
same time, Player II should listen to the music and try to memorize it, so that later he can
repeat the exact piece of music by hitting the appropriate sequence of keys in the
keyboard. If the music played by Player II doesn’t match that of Player I, we say that
Player I wins and Player II loses, and this round of game ends. Otherwise, the game
continues and proceeds to another round, and Player I and Player II switch their roles.
That is, Player II plays the music first, and Player I tries to remember and replay the
music. So on and so forth, until one of the player wins.
The player who is supposed to replay the music should press the appropriate sequence of
keys as soon as possible. A maximum respond time T is defined. If he cannot replay the
music within T time after the original music was played, the player is also considered as
the loser.
The game will end immediately when one player defeats the other player. Then the users
will return to the main menu to choose a difficulty level and continue playing or exit from
the game.
Here we assume that the player who is listening to the music will not cheat. At no time
should he look at the sequence of the keys being input by the other player, instead he
should try to only listen to the music and keep it in mind.
A typical sample graphic user interface (GUI) of the game is shown below (for students
to understand how to play this game, NO NEED to implement exactly the same).
Design Requirements:
1. Altogether there are 12 music notes: C, C#, D, D#, E, F, F#, G, G#, A, A#, B. You
should implement at least 4 music notes.
2. The length of the music piece, i.e., the number of notes in the piece of music,
should be at least 3.
3. The game should have at least 3 different levels of difficulty. The difficulty level
can be increased by using one or more of the following ways:
(1) Increase the length of the music piece.
(2) Have more out of the 12 kinds of music notes in the music.
(3) Make the respond time T smaller.
4. The game GUI should be displayed at the VGA video mode (640 * 480).
5. In the game GUI, a clock countdown from T to 0 should be displayed, so that the
player knows how much time is left.
6. A bonus (lucky) music piece can be implemented. If the music played by, say,
Player I is the bonus music, then Player II will be penalized. That is, his respond
time T will be decreased by t.
7. If any rule is not fully specified, you may interpret the rule in your own way.
Extra Features:
2. Record keeping
System would allow players to input a nickname before playing a level, and then
keep a record of which player wins after how many rounds. This way would make
the game more interesting.
3. This game may be played by two players on two connected PCs. The rules
remain the same, but each player will operate one PC. This will lower the chance
of cheating, in case some players tend to rely more on their eyes than their ears.
The two PCs can be connected using RS232 connectors and cables and
communicate with each other through the serial ports.
Additional Help:
1. Music sound is generated by using the timer chip and the PC’s built-in speaker. Each
music note is specified by a frequency and duration. Both frequency and duration are
defined by the programmable interval timer (PIT) connected to the PC’s speaker. The
sound is generated by activating the speaker via the programmable peripheral interface
(PPI) chip.
More detailed information on programming the PIT and PPI chip and generating music
can be found at Chapter 10 of Randall Hyde’s book The Art of Assembly Language.
2. A sample code used to draw a simple GUI will be provided at the IVLE Workbin for
your reference.
Submission Requirements:
Package your report (at least two pages) and your commented code and submit by email
to your GA by the time and date that will be announced separately.
Marking Scheme:
The full mark of the major project is 25.
(1% log book, 4% flow chart, 13 working program (10% game implementation, 3% extra
features), 2% presentation, 5% report).
;Definition
N = 0DH ;N=0DH for invoking interrupt 0DH
;======================================================================
; stack segment
;======================================================================
STACK_SEG SEGMENT STACK
DB 64 DUP(?)
STACK_SEG ENDS
;======================================================================
; data segment
;======================================================================
DATA_SEG SEGMENT
MSG DB 'my new interrupt prints: receive an interrupt', 0DH, 0AH
CHCOUNT DW $-MSG
TEMPVECT DW 2 DUP(?) ;Temporary place for current vector
DATA_SEG ENDS
;======================================================================
; code segment
;======================================================================
CODE_SEG SEGMENT
Lab PROC FAR
ASSUME CS:CODE_SEG, SS:STACK_SEG, DS:DATA_SEG
;----------------------------------------------------------------------
; Interrupt service routine
;----------------------------------------------------------------------
INT_SRV_RTN:
PUSH DS ;Save registers to be used
PUSH AX
PUSH SI
PUSH CX
NXT_CHAR:
MOV AL, [SI] ;Get character to be displayed
MOV AH, 14 ;Use INT 10H WITH AH=14 to
INT 10H ;Display the character
INC SI ;Point to next character
LOOP NXT_CHAR ;Repeat till all character are displayed
Lab ENDP
;======================================================================
CODE_SEG ENDS
END Lab
;===============================================================