Skip to content

Commit

Permalink
Invitations Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Mostafa-wael committed Jan 11, 2021
1 parent 1612984 commit 589a9f0
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 186 deletions.
Binary file modified Code/APP.EXE
Binary file not shown.
8 changes: 4 additions & 4 deletions Code/APP.MAP
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

Start Stop Length Name Class

00000H 01E8BH 01E8CH _TEXT CODE
01E90H 10388H 0E4F9H _DATA DATA
10390H 107CFH 00440H STACK STACK
107D0H 1B6F1H 0AF22H EXTRA
00000H 02031H 02032H _TEXT CODE
02040H 105ECH 0E5ADH _DATA DATA
105F0H 10A2FH 00440H STACK STACK
10A30H 1B951H 0AF22H EXTRA

Program entry point at 0000:0000

Binary file modified Code/APP.OBJ
Binary file not shown.
Binary file modified Code/CHAT.OBJ
Binary file not shown.
115 changes: 32 additions & 83 deletions Code/MACROS.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ checkIfInput MACRO noInputLabel ; jumps to this label if there is no input ;
jz noInputLabel
ENDM
;
printInMsgBoxUP MACRO string
mov bx, 2
; BX: 0 down character1, 1 down character2, 2 up character1, 3 up character2
call DrawMsgWithBox
printStringAtLoc string, 2, 20
ENDM
printInMsgBoxLow MACRO string
mov bx, 1
; BX: 0 down character1, 1 down character2, 2 up character1, 3 up character2
call DrawMsgWithBox
printStringAtLoc string, 4, 20
ENDM
;
printChar macro char ; prints the char at the current cursor position
mov ah,2
mov dl,char
Expand Down Expand Up @@ -160,20 +173,20 @@ getPlayersName_ID MACRO
call getCharID ; adds the player ID in BL
MOV playerID1, BL
;//////////////////////////////;//////////////////////////////;//////////////////////////////;//////////////////////////////
;////////////////////////////// get player2 name
;///// color the background and draw the logo
call DrawRec
editDrawPrams logo, logoSizeX, logoSizeY, logoOffsetX2, logoOffsetY2
call drawShape_extra
;///// get the name and validate it
printStringAtLoc getname2, 2, 28
GetPlayer2Name:
getString playername2
validateName playername2, maxPlayerSize, validName2, GetPlayer2Name
validName2:
;//// choose character2
call getCharID ; adds the player ID in BL
MOV playerID2, BL
; ;////////////////////////////// get player2 name
; ;///// color the background and draw the logo
; call DrawRec
; editDrawPrams logo, logoSizeX, logoSizeY, logoOffsetX2, logoOffsetY2
; call drawShape_extra
; ;///// get the name and validate it
; printStringAtLoc getname2, 2, 28
; GetPlayer2Name:
; getString playername2
; validateName playername2, maxPlayerSize, validName2, GetPlayer2Name
; validName2:
; ;//// choose character2
; call getCharID ; adds the player ID in BL
; MOV playerID2, BL
ENDM
;///////////////////////////////
;/////////////////////////////// related to the screen
Expand Down Expand Up @@ -269,11 +282,9 @@ scrollScreen_text MACRO BF_color, topLeftX, topLeftY, bottomRightX, bottomRightY
cmp ch,bottomRightY
jbe Loop1
ENDM
; can be converted into a procedure

;///////////////////////////////
;/////////////////////////////// Draw operations
;///////////////////////////////
;///////////////////////////////
;/////////////////////////////// Draw operations
;///////////////////////////////
editDrawPrams MACRO shape, sizeX, sizeY, offsetX, offsetY ; modifies the draw parameters before the drawShape proc
MOV AX, sizeX
MOV shapeSizeX, AX
Expand Down Expand Up @@ -333,9 +344,8 @@ setCurrentChar MACRO playerID
;///////////////////////////////
;/////////////////////////////// related to the main menu and the choosing character screen
;///////////////////////////////
displayMainMenu MACRO ; responsible for drawing the main menu
displayMainMenu MACRO ; without the logo ; responsible for drawing the main menu
call background
mov Ers, 0
mov REV, 0
editDrawPrams gamebtn, btnsize, btnsize+2, gamebtnOffset, gamebtnOffset+2
call drawShape_extra
Expand All @@ -344,7 +354,7 @@ displayMainMenu MACRO
editDrawPrams exitbtn, btnsize, btnsize+2, exitbtnOffset, exitbtnOffset+2
call drawShape_extra
call drawLogo
;call drawLogo
call eraseArrows
add arrowoffsetY, arrowStep
call eraseArrows
Expand All @@ -363,67 +373,6 @@ displayMainMenu MACRO
Lea SI, Ship1
call drawShape
ENDM
checkMainMenuOptions MACRO gameLoop_label, exitProg_label, chatLoop_label ; remember to add the chatLoop_label
local CheckInMainMenu, Make_THE_JMP_CLOSER, downArrow_label, enterKey_label
CheckInMainMenu:
waitForInput

cmp ah, key_upArrow ; up arrow
jne downArrow_label
cmp arrowoffsetY, arrowAtgame
je CheckInMainMenu
call eraseArrows
mov AX, arrowStep
SUB arrowoffsetY, AX
mov Rev, 1
Lea SI, Ship1
mov AX, arrowOffsetXRev
mov shapeOffsetX, AX
mov AX, arrowoffsetY
mov shapeOffsetY, AX
call drawShape
Lea SI, Ship1

mov Rev, 0
mov AX, arrowOffsetX
mov shapeOffsetX, AX
call drawShape
Make_THE_JMP_CLOSER: jmp CheckInMainMenu

downArrow_label: cmp ah, key_downArrow ; down arrow
jne enterKey_label
cmp arrowoffsetY, arrowAtExit
je CheckInMainMenu
call eraseArrows

mov AX, arrowStep
ADD arrowoffsetY, AX
mov Rev, 1
Lea SI, Ship1
mov AX, arrowOffsetXRev
mov shapeOffsetX, AX
mov AX, arrowoffsetY
mov shapeOffsetY, AX
call drawShape
Lea SI, Ship1
mov Rev, 0
mov AX, arrowOffsetX
mov shapeOffsetX, AX
call drawShape

jmp Make_THE_JMP_CLOSER

enterKey_label: cmp ah, key_enter ; enter
jne Make_THE_JMP_CLOSER ; added to prevent other buttons from doing enter's action

cmp arrowoffsetY, arrowAtChat
je chatLoop_label
cmp arrowoffsetY, arrowAtgame
je gameLoop_label
cmp arrowoffsetY, arrowAtExit
je exitProg_label
jmp Make_THE_JMP_CLOSER
ENDM
;///////////////////////////////
;/////////////////////////////// related to keys
;///////////////////////////////
Expand Down
150 changes: 143 additions & 7 deletions Code/app.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,75 @@ PUBLIC DrawMsgWithBox
.stack 1024
;///////////////////////////////Macros////////////////////////////////////
include MACROS.inc
checkMainMenuOptions MACRO ; can be converted into a proc
local CheckInMainMenu, Make_THE_JMP_CLOSER, downArrow_label, enterKey_label, nothingLeft
CheckInMainMenu:
waitForInput

cmp ah, key_upArrow ; up arrow
jne downArrow_label
cmp arrowoffsetY, arrowAtgame
je CheckInMainMenu
call eraseArrows
mov AX, arrowStep
SUB arrowoffsetY, AX
mov Rev, 1
Lea SI, Ship1
mov AX, arrowOffsetXRev
mov shapeOffsetX, AX
mov AX, arrowoffsetY
mov shapeOffsetY, AX
call drawShape
Lea SI, Ship1

mov Rev, 0
mov AX, arrowOffsetX
mov shapeOffsetX, AX
call drawShape
Make_THE_JMP_CLOSER: jmp CheckInMainMenu

downArrow_label: cmp ah, key_downArrow ; down arrow
jne enterKey_label
cmp arrowoffsetY, arrowAtExit
je CheckInMainMenu
call eraseArrows

mov AX, arrowStep
ADD arrowoffsetY, AX
mov Rev, 1
Lea SI, Ship1
mov AX, arrowOffsetXRev
mov shapeOffsetX, AX
mov AX, arrowoffsetY
mov shapeOffsetY, AX
call drawShape
Lea SI, Ship1
mov Rev, 0
mov AX, arrowOffsetX
mov shapeOffsetX, AX
call drawShape

jmp Make_THE_JMP_CLOSER

enterKey_label: cmp ah, key_enter ; enter
jne Make_THE_JMP_CLOSER ; added to prevent other buttons from doing enter's action
; check for the selected button
cmp arrowoffsetY, arrowAtChat
mov currentScreen, 2
je nothingLeft

cmp arrowoffsetY, arrowAtgame
mov currentScreen, 1
je nothingLeft

cmp arrowoffsetY, arrowAtExit
mov currentScreen, 3
je nothingLeft

jmp Make_THE_JMP_CLOSER
nothingLeft:
ENDM

;///////////////////////////////Macros////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////
;///////////////////////////////Extra segment////////////////////////////////////
Expand Down Expand Up @@ -1126,6 +1195,12 @@ extra SEGMENT
;/////////////////////////////////////////////////////////////////////////
;///////////////////////////////Data segment////////////////////////////////////
.data
;////////////////////////////////
; 0-> main menu, 1-> gameloop, 2-> chat, 3-> exit
currentScreen DB ?
invitedScreen DB ?
isSend DB 0
isRec DB 0
;////////////////////////////////
; initializations
REV DB 0
Expand Down Expand Up @@ -1230,12 +1305,18 @@ extra SEGMENT
arrowAtExit equ 344
;////////////////////////////////
; getting players' names ;don't make this 0
getName1 DB " Player1 Name: $"
getName2 DB " Player2 Name: $"
getName1 DB " Player Name: $"
;getName2 DB " Player2 Name: $"
;
enterValidName DB " Please, enter a valid name: $"
enterShorterName DB " Please, enter a shorter name: $"
;
sentGameInvitation DB " You have sent a Game invitation! $"
sentChatInvitation DB " You have sent a chat invitation! $"
recGameInvitation DB " You have recieved a Game invitation! $"
recChatInvitation DB " You have recieved a chat invitation! $"
declinedReq DB " Oops ... Your invitation was declined $"
;
playerName1 DB 10,?,10 dup("$")
playerName2 DB 10,?,10 dup("$")
maxPlayerSize equ 7
Expand Down Expand Up @@ -2807,8 +2888,63 @@ MAIN PROC FAR
;///////////////////////////////Main Menu////////////////////////////////////
mainMenuLoop:
clearWholeScreen
displayMainMenu
checkMainMenuOptions gameLoop, exitProg, chatLoop
displayMainMenu ; doesn't draw the logo
call drawLogo
checkMainMenuOptions

clearWholeScreen
displayMainMenu ; doesn't draw the logo

cmp currentScreen, 1
JNE mm_notGame
printInMsgBoxUP sentGameInvitation
jmp mm_sendResponse

mm_notGame: cmp currentScreen, 2
JNE mm_notChat
printInMsgBoxUP sentChatInvitation
jmp mm_sendResponse

; cmp currentScreen, 3
; JNE mm_notEnd
mm_notChat: ; caused a jump error ;je exitProg
clearWholeScreen
showScreen byebye
returnTODos
;mm_notEnd:

mm_sendResponse: port_checkCanSend mm_waitForResponse
port_sendChar currentScreen
mov isSend, 1

mm_waitForResponse: port_checkReceive mm_sendResponse
port_getChar invitedScreen
mov isRec, 1
;
cmp isSend, 1
JNE mm_sendResponse
mov isSend, 0
cmp isRec, 1
JNE mm_waitForResponse
mov isRec, 0
;
mov al, currentScreen
cmp al, invitedScreen
JE mm_goToScreen
printInMsgBoxLow declinedReq
delay 10000
mov currentScreen, 0
mov invitedScreen, 0
jmp mainMenuLoop
mm_goToScreen: cmp currentScreen, 2
je chatLoop
cmp currentScreen, 1
je gameLoop
cmp currentScreen, 3
clearWholeScreen
showScreen byebye
returnTODos
;jmp mainMenuLoop
;///////////////////////////////CHATModule Loop////////////////////////////////////
chatLoop:
call CHATModule
Expand All @@ -2835,9 +2971,9 @@ MAIN PROC FAR
jz gameLoopRoutine ; check if there is any input
cmp ah, 3Bh ; if the input is F1 then, enter the in game chatting
JNE no_GC ; if not f1 then, continue the game
call inGameChat; enter the in-game chat module
; after leaving the module, return to the loop again without cleaning the boxes
jmp gameLoopRoutine
call inGameChat ; enter the in-game chat module
; after leaving the module, return to the loop again without cleaning the boxes
jmp gameLoopRoutine
no_GC:
inputToMoveShip key_w, key_s, key_a, key_d, key_f, moveShip1_label
inputToMoveShip key_upArrow, key_downArrow, key_leftArrow, key_rightArrow, key_enter, moveShip2_label
Expand Down
2 changes: 1 addition & 1 deletion Code/chat.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ EXTRN DrawMsgWithBox:FAR
include MACROS.inc
;///////////////////////////////Macros////////////////////////////////////
.data
; you only need to edit those numbers to specify the cooardinates you want!
;////////////////////////////// Chat Module Parameters
; you only need to edit those numbers to specify the cooardinates you want!
M_BF_upper equ 3Fh
M_topLeftX_upper equ 0
M_topLeftY_upper equ 0
Expand Down
Loading

0 comments on commit 589a9f0

Please sign in to comment.