-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFRAME.ASM
363 lines (286 loc) · 7.84 KB
/
FRAME.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
.model tiny
.data
VIDEOSEG = 0b800h
CONSOLE_WIDTH = 25d
CONSOLE_LENGTH = 80d
Msg db 'Dear RT girls free me$'
MSG_SIZE = 21d
MSG_COLOR = 7400h
FRAME_WIDTH = 3d
FRAME_LENGTH = MSG_SIZE + 2d
Elems db 21h, 03h, 21h, 03h, 20h, 03h, 21h, 03h, 21h ; ! 03h !
; 03h 03h
; ! 03h !
; Elems db 20h, 20h, 20h, 20h, 20h, 20h, 20h, 20h, 20h ; _ _ _
; _ _ _
; _ _ _
; '_' - Netflix space
Status db 01h, 01h
;------------------------------------------------
; Calculate a two-digit number (decimal number system)
;
; Entry: SI - addr of 2-byte array containing number
; Exit: AH - two-digit number
; Destr: AX, SI
;------------------------------------------------
CalcTwoDigitNum proc
mov ah, [si] ; calculation of the highest digit
inc si
sub ah, 30h
mov al, 10d
mul ah
mov ah, al
mov al, [si] ; calculating of the lowest digit
inc si
sub al, 30h
add ah, al ; number
ret
CalcTwoDigitNum endp
;------------------------------------------------
; Calculate start point
;
; Entry: SI - args cmd addr (81h)
; Exit: DI - start point of frame
; Destr: AX, DI, SI
;------------------------------------------------
CalcStPt proc
mov si, CMD_LINE
call CalcTwoDigitNum
mov al, CONSOLE_LENGTH * 2d
mul ah
mov di, ax
inc si
call CalcTwoDigitNum
mov al, 2d
mul ah
add di, ax
ret
CalcStPt endp
;------------------------------------------------
; Draw a line in a frame
;
; Entry: AH - color (attr) of line
; CX - lenght of string
; SI - addr of 3-byte array containing line elements
; DI - adress of start of line
; Note: ES - videoseg addr (0b800h)
; Exit: None
; Destr: AX, CX, DI, SI
;------------------------------------------------
DrawLine proc ; cld (Clear Dest Flag) (++)
; std (Set Dest Flag) (--)
mov al, [si] ; lodcb (Load String of )
inc si
mov es:[di], ax ; stosw (Store String of Words)
add di, 2d
mov al, [si] ; lodcb
inc si
sub cx, 2d
jbe @@stopLine
@@nextSym: mov es:[di], ax ; rep stosw
add di, 2d
loop @@nextSym
mov al, [si] ; lodsb
mov es:[di], ax ; stosw
add di, 2d
@@stopLine: ret
DrawLine endp
;------------------------------------------------
; Draw frame
;
; Entry: None
; Note: ES - videoseg addr (0b800h)
; Exit: None
; Destr: AX, BX, CX, DX, DI, SI
;------------------------------------------------
DrawFrame proc
mov ax, VIDEOSEG
mov es, ax
;================================================
; Draw first line of frame
;------------------------------------------------
call CalcStPt
mov si, offset Elems
mov ax, MSG_COLOR
mov cx, FRAME_LENGTH
call DrawLine
;================================================
;================================================
; Draw the main part of frame
;------------------------------------------------
mov dh, 1d
mov cx, FRAME_WIDTH
sub cx, 2d
lp1: call CalcStPt
mov ah, dh
mov al, CONSOLE_LENGTH * 2d
mul ah
add di, ax
mov ax, MSG_COLOR
mov bx, cx
mov cx, FRAME_LENGTH
mov si, offset Elems
add si, 3d
call DrawLine
inc dh
mov cx, bx
loop lp1
;================================================
mov si, offset Msg ; displaying text in a frame
sub di, 2d * FRAME_LENGTH
add di, 2d
mov cx, MSG_SIZE
lp: mov bl, [si]
mov es:[di], bl
inc si
add di, 2d
loop lp
;================================================
; Draw last line of frame
;------------------------------------------------
mov si, offset Elems
add si, 6d
mov bx, si
call CalcStPt
mov ah, dh
mov al, CONSOLE_LENGTH * 2d
mul ah
add di, ax
mov si, bx
mov ax, MSG_COLOR
mov cx, FRAME_LENGTH
call DrawLine
;================================================
ret
DrawFrame endp
;------------------------------------------------
; Function add
;
; Entry: SI - addr number
; Exit: increasing the number by one
; Destr: AX, SI
;------------------------------------------------
FuncAdd proc
inc si
mov al, [si]
cmp al, 09d
je TEN_ADD
add al, 01h
mov [si], al
jmp NO_TEN_ADD
TEN_ADD: mov al, 30h
mov [si], al
dec si
mov al, [si]
add al, 1h
mov [si], al
NO_TEN_ADD:
ret
FuncAdd endp
;------------------------------------------------
; Function sub
;
; Entry: SI - addr number
; Exit: dec the number by one
; Destr: AX, SI
;------------------------------------------------
FuncSub proc
inc si
mov al, [si]
cmp al, 00d
je TEN_SUB
sub al, 1h
mov [si], al
jmp NO_TEN_SUB
TEN_SUB: mov al, 39h
mov [si], al
dec si
mov al, [si]
sub al, 1h
mov [si], al
NO_TEN_SUB:
ret
FuncSub endp
;-------------------------------------------------
; Change coordinates start point
;
; Entry: BP - bypass direction ( 01h - down, 00h - up)
; DS - bypass direction ( 01h - right, 00h - left)
; Note: ES - videoseg addr (0b800h)
; Exit: new coordinates
; Destr: AX, BX, SI, BP
;-------------------------------------------------
ChangeCordStPr proc
mov si, CMD_LINE
call CalcTwoDigitNum
mov si, offset Status
cmp ah, 00d
jne skip11
mov bl, 01h
mov [si], bl
skip11: cmp ah, CONSOLE_WIDTH - FRAME_WIDTH
jne skip12
mov bl, 00h
mov [si], bl
skip12: mov bl, 01h
cmp [si], bl
je add1
mov si, CMD_LINE
call FuncSub ; function sub
jmp sub1
add1: mov si, CMD_LINE
call FuncAdd ; function add
sub1: mov si, CMD_LINE
add si, 3
call CalcTwoDigitNum
mov si, offset Status
inc si
cmp ah, 00d
jne skip21
mov bl, 01h
mov [si], bl
skip21: cmp ah, CONSOLE_LENGTH - FRAME_LENGTH
jne skip22
mov bl, 00h
mov [si], bl
skip22: mov bl, 01h
cmp [si], bl
je add2
mov si, CMD_LINE
add si, 3
call FuncSub ; function sub
jmp sub2
add2: mov si, CMD_LINE
add si, 3
call FuncAdd ; function add
sub2:
ret
ChangeCordStPr endp
.code
org 100h
locals @@ ; (lb - global label, @@lb - local label)
.getch macro
nop
xor ah, ah
int 16h
nop
endm
CMD_LINE = 82h
Start: mov ax, VIDEOSEG
mov es, ax
lp2: call DrawFrame
call ChangeCordStPr
mov ax, 8600h ; pause for 0,4 second
mov cx, 0006h
mov dx, 1a80h
int 15h
mov ax, 0h ; clearing the console
mov di, 0h
mov cx, 4000d
rep stosw
mov ax, 6B00h
int 21h
jmp lp2
mov ax, 4c00h
int 21h
end Start