Methods:
Timer ISR:
_timerInstall proc near
This function replaces the IVT by the address of _timerHandler and saves the 4 byte address in oldTimerIsr
_timerInstall endp
Inputs: none
Purpose: To provide a tick once every 72 times in a second
Outputs: timerFlag
_timerHandler proc near
Set tickFlag to 1 and call the oldTimerISR once every 4 times.
_timerHandler endp
_timerUninstall proc near
This function replaces the 4 byte address in saved in oldTimerIsr back into the IVT
_timerUninstall endp
Keyboard ISR:
_keyboardInstall proc near
This function replaces the IVT by the address of _timerHandler and saves the 4 byte address in oldKeyboardIsr
_keyboardInstall endp
Inputs: menuOption,
arcadeOption
Purpose: To process the Keyboard input when in appropriate game modes
Outputs: menuOption, keyboardFlag
_keyboardHandler proc near
Fetch a character from the keyboard buffer
Set keyboardFlag accordingly [ -1 = Esc, 1 = Enter, 2 = menuOption ]
Set menuOption accordingly
_keyboardHandler endp
_keyboardUninstall proc near
This function replaces the 4 byte address in saved in oldKeyboardIsr back into the IVT
keyboardUninstall endp
Engine Methods:
Main Function:
Inputs: none
Purpose: Main program control routine, at beginning of program execution. It
also handles the Menu Window
Outputs: Depending
on modeOption, appropriate method is called
_main proc near
Load all PCX files and switch to GMode
Main Loop
Draw WallpaperLoop for Options:
Draw Options
Poll the menuOption flag untill an enter is pressed
End of Options LoopIf Quit Option is selected
Break out of LoopBegin appropriate Game Mode
End of Main LoopSwitch to TMode
_main endp
Gaming Mode Functions:
Inputs: None
Purpose: Routine for Arcade Mode Gaming
Outputs:
<miss> and <hits>
_arcadeMode proc near
Loop for each Level:
Draw Wallpaper
Draw SpriteLoop for each Round:
Set shootPerm ON
Loop for Animation:
Animate Sprite
Poll shotStatus flag
Check if time has run out
End of Animation LoopBlow sprite
Reset varaibles
Update Scores
End of Round Loop
Go to the next round
End of Level Loop - 3 levels each with 5 rounds
_arcadeMode endp
Inputs: None
Purpose: Routine for Practice Mode Gaming
Outputs: none
_practiceMode
Loop for each Game:
Draw Wallpaper
Draw SpriteLoop for Animation:
Animate Sprite
Poll shotStatus flag
If shot is successful display [blown up] sprite
Check if time has run out
End of Animation LoopCheck if Esc key is pressed
End of Game Loop
_practiceMode endp
Inputs: None
Purpose: Routine for Versus Mode Gaming [This algorithm
also contains functioning of NetPost routine]
Outputs: <miss>
<hits>
_versusMode proc near
Draw Wallpaper [Initial waiting screen]
Send searchMsg packet
Wait for rsvpMsg packet
Send acceptMsg packet and begin game
If game underway, send rejectMsg packet
If Server: [ lower of the two numbers as assigned by NetBios ]
Draw WallpaperSend serverMsg packet
Check if blowFlag is 1 - This flag is set when an updatePacket comes
If so, Blow the spriteCheck if serverFlag is 1 - If so, draw sprite on screen from packet
If shotStatus is 1, send updateMsg packet
Check if Esc Key was pressed
If so, Send goodbyeMsg packetLoop 15 times
End of Network Game
If Client:
Draw Wallpaper
Check if blowFlag is 1 - This flag is set when an updatePacket comes
If so, Blow the spriteCheck if serverFlag is 1 - If so, draw sprite on screen from packet
If shotStatus is 1, send updateMsg packet
Check if Esc Key was pressed
If so, Send goodbyeMsg packetLoop till server send goodbyeMsg packet
_versusMode endp
_mouseMove
This routine sets the mouse boundaries and obtains the position of the mouse on the screen.
[Input none, Output mousePosition]
_randGenerator
This routine generates a random location for the sprite. It constitutes the AI for the game
[Input <randRow>, <randCol>, Output <randRow> <randCol> <randLoc>]
_checkShootStatus
This routine checks if the player has shot the sprite
[Input <mousePosition>, <randLoc>, Output shotStatus]
Graphic Methods:
_load PCX
This routine loads a PCX file into the appropriate location in the Image Array and sets the video pallette DAC
[Input AX - sprite ID, DX - offset of filename, No Output]
_drawWallpaper
This routine draws the wallpaper to buffer
[Input DX - offset of wallpaper, No Output]
_fadeOut
This routine fades the screen to blank by masking every "fadeNum"th pixel then "fadeNum-1"th pixel and so on
[Input <fadeNum>, No Output]
_animateSpriteIn
This routine cycles through images of a sprite of different sizes to give a fade out effect
[Input AX - sprite ID, DI - location in buffer No Output]
_animateSpriteOut
This routine cycles through images of a sprite of different sizes to give a fade out effect
[Input AX - sprite ID, DI - location in buffer, Output none]
_drawToBuffer
This routine draws a sprite onto the buffer. It takes care of invisible color
[Input AX - sprite ID, DI - location in buffer, No Output]
_drawToScreen
This routine waits for V_Sync to go high and dumps the buffer onto the video memory
[Input none, No Output]
_netScores
This routine displays the appropriate splash screen after a Network game
[Input <miss>, <hits>, No Output]
_drawNum
This routine takes draws the score on the screen
[Input DX - buffer offset, AL - number, Ouput none]
_scoreDisplay
This routine displays the score on the screen at the end of an arcade game
[Input <miss>, <hits>, Ouput none, Call _drawNum]
Sound Methods:
_playMidi
This routine registers the midi file and plays it. Reference: MIDPAK API
[Input none, Output none]
_stopMidi
This routine stops the currently playing midi file. Reference: MIDPAK API
[Input none, Ouput none]
_initializeSoundSeg
This routine is called in the beginning of the program. It calculates sound variables
[Input none, Ouput <sbuf_length>, <sbuf_page>, <sbuf_offset>, <snd_offset>]
_openWav
This routine opens the Wav file to be played
[Input DX - offset of filename, Output <loadbuf> stores Wav header and SoundSeg stores Wav data]
_playWav
This routine plays the Wav file using the Library Routines to program the DMA
[Input DX - offset of filename, Output <playing> is set to 1, Calls _openWav]
SoundHandler
This routine is called when the Wav file completes playing. It sets playing to 0
[Input none, Output <playing> is set to 0]
All Methods written by Karan Mehra