Procedure/routine documentation: Main: Writer's name: Michael Wikoff Most recent update Date: 16 Nov. 2008 Brief description: This is the main loop that calls the other procedures and keeps track of the top-level game state. Inputs: Preconditions: None. I use: - Globals:
- Boxflag (Was a box just completed?)
- (Probably other globals as well.)
Outputs and Postconditions: I Change in computer: - Global(s):
- humORcom
- newgame
- rows
- cols
- CurrPlay
- Player1
- Player2
- Score1
- Score2
- (Probably other globals as well.)
- Postcondition I leave things in what state?
- The game is over all memory is returned to PEP8.
Routine(s) I call: Initial, InptMove, Multiply, others. Routine(s) that call me: None. Status: Assembly language prototype.
Pseudocode: Play Again Loop
{
Get user-decided information:
Output: "How many rows?"
Store answer to rows.
Load rows.
Check rows for out-of-bounds.
(Optional) calculate maximum columns, based on rows.
Output: How many columns?
Store answer to cols.
Load cols.
Check cols for out-of-bounds.
Output: "Is Player1 human (H) or computer (C)?"
Store answer to humORcom.
Load humORcom.
If answer is "c" or "C" set Player1 to be a computer.
(Will require a bit-changing operation.)
Output: "Is Player2 human (H) or computer (C)?"
Store answer to humORcom.
Load humORcom.
If answer is "c" or "C" set Player2 to be a computer.
(Will require a bit-changing operation.)
Call initialization procedure. ( Initial )
Output: Instructions. (Write these up myself, get them from somewhere?)
Game Loop
{
Player1 Loop:
{
Call output board procedure. (????)
If Player1 is human, branch to GetMove.
Call AI move selection procedure. (ArtInt)
Branch to Update.
GetMove: Call human input procedure. (InptMove)
(InptMove handles move validity checking.)
Update: Call data structure update prodecure. (squareUp?)
Load Boxflag.
If a box was just completed:
If Score1 + Score2 = rows * cols, branch to GameOver.
Else branch to Player1 loop beginning.
}
Player2 Loop: (Identical to Player1 loop.)
{
Call output board procedure. (????)
If Player1 is human, branch to GetMove2.
Call AI move selection procedure. (ArtInt)
Branch to Update2.
GetMove2: Call human input procedure. (InptMove)
(InptMove handles move validity checking.)
Update2: Call data structure update prodecure. (squareUp?)
Load Boxflag.
If a box was just completed:
If Score1 + Score2 = rows * cols, branch to GameOver.
Else branch to Player2 loop beginning.
}
Branch to Game Loop beginning.
{
GameOver:
Output: "Player1 scored Score1. Player2 scored Score2."
Compare Score1 to Score2.
Output: "PlayerX wins!"
Output: "Would you like to play again? (Y/N)"
Store answer to newgame.
Load answer.
If answer is "y" or "Y", break to beginning of loop.
}Design Prototype: BR beginW
BoxFlag: .WORD 0xFFFF
CurrPlay: .WORD 00
Player1: .WORD 00
Player2: .WORD 00
Score1: .WORD 00
Score2: .WORD 00
rows: .WORD 00
cols: .WORD 00
qw: .WORD 00
Inptmove: RET0
Initial: RET0
ArtInt: RET0
markSq: RET0
ROutput: RET0
InstrucW: .ASCII "Instructions go here.\n\x00"
; Play Again Loop
; {
; User interactivity at this point not yet implemented.
beginW: LDA 3, i
STA rows, d
LDA 10, i
STA cols, d
LDA 0x2400, i
STA Player1, d
LDA 0x40FF, i
STA Player2, d
CALL Initial, i
STRO InstrucW, d
; Game Loop (purely abstract)
; {
; Player 1 Loop
; {
P1LoopW: LDA 0x0000, i
STA CurrPlay, d
CALL ROutput
; If Player1 is human, get human input.
LDA Player1, d
CPA 00, i
BREQ GetMove, i
; Else get AI input.
CALL ArtInt, i
BR Update
GetMove: CALL Inptmove, i
Update: CALL markSq, i ; Still need proper name of process.
; If no boxes were made, go to Player2.
LDA BoxFlag, d
CPA 00, i
BREQ P2LoopW
; Else check for GameOver.
; Temporary substitute for GameOver.
BR TempW
Temp1W: .ASCII "Would you like to quit now? (0/1)\n\x00"
TempW: STRO Temp1W, d
DECI qw, d
LDA qw, d
CPA 00, i
BREQ LoopW
BR theEndW
; Gameover checking goes here, presently not implemented.
LoopW: BR P1LoopW
; }
;
; Player 2 Loop
; {
P2LoopW: LDA 0x0000, i
STA CurrPlay, d
CALL ROutput
; If Player2 is human, get human input.
LDA Player2, d
CPA 00, i
BREQ GetMove2, i
; Else get AI input.
CALL ArtInt, i
BR Update2
GetMove2: CALL Inptmove, i
Update2: CALL markSq, i ; Still need proper name of process.
; If no boxes were made, go to Player1.
LDA BoxFlag, d
CPA 00, i
BREQ P1LoopW
; Else check for GameOver.
; Temporary substitute for GameOver.
STRO Temp1W, d
DECI qw, d
LDA qw, d
CPA 00, i
BREQ Loop2W
BR theEndW
; Gameover checking goes here, presently not implemented.
Loop2W: BR P2LoopW;
; }
;
; }
Output0W: .ASCII "\n\x00"
Output1W: .ASCII "Player 1 scored: \x00"
Output2W: .ASCII "Player 2 scored: \x00"
Output3W: .ASCII "Player 1 wins!\x00"
Output4W: .ASCII "Player 2 wins!\x00"
Output5W: .ASCII "Would you like to play again?\x00"
gameOver: STRO Output1W, d
DECO Score1, d
STRO Output0W, d
STRO Output2W, d
DECO Score2, d
STRO Output0W, d
LDA Score1, d
CPA Score2, d
BRGT P1WinsW
P2WinsW: STRO Output4W, d
STRO Output0W, d
BR theEndW
P1WinsW: STRO Output3W, d
STRO Output0W, d
BR beginW
STRO Output5W, d
theEndW: STOP
.END
;}
|
Main calls squareUp instead of markSq I believe.