You are on page 1of 6

EE2007 Major Project (Sem II, 2009/2010):

A Music Memory Game Interrupt Service

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:

1) Application of Timer to generate real time delay


2) Application of Programmable Peripheral Interface (PPI)
3) Development of a new Interrupt Service to solve a practical problem
4) Development of Graphic User Interface
5) Programming with subroutines and program control

Descriptions:

In this project, you are going to design a music memory game as an interrupt service.

Provide the game code as an interrupt service routine:


We require that the game is provided as one interrupt service just like the various services
that INT 21H has provided to you. Assume the interrupt number assigned to this music
memory game interrupt service is 0DH. The game will be started whenever you call the
software interrupt using “INT 0DH” in the main assembly program. Appendix 1 gives a
sample program that shows how you can set up your own interrupt service routine for an
interrupt N.

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:

1. Clear and easy-to-use interface


Note: basic GUI is ok, no need to spend too much time on GUI, more function
features would be better than a more flaring GUI.

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.

Remember to include the following information in your report:

(1) Name and matriculation number;


(2) Lab date;
(3) The name of your program (e.g., "lab3.asm");
(4) Objective of this lab;
(5) Flow chart of your program;
(6) Describe the detailed implementation steps, especially indicate and
explain your essential steps.
(7) What did you learn? What are the problems you encountered and how did
you solve them in this project? If your code did not work in the lab,
explain why.
(8) Any other issues you want to include.

You should comment your code in detail.

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).

Appendix A: A Sample Program to Set Up an Interrupt


Service Routine for your Own Interrupt Service
; You may copy and past the following code into a file and name it for
; example “customI.asm”. You may then assemble, link and execute this
; file to see the output of the interrupt service routine.
; CustomI.asm: Make your own interrupt service routine
; Learn from this program how to add new interrupts or modify existing
; interrupts
; The interrupt vector table (memory from 00000h to 003ffh)
; keeps the addresses of all interrupts(from 00000h to 000ffh).
; The address of the interrupt vector for INT N is stored in the table
; at offset N * 4. For example: interrupt 10h is stored at 10h*4.

;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

PUSH DS ;Return address of DOS (OR DEBUG)


MOV AX, 0
PUSH AX

MOV ES, AX ;ES=0

MOV AX, DATA_SEG ;Establish data segment


MOV DS, AX

MOV AX, ES:[N*4] ;Save current vector temporarily


MOV TEMPVECT, AX
MOV AX, ES:[N*4+2]
MOV TEMPVECT+2, AX

;Establish interrupt vector


MOV WORD PTR ES:[N*4], OFFSET INT_SRV_RTN
MOV WORD PTR ES:[N*4+2], SEG INT_SRV_RTN

INT N ;Invoke the interrupt N

MOV AX, TEMPVECT ;Restore original vector


MOV ES:[N*4], AX
MOV AX, TEMPVECT+2
MOV ES:[N*4+2], AX

RET ;Return to DOS (OR DEBUG)

;----------------------------------------------------------------------
; Interrupt service routine
;----------------------------------------------------------------------
INT_SRV_RTN:
PUSH DS ;Save registers to be used
PUSH AX
PUSH SI
PUSH CX

MOV AX, DATA_SEG ;Establish data segment


MOV DS, AX
LEA SI, MSG ;Point to display message
MOV CX, CHCOUNT ;Message length

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

POP CX ;Restore registers


POP SI
POP AX
POP DS
IRET ;Return from interrupt

Lab ENDP
;======================================================================
CODE_SEG ENDS
END Lab
;===============================================================

You might also like