-
Notifications
You must be signed in to change notification settings - Fork 1
/
screen.asm
159 lines (126 loc) · 1.75 KB
/
screen.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
; Output line feed
_new_line:
pusha
mov eax, 4
mov ebx, 1
mov ecx, new_line
mov edx, 1
int 0x80
popa
ret
; Clear screen
_clear_screen:
pusha
mov ecx, 256
.loop:
call _new_line
loop .loop
popa
ret
; Output String of n length
; n -> edx, addr of first char in ecx
_print_line:
pusha
mov eax, 4
mov ebx, 1
int 0x80
popa
ret
; copy n bytes n -> ecx | dest -> edi | src -> esi
_n_cpy:
pusha
.loop:
movsb
loop .loop
popa
ret
; n cmp -> compare strings | n-> ecx | str1 -> edi | str2 -> esi | returns 0 in eax if match
_n_cmp:
pusha
.loop:
mov al, [esi]
mov bl, [edi]
cmp al, bl
jne .end
inc edi
inc esi
loop .loop
popa
mov eax, 0
ret
.end:
popa
mov eax, 1
ret
_update_targets:
pusha
mov ecx, 5630
mov esi, world + 5630
.loop:
cmp [esi], byte '*'
jne .next
mov [esi], byte ' '
add esi, 120
mov [esi], byte '*'
sub esi, 120
.next:
dec esi
loop .loop
; clear * at bottom
mov ecx, 200
mov esi, world + 5640
.loop2:
cmp [esi], byte '*'
jne .next2
mov [esi], byte ' '
.next2:
inc esi
loop .loop2
popa
ret
; render screen
_render:
pusha
mov eax, [playerX]
mov eax, [playerY]
; copy world into screen buffer
mov edi, screen
mov esi, world
mov ecx, world_len
call _n_cpy
; copy player into world
mov edi, screen
mov eax, 0
mov edx, 0
mov al, [playerY]
mov dl, 120
mul dl
add edi, eax
add edi, [playerX]
; see if player is hitting a target if so add to score
pusha
add edi, 1
cmp [edi - 120], byte '*'
je .s_add
cmp [edi], byte '*'
je .s_add
jmp .s_end
.s_add:
add [score], dword 50
.s_end:
sub edi, 1
popa
; end score calc
mov esi, player
mov ecx, 3
pusha
.loop:
movsb
loop .loop
popa
; Print screen
mov ecx, screen
mov edx, world_len
call _print_line
popa
ret