-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovingObj.asm
269 lines (193 loc) · 3.67 KB
/
movingObj.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
.model large
.stack 64
.data
;width1 dw 140h ;width (320 pixel)
;height1 dw 0c8h ;height (200 pixel)
time db 0 ;var to check if time changed
ballX dw 0ah
ballY dw 0ah
ballSize dw 04h
arrowX dw 9ah
arrowY dw 9ah
arrowSize dw 04h ;width
arrowL dw 0ch ;length
fireX dw 9ah
fireY dw 9ah
;fire dw 9ah
;fireSize dw 04h
ballSpeed equ 05h ;X velocity of the ball
.code
main proc far
mov ax,@data
mov ds,ax
mov ah,00h
mov al,13h
int 10h
;call clearScreen
;mov ah,0bh
;mov bh,00h
;mov bl,00h
;int 10h
move:
mov ah, 2ch
int 21h
cmp dl,time
je move
mov time,dl
;inc ballX
call clearScreen
inc ballX
call drawBall
move1:
;call moveArrow
call arrow
call drawFire
call moveArrow
call moveFire
;call throw
;call clearScreen
jmp move
ret
main endp
drawBall proc near
mov cx,ballX ; initial position
mov dx,ballY
drawHorizBall:
mov ah,0ch ; pixel
mov al,0fh
mov bh,00h
int 10h
inc cx ;horiz
mov ax,cx
sub ax,ballX
cmp ax,ballSize
jng drawHorizBall
mov cx,ballX ;cx goes back to initial column
inc dx
mov ax,dx
sub ax,ballY ;vertical
cmp ax,ballSize
jng drawHorizBall
ret
drawBall endp
arrow proc near
;xor cx,cx
;xor dx,dx
mov cx,arrowX ; initial position
mov dx,arrowY
drawHorizArr:
mov ah,0ch ; pixel
mov al,0fh
mov bh,00h
int 10h
inc cx ;horiz
mov ax,cx
sub ax,arrowX
cmp ax,arrowSize
jng drawHorizArr
mov cx,arrowX ;cx goes back to initial column
inc dx
mov ax,dx
sub ax,arrowY ;vertical
cmp ax,arrowL
jng drawHorizArr
ret
arrow endp
moveArrow proc near
mov ah,01h ;check key press
int 16h
je noMotion
mov ah,00h ;check which key is pressed (al -> ascii char)
int 16h
;cmp al,64h
;cmp al,61h ;if a or A move left
;je left
;cmp al,41h
;je left
;cmp al,44h
; if d or D move right
cmp ah,4dh
je right
cmp ah,4bh
je left
jmp noMotion
right:
inc arrowX
ret
left:
dec arrowX
noMotion:
ret
moveArrow endp
drawFire proc near
mov cx,fireX ; initial position
mov dx,fireY
drawFire1:
mov ah,0ch ; pixel
mov al,0fh
mov bh,00h
int 10h
;inc cx ;horiz
;mov ax,cx
;sub ax,fireX
;cmp ax,fireSize
;jng drawFire1
;mov cx,fireX ;cx goes back to initial column
;inc dx
;mov ax,dx
;sub ax,fireY ;vertical
;cmp ax,fireSize
;jng drawFire1
ret
drawFire endp
moveFire proc near
mov ah,01h ;check key press
int 16h
je noMotion1
mov ah,00h ;check which key is pressed (al -> ascii char)
int 16h
cmp ah,4bh ;if <- to move left
je left1
; if -> move right
cmp ah,4dh
je right1
jmp noMotion1
right1:
inc fireX
ret
left1:
dec fireX
noMotion1:
ret
moveFire endp
throw proc near
;mov ah,01h ;check key press
;int 16h
;je noMotion2
;mov ah,00h ;check which key is pressed (al -> ascii char)
;int 16h
;cmp al,20h
;je up
;jmp noMotion2
up:
mov ah, 2ch
int 21h
cmp dl,time
je noMotion2
;test1:
mov time,dl
;call clearScreen
dec fireY
cmp fireY,0c8h
jne up
jmp noMotion2
noMotion2:
ret
throw endp
clearScreen proc near
mov ah,00h
mov al,13h
int 10h
ret
clearScreen endp
end main