#include "dos.h"
#include "bios.h"
void set_video_mode(int mode) { union REGS inregs,outregs; inregs.h.ah=0 outregs.ah=mode; _int86(0x10,inregs,outregs); }or using the inline assembler:
void set_video_mode(int mode) { _asm { mov ah,0 mov al,mode int 10h } }
Then we have to calculate its position:
offset=y*320+x;
Then change its color:
video_buffer[offset]=color;
Let's look at the entire function:
unsigned char video_buffer[]=0xA0000000L
void plot(int x, int y, char color) { offset=y*320+x; video_buffer[offset]=color; }
First we have to declare some variables that will hold the X and Y values:
int MOUSE_X; int MOUSE_Y; int MOUSE_BUTTONS; union _REGS inregs,outregs; // To hold _int86() callsNow, we have to show the mouse:
void Show_Mouse() { inregs.x.ax=0x01 _int86(0x33,&inregs,&outregs); }Now, we can detect the X and Y and get the button position:
void Mouse_X_Y(int *x,int *y,int *buttons) { inregs.x.ax=0x03; _int86(0x33,&inregs,&outregs); *x= outregs.x.cx; *y= outregs.x.dx; *buttons=outregs.x.bx; }Finally, let's see a demo program.
#include <stdio.h> #include <stdlib.h> #include <dos.h> #include <bios.h> int MOUSE_X; int MOUSE_Y; int MOUSE_BUTTONS; union REGS inregs,outregs; void main() { int x=0 Mouse_Show(); do { Mouse_X_Y(MOUSE_X,MOUSE_Y,MOUSE_BUTTONS); printf("%i %i %i",MOUSE_X,MOUSE_Y,MOUSE_BUTTONS); } (x=1);Wow, wasn't that easy.