Created
July 17, 2019 05:00
-
-
Save Sgeo/57b04467243f15f2e6db552ff07c8e7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
#include <dos.h> | |
#include <i86.h> | |
#include <conio.h> | |
#include "vfx1.h" | |
extern unsigned _psp; | |
unsigned __far *psp_pointer; | |
unsigned _get_memsize(); | |
void (__interrupt __far *prev_mouse_handler)(); | |
void debug(const char *format, ...) { | |
int i = 0; | |
char buffer[256]; | |
va_list args; | |
va_start(args, format); | |
vsprintf(buffer, format, args); | |
while(buffer[i] != '\0') { | |
outp(0xE9, buffer[i]); | |
i++; | |
} | |
va_end(args); | |
} | |
void __interrupt __far sense_hander(union INTPACK regs) { | |
if(regs.h.ah < MIN_SENSE_FUNCTION || regs.h.ah > MAX_SENSE_FUNCTION) { | |
_chain_intr(prev_mouse_handler); | |
} | |
switch(regs.h.al) { | |
case SENSE_DRIVER_STATUS: | |
regs.h.al = regs.h.ah; | |
regs.h.ah = SENSE_DRIVER_STATUS; | |
break; | |
case GET_DEVICE_DATA: | |
// TODO: Look at device class | |
// Note that yaw/pitch/roll may not have standard meanings, review documentation. | |
regs.x.bx = 0; // Yaw | |
regs.x.cx = 0; // Pitch | |
regs.x.dx = 0; // Roll | |
regs.h.al = 0; // Buttons | |
} | |
} | |
void transient() {} | |
int main(void) { | |
outp(0xE9, 'A'<<8); | |
outp(0xE9, '\r'<<8); | |
outp(0xE9, '\n'<<8); | |
outp(0xE9, '\0'); | |
//debug("Hello, world!\n"); | |
prev_mouse_handler = _dos_getvect(SENSE_VECTOR); | |
printf("prev_mouse_handler = %p", prev_mouse_handler); | |
flushall(); | |
_dos_setvect(SENSE_VECTOR, sense_hander); | |
_dos_keep(0, _get_memsize()); | |
return 0; | |
} | |
unsigned _get_memsize() | |
{ | |
psp_pointer = (int far *) (_psp << 16); /* Get segment of the PSP*/ | |
return(psp_pointer[1] - _psp); /* Amount of memory to stay resident */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment