vsync.asm
comment *
MASM32 SDK
ml /c /AT /Fl vsync.asm
link16 /t vsync;
*
.model tiny
VRAMSEG equ 0a000h
CLS equ 1ah
.code
.186
org 0100h
main proc
mov ah, 02h
mov dl, CLS
int 21h
push es
mov ax, 350ah ; ベクタ取得
int 21h
mov old0a_off, bx
mov old0a_seg, es
pop es
mov dx, offset myint0a
mov ax, 250ah ; ベクタ設定
int 21h
in al, 02h
and al, 0fbh ; VSYNC割り込みマスク on
out 02h, al
sti
out 64h, al ; VSYNCリセット
@@loop:
mov ah, 01h
int 21h
cmp al, 1bh
jne @@loop
push ds
lds dx, old0a
mov ax, 250ah ; ベクタ復帰
int 21h
pop ds
mov ax, 4c00h
int 21h
main endp
myint0a proc far
cmp cs:in0a, 0
jne @@exit
inc cs:in0a
push ds
push es
pusha
push cs
pop ds
inc count
mov ax, count
mov di, offset buf
call todec5
mov ax, VRAMSEG
mov es, ax
mov si, offset buf
mov di, 0
cld
mov ah, 0
mov cx, 5
@@loop:
lodsb
stosw
loop @@loop
popa
pop es
pop ds
dec cs:in0a
@@exit:
out 64h, al ; VSYNCリセット
jmp cs:[old0a]
myint0a endp
; ax=数値 di=バッファ
todec5 proc
add di, 5
mov bx, 10
mov cx, 5
@@loop:
mov dx, 0
div bx
add dl, '0'
dec di
mov [di], dl
loop @@loop
ret
todec5 endp
old0a label dword
old0a_off dw ?
old0a_seg dw ?
in0a dw 0
count dw 0
buf db 5 dup (?)
end main
最終更新:2018年08月22日 13:43