Mail Archives: djgpp/2000/11/22/01:01:42
From: | "Gorden" <gorden AT ms9 DOT url DOT com DOT tw>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | about bios graphics mode mouse cursor
|
Date: | Mon, 20 Nov 2000 15:16:09 +0800
|
Organization: | DCI HiNet
|
Lines: | 274
|
Message-ID: | <8vfkg2$ahl@netnews.hinet.net>
|
NNTP-Posting-Host: | 210.242.228.137
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2615.200
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2615.200
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Why I cant not changce mouse cursor in bios graphics, and I post my source
My problem is why I can not regist my new mouse cursor, in main() function
#include <conio.h>
#include <go32.h>
#include <dpmi.h>
#ifndef __cplusplus
typedef unsigned bool;
#define true 0
#define false 1
#endif
#define END_OF_FUNCTION(x) void x##_end(void) { }
#define LOCK_DATA(d,s) _go32_dpmi_lock_data((d), (s))
#define LOCK_CODE(c,s) _go32_dpmi_lock_code((c), (s))
#define UNLOCK_DATA(d,s) _unlock_dpmi_data((d), (s))
#define LOCK_VARIABLE(x) LOCK_DATA((void *)&x, sizeof(x))
#define LOCK_FUNCTION(x) LOCK_CODE(x, (long)x##_end - (long)x)
/***************************************************************************
****************
Function : bool _mouse_detect(void)
Parameter: none
Returns : on success returns true, otherwise return false
Rrmarks : determines mouse driver
****************************************************************************
***************/
bool _mouse_detect(void)
{
__dpmi_regs r;
r.x.ax = 0;
__dpmi_int(0x33, &r);
return ((r.x.ax == 0) ? false : true);
}
/***************************************************************************
****************
Function : void _mouse_show(void)
Parameter: none
Returns : nothing
Rrmarks : show the mouse coursor
****************************************************************************
***************/
void _mouse_show(void)
{
__dpmi_regs r;
r.x.ax = 1;
__dpmi_int(0x33, &r);
}
/***************************************************************************
****************
Function : void _mouse_hide(void)
Parameter: none
Returns : nothing
Rrmarks : hide the mouse cursor
****************************************************************************
***************/
void _mouse_hide(void)
{
__dpmi_regs r;
r.x.ax = 2;
__dpmi_int(0x33, &r);
}
/***************************************************************************
****************
Function : int _mouse_where(int x, int y)
Parameter: x position and y position
Returns : mouse button state
Rrmarks : gets the mouse position and button state.
****************************************************************************
***************/
int _mouse_where(int *x, int *y)
{
__dpmi_regs r;
r.x.cx = 3;
__dpmi_int(0x33, &r);
*x = r.x.cx;
*y = r.x.dx;
return r.x.bx;
}
/***************************************************************************
****************
Function : void _mouse_goto(int x, int y)
Parameter: x position and y position
Returns : nothing
Rrmarks : moves mouse cursor to the given position.
****************************************************************************
***************/
void _mouse_goto(int x, int y)
{
__dpmi_regs r;
r.x.ax = 4;
r.x.cx = x;
r.x.dx = y;
__dpmi_int(0x33, &r);
}
/***************************************************************************
****************
Function : int _mouse_pressed(int *c, int *x, int *y)
Parameter: mouse position's x, y and button pressed times
Returns : mouse button state
Rrmarks : gets the number of releases and last pressed position
****************************************************************************
***************/
int _mouse_pressed(int *c, int *x, int *y)
{
__dpmi_regs r;
r.x.ax = 5;
__dpmi_int(0x33, &r);
*c = r.x.bx;
*x = r.x.cx;
*y = r.x.dx;
return r.x.ax;
}
/***************************************************************************
****************
Function : _mouse_release(int *c, int *x, int *y)
Parameter: mouse position's x, y and button release times
Returns : mouse button state
Rrmarks : gets the number of releases and last release position
****************************************************************************
***************/
int _mouse_release(int *c, int *x, int *y)
{
__dpmi_regs r;
r.x.ax = 6;
__dpmi_int(0x33, &r);
*c = r.x.bx;
*x = r.x.cx;
*y = r.x.dx;
return r.x.ax;
}
/***************************************************************************
****************
Function : void mouse_window(int left, int top, int right, int bottom)
Parameter: left, top, right, bottom position of the window's
Returns : nothing
Rrmarks : set mouse vertical range and horizontal range
****************************************************************************
***************/
void mouse_window(int left, int top, int right, int bottom)
{
__dpmi_regs r;
r.x.ax = 7;
r.x.cx = left;
r.x.dx = right;
__dpmi_int(0x33, &r);
r.x.ax = 8;
r.x.cx = top;
r.x.dx = bottom;
__dpmi_int(0x33, &r);
}
/***************************************************************************
****************
Function :
Parameter:
Returns :
Rrmarks :
****************************************************************************
***************/
void mouse_range(int *x, int *y)
{
__dpmi_regs r;
r.x.ax = 0x000B;
__dpmi_int(0x33, &r);
*x = r.x.cx;
*y = r.x.dx;
}
/***************************************************************************
****************
Function :
Parameter:
Returns :
Rrmarks :
****************************************************************************
***************/
static unsigned char mouse_cursor[64] =
{
/* screen mask */
0xff, 0xff, // 1111111111111111b
0xff, 0xff, // 1111111111111111b
0xff, 0xff, // 1111111111111111b
0xff, 0xff, // 1111111111111111b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xc0, 0x03, // 1100000000000011b
0xff, 0xff, // 1111111111111111b
0xff, 0xff, // 1111111111111111b
0xff, 0xff, // 1111111111111111b
0xff, 0xff, // 1111111111111111b
/* cursor mask */
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x1f, 0xf8, // 0001111111111000b
0x1f, 0xf8, // 0001111111111000b
0x1f, 0xf8, // 0001111111111000b
0x1f, 0xf8, // 0001111111111000b
0x1f, 0xf8, // 0001111111111000b
0x1f, 0xf8, // 0001111111111000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00, // 0000000000000000b
0x00, 0x00 // 0000000000000000b
};
int main(void)
{
__dpmi_regs r;
/* initial bios graphics mode 640x480x16 */
r.h.ah = 0;
r.h.al = 0x12;
__dpmi_int(0x10, &r);
/* determines mouse driver */
_mouse_detect();
/* register my new mouse cursor */
r.x.ax = 0x0009;
r.x.bx = 0;
r.x.cx = 0;
r.x.dx = (int) mouse_cursor; /* problem in here */
r.x.es = _my_cs(); /* problem in here */
__dpmi_int(0x33, &r);
/* showing mouse cursor */
_mouse_show();
/* waitting a key input */
getch();
return 0;
}
- Raw text -