< -->

;scrolls.asm
            .model tiny
            .code
            .386
            org 100h
start:
        mov     ax, 4F01h
        mov     cx, 116h
        mov     di, offset vbe_mode_buffer
        int     10h
;! Пропущена проверка наличия режима !
        mov     ax, 4F02h
        mov     bx, 116h
        int     10h
        push    word ptr [ vbe_mode_buffer + 8 ]
        pop     es

        cld

        mov     cx, -1
        mov     si, 100
        mov     bx, 300
        mov     ax, 200

main_loop:
        inc     si
        inc     ax
        inc     bx
        call    fast_circle
        sub     cx, 0000100000100001b ; 0821h
        cmp     si, 350               ; 350 circles
        jb      main_loop
        xor     cx, cx
        call    fast_circle

        xor     bx, bx
        xor     dx, dx
main_loop_2:
	mov     ax, 4F07h
        int     10h
 	mov     ah, 7
        int     21h
        test    al, al
        jnz     exit_loop_2
        int     21h
        cmp     al, 50h
        je      key_down
        cmp     al, 48h
        je      key_up
exit_loop_2:
        mov     ax, 3
        int     10h
        ret
key_down:
        dec     dx
        jns     main_loop_2
key_up:
        inc     dx
        jmp     short main_loop_2

putpixel16b:
        push    dx
        push    di
        xor     di, di
        shrd    di, dx, 6
        shr     dx, 5
        inc     dx
        cmp     dx, current_bank
        jne     bank_switch
switched:
        add     di, bx
        mov     ax, cx
        shl     di, 1
        stosw
        pop     di
        pop     dx
        ret
bank_switch:
        push    bx
        xor     bx, bx
        mov     current_bank, dx
        call    dword ptr [vbe_mode_buffer+0Ch]
        pop     bx
        jmp     short switched

fast_circle:
        push    si
        push    ax
        push    bx
        xor     di, di
        dec     di
        mov     ax, 1
        sub     ax, si
circle_loop:
        inc     di
        cmp     di, si
        ja      exit_main_loop

        pop     bx
        pop     dx
        push    dx
        push    bx

        push    ax
        add     bx, di
        add     dx, si
        call    putpixel16b
        sub     dx, si
        sub     dx, si
        call    putpixel16b
        sub     bx, di
        sub     bx, di
        call    putpixel16b
        add     dx, si
        add     dx, si
        call    putpixel16b
        sub     dx, si
        add     dx, di
        call    putpixel16b
        add     bx, di
        add     bx, si
        call    putpixel16b
        sub     dx, di
        sub     dx, di
        call    putpixel16b
        sub     bx, si
        sub     bx, si
        call    putpixel16b
        add     dx, di
        add     dx, di
        call    putpixel16b
        pop     ax

        test    ax, ax
        js      slop_negative
        mov     dx, di
        sub     dx, si
        shl     dx, 1
        inc     dx
        add     ax, dx
        dec     si
        jmp     circle_loop
slop_negative:
        mov     dx, di
        shl     dx, 1
        inc     dx
        add     ax, dx
        jmp     circle_loop
exit_main_loop:
        pop     bx
        pop     ax
        pop     si
        ret

current_bank    dw      0
vbe_mode_buffer:
                end     start

Назад