-
Notifications
You must be signed in to change notification settings - Fork 0
/
sine.inc
executable file
·356 lines (297 loc) · 9.02 KB
/
sine.inc
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
; sine stuff
DYCPSineText PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
DXYCPSineScroll PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
BlitChar PROTO :DWORD, :DWORD, :BYTE, :DWORD, :DWORD,:DWORD,:DWORD,:DWORD
GetSineValue PROTO :DWORD
.data
sinpos dd 0
sinelen dd 512
sineorg dd 0
sineorg2 dd 0
include sinedata.inc
.code
DYCPSineText PROC xPos:DWORD, yPos:DWORD, mArray:DWORD, hPal:DWORD, hImg:DWORD , cBuffer:DWORD, font_allwid:DWORD, charWid:DWORD, charLen:DWORD
LOCAL sineadd:DWORD
LOCAL xposb :DWORD
LOCAL yposb :DWORD
LOCAL char :BYTE
LOCAL arrayad:DWORD
LOCAL count :DWORD
LOCAL sinpos2 :DWORD
pushad
mov eax, sinpos
mov sinpos2, eax
mov eax, yPos
mov yposb, eax
mov eax, xPos
mov xposb, eax
mov count, 0
mov arrayad, 0
nextchar:
mov edi, mArray ; offset of ascii
mov ecx, arrayad
mov al, byte ptr [edi+ecx]
cmp al, 0
je enddraw
cmp al, 0aah ; 0aah == lf
je newline ; newline
mov char, al
invoke GetSineValue , offset SinTabDiv4 ; get sine value
mov sineadd, eax
add eax, 20
add eax, yposb
mov edx, eax
mov edi, cBuffer
invoke BlitChar,edx , xposb, char, hPal, hImg, font_allwid, charWid, charLen ; write char
call ResetPos
mov eax, charWid
add xposb, eax
inc count
inc arrayad
jmp nextchar
newline:
mov eax, sinpos2
mov sinpos, eax
mov sineorg, eax
mov sineorg2, eax
mov eax, count
mov count,0
imul eax, charWid
sub xposb, eax
mov eax, charLen
add yposb, eax
inc arrayad
jmp nextchar
enddraw:
call ReallyResetPos ;reset sinepos
popad
mov eax, 1
Ret
DYCPSineText EndP
.data
msgcharpos dd 0
lettercharpos dd 8
.code
DXYCPSineScroll PROC yPos:DWORD, mArray:DWORD, hPal:DWORD, hImg:DWORD,allwid:DWORD,wid:DWORD,len:DWORD, cBuffer:DWORD
LOCAL xPb:DWORD
LOCAL yPb:DWORD
LOCAL sineadd:DWORD
LOCAL char:BYTE
LOCAL count:DWORD
LOCAL cc:DWORD
LOCAL sinepos1:DWORD
pushad
mov cc,0
mov eax, sinpos
mov sinepos1,eax
mov count, 0
mov xPb, 0
mov esi, mArray
add esi, msgcharpos
mov eax, lettercharpos
add eax, xPb
mov xPb, eax
startscroll:
mov al, byte ptr [esi]
cmp al, 0
je RESET
; otherwise
inc cc
cmp cc, 690/16
ja EndScroll
mov char, al
invoke GetSineValue, offset SinTabDiv4 ; fetch sine
mov sineadd, eax
add eax, 20
add eax, yPos
mov edx, eax
invoke BlitChar, edx, xPb, char, hPal, hImg, allwid, wid, len ; blit character
call ResetPos
inc esi ; next char
mov eax, wid
add xPb, eax
jmp startscroll
DoneOne:
inc msgcharpos ;we completed scrolling 1 char
mov eax, wid
mov lettercharpos, eax
inc esi
inc count
; call ResetPos
mov eax, wid
add xPb, eax
jmp startscroll
EndScroll:
call ReallyResetPos
mov eax, sinepos1
mov sinpos, eax
.if lettercharpos == 0
mov eax, wid
mov lettercharpos, eax
inc msgcharpos
mov eax, count
add msgcharpos, eax
.else
sub lettercharpos, 2
.endif
popad
Ret
RESET:
mov msgcharpos, 0
mov count, 0
mov eax, wid
mov lettercharpos, eax
jmp EndScroll
DXYCPSineScroll EndP
GetSineValue PROC sintab:DWORD
LOCAL sinv:DWORD
pushad
mov esi, sintab
startsine:
mov edx, sinpos
cmp edx, sinelen
je resetp
ja resetp
; else
imul edx, 4 ; dword!
mov eax, dword ptr [esi+edx]
mov sinv, eax
add sinpos,2
popad
mov eax, sinv
add eax, 1
Ret
resetp:
xor edx, edx
mov sinpos, 0
jmp startsine
GetSineValue EndP
ResetPos PROC
pushad
mov sinpos, 0
add sineorg, 2
mov eax, sinelen
cmp sineorg, eax
je reset
ja reset
startr:
mov eax, sineorg
mov sinpos,eax
popad
ret
reset:
mov sineorg, 0
jmp startr
ResetPos EndP
ReallyResetPos PROC
pushad
mov sinpos, 0
mov sineorg, 0
add sineorg2, 2
mov eax, sineorg2
mov sineorg, eax
mov eax, sinelen
cmp sineorg2, eax
je reset
ja reset
startr:
mov eax, sineorg2
mov sinpos, eax
popad
ret
reset:
mov sineorg2,0
jmp startr
ReallyResetPos EndP
BlitChar proc yp:DWORD, xp:DWORD, char:BYTE, fontpal:DWORD, fontimg:DWORD, allwidth:DWORD, charwidth:DWORD, charleng:DWORD
LOCAL gfx_yindex :DWORD
LOCAL sm_allcharswidth :DWORD
LOCAL sm_onecharwidth :DWORD
LOCAL sm_onecharleng :DWORD
LOCAL letter_index :DWORD
LOCAL x_position :DWORD
LOCAL y_position :DWORD
LOCAL msg_index :DWORD
LOCAL sin_status :DWORD
LOCAL sin_addition :DWORD
LOCAL letterx_pos :DWORD
LOCAL lettery_pos :DWORD
LOCAL invert_me :DWORD
LOCAL invert_counter :DWORD
LOCAL draw_buffer :DWORD
pushad
mov eax,yp
mov y_position,eax
mov draw_buffer,edi
mov invert_counter,0
mov msg_index,0
mov eax, xp
mov x_position,eax
mov eax,yp
mov y_position,eax
mov eax, allwidth
mov sm_allcharswidth,eax
mov eax, charwidth
mov sm_onecharwidth,eax
mov eax, charleng
mov sm_onecharleng,eax
mov letterx_pos,0
mov lettery_pos,0
next_char:
mov gfx_yindex,0
movzx edi, char
cmp edi,0
jz end_func
no_newline:
sub edi,20h
mov eax, edi
mov char,al
mov edi,draw_buffer
mov eax,letterx_pos
imul eax,sm_onecharwidth
shl eax,2
add edi,eax
mov eax,lettery_pos
imul eax,sWidth*4
add edi,eax
mov esi,fontimg
movzx eax,char
imul eax,sm_onecharwidth
add esi,eax
mov eax,x_position
shl eax,2
add edi,eax
mov edx,y_position
imul edx,sWidth*4
add edi,edx
incY_line:
xor ecx,ecx
incX_line:
movzx eax,byte ptr [esi+ecx]
mov edx,fontpal
mov eax,[edx+eax*4]
cmp eax,0
jz clip_pixel
plot_to_screen:
stosd
clip_pixel_return:
inc ecx
cmp ecx,sm_onecharwidth
jnz incX_line
mov eax,sm_onecharwidth
mov ecx,sWidth
sub ecx,eax
shl ecx,2
add edi,ecx
add esi,sm_allcharswidth
inc gfx_yindex
mov eax,sm_onecharleng
cmp gfx_yindex,eax
jnz incY_line
end_func:
popad
ret
clip_pixel:
add edi,4
jmp clip_pixel_return
BlitChar endp