-
Notifications
You must be signed in to change notification settings - Fork 0
/
plasma.nasm
210 lines (158 loc) · 10.8 KB
/
plasma.nasm
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
org 100h ; offset for com
section .data
sintb: db 0x80,0x82,0x84,0x86,0x88,0x8b,0x8d,0x8f,0x91,0x93,0x96,0x98,0x9a,0x9c,0x9e,0xa0,0xa3,0xa5,0xa7,0xa9,0xab,0xad,0xaf,0xb1,0xb3,0xb5,0xb7,0xb9,0xbb,0xbd,0xbf,0xc1,0xc3,0xc5,0xc7,0xc9,0xca,0xcc,0xce,0xd0,0xd1,0xd3,0xd5,0xd6,0xd8,0xda,0xdb,0xdd,0xde,0xe0,0xe1,0xe3,0xe4,0xe5,0xe7,0xe8,0xe9,0xea,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf7,0xf8,0xf9,0xf9,0xfa,0xfb,0xfb,0xfc,0xfc,0xfd,0xfd,0xfd,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfe,0xfd,0xfd,0xfd,0xfc,0xfc,0xfb,0xfb,0xfa,0xf9,0xf9,0xf8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ef,0xf5,0xf5,0xf5,0xfb,0xfb,0xfb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,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0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
section .text
start:
push es
; gfx mode
mov al, 13h
int 10h
; screen ptr
mov ax, 0a000h
mov es, ax
; clear screen
xor di, di ; offset
mov ax, 0 ; color index
mov cx, 320*200/2 ; num repeats
rep stosw
pop es
; set palette
mov ax, 1012h
xor bx, bx
mov cx, 256
mov dx, palette
int 10h
call generate_plasma
.loop_effect:
; TODO: wait for retrace
call cycle_palette
; check key
mov ah, 0bh
int 21h
cmp al, 0
je .loop_effect
; text mode
mov ax, 0003h
int 10h
ret
generate_plasma:
push ax
push bx
push cx
push dx
push es
; screen ptr
mov ax, 0a000h
mov es, ax
xor dx, dx ; offset
xor cx, cx ; y
.next_row:
xor bx, bx ; x
.next_pixel:
push bx
push cx
push dx
;shl bx, 1
shl cx, 1
xor ax, ax
; x
push ax
push bx
xor dx, dx
mov ax, bx
mov bx, 360
div bx
mov bx, dx
mov dx, [sintb+bx]
pop bx
pop ax
add ax, dx
; y
push ax
push bx
push cx
xor dx, dx
mov ax, cx
mov bx, 360
div bx
mov bx, dx
mov dx, [sintb+bx]
pop cx
pop bx
pop ax
add ax, dx
; y+x
push ax
push bx
push cx
add cx, bx
xor dx, dx
mov ax, cx
mov bx, 360
div bx
mov bx, dx
mov dx, [sintb+bx]
pop cx
pop bx
pop ax
add ax, dx
pop dx
pop cx
pop bx
mov di, dx
mov byte [es:di], al
inc bx
inc dx
cmp bx, 320
jl .next_pixel
inc cx
cmp cx, 200
jl .next_row
pop es
pop dx
pop cx
pop bx
pop ax
ret
cycle_palette:
push ax
push bx
push cx
push dx
mov al, [palette]
mov [palette+765], al
mov al, [palette+1]
mov [palette+766], al
mov al, [palette+2]
mov [palette+767], al
xor bx, bx
.loop:
mov al, [palette+bx]
mov dl, [palette+bx+3]
mov [palette+bx], dl
mov [palette+bx+3], al
inc bx
mov al, [palette+bx]
mov dl, [palette+bx+3]
mov [palette+bx], dl
mov [palette+bx+3], al
inc bx
mov al, [palette+bx]
mov dl, [palette+bx+3]
mov [palette+bx], dl
mov [palette+bx+3], al
inc bx
cmp bx, 768
jl .loop
; set palette
mov ax, 1012h
xor bx, bx
mov cx, 256
mov dx, palette
int 10h
pop dx
pop cx
pop bx
pop ax
ret