заказать эксклюзивный памятник. oralcare.lt Elektrinis dantu sepetelisyra geras pasirinkimas vaikams.

Компьютерная графика. Полигональные модели

#define BUTT0N_1_B 0x40 //joystick B, button 1
#define BUTTON_2_B 0x80 // joystick B, button 2
#define JOYSTICK_1_X 0x01 //joystick A, X axis
#define JOYSTICK_1_Y 0x02 // joystick A, Y axis
#define JOYSTICK_2_X 0x04 // joystick B, X axis
#define JOYSTICK_2_Y 0x08 // joystick B, Y axis
// global values
extern unsigned joy1 MinX, joy1 MaxX, joy1 MinY, joy1 MaxY;
extern unsigned joy2MinX, joy2MaxX, joy2MinY, joy2MaxY;
unsigned joystickButtons ( char button ); unsigned joystickValue ( char stick ); unsigned joystickValueBIOS ( char stick ); int joystickPresent ( char stick ); #endif
S] // File joystick.cpp
#include <dos.h> #include "joystick.h"
unsigned joy1 MinX, joy1 MaxX, joy1 MinY, joy1 MaxY; unsigned joy2MinX, joy2MaxX, joy2MinY, joy2MaxY;
unsigned joystickButtons ( char button ) {
outportb ( JOYPORT, 0 ); return Hnportb ( JOYPORT) & button;
}
unsigned joystickValue ( char stick ) {
asm {
cli
mov ah, byte ptr stick
xor al, al
xor cx, cx
mov dx, JOYPORT
out dx, al
}
discharge: asm {
in al, dx
test al, ah loopne discharge
sti
xor ax, ax sub ax, cx
}
}
unsigned joystickValueBIOS ( char stick ) {
REGS inregs, outregs;

4. Работа с основными графическими устройствам

inregs.h.ah = 0x84; inregs.x.clx = 0x01;
int86 ( 0x15, &inregs, &outregs );
switch (stick) {
case JOYSTICK_1__X:
return outregs.x.ax;
case JOYSTICK_1_Y:
return outregs.x.bx;
case JOYSTICK_2_X:.
return outregs.x.cx;
case JOYSTICK2_Y:
return outregs.x.dx;
}
return 0;
}
int joystickPresent ( char stick ) {
asm {
mov ah, 84h mov dx, 1
int 15h //call BIOS to read
// joystick values
}
if (_AX == 0 && _BX == 0 && stick == 1 ) return 0;
if (_CX == 0 && „DX == 0 && stick == 2 ) return 0;
return 1;
}
// File joytest.cpp #include <bios.h> #include <stdio.h> #include "joystick.h"

⇐ Предыдущая| |Следующая ⇒