blob: 48c718eb387c9dc5623d9405fff4afe5ee53ba00 (
plain) (
blame)
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
|
section .data
; position of the fruit
global fruit_x
global fruit_y
fruit_x db 0
fruit_y db 0
section .text
global draw_fruit
global spawn_fruit
extern width
extern height
extern reset_cursor
extern write_byte
extern move_cursor_right
extern move_cursor_down
spawn_fruit:
; x position
rdtsc
shr ax, 5
div byte [width]
inc ah
mov byte [fruit_x], ah
; y position
rdtsc
shr ax, 5
div byte [height]
inc ah
mov byte [fruit_y], ah
ret
draw_fruit:
push rbx
call reset_cursor
mov bh, byte [fruit_x]
mov bl, byte [fruit_y]
_30:call move_cursor_right
dec bh
cmp bh, 0
jnz _30
_31:call move_cursor_down
dec bl
cmp bl, 0
jnz _31
mov rax, '-'
call write_byte
pop rbx
call reset_cursor
ret
|