-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.asm
426 lines (343 loc) · 6.25 KB
/
draw.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
; All the procs that works with pixels.
proc DrawPix
push ax
push bx
push cx
push dx
mov bh, 0
mov cx,[x]
mov dx,[y]
mov ax,[color]
mov ah, 0ch
int 10h
pop dx
pop cx
pop bx
pop ax
ret
endp DrawPix
; properties are being delivered throw the memory
proc DrawRect
push ax
push cx
mov cx, [rectHeight]
add [y], cx
Rect1:
push cx
mov cx, [rectWidth]
add [x], cx
Rect2:
dec [x]
call DrawPix
loop Rect2
pop cx
dec [y]
loop Rect1
pop cx
pop ax
ret
endp DrawRect
proc DrawScrn
push ax
push cx
push [y]
mov cx, 4
Scrn1:
push cx
push [x]
mov cx, 16
Scrn2:
call DrawRect
mov ax, [spacingX]
add [x], ax
loop Scrn2
pop [x]
pop cx
mov ax, [spacingY]
add [y], ax
loop Scrn1
pop [y]
pop cx
pop ax
ret
endp DrawScrn
proc InitScrn
; lower layer
mov [x], 54
mov [y], 80
mov [rectWidth], 10
mov [rectHeight], 18
mov [spacingX], 16
mov [spacingY], 28
mov [color], normal
call DrawScrn
; upper layer
mov [x], 55
mov [y], 82
mov [rectWidth], 8
mov [rectHeight], 14
mov [spacingX], 16
mov [spacingY], 28
mov [color], off
call DrawScrn
; The long vertical rectangle to the right
; silver Theme
mov [color], silver
mov [x], 40
mov [y], 0
mov [rectWidth], 6
mov [rectHeight], 200
call DrawRect
mov [x], 0
mov [rectWidth], 320
mov [rectHeight], 6
mov [y], 0 ; from the beginning.
call DrawRect
mov [y], 193 ; windowHeight - rectHeight - the first pixel that bugs me.
call DrawRect
; -----
mov [x], 50
mov [y], 80
mov [rectWidth], 2
mov [rectHeight], 102 ; spacingY (init) * 3 + rect height (lower layer) = > 28 * 3 + 18
mov [color], silver
push cx
mov cx, 4
Setup:
call DrawRect
add [x], 64 ; spacingX
loop Setup
pop cx
call DrawCurrBit
call PlayingBtn
call DrawSpd
ret
endp InitScrn
proc DrawSpd
; cleans the speed
mov [x], 54
mov [y], 14
mov [rectHeight], 18 ;
mov [rectWidth], 40 ; maxSpeed * width + spacingSpd = 10 * (2 + 2) => 40
mov [color], background
call DrawRect
; draws the new speed
push cx
push dx
mov [rectWidth], 2
mov [color], silver
xor cx, cx
mov cl, 11d ; 10 speed lvls Therefore 11 minus speed so if speed is 10
sub cl, [speed]
SpdLoop:
call DrawRect
mov dx, [spacingSpd]
add [x], dx
loop SpdLoop
pop dx
pop cx
ret
endp DrawSpd
proc PlayingBtn
mov [x], 8
mov [y], 14 ; same height as speed
mov [rectWidth], 24
mov [rectHeight], 18
cmp [isPlaying], 0
jz RedBtn
GreenBtn:
mov [color], green
call DrawRect
ret
RedBtn:
mov [color], red
call DrawRect
ret
endp PlayingBtn
proc DrawPointer
; cleans the last pointer
mov [x], 55
mov [y], 186
mov [rectWidth], 248 ; 16 * (8 + 8) - rectWidth = 256 - 8 = 248
mov [rectHeight], 4
mov [color], background
call DrawRect
; draws the new pointer
push cx
push dx
mov [x], 55
mov [y], 186
mov [rectWidth], 8
mov [rectHeight], 4
mov [spacingX], 16
mov [color], silver
mov dx, [spacingX]
mov cx, [pointer]
PointLoop:
add [x], dx
loop PointLoop
call DrawRect
pop dx
pop cx
ret
endp DrawPointer
; -----
; Tracks
; -----
proc LowerBit ; lower layer
mov [x], 54
mov [y], 80
mov [rectWidth], 10
mov [rectHeight], 18
mov [spacingX], 16
mov [spacingY], 28
ret
endp LowerBit
proc UpperBit ; upper layer
mov [x], 55
mov [y], 82
mov [rectWidth], 8
mov [rectHeight], 14
mov [spacingX], 16
mov [spacingY], 28
ret
endp UpperBit
proc DrawCurrBit
; lower layer settings
call LowerBit
push [currIndex]
mov [color], curr ; means that we are currently on the track bit.
call DrawLayer
push ax
push bx
push cx
push dx
push si
mov cx, [currIndex]
mov cl, ch
mov ch, 0
mov si, cx ; now we have in cx the rows.
add si, cx ; because we are using words.
mov cx, [currIndex] ; now we have in cx the columns.
mov dx, 1
; we rol 1 cl times in order to mask the bit of the tracks cl is the curr position.
rol dx, cl
mov bx, offset Tracks
mov ax, [bx + si]
and ax, dx
pop si
pop dx
pop cx
pop bx
pop ax
; upper layer settings
call UpperBit
jz BitOff1
BitOn1:
; upper layer Color.
mov [color], on
push [currIndex]
call DrawLayer
ret
BitOff1:
; upper layer Color.
mov [color], off
push [currIndex]
call DrawLayer
ret
endp DrawCurrBit
proc ClnHistBit
; lower layer
call LowerBit
push [histIndex]
mov [color], normal ; means that we are currently on the track bit.
call DrawLayer
push ax
push bx
push cx
push dx
push si
mov cx, [histIndex]
mov cl, ch
mov ch, 0
mov si, cx ; now we have in cx the rows.
add si, cx ; because we are using words.
mov cx, [histIndex] ; now we have in cx the columns.
mov dx, 1
; we rol 1 cl times in order to mask the bit of the tracks cl is the curr position.
rol dx, cl
mov bx, offset Tracks
mov ax, [bx + si]
and ax, dx
pop si
pop dx
pop cx
pop bx
pop ax
; upper layer settings
call UpperBit
jz BitOff2
BitOn2:
; upper layer Color.
mov [color], on
push [histIndex]
call DrawLayer
ret
BitOff2:
; upper layer Color.
mov [color], off
push [histIndex]
call DrawLayer
ret
endp ClnHistBit
proc DrawLayer
push bp
mov bp, sp
push cx
push dx
mov dx, [spacingX]
mov cx, [bp + 4]
mov ch, 0 ; get the Rows
DrawLayer1:
add [x], dx
loop DrawLayer1
mov dx, [spacingY]
mov cx, [bp + 4]
mov cl, ch
mov ch, 0 ; get the Columns
DrawLayer2:
add [y], dx
loop DrawLayer2
call DrawRect
pop dx
pop cx
pop bp
ret 2
endp DrawLayer
proc MarkBit
push ax
push bx
push cx
push dx
push si
mov cx, [currIndex]
mov cl, ch
mov ch, 0
mov si, cx ; now we have in cx the rows.
add si, cx ; because we are using words.
mov cx, [currIndex] ; now we have in cx the columns.
mov dx, 1
; we rol 1 cl times in order to mask the bit of the tracks cl is the curr position.
rol dx, cl
mov bx, offset Tracks
mov ax, [bx + si]
xor ax, dx
mov [bx + si], ax
pop si
pop dx
pop cx
pop bx
pop ax
call DrawCurrBit
ret
endp MarkBit