SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00013 CURSOR HANDLING ROUTINES 1 05-28-9313:36ALL SWAG SUPPORT TEAM Cursor SIZE/COLOR IMPORT 7 {> And how can I hide my cursor ? I know it's something With INT 10 butπ> that's all I know...ππTry this:πSType 'C' or 'M' - Color or monchrome displayπSize 'S' or 'B' or 'O' cursor small, big, or none (invisible)π}πUses Dos;ππProcedure CursorSize(SType, Size : Char);ππVarπ Regs : Registers;π i : Integer;ππbeginπ Size := UpCase(Size);π if UpCase(SType) = 'M' thenπ i := 6π ELSEπ i := 0;ππRegs.AH := $01;πCASE Size ofπ'O' :π beginπ Regs.CH := $20;π Regs.CL := $20;π end;π'B' :π beginπ Regs.CH := $0;π Regs.CL := $7 + i;π end;π'S' :π beginπ Regs.CH := $6+i;π Regs.CL := $7+i;π end;πend;πIntr($10, Regs);πend;ππbeginπ CursorSize('C','B');π readln;πend. 2 05-28-9313:36ALL SWAG SUPPORT TEAM CUSOR Handling #1 IMPORT 22 Unit cursor;ππ(*π * CURSOR v1.1 - a Unit to provide extended control of cursor shape.π *π * Public Domain 1991 by John Giesbrecht (1:247/128)π *π * Notes:π *π * - This version requires Turbo Pascal 6.0 or later.π * - These routines affect only the cursor on page 0.π * - This Unit installs an Exit Procedure which restores the cursorπ * to its original shape when the Programme terminates.π *)ππInterfaceππProcedure cursoroff;πProcedure cursoron; (* original cursor shape *)ππProcedure blockcursor;πProcedure halfblockcursor;πProcedure linecursor; (* Default Dos cursor *)ππProcedure setcursor(startline, endline : Byte);πProcedure getcursor(Var startline, endline : Byte);ππ(********************************************************************)ππImplementationππConstπ mono = 7;ππVarπ origstartline,π origendline,π mode : Byte;π origexitproc : Pointer;ππ(********************************************************************)πProcedure setcursor(startline, endline : Byte); Assembler;ππAsmπ mov ah, $01π mov ch, startlineπ mov cl, endlineπ int $10πend;π(********************************************************************)πProcedure getcursor(Var startline, endline : Byte); Assembler;ππAsmπ mov ah, $03π mov bh, $00π int $10π les di, startlineπ mov Byte ptr es:[di], chπ les di, endlineπ mov Byte ptr es:[di], clπend;π(********************************************************************)πProcedure cursoroff;ππbeginπ setcursor(32, 32);πend;π(********************************************************************)πProcedure cursoron;ππbeginπ setcursor(origstartline, origendline);πend;π(********************************************************************)πProcedure blockcursor;ππbeginπ if mode = monoπ then setcursor(1, 12)π else setcursor(1, 7);πend;π(********************************************************************)πProcedure halfblockcursor;ππbeginπ if mode = monoπ then setcursor(7, 12)π else setcursor(4, 7);πend;π(********************************************************************)πProcedure linecursor;πbeginπ if mode = monoπ then setcursor(11, 12)π else setcursor(6, 7);πend;π(********************************************************************)πProcedure restorecursor; Far;ππbeginπ system.exitproc := origexitproc;π cursoron;πend;π(** I N I T I A L I Z A T I O N ***********************************)πbeginπ getcursor(origstartline, origendline);π Asmπ mov ah, $0Fπ int $10π mov mode, alπ end;π origexitproc := system.exitproc;π system.exitproc := addr(restorecursor);πend.π 3 05-28-9313:36ALL SWAG SUPPORT TEAM Cursor Handling #2 IMPORT 15 MN> Anyone have any code on hiding the cursor and then bringing it back.ππMN> -+- Mike Normand -+-πππI've seen many replies to this but all suffer the same disadvantage: they allπassume you know the size of the cursor. A little bit debugging BASIC revealsπwhat's up (by the way, you'll find it described in some good books): you haveπto set bit 5 For the start line and the cursor will disappear since this valueπis not allowed. To get the cursor back again, clear bit 5 again. Use thisπsolution, if you Really just want to turn on/off the cursor. CursorOn/CursorOffπdo *not* change the cursor shape!!! and do *not* need an external Variable toπmanage this.ππThe PUSH BP / POP BP is needed For some *very* old BIOS versions using CGA/πmonochrome :-( display, that trash BP during an INT 10h. If you just want doπsupport EGA/VGA :-) and better, just push 'em out.ππ-----------------------------------------------------πProcedure CursorOff; Assembler;πAsmπ push bp { For old BIOSs }π xor ax, axπ mov es, axπ mov bh, Byte ptr es:[462h] { get active page }π mov ah, 3π int 10h { get cursor Characteristics }π or ch, 00100000bπ mov ah, 1π int 10h { set cursor Characteristics }π pop bp { restore bp For old BIOSs }πend;ππProcedure CursorOn; Assembler;πAsmπ push bp { old BIOSs like this... }π xor ax, axπ mov es, axπ mov bh, Byte ptr es:[462h] { get active page }π mov ah, 3π int 10h { get cursor Characteristics }π and ch, 00011111bπ mov ah, 1π int 10h { set cursor Characteristics }π pop bp { ...and this, too }πend;π 4 05-28-9313:36ALL SWAG SUPPORT TEAM Show/Hide Cursor IMPORT 4 Uses Crt;ππVarπ Continue : Char;ππProcedure HideCursor; Assembler;πAsmπ MOV ax,$0100π MOV cx,$2607π INT $10πend;ππProcedure ShowCursor; Assembler;πAsmπ MOV ax,$0100π MOV cx,$0506π INT $10πend;ππbeginπ Writeln('See the cursor ?');π Continue := ReadKey;π HideCursor;π Writeln('Gone! ');π Continue := ReadKey;π ShowCursor;πend. 5 05-28-9313:36ALL SWAG SUPPORT TEAM Cursor Size & Detect IMPORT 9 {πSEAN PALMERπ}ππunit cursor; {Public domain, by Sean Palmer aka Ghost}ππinterfaceππvarπ maxSize : byte;ππprocedure setSize(scans : byte); {set size from bottom, or 0 for off}πprocedure detect; {get max scan lines by reading current cursor}ππimplementationππprocedure setSize(scans : byte);πvarπ t : byte;πbeginπ if scans = 0 thenπ t := $20π elseπ t := maxSize - scans;π asmπ mov ah, 1π mov bh, 0π mov ch, tπ mov cl, maxSizeπ dec clπ int $10π end;πend;ππprocedure detect; assembler;πasm {do NOT call while cursor's hidden}π mov ah, 3π mov bh, 0π int $10π inc clπ mov maxSize, clπend;ππbeginπ detect;πend.ππprogram test;πusesπ cursor;πbeginπ writeln(cursor.maxSize);π cursor.setSize(cursor.maxSize);π readln; {block}π cursor.setSize(0);π readln; {hidden}π cursor.setSize(cursor.maxSize div 2);π readln; {half}π cursor.setSize(2);π readln; {normal}πend.π 6 05-28-9313:36ALL SWAG SUPPORT TEAM Cursor Show/Hide #2 IMPORT 5 Procedure HideCursor; assembler;π asmπ mov ah,$01 { Function number }π mov ch,$20π mov cl,$00π Int $10 { Call BIOS }π end; { HideCursor }πππ Procedure RestoreCursor; assembler;π asmπ mov ah,$01 { Function number }π mov ch,$06 { Starting scan line }π mov cl,$07 { Ending scan line }π int $10 { Call BIOS }π end; { RestoreCursor }π 7 05-28-9313:36ALL SWAG SUPPORT TEAM Find The Cursor IMPORT 3 Usesπ Dos;ππProcedure FindXY(Var X, Y : Byte; Page : Byte);π{X = Row of Cursor}π{Y = Colum of Cursor}π{Page = Page Nummber}πVarπ Regs : Registers;πbeginπ Regs.Ah := 3;π Regs.Bh := Page;π intr($10, Regs);π X := Regs.Dl;π Y := Regs.Dh;πend;π 8 05-28-9313:36ALL SWAG SUPPORT TEAM Spin The Cursor INPUT IMPORT 13 Program SpinKey;ππUses Crt;π(* ^^^^π This is only For "beautifying" the stuff. XCrt has the Procedures:π HideCursorπ ShowCursorπ but they are not Really important, perhaps you have youre ownπ*)ππConstπ SpinChar : Array [1..4] of Char = ('│','/','─','\');ππFunction ReadKeySpin(Wait : Byte) : Char;πVarπ X,Y : Byte;π Num : Byte;π Ch : Char;πbeginπ Num := 1; (* initialize SpinChars *)π X := WhereX; (* Where am I ?? *)π Y := WhereY;π Repeatπ Write(SpinChar[Num]); (* Spin the Cursor *)π GotoXY(X, Y); (* Go back *)π Delay(Wait); (* Wait, it's to fast! *)π Write(#32); (* Clean Screen *)π GotoXY(X, Y); (* Go back *)π Inc(Num); (* Next SpinChar, please *)π if Num = 5 then Num := 1; (* I have only 5 Chars *)π Until KeyPressed;π Ch := ReadKey; (* Get the pressed Key *)π Write(Ch); (* and Write it to screen*)π ReadKeySpin := Ch; (* give a result *)πend;ππFunction ReadStringSpin : String;πVarπ Help : String;π Ch : Char;π i : Byte;πbeginπ Help := '';π Repeatπ Ch := ReadKeySpin(40);π if Ch <> #13 then Help := Help + Ch;π Until Ch = #13;π ReadStringSpin := Help;π WriteLn;πend;ππVarπ TestString : String;πbeginπ TestString := ReadStringSpin;πend.π 9 06-08-9308:22ALL SWAG SUPPORT TEAM Cursor Stuff in ASM IMPORT 20 (*π===========================================================================π BBS: Canada Remote SystemsπDate: 05-28-93 (05:36) Number: 8641πFrom: LOU DUCHEZ Refer#: NONEπ To: KURT TAN Recvd: NOπSubj: CURSOR CONTROL Conf: (58) PASCALπ---------------------------------------------------------------------------πKT>Can someone tell me how to make the cursor in Turbo Pascal disappear andπKT>appear?ππWhah, sher, li'l pardner. There is *no* function to turn off the cursorπper se in Pascal or among the BIOS interrupts. However, you can changeπthe appearance of the cursor, making it span 0 pixels (as opposed to theπusual 2). And to this purpose, I've included some of my favorite cursorπroutines, stored in a prize Unit of mine.ππTo define a cursor, you need to store the format in a word. The standardπcursor for, say, CGA is $8786 (I think); the "6" and "7" say that theπcursor starts at pixel 7 and ends at pixel 6. The eights mean that thereπare eight pixels to be messing with -- honestly that's a guess, I'veπnever seen it in a book anywhere. For VGA and Hercules, I'm pretty sureπyou have 15 pixels to work with; the normal cursor there is something likeπ$fefc (something like that -- I'm working off CGA, so it's hard for me toπtest that theory). In either case, no matter the graphics system, a goodπway to turn off the cursor is to set it to $ffff.π*)ππprocedure cursoff;πconst ffff: word = $ffff;ππ{ Turns the cursor off. Stores its format for later redisplaying. }ππbeginπ asmπ mov ah, 03hπ mov bh, 00hπ int 10hπ mov crstyp, cx { global variable -- for later retrieval }π mov ah, 01hπ mov cx, ffffπ int 10hπ end;π end;πππprocedure curson;ππ{ Turns the cursor back on, using the cursor display previously stored. }ππbeginπ asmπ mov ah, 01hπ mov cx, crstyp { previously-stored cursor format }π int 10hπ end;π end;πππfunction getcursor: word;ππ{ Returns the cursor format. }ππvar tempword: word;πbeginπ asmπ mov ah, 03hπ mov bh, 00hπ int 10hπ mov tempword,cxπ end;π getcursor := tempword;π end;πππprocedure setcursor(curstype: word);ππ{ Sets the cursor format. }ππvar tempword: word;πbeginπ tempword := curstype;π asmπ mov ah, 01hπ mov cx,tempwordπ int 10hπ end;π end;ππ 10 07-16-9306:05ALL SWAG SUPPORT TEAM Cursor Manipulations IMPORT 15 .] π{ unit to manipulate the text cursor }ππunit Cursor;ππINTERFACEππTYPEππ PCursorRec = ^TCursorShape;π TCursorShape = recordπ Start : byte;π Stop : byte;π end;ππprocedure GetCursorShape (var Shape : TCursorShape);π{ Sets the Start and Stop fields of Shape }ππprocedure CursorOff;π{ Turns the cursor off }ππprocedure NormCursorOn;π{ Turns underscore cursor on }ππprocedure BlockCursorOn;π{ Turns block cursor on }ππprocedure SetCursorShape (Shape : TCursorShape);π{ Set cursor shape with Start and Stop fields of Shape }ππIMPLEMENTATIONπVARπ VideoMode : BYTE ABSOLUTE $0040 : $0049; { Video mode: Mono=7, Color=0-3 }ππprocedure GetCursorShape (var Shape : TCursorShape); assembler;π asmπ mov ah,$03π mov bx,$00π int $10π les di,Shapeπ mov TCursorShape (es:[di]).Start,ch {es:[di] is Start field of Shape}π mov TCursorShape (es:[di]).Stop,cl {es:[di+1] is Stop field of Shape}π end;ππprocedure SetCursorShape; assembler;π asmπ mov ah,$01 { Service 1, set cursor size }π mov ch,Shape.Startπ mov cl,Shape.Stopπ int $10π end;ππprocedure CursorOff; assembler;π asmπ mov ah,$01π mov ch,$20π mov cl,$00π int $10π end;ππprocedure NormCursorOn;π varπ Shape : TCursorShape;π beginπ if VideoMode = 7 thenπ beginπ Shape.Start := $0A;π Shape.Stop := $0B;π endπ elseπ beginπ Shape.Start := $06;π Shape.Stop := $07;π end;π SetCursorShape (Shape);π end;ππprocedure BlockCursorOn;π varπ Shape : TCursorShape;π beginπ if VideoMode = 7 thenπ beginπ Shape.Start := $02;π Shape.Stop := $0B;π endπ elseπ beginπ Shape.Start := $02;π Shape.Stop := $08;π end;π SetCursorShape (Shape);π end;ππEND. 11 08-18-9312:24ALL JOSE ALMEIDA Get Cursor Position IMPORT 9 .] { Gets the cursor position for each of the eight display pages.π Part of the Heartware Toolkit v2.00 (HTcursor.PAS) for Turbo Pascal.π Author: Jose Almeida. P.O.Box 4185. 1504 Lisboa Codex. Portugal.π I can also be reached at RIME network, site ->TIB or #5314.π Feel completely free to use this source code in any way you want, and, ifπ you do, please don't forget to mention my name, and, give me and Swag theπ proper credits. }ππPROCEDURE Get_Cursor_Position(Page : byte;π var Column,π Row : byte);π{ DESCRIPTION:π Gets the cursor position for each of the eight display pages.π SAMPLE CALL:π Get_Cursor_Position(0,Col,Row);π RETURNS:ππ NOTES:π Page value must be from 0 to 7 }ππBEGIN { Get_Cursor_Position }π Column := Succ(Lo(MemW[$0000:$0450 + Page * 2]));π Row := Succ(Hi(MemW[$0000:$0450 + Page * 2]));πEND; { Get_Cursor_Position }π 12 08-27-9320:34ALL BRIAN DHATT GoToXY Replacment IMPORT 22 .] {BRIAN DHATTππ> Does anyone have codes/source For replacing GotoXY Procedure?π}πAsmπ MOV AH,$0F {To get active page, returns BH}π INT $10π MOV Page,BHπend;ππAsm {to find current cursor pos in form XX,YY}π MOV AH,$3 {Equiv of XX:=WhereX, YY:=WhereY }π MOV BH,Pageπ INT $10π MOV YY,DHπ MOV XX,DLπend;ππAsm {This block moves the cursor to }π MOV AH,$02 {XX,YY just like GotoXY(XX,YY) }π MOV BH,Pageπ MOV DL,XXπ MOV DH,YYπ INT $10πend;ππ{πGREG ESTABROOKSππ>Can someone tell me how to make the cursor in Turbo Pascal disappear andπ>appear?π}ππProgram CursorDemo; (* May 27/93, Greg Estabrooks *)πUsesπ Crt; (* For ReadKey, ClrScr. *)πConstπ (* Define Cursor Value to make chaning cursor easier *)π NoCursor = $2000;π DefaultCursor = $0607;π BlockCursor = $000A;πVarπ Curs : Word; (* Stores saved cursor value *)π Ch : Char;ππProcedure SetCursor(Cursor : Word); Assembler;π (* Routine to change the shape of the cursor *)πAsmπ Mov AH,1 (* Function to change cursor shape *)π Mov BH,0 (* Set Page to 0 *)π Mov CX,Cursor (* Load new cursor Shape Value *)π Int $10 (* Call Dos *)πend;{SetCursor}ππFunction GetCursor : Word; Assembler;π (* Routine to return Cursor Shape *)πAsmπ Mov AH,3 (* Function to return cursor shape *)π Mov BH,0 (* Set Page to 0 *)π Int $10 (* Call Dos *)π Mov AX,CX (* Move Result to proper register *)πend;{GetCursor}ππbeginπ ClrScr; (* Clear the screen For demonstration*)π Curs := GetCursor; (* Save Current Cursor Value *)π Writeln('The Cursor is turned off');π SetCursor( NoCursor ); (* Turn off the cursor *)π Ch := ReadKey; (* Pause to show user new cursor *)π Writeln('The Cursor is a block shape');π SetCursor( BlockCursor ); (* Set the cursor to a block *)π Ch := ReadKey;π Writeln('The Cursor is now the normal shape');π SetCursor( DefaultCursor ); (* Set Default Cursor *)π Ch := ReadKey;ππ SetCursor( Curs ); (* Restore cursor to previous style *)πend.π 13 08-27-9321:58ALL SEAN PALMER Spinning Cursor IMPORT 5 .] {πSEAN PALMERππThis is an example for the cursor I talked about to someone on here...π}ππprogram spinCursor;ππusesπ crt;ππvarπ cursorState : byte; {0..3}π i : integer;ππconstπ cursorData : array [0..3] of char = (#30, #17, #31, #16);ππprocedure updateCursor;πbeginπ cursorState := succ(cursorState) and 3;π write(cursorData[cursorState], ^H);πend;ππbeginπ for i := 1 to 100 doπ beginπ gotoxy(1,1);π updateCursor;π gotoxy(1,41);π delay(100);π end;πend.π