@@ -19,23 +19,30 @@ color1 equ GREEN
1919color2 equ BLUE
2020
2121entrypoint:
22- push cs
2322 push cs
2423 pop ds
24+ push cs
2525 pop es
2626 xor bx , bx
2727
2828; palette computation
2929 mov ax , 0x3F00
3030 mov di , pal
31- push di
32- mov cx , 768
31+ mov cx , 768 * 3
3332 rep stosb ; in DI rests offset of waves
3433pal_loop:
35- mov [ bx + pal + color1 + 0 * 3 ], al ; red ascending
36- mov [ bx + pal + color1 + 64 * 3 ], ah ; red descending
37- mov [ bx + pal + color2 + 128 * 3 ], al ; green ascending
38- mov [ bx + pal + color2 + 192 * 3 ], ah ; green descending
34+ mov [ bx + pal + RED + 0 * 3 ], al ; red ascending
35+ mov [ bx + pal + RED + 64 * 3 ], ah ; red descending
36+ mov [ bx + pal + GREEN + 128 * 3 ], al ; green ascending
37+ mov [ bx + pal + GREEN + 192 * 3 ], ah ; green descending
38+ mov [ bx + pal + RED + 256 * 3 ], al ; red ascending
39+ mov [ bx + pal + RED + 320 * 3 ], ah ; red descending
40+ mov [ bx + pal + BLUE + 384 * 3 ], al ; blue ascending
41+ mov [ bx + pal + BLUE + 448 * 3 ], ah ; blue descending
42+ mov [ bx + pal + GREEN + 512 * 3 ], al ; green ascending
43+ mov [ bx + pal + GREEN + 576 * 3 ], ah ; green descending
44+ mov [ bx + pal + BLUE + 640 * 3 ], al ; blue ascending
45+ mov [ bx + pal + BLUE + 704 * 3 ], ah ; blue descending
3946 dec ah
4047 inc al
4148 add bx , 3
@@ -44,7 +51,6 @@ pal_loop:
4451
4552; waves computation
4653 mov cx , 0x100 ; array size of 0x100
47- push cx ; store same for palette
4854 finit ; coprocessor init
4955wave_loop:
5056 fld dword [ konst ]
@@ -86,15 +92,12 @@ wave_loop:
8692 out dx , al
8793 sti
8894
89- set_palette:
90- pop cx
91- pop dx
92- mov ax , 0x1012
93- xor bx , bx
94- int 0x10 ; use bios service call to set the palette
95+ mov cx , 0x100
96+ mov dx , pal
97+ call set_palette
9598
9699 push word 0xA000
97- pop es ; use 386 segment register fs, useful for xlatb instruction
100+ pop es
98101
99102waitvr: mov dx , 0x3DA
100103w1: in al , dx
@@ -135,15 +138,50 @@ s1: lodsb
135138 sub byte [ pos2 ], spd2
136139 add byte [ pos3 ], spd3
137140 sub byte [ pos4 ], spd4
141+
142+ in al , 0x60
143+ dec al
144+ jnz waitvr
145+
146+ push cx
147+ push dx
148+ mov dx , [ pal_offset ]
149+ add dx , 768
150+ cmp dx , pal3
151+ jng next_pal
152+ mov dx , pal1 ; reset offset
153+ next_pal:
154+ mov [ pal_offset ], dx
155+ mov cx , 0x100
156+ call set_palette
157+ pop dx
158+ pop cx
138159 jmp waitvr
139160
161+ set_palette: ; cx = colors, es:dx = palette address offset
162+ push es
163+ push ax
164+ push bx
165+ push cs
166+ pop es
167+ mov ax , 0x1012
168+ xor bx , bx
169+ int 0x10 ; use bios service call to set the palette
170+ pop bx
171+ pop ax
172+ pop es
173+ ret
174+
140175; the end of code section
141176
142177pos1: db 0
143178pos2: db 0
144179pos3: db 0
145180pos4: db 0
146181
182+ pal_offset:
183+ dw pal1
184+
147185; pi = 355 ⁄ 113
148186konst: dd 355 . 0 / 113 / 128 ; pi / 128
149187THIRTY: dw 30
@@ -159,6 +197,10 @@ tpos2: rb 1
159197tpos3: rb 1
160198tpos4: rb 1
161199
162- pal: rb 768
200+ pal:
201+ pal1: rb 768
202+ pal2: rb 768
203+ pal3: rb 768
204+
163205waves: rb 256
164206
0 commit comments