-
Notifications
You must be signed in to change notification settings - Fork 1
/
movback.asm
186 lines (149 loc) · 2.77 KB
/
movback.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
; (C) July 31, 2001 M. Feliks
include sys.inc
VC_DELTA equ 1
HC_DELTA equ 2
.model tiny
.code
.386
org 100h
entrypoint:
call do_startup
call alloc_seg
or ax, ax
jz quit_effect
mov background_seg, ax
call init_sine
call init_background
call set_moveback_palette
main_loop:
add ver_counter, VC_DELTA
add hor_counter, HC_DELTA
call animation
call timer_wait
call copy_buffer
mov ah, 6h
mov dl, 0ffh
int 21h
jz main_loop
quit_effect:
mov ax, background_seg
call free_seg
call do_shutdown
animation proc
@@offx equ word ptr [bp-2]
@@offy equ word ptr [bp-4]
push bp
mov bp, sp
sub sp, 4
mov bx, ver_counter
and bx, 255
shl bx, 1
mov ax, word ptr sinetable[bx]
mov @@offy, ax
mov bx, hor_counter
and bx, 255
shl bx, 1
mov ax, word ptr sinetable[bx]
mov @@offx, ax
push ds
push es
mov ax, buffer_seg
mov es, ax
xor di, di
mov ax, background_seg
mov ds, ax
mov dx, 199
a_ver:
mov cx, 319
mov bx, @@offy
add bx, dx
and bx, 255
shl bx, 8
a_hor:
mov ax, @@offx
add ax, cx
and ax, 255
mov si, bx
add si, ax
mov al, byte ptr [si]
stosb
dec cx
jge a_hor
dec dx
jge a_ver
pop es
pop ds
mov sp, bp
pop bp
ret
endp
set_moveback_palette proc
mov dx, 03c8h
xor ax, ax
out dx, al
inc dx
mov cx, 256
spal_loop:
mov al, ah
shr al, 2
out dx, al
out dx, al
out dx, al
inc ah
dec cx
jnz spal_loop
ret
endp
init_background proc
push es
mov ax, background_seg
mov es, ax
xor di, di
xor dx, dx
ib_ver:
xor cx, cx
ib_hor:
mov ax, cx
xor ax, dx
stosb
inc cx
cmp cx, 256
jne ib_hor
inc dx
cmp dx, 256
jne ib_ver
pop es
ret
endp
init_sine proc
@@angle equ dword ptr [bp-4]
push bp
mov bp, sp
sub sp, 4
mov @@angle, 0
mov cx, 256
mov di, offset sinetable
is_loop:
fld @@angle
fld st(0)
fsin
fmul scale_sin
fistp word ptr [di]
fadd delta_angle
fstp @@angle
add di, 2
dec cx
jnz is_loop
mov sp, bp
pop bp
ret
endp
.data
delta_angle dd 0.0245436926066 ; pi/128
scale_sin dd 128.0
ver_counter dw 0
hor_counter dw 0
.data?
background_seg dw ?
sinetable dw 256 dup(?)
end entrypoint