-
Notifications
You must be signed in to change notification settings - Fork 1
/
rtplasma.asm
233 lines (187 loc) · 3.46 KB
/
rtplasma.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
; (C) May 31, 2001 M. Feliks
include sys.inc
.model tiny
.code
.386
org 100h
entrypoint:
call do_startup
call generate_palette
call init_costable
mov si, offset palette
call set_palette
progy_loop:
call plasma
call timer_wait
call copy_buffer
mov ah, 6h
mov dl, 0ffh
int 21h
jz progy_loop
call do_shutdown
generate_palette proc
push bp
mov bp, sp
sub sp, 6
mov di, offset palette
mov cx, 256
cld
fldz
fstp dword ptr [bp-4]
gp_loop:
fld dword ptr [bp-4]
fld st
fsin
fmul col_const
fistp word ptr [bp-6]
mov ax, word ptr [bp-6]
sar ax, 2
and ax, 255
push ax
xor al, al
stosb
pop ax
stosb
stosb
fadd delta_c
fstp dword ptr [bp-4]
dec cx
jnz gp_loop
mov sp, bp
pop bp
ret
endp
plasma proc
push es
mov es, buffer_seg
xor di, di
mov dx, word ptr rver_1
mov cx, 200/2
@@ver_loop:
mov si, dx
and si, 0ffh
mov al, byte ptr costable[si]
mov si, dx
shr si, 8
add al, byte ptr costable[si]
mov bx, word ptr rhor_1
push cx
mov cx, 320/2
@@hor_loop:
push ax
mov si, bx
and si, 0ffh
add al, byte ptr costable[si]
mov si, bx
shr si, 8
add al, byte ptr costable[si]
mov ah, al
stosw
mov word ptr es:[di+320-2], ax
pop ax
add bl, 4
add bh, 1
dec cx
jnz @@hor_loop
add dl, 4
add dh, 5
add di, 320
pop cx
dec cx
jnz @@ver_loop
add rver_1, -4
add rver_2, -1
add rhor_1, 2
add rhor_2, 3
pop es
ret
endp
comment #
plasma proc
push es
mov es, buffer_seg
xor di, di
mov dx, word ptr rver_1
mov cx, 200
@@ver_loop:
mov si, dx
and si, 0ffh
mov al, byte ptr costable[si]
mov si, dx
shr si, 8
add al, byte ptr costable[si]
mov bx, word ptr rhor_1
push cx
mov cx, 320
@@hor_loop:
push ax
mov si, bx
and si, 0ffh
add al, byte ptr costable[si]
mov si, bx
shr si, 8
add al, byte ptr costable[si]
stosb
pop ax
add bl, 4
add bh, 1
dec cx
jnz @@hor_loop
add dl, 4
add dh, 5
pop cx
dec cx
jnz @@ver_loop
add rver_1, -4
add rver_2, -1
add rhor_1, 2
add rhor_2, 3
pop es
ret
endp
#
init_palette proc
mov dx, 03c8h
xor ax, ax
out dx, al
inc dx
mov cx, 256
@@color:
out dx, al
out dx, al
out dx, al
inc al
loop @@color
ret
endp
init_costable proc
mov di, offset costable
xor cx, cx
@@loop:
mov _f16, cx
fild _f16
fmul pi_128
fcos
fmul scale_const
fistp _f16
mov ax, _f16
stosb
inc cx
cmp cx, 256
jne @@loop
ret
endp
.data
col_const dd 255.0
delta_c dd 0.01232 ; (180/255)*PI/180
pi_128 dd 0.02454369260617
scale_const dd 32.0
.data?
_f16 dw ?
palette db 768 dup(?)
costable db 256 dup(?)
rver_1 db ?
rver_2 db ?
rhor_1 db ?
rhor_2 db ?
end entrypoint