summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/cursize.c
diff options
context:
space:
mode:
Diffstat (limited to 'reference/C/CONTRIB/SNIP/cursize.c')
-rwxr-xr-xreference/C/CONTRIB/SNIP/cursize.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/reference/C/CONTRIB/SNIP/cursize.c b/reference/C/CONTRIB/SNIP/cursize.c
new file mode 100755
index 0000000..18d8172
--- /dev/null
+++ b/reference/C/CONTRIB/SNIP/cursize.c
@@ -0,0 +1,66 @@
+/*
+** Program to set the size of the cursor
+**
+** Public domain demonstration by Bob Jarvis
+*/
+
+#include <stdio.h> /* puts() */
+#include <dos.h> /* int86(), union REGS */
+#include <stdlib.h> /* exit(), atoi() */
+
+char *help = "CURSIZE - sets the cursor size.\n"
+ "Usage:\n"
+ " CURSIZE <top-line> <bottom-line>\n"
+ "where\n"
+ " top-line = top line of cursor within character cell\n"
+ " bottom-line = bottom line\n"
+ "Example:\n"
+ " CURSIZE 7 8 <set cursor to bottom 2 lines of VGA>\n"
+ " CURSIZE 32 32 <turns cursor off>";
+
+void cursor_size(int top_line, int bottom_line)
+{
+ union REGS regs;
+
+ regs.h.ah = 1;
+ regs.h.ch = (unsigned char)top_line;
+ regs.h.cl = (unsigned char)bottom_line;
+
+ int86(0x10,&regs,&regs);
+}
+
+void get_cursor_size(int *top_line, int *bottom_line)
+{
+ union REGS regs;
+
+ regs.h.ah = 3;
+ regs.h.bh = 0;
+ int86(0x10, &regs, &regs);
+
+ *top_line = regs.h.ch;
+ *bottom_line = regs.h.cl;
+
+ return;
+}
+
+void main(int argc, char *argv[])
+{
+ int top, bottom;
+
+ if(argc < 3)
+ {
+ puts(help);
+ exit(1);
+ }
+
+ top = atoi(argv[1]);
+ bottom = atoi(argv[2]);
+
+ cursor_size(top,bottom);
+
+ top = bottom = -1;
+
+ get_cursor_size(&top, &bottom);
+
+ printf("top = %d bottom = %d\n", top, bottom);
+}