CS306 Processing Systems and Structures B. Klaydman

Final Project
Word School

Updated on 4-20-2002

Updated again on 4-21-2002

Team members:

Project leader and programmer: Boris Klaydman.

This is a single user project and was implemented solely by me. This implementation includes:

Introduction

This project is an Assembler implementation of educational game for pre-school age children. When player loads the game he or she is presented with a random picture that represents a word. The child has three attempts to guess the correct letter. Each time the child presses a letter it is graphically displayed on the screen with a corresponding message letting him/her know if the guess was right. If the number of guesses exceeds three or child guesses correctly the new image loaded and the game starts over.

Problem Description:

The most challenging aspect of the project is the time frame (only a week left with 3 other labs due on the same week) and total isolation (working on the project alone). The project is designed to as practice of displaying graphic image files on the screen using assembler. The PCX format was chosen as primary graphic format of images that the user interface is composed of. In the project the programmer has to deal with processing of the user input, refreshing small positions of the screen, randomly selecting objects for displaying. The scope of the problem is limited, but it extendable. Other options may include use of sound, transitions between images, and creating different modes of the game. For example, the game can be changed with some effort to a math game, where the user has to guess the result of the simple calculations, but this option requires a team of at least 2 people to be done in time.

Implementation:

Since the main focus of the problem is loading and displaying of the PCX files and the target to the game is letter recognition, there will be two main byte sizes arrays that hold the names of the files to process. The names of the files are null terminated and contain only 8 characters for easy access using the shift operation (SHL BX, 3 multiplies by 8). Array of picture files: Pict db 'p00.pcx', 0 db 'p01.pcx', 0 db 'p02.pcx', 0 db ............ db 'p26.pcx', 0 Array of letter files: Lett db 'L00.pcx', 0 db 'L01.pcx', 0 db 'L02.pcx', 0 db ............ db 'L26.pcx', 0 ; Holds array of picture that represent answers to a question Ansr db 'an0.pcx', 0 db 'an1.pcx', 0 db 'an2.pcx', 0 db 'an3.pcx', 0 ; Holds array of picture that represent guess number Tryn db 'tr0.pcx', 0 db 'tr1.pcx', 0 db 'tr2.pcx', 0 db 'tr3.pcx', 0 Screen db 'screen.pcx', 0 ; The main screen The main procedure loops until user presses the escape key. During each iteration of the loop the input from the user is processed and the screen is updated accordingly. The main component of the project is the PCX loading routine. This routine loads image files from the disk and displays them starting from position specified by DX. The size of current picture is specified in variables: XSize dw 0 ; Size of currently loaded picture PicStart dw 0 ; End position of current picture on the screen PicEnd dw 0 ; End position of current picture on the screen To clear the parts of the screen the empty images are loaded and displayed in correct places. The whole algorithm of the project is based on splitting the screen into small pieces and loading them in correct places and order.

Additional constants:

; Video Memory Segments (Store in ES) VIDTEXTSEG EQU 0B800h ; Text-mode video VIDGRSEG EQU 0A000h ; Graphics video SCREENSTART EQU 0; Starting position of screen on the screen SCREENEND EQU 320*200; Ending position of screen on the screen SCREENWIDTH EQU 320 ; Width of screen on the screen LETTERSTART EQU 30*320 -187 ; Starting position of letters on the screen LETTEREND EQU 30*320 -187 + 121*320 + 130; Ending position of letters on the screen LETTERWIDTH EQU 130 ; Width of letters on the screen PICTURESTART EQU 37*320 ; Starting position of pictures on the screen PICTUREEND EQU 37*320 + 125*320 + 186; Ending position of pictures on the screen PICTUREWIDTH EQU 186 ; Width of pictures on the screen TRYSTART EQU 175*320 + 80; Starting position of tries on the screen TRYEND EQU 175*320 + 80 + 24*320 + 22; Ending position of tries on the screen TRYWIDTH EQU 22 ; Width of tries picture on the screen ANSSTART EQU 160*320 ; Starting position of answers on the screen ANSEND EQU 160*320 + 40*320 + 200; Ending position of answers on the screen ANSWIDTH EQU 200 ; Width of tries answers on the screen

Procedures:

main

clearScreen

displayPicture

randomNum

showLetter

showPicture

showGuessNum

showGuess

External Routines:

In the project some of the library functions from MP5 are used: