14cf ; Makes adress offsets out of cursor movements INCLUDELIB <\DVL\MASM\LIB\GRAPHICS> INCLUDE GRAPHICS.INC INCLUDE DOS.INC INCLUDE BIOS.INC DOSSEG .MODEL SMALL .386 .STACK .DATA wordbuf db 6 dup (0) comma db ',' newline db 13,10,'dw ' linecntr dw 0 backfname db 'NIGHT.LBM',0 cursorfname db 'CURSOR.LBM',0 posfname db 'XY2POS.DAT',0 old_mx dw 11 old_my dw 10 mouse_plotpos dw 11+(10*320) mouse_save db 11*10 dup (0) back_seg dw ? cursor_seg dw ? vidseg dw 0A000h posbufseg dw ? posbuf_off dw ? handle dw ? .CODE .STARTUP @ModBlock 65536/16 @SetMode 13h call init_mouse mov cx,0 mov dx,offset cursorfname call load_iff mov cursor_seg,ax call load_back call make_posbuf mov es,vidseg mov gs,cursor_seg call draw_mouse call do_mouse call exit_mouse @SetMode 3 cmp posbuf_off,0 jz no_save call save_posbuf no_save: mov es,back_seg @FreeBlock mov es,cursor_seg @FreeBlock .EXIT do_mouse PROC NEAR again: call hide_mouse mov dx,event_flags mov event_flags,0 bt dx,1 jc plot bt dx,3 jnc just_drawcursor call restore_back mov posbuf_off,0 jmp just_drawcursor plot: mov ax,mousey mov dx,320 mul dx add ax,mousex mov mouse_plotpos,ax mov di,mouse_plotpos sub di,1 mov byte ptr es:[di],15 ;plot a white pixel mov si,posbuf_off mov fs:[si],di add posbuf_off,2 just_drawcursor: cmp mousex,12 jae ok mov mousex,12 ok: mov ax,mousey mov dx,320 mul dx add ax,mousex mov mouse_plotpos,ax call draw_mouse call vsync mov ah,01 int 16h jz again ret do_mouse ENDP hide_mouse PROC NEAR mov si,offset mouse_save ;Restore mouse background mov di,mouse_plotpos sub di,11 ;take cursor width in account! mov ax,10-1 rlp44: mov bx,11-1 rlp45: mov dl,[si] mov es:[di],dl inc si inc di dec bx jns rlp45 add di,320-11 dec ax jns rlp44 ret hide_mouse ENDP draw_mouse PROC NEAR mov si,mouse_plotpos ;first save cursor backg sub si,11 mov di,offset mouse_save mov ax,10-1 slp44: mov bx,11-1 slp45: mov dl,es:[si] mov [di],dl inc si inc di dec bx jns slp45 add si,320-11 dec ax jns slp44 mov si,0 ;Draw mouse cursor mov di,mouse_plotpos sub di,11 ;take cursor width in account! mov ax,10-1 lp44: mov bx,11-1 lp45: mov dl,gs:[si] cmp dl,0 jz skip_empty4 mov es:[di],dl skip_empty4: inc si inc di dec bx jns lp45 add di,320-11 dec ax jns lp44 ret draw_mouse ENDP restore_back PROC NEAR push ds mov ds,back_seg mov si,0 mov di,0 mov cx,64000/4 rep movsd pop ds ret restore_back ENDP load_back PROC mov cx,0 mov dx,offset backfname call load_iff mov back_seg,ax mov si,0 mov di,0 mov es,vidseg push ds mov ds,back_seg mov cx,64000/4 rep movsd pop ds ret load_back ENDP make_posbuf PROC NEAR @GetBlock 16000 mov posbufseg,ax mov fs,posbufseg ret make_posbuf ENDP save_posbuf PROC NEAR mov di,offset posfname @MakeFile di,0 mov di,offset posfname @OpenFile di,1 mov handle,ax mov si,0 wloop: mov dx,fs:[si] push si call make_ascii pop si mov di,offset wordbuf @Write di,6,handle inc linecntr cmp linecntr,15 jnz write_comma mov linecntr,0 mov di,offset newline @Write di,5,handle jmp over_comma write_comma: mov di,offset comma @Write di,1,handle over_comma: add si,2 cmp si,posbuf_off jnz wloop @CloseFile handle mov es,posbufseg @FreeBlock ret save_posbuf ENDP make_ascii PROC NEAR mov si,offset wordbuf mov byte ptr[si],'0' inc si mov cl,08h ;First the Hi byte... ror dx,cl mov di,0002h ;DI = ByteR„knare Next_Byte: mov ch,02h ;CH = NibbleR„knare Next_Nibble: mov cl,04h ;F”rbered shift 4 ggr rol dl,cl ;Hi nibble <-> Lo nibble mov al,dl ;Konvertering H2A med Hi ;Nibble i 1:a varvet and al,0fh ;Maska bort h”ga delen daa ;add 6 om 'A'-'F' !!! add al,0f0h ;Carry=1 om 'A'-'F' adc al,40h ;Klart ASCII-v„rde Skriv: push dx ;Spara ordet tillf„lligt mov [si],al ;store in buffer inc si pop dx ;H„mta ordet dec ch ;R„kna ner nibble-r„knaren cmp ch,00h ;B†da nibblarna bearbetade? jnz Next_Nibble ;Om inte forts„tt dec di cmp di,0000h je Reddy mov cl,08h ror dx,cl ;Make Hi Byte -> Lo Byte jmp Next_Byte Reddy: mov byte ptr[si],'h' ret make_ascii ENDP END . 0