; program with keyboard handler .model small .486 .stack 100h .data Hitime EQU 1h ; delay time constants (approximate 1/10 sec.) Lotime EQU 8000h hdtime equ 10 ; 1/100 seconds, used by delay2 rows dw 9 ; variables to store size of bitmap columns dw 24 kbd dd ? ; use this 24x9 bit map for the shape of a flying saucer (you can ; change it of course). Can you figure out a way to interpret 00 as ; transparent instead of as color black? shape db 9,0,24,0 db 00,00,00,00,00,00,00,00,00,00,04,04,04,04,04,00,00,00,00,00,00,00,00,00 db 00,00,00,00,00,00,00,00,04,04,04,04,04,04,04,04,04,00,00,00,00,00,00,00 db 00,00,00,00,00,00,00,00,04,04,04,04,04,04,04,04,04,00,00,00,00,00,00,00 db 00,00,00,00,00,00,04,04,04,04,02,04,02,04,02,04,04,04,04,00,00,00,00,00 db 00,00,04,04,04,04,04,04,04,04,02,04,04,04,02,04,04,04,04,04,04,04,04,00 db 00,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04 db 00,00,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,00 db 00,00,00,00,00,00,00,04,00,00,00,00,00,00,00,00,00,04,00,00,00,00,00,00 db 00,00,00,00,00,00,04,00,00,00,00,00,00,00,00,00,00,00,04,00,00,00,00,00 buffer db 216 dup(?) .code mymain proc start: mov ax,@data mov ds,ax mov ax,0a000h mov es,ax mov ax,0013h int 10h call KEYD mov cx,150 ; x coord mov dx,190 ; y coord mov eax,03000000h call BACKGROUND ; draw uniform background mov bx, offset shape ; prepare to call drawshape call DRAWSHAPE ; initial shape call DELAY push ds push ax push bx push es mov ax,3509h ; get location old int 9 handler int 21h mov word ptr [kbd],bx mov word ptr [kbd+2],es mov ax,cs mov ds,ax mov ax,2509h mov dx, offset khandler int 21h pop es ; install my int 9 handler pop bx pop ax pop ds bigd: mov cx,16000 call DELAY loop bigd jmp ENDPROG mymain endp ; procedures ; my keyboard handler khandler: sti ; APIC chip disables interrupts pushf pusha push es ;mov ax,0a000h ;mov es,ax in al,60h ; get code from keyboard cmp al,32 ; d key or space? jne skip3 ;call BACKGROUND xor ah,ah mov cx,ax mov dx,1 mov bx, offset shape call drawshape skip3: mov ax,@data mov ds,ax pop es popa popf ; call existing int9 handler: jmp ds:[kbd] iret ; doesn't draw saucer DRAWSHAPE proc pusha mov ax,@data mov ds,ax mov ax,[bx] ; save dimensions mov di,offset rows mov [di],ax mov ax,[bx+2] mov di,offset columns mov [di],ax add bx,4 ; move to start of real image mov ax,320 ; compute initial y offset mul dx add ax,cx ; add x offset mov di,ax ; initial destination index mov ax,0a000h mov es,ax ; be safe mov es:[di],eax ; changed popa ret ; end of procedure (line 85) DRAWSHAPE endp ;The background procedure uses eax as pattern to fill background BACKGROUND proc pushad xor di,di mov cx,16000 bloop: mov es:[di],eax add di,4 loop bloop popad ret BACKGROUND endp ENDPROG proc call KEYD mov ax,0003h ;3 reset to text mode int 10h ;3 mov ax,4c00h int 21h ENDPROG endp ; key delay procedure - wait for keypress before continuing KEYD proc push ax ; save ax register before local use mov ah,1 ;k1 DOS interrupt for keyboard input int 21h ;k1 pop ax ; restore ax ret ; pop saved instruction address and jump KEYD endp DELAY proc push ax ; save registers push cx push dx mov cx,Hitime ; move time to delay into cx:dx mov dx,Lotime mov ah,86h ; call bios to suspend process int 15h pop dx ; restore registers and return pop cx pop ax ret DELAY endp end