Posted By: Jovo (Jovo) on 'CZprogram' Title: Mys Date: Fri May 30 10:04:39 1997 Hmmm, mouska se neda v SVGA jen tak jednoduse pripojit. Tohle jsem nasel v PCGPE a vyzkousel. Jako kurzor to ma jen jeden bod. Reseni : udelej si malinkou bitmapku do ni si nakresli sipecku a pri pohybu mousky vem oblast pod ni, schovej ji, XORni (nebo co budes chtit) to bitmapou mousky a pri dalsim pohybu tam vrat puvodni - pekne, ze :) ? Optimalizace necham na tobe. So here it goes : program PC_GPE_MOUSE; Uses Crt, Dos,graph; {$F+} const COM1INTR = $0C; COM1PORT = $3F8; var bytenum : word; combytes : array[0..2] of byte; x, y : longint; button1, button2 : boolean; MouseHandler : procedure; var grDriver: Integer; grMode: Integer; ErrCode: Integer; mx,my:integer; procedure MyMouseHandler; Interrupt; var dx, dy : integer; var inbyte : byte; begin { Get the port byte } inbyte := Port[COM1PORT]; { Make sure we are properly "synched" } if (inbyte and 64) = 64 then bytenum := 0; { Store the byte and adjust bytenum } combytes[bytenum] := inbyte; inc(bytenum); { Have we received all 3 bytes? } if bytenum = 3 then begin { Yes, so process them } dx := (combytes[0] and 3) shl 6 + combytes[1]; dy := (combytes[0] and 12) shl 4 + combytes[2]; if dx >= 128 then dx := dx - 256; if dy >= 128 then dy := dy - 256; x := x + dx; y := y + dy; button1 := (combytes[0] And 32) <> 0; button2 := (combytes[0] And 16) <> 0; { And start on first byte again } bytenum := 0; end; if x>mx then x:=mx; if y>my then y:=my; if x<00 then x:=00; if y<00 then y:=00; { Acknowledge the interrupt } Port[$20] := $20; end; procedure InitMyDriver; begin { Initialize the normal mouse handler } asm mov ax, 0 int $33 end; { Initialize some of the variables we'll be using } bytenum := 0; x := 0; y := 0; button1 := false; button2 := false; { Save the current mouse handler and set up our own } GetIntVec(COM1INTR, @MouseHandler); SetIntVec(COM1INTR, Addr(MyMouseHandler)); end; procedure CleanUpMyDriver; begin SetIntVec(COM1INTR, @MouseHandler); end; procedure mouse; var ox,oy:integer; begin InitMyDriver; while not keypressed do begin; putpixel(ox,oy,black); ox:=x;oy:=y; putpixel(x,y,yellow); end; CleanUpMyDriver; end; begin grDriver := Detect; InitGraph(grDriver, grMode,'c:bpbgi'); ErrCode := GraphResult; if ErrCode = grOk then begin { Ulat jakou grafiku } mx:=getmaxx; my:=getmaxy; mouse; end else Writeln('Chyba grafiky: ', GraphErrorMsg(ErrCode)); end. --------------------------------------------------------------------------- Tak si to uzij ve zdravi. Jovo.