< -->
.model tiny
.code
.386
org 100h
SCALE_H equ 7
SCALE_V equ 9
start proc near
cld
mov di, offset cos_table
mov ebx, 16777137
mov cx, 2048
call build_table
mov ax, 0013h
int 10h
mov ax, 1012h
mov bx, 70h
mov cx, 4
mov dx, offset palette
int 10h
push 0A000h
pop es
main_loop:
call display_picture
mov dx, 5000
xor cx, cx
mov ah, 86h
int 15h
mov ah, 11h
int 16h
jz main_loop
mov ax, 0003h
int 10h
ret
start endp
;------------build_table--------------
build_table proc near
mov dword ptr [di+4], ebx
sub cx, 2
add di, 8
mov eax, ebx
build_table_loop:
imul ebx
shrd eax, edx, 23
sub eax, dword ptr [di-8]
stosd
loop build_table_loop
ret
build_table endp
;-------------display_picture----------------
display_picture proc near
call move_point
mov bp, 73h
mov bx, 3
call draw_point
dec bp
dec bx
call draw_point
dec bp
dec bx
call draw_point
dec bp
dec bx
call draw_point
ret
display_picture endp
;----------------------
draw_point proc near
movzx cx, byte ptr point_x[bx]
movzx dx, byte ptr point_y[bx]
call putpixel_13h
ret
draw_point endp
;---------------------
move_point proc near
inc word ptr time
and word ptr time, 2047
mov eax, dword ptr point_x
mov ebx, dword ptr point_y
mov dword ptr point_x[1], eax
mov dword ptr point_y[1], ebx
mov di, word ptr time
imul di, di, SCALE_H
and di, 2047
shl di, 2
mov ax, 50
mul word ptr cos_table[di+2]
mov dx, 0A000h
sub dx, ax
mov byte ptr point_x, dh
mov di, word ptr time
imul di, di, SCALE_V
add di, 256 ;512-=-=-=256
and di, 2047
shl di, 2
mov ax, 50
mul word ptr cos_table[di+2]
mov dx, 06400h
sub dx, ax
mov byte ptr point_y, dh
ret
move_point endp
;----------------------
putpixel_13h proc near
push di
mov ax, dx
shl ax, 8
mov di, dx
shl di, 6
add di, ax
add di, cx
mov ax, bp
stosb
pop di
ret
putpixel_13h endp
;=================================
point_x db 0FFh, 0FFh, 0FFh, 0FFh
point_y db 0FFh, 0FFh, 0FFh, 0FFh
db ?
time dw 0
palette db 3Fh, 3Fh, 3Fh
db 30h, 30h, 30h
db 20h, 20h, 20h
db 10h, 10h, 10h
cos_table dd 1000000h
end start
Назад