Final Project: Zelda 291: Input
Introduction
Zelda 291 will accept information from both the
keyboard and either a joystick or gamepad.
Problem Description
This part of the program is fairly straightfoward. It
basically just uses a common keyboard interrupt and a standard
joystick function. If two direction keys are pressed, the program
will move in one direction and must "remember" the
other direction in case the player releases the other key. A new
aspect of this that was not done in the machine problems is that
we will use press and release interrupts for the keyboard.
I also worked on various introduction screens. Perhaps the
most difficult part of this was implementing a scrolling feature.
It was also a challenge to display the scrolling file since it
was 800 lines long and only 200 can be on the screen at once.
Keyboard
The gaming controls on the keyboard will be functional only
when the joystick is on. The control keys will always be
functional. The keyboard will accept the following commands:
- Arrow Keys -- Movement (Cardinal Directions)
- Alt -- Primary Attack
- Space Bar -- Pause
- J -- Toggle Joystick On/Off
- Esc -- Exit the Game
Joystick/GamePad
The joystick will only become functional if the user presses
the Y key at the intial screen. Some joysticks contain only two
buttons (A and B). However, the Gravis Gamepad contains four
buttons, two of which will be used. It will accept the following
inputs:
- D-pad or Joystick -- Movement (Cardinal Directions)
- Button A -- Primary Attack
- Button D -- Pause
Scrolling
The scrolling was implemented by first loading the screen with
the first 64000 bytes of the uncompressed file. Then, to
implement scrolling, each line on the screen was shifted up one
row, and the last row was filled with the next block of data from
the file.
Procedures
InputInstKbdInt
- Purpose: Installs InputNewKbdInt as the new
interrupt
- Inputs: None
- Outputs: Stores old interrupt in OldKIVector
InputDeInstKbdInt
- Purpose: OldKIVector is installed as the
interrupt
- Inputs: None
- Outputs: None
InputNewKbdInt
- Purpose: The keyboard interrupt used for the game
- Inputs: None
- Outputs: Writes InputAction, InputX_Direction and
InputY_Direction
InputGetJstkInfo
- Purpose: Polls the joystick for x,y values and
gets the buttons pressed
- Inputs: Joystick input
- Outputs: Writes Action, X_Direction and
Y_Direction
InputJstkCalib
- Purpose: Calibrates the joystick
- Inputs: None
- Outputs: Writes Xmin, Xmax, Ymin, Ymax
- Notes:
- First, an inital screen is shown asking
the user to choose joystick input.
- Then, if Y is pressed, another screen
appears, instructing the user.
- The user holds direction in upper left
position and presses button A.
- Then, another screen appears, instructing
the user.
- The user holds direction in lower right
position and presses button A.
- If 'N' is pressed at title screen, the
function skips to normal gameplay.
- The function calculates an automatic
12.5% tolerance on all the inputs.
DisplayStory
- Purpose: Displays the initial scrolling screen
- Inputs: None
- Outputs: Writes to screen
GetPallette
- Purpose: Gets the pallette from the file
pallette.pcx. Used because the pallette must be
set before the scrolling screen begins.
- Inputs: None
- Outputs: Writes to Screen
LoadPCX
- Taken directly from my mp4. It worked then, why
won't it work now.