-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputMotion.inc
97 lines (88 loc) · 2.19 KB
/
InputMotion.inc
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
TakeGameInput MACRO FrogPos1, BoundsFlag1
;Inputs to this macro are the frog position (word) and a collision flag (byte)
LOCAL KeyPressed
LOCAL Up
LOCAL Down
LOCAL Right
LOCAL Left
LOCAL TouchedUp
LOCAL TouchedDown
LOCAL TouchedLeft
LOCAL TouchedRight
LOCAL Finished
LOCAL AgainU
LOCAL char
LOCAL escape
pusha
;Get key pressed
mov ah,1
int 16h
jnz KeyPressed ;If a key was pressed, let's process it
jmp Finished ;If not, return
KeyPressed:
mov ah,00 ;consume buffer
int 16h ;Ah holds the key status
cmp ah,48h ;(first player up)
je Up
cmp ah,50h ;(first player down)
je Down
cmp ah,4bh ;(first player left)
je Left
cmp ah,4dh ;(first player right)
je Right
cmp al,27
je escape
cmp al,0
jne char
jmp Finished ;otherkey
Up:
mov BoundsFlag1,1 ;Set flag top
sub FrogPos1,32 ;y--
cmp FrogPos1,64 ;if(y>=64 && y<=95) then it's in the top row (pavement)
jb TouchedUp
jae AgainU
jmp Finished
AgainU:
cmp FrogPos1, 95
jbe TouchedUp
jmp Finished
TouchedUp:
jmp Finished
Down:
mov BoundsFlag1,2 ;Set flag buttom
add FrogPos1, 32 ;y++
cmp FrogPos1, 608 ;if(y>=608 && y<=639) then it's in the buttom row (pavement)
jae TouchedDown
jmp Finished
TouchedDown:
jmp Finished
Right:
mov BoundsFlag1,3 ;set flag right
inc FrogPos1 ;x++
mov ax, FrogPos1 ;if((x+1)%32==0) then it's on the right col
inc ax
mov bl,32
div bl
cmp ah,0
je TouchedRight
jmp Finished
TouchedRight:
jmp Finished
Left:
mov BoundsFlag1,4 ;set left
dec FrogPos1
mov ax, FrogPos1 ;if(y%32==0) then it's on the left col
mov bl,32
div bl
cmp ah,0
je TouchedLeft
jmp Finished
TouchedLeft:
jmp Finished
escape:
jmp MainMenu
char:
mov BoundsFlag1, al
Finished:
popa
ENDM TakeGameInput