-
Notifications
You must be signed in to change notification settings - Fork 0
/
volfied_YahliAlton2.asm
585 lines (555 loc) · 9.09 KB
/
volfied_YahliAlton2.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
IDEAL
MODEL small
STACK 100h
DATASEG
x dw 308 ; the cords of the character
y dw 191
xs dw 10 ; the cords of the screen
ys dw 190
xs2 dw 10
ys2 dw 190
startx dw 0
starty dw 0 ;the cords when pressing space
paintx dw 0
painty dw 0
color db 7
color2 db 4 ; צבע השובל
colors db 0eh ;צבע המסך
colord db 5 ;for debug
index dw 0
i dw 0
my_zone db 1h, 2h, 3h, 4h, 5h, 6h, 7h, 8h, 9h
CODESEG
proc my_character ; מציירת קוביה
push [x]
push [y]
mov cx, 3
mov [index], 0
loopXP: ;מעלה את x
; שמירה
push cx
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset my_zone
add bx, index
mov [bx], al
add [index], 1
; ציור
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov al,[color]
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopXP
; שינוי מיקום
sub [y], 1
sub [x], 1
mov cx, 3
loopXN: ;מוריד את x
push cx
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset my_zone
add bx, index
mov [bx], al
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
mov al,[color]
mov ah,0ch
int 10h
pop cx
add [x],-1
loop loopXN
sub [y], 1
add [x], 1
mov cx, 3
loopXP2: ;מעלה את x
push cx
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset my_zone
add bx, index
mov [bx], al
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
mov al,[color]
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopXP2
pop [y]
pop [x]
ret
endp my_character
proc delete_char ; מוחק את הקוביה
mov [color], 0
call my_character
mov [color], 7
; mov bh,0h
; mov cx,[x]
; add cx, 1
; mov dx,[y]
; mov al,[color2]
; mov ah,0ch
; int 10h
; mov bh,0h
; mov cx,[x]
; sub cx, 1
; mov dx,[y]
; mov al,[color2]
; mov ah,0ch
; int 10h
; mov bh,0h
; mov cx,[x]
; mov dx,[y]
; add dx, 1
; mov al,[color2]
; mov ah,0ch
; int 10h
; mov bh,0h
; mov cx,[x]
; mov dx,[y]
; sub dx, 1
; mov al,[color2]
; mov ah,0ch
; int 10h
ret
endp delete_char
proc delete_char2
push [x]
push [y]
mov cx, 3
mov [index], 0
loopDXP: ;מעלה את x ;D - delete, X - x, P - positive, N - negative
; שמירה
push cx
; קליטה מהמערך
mov bx, offset my_zone
add bx, index
mov al, [bx] ;save to al the color
add [index], 1
; ציור
mov bh, 0h
mov cx, [x]
mov dx, [y]
; al - the color from the array
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopDXP
; שינוי מיקום
sub [y], 1
sub [x], 1
mov cx, 3
loopDXN: ;מוריד את x
push cx
; קליטה מהמערך
mov bx, offset my_zone
add bx, index
mov al, [bx] ;save to al the color
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
; the color is - al
mov ah,0ch
int 10h
pop cx
add [x],-1
loop loopDXN
sub [y], 1
add [x], 1
mov cx, 3
loopDXP2: ;מעלה את x
push cx
; קליטה מהמערך
mov bx, offset my_zone
add bx, index
mov al, [bx]
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
; al - the color
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopDXP2
pop [y]
pop [x]
ret
endp delete_char2
proc make_screen
mov cx, 300
loopSXP: ;מעלה את x ;s = screen x
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
add [xs],1
loop loopSXP
mov cx, 180
loopSYP:
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
sub [ys],1
loop loopSYP
mov cx, 300
loopSXN: ;מעלה את x
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
sub [xs],1
loop loopSXN
mov cx, 180
loopSYN:
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
add [ys],1
loop loopSYN
ret
endp make_screen
proc print_array ;for debug
push dx
push ax
push cx
push bx
mov cx, 9
mov dh, 1
mov [i], 0
loopP:
mov dl, 48
add dl, dh
mov ah, 02h
int 21h
mov bx, offset my_zone
add bx, [i]
sub bx, 1
mov dl, 48
add dl, [bx]
mov ah, 02h
int 21h
mov dl, ' '
int 21h
add dh, 1
add [i], 1
loop loopP
mov dl, '-'
int 21h
pop bx
pop cx
pop ax
pop dx
ret
endp print_array
proc red_to_yellow
mov [xs2], 10
mov [ys2], 190
loopaint:
mov bh, 0h
mov cx, [xs2]
mov dx, [ys2]
mov ah, 0dh
int 10h
cmp al, 4
je paint_red
jmp loopend
paint_red:
mov bh,0h
mov cx,[xs2]
mov dx,[ys2]
mov al,[colors]
mov ah,0ch
int 10h
loopend:
add [xs2], 1
cmp [xs2], 310
je upy
jmp loopaint
upy:
mov [xs2], 10
sub [ys2], 1
cmp [ys2], 10
je endpaint
jmp loopaint
endpaint:
ret
endp red_to_yellow
proc paint_area2 ; algorithm flood_fill
; save to al the color
mov bh, 0h
mov cx, [paintx]
push cx ;save cx (paintx)
mov dx, [painty]
push dx ;save dx (painty)
mov ah, 0dh
int 10h
cmp al, 4
je end_func
cmp al, 0eh
je end_func
; paint
mov bh,0h
mov cx,[paintx]
mov dx,[painty]
mov al,[colors]
mov ah,0ch
int 10h
; go to all 4 directions
add paintx, 1
call paint_area2
sub paintx, 2
call paint_area2
add paintx, 1 ;return paintx to default
add painty, 1
call paint_area2
sub painty, 2
call paint_area2
end_func:
pop dx ;get painty
pop cx ;get paintx
mov [paintx], cx ;return to the back cords
mov [painty], dx
ret
endp paint_area2
proc start_paint ;where to start painting ;right now not ready
mov ax, startx
mov [paintx], ax
; add [paintx], 1
mov ax, starty
mov [painty], ax
sub [painty], 2
ret
endp start_paint
start:
mov ax, @data
mov ds, ax
; Graphic mode
mov ax, 13h
int 10h
; screen
call make_screen
mov ah, 00h
int 16h
main:
call my_character
; call print_array
mov ah,00h
int 16h
cmp al, 'w'
je movup
cmp al, 's'
je movdown
cmp al, 'a'
je movleft
cmp al, 'd'
je help ; help jump to movright
cmp al, ' '
je help2 ;jump to space
call delete_char2
jmp main
help:
jmp movright
help2:
jmp space
movup:
call delete_char2
mov bx, offset my_zone
add bx, 7
mov al, [bx] ;save to al the color
cmp al, 0eh
Je paintUP
jmp main
paintUP: ; paint the shvil מצייר שובל
sub [y], 1
jmp main
movdown:
call delete_char2
mov bx, offset my_zone
add bx, 1
mov al, [bx] ;save to al the color
cmp al, 0eh
Je paintD
jmp main
paintD: ; paint the shvil מצייר שובל
add [y], 1
jmp main
movleft:
call delete_char2
mov bx, offset my_zone
add bx, 5
mov al, [bx] ;save to al the color
cmp al, 0eh
Je paintL
jmp main
paintL: ; paint the shvil מצייר שובל
sub [x], 1
jmp main
movright:
call delete_char2
mov bx, offset my_zone
add bx, 3
mov al, [bx] ;save to al the color
cmp al, 0eh
Je paintR
jmp main
paintR:
add [x], 1
jmp main
space:
call delete_char2
mov ax, [x]
mov [startx], ax
mov ax, [y]
mov [starty], ax
; cmp [x], 308
space_main:
; like main
call make_screen
call my_character
; call print_array
mov ah,00h
int 16h
cmp al, 'w'
je movup2
cmp al, 's'
je movdown2
cmp al, 'd'
je movright2
cmp al, 'a'
je help3 ;jmp to movleft2
call delete_char2
jmp space_main
help3:
jmp movleft2
movup2:
call delete_char2
; paint the red dot
sub [y], 1
mov bh,0h
mov cx,[x]
mov dx,[y]
; sub dx, 1
add cx, 1
mov al,[color2]
mov ah,0ch
int 10h
mov bx, offset my_zone
add bx, 7
mov al, [bx] ;save to al the color
cmp al, 0eh
je help_main ;jmp to main
jmp space_main
movdown2:
call delete_char2
; paint the shvil מצייר שובל
add [y], 1
mov bh,0h
mov cx,[x]
mov dx,[y]
sub dx, 2
add cx, 1
mov al,[color2]
mov ah,0ch
int 10h
mov bx, offset my_zone
add bx, 1
mov al, [bx] ;save to al the color
cmp al, 0eh
je help_main ;jmp to main
jmp space_main
help_main:
; call make_screen
call start_paint
call paint_area2
call red_to_yellow
jmp main
movright2:
call delete_char2
; paint
add [x], 1
mov bh,0h
mov cx,[x]
mov dx,[y]
sub dx, 1
; sub cx, 2
mov al,[color2]
mov ah,0ch
int 10h
mov bx, offset my_zone
add bx, 3
mov al, [bx] ;save to al the color
cmp al, 0eh
je help_main ;jmp to main
jmp space_main
movleft2:
call delete_char2
; paint the shvil מצייר שובל
sub [x], 1
mov bh,0h
mov cx,[x]
mov dx,[y]
sub dx, 1
add cx, 2
mov al,[color2]
mov ah,0ch
int 10h
mov bx, offset my_zone
add bx, 5
mov al, [bx] ;save to al the color
cmp al, 0eh
je help_main ;jmp to main
jmp space_main
mainloop:
jmp mainloop
exit :
mov ax, 4c00h
int 21h
END start