forked from AhmedAmrNabil/brick-breaker-assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkInp.asm
70 lines (56 loc) · 1.07 KB
/
checkInp.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
EXTRN PADDLE1_VEL_X:WORD
EXTRN GAME_EXIT_FLAG:BYTE
EXTRN PADDLE_VEL_MAG:WORD
EXTRN CI_MOVE_LEFT:WORD
EXTRN CI_MOVE_RIGHT:WORD
PUBLIC checkInput
.MODEL small
.386
.DATA
.CODE
checkInput PROC FAR
PUSHA ;push all regs to the stack
PUSHF ;push flag register to the stack
IN AL,60h
; check for a or A to move left
CMP AL,1EH
JE moveLeft
; check for d or D to move right
CMP AL,20H
JE moveRight
CMP AL, 1EH + 80H
JE stopMoveLeft
CMP AL, 20H + 80H
JE stopMoveRight
CMP AL, 01h
JE exitGame
JMP exit
moveLeft:
MOV AX, PADDLE_VEL_MAG
NEG AX
MOV CI_MOVE_LEFT, AX
JMP exit
stopMoveLeft:
MOV CI_MOVE_LEFT, 0
JMP exit
moveRight:
MOV AX, PADDLE_VEL_MAG
MOV CI_MOVE_RIGHT,AX
JMP exit
stopMoveRight:
MOV CI_MOVE_RIGHT, 0
JMP exit
exitGame:
MOV GAME_EXIT_FLAG, 1
JMP exit
exit:
MOV AX, CI_MOVE_LEFT
ADD AX, CI_MOVE_RIGHT
MOV PADDLE1_VEL_X, AX
MOV AL, 20h ;The non specific EOI (End Of Interrupt)
OUT 20h, AL
POPF
POPA
IRET
checkInput ENDP
END