org 256 R equ 31 N equ 2 M equ 3 mov ah,04ah ;MEM alloc mov bx,2*4096 int 21h jnc alo ret alo mov bx,1-R ;MAP build mov si,R*R mov di,map mov bp,-2*R*(R-1) nok mov cx,1-R nol mov ax,cx imul cx push ax mov ax,bx imul bx pop dx add ax,dx cmp ax,si jc nor mov ax,bx push cx jmp short nos nor mov dx,65536*(M-N)/M/N mul dx mov ax,dx add ax,R*R/M push ax imul cx idiv si mov dx,ax pop ax push dx imul bx idiv si nos mov ah,2*R-1 imul ah pop dx add ax,dx push ax sub ax,bp stosw pop bp inc cx cmp cl,R jl nol inc bx cmp bl,R jl nok mov si,80h ;ARG open lodsb cbw add si,ax mov ax,3d00h mov dx,82h mov [si],al int 21h jnc ope ret ope mov bx,ax ;PAL read mov dx,tmp mov cx,768+18 mov ah,3fh int 21h mov ax,cs add ax,4096 mov es,ax mov cx,200 ;BMP read xor di,di rlp push cx mov dx,tmp+768+18 mov si,dx mov cx,320 mov ah,3fh int 21h rep movsb pop cx loop rlp mov ah,3eh ;ARG close int 21h xor ax,ax ;MICE detect int 33h inc ax jz mok ret mok mov ah,0fh ;VGA init int 10h cbw push ax mov al,13h int 10h inc ch ;PAL setup xor ax,ax mov dx,03c8h mov si,tmp+18 out dx,al inc dx pst mov bl,3 lodsb push ax lodsb push ax lodsb push ax psl pop ax shr al,1 shr al,1 out dx,al dec bl jnz psl loop pst mov ax,7h ;MICE limits mov dx,321-2*R int 33h inc ax mov dx,201-2*R int 33h lof mov ax,3 int 33h mov ax,320 mul dx add ax,cx mov di,ax mov si,tmp push si push di call arm pop di pop bx push bx push di mov si,map mov dl,2*R-1 mal mov cl,2*R-1 mag lodsw add bx,ax mov al,[bx] stosb loop mag add di,321-2*R dec dl jnz mal mov dx,03dah psa in al,dx and al,8 jnz psa psb in al,dx and al,8 jz psb push es pop ds mov ax,0a000h mov es,ax xor si,si xor di,di mov cx,80*200 rep movsd pop di pop si push ds pop es push cs pop ds call arm mov ah,6 mov dl,0ffh int 21h jz lof nms pop ax ;VGA restore int 10h ret arm mov ah,2*R-1 ;PIX swapper arl mov cx,2*R-1 arp mov al,[es:di] movsb mov [si-1],al loop arp add di,321-2*R dec ah jnz arl ret WAR ABSOLUTE WAR map resw (2*R-1)*(2*R-1) tmp ;generic buffer